Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
parser h264: fix h264_nal_deescape regression
  • Loading branch information
perexg committed Sep 24, 2015
1 parent 214279e commit a70bdf3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/parsers/parser_h264.c
Expand Up @@ -43,35 +43,38 @@
void *
h264_nal_deescape(bitstream_t *bs, const uint8_t *data, int size)
{
int_fast32_t i = 0;
uint_fast8_t c;
uint8_t *d;
const uint8_t *end, *end2;

bs->rdata = d = malloc(size);
bs->offset = 0;

end2 = data + size;

if (size > 2) {

/* Escape 0x000003 into 0x0000 */
/* Escape 0x000003 into 0x0000 */

for( ; i < size - 2; i++) {
end = end2 - 2;
while (data < end) {
c = *data++;
if (c || data[1] || data[2] != 3) {
if (c || *data || *(data + 1) != 3) {
*d++ = c;
continue;
} else {
*d++ = 0;
*d++ = 0;
data += 2;
}
*d++ = 0;
*d++ = 0;
i+= 2;
}

}

for (; i < size; i++)
while (data < end2)
*d++ = *data++;

bs->len = (d - bs->rdata) * 8;
return d;
return (void *)bs->rdata;
}


Expand Down

0 comments on commit a70bdf3

Please sign in to comment.