Commit 654e5498 authored by Fiona Glaser's avatar Fiona Glaser

Revert part of r963

In some rare (but significant) cases, the optimized nal_encode algorithm gave incorrect results.
parent cc0c3d4d
......@@ -641,6 +641,7 @@ int x264_nal_encode( void *p_data, int *pi_data, int b_annexeb, x264_nal_t *nal
uint8_t *dst = p_data;
uint8_t *src = nal->p_payload;
uint8_t *end = &nal->p_payload[nal->i_payload];
int i_count = 0;
/* FIXME this code doesn't check overflow */
......@@ -656,12 +657,17 @@ int x264_nal_encode( void *p_data, int *pi_data, int b_annexeb, x264_nal_t *nal
/* nal header */
*dst++ = ( 0x00 << 7 ) | ( nal->i_ref_idc << 5 ) | nal->i_type;
if( src < end ) *dst++ = *src++;
if( src < end ) *dst++ = *src++;
while( src < end )
{
if( src[0] <= 0x03 && !src[-2] && !src[-1] )
if( i_count == 2 && *src <= 0x03 )
{
*dst++ = 0x03;
i_count = 0;
}
if( *src == 0 )
i_count++;
else
i_count = 0;
*dst++ = *src++;
}
*pi_data = dst - (uint8_t*)p_data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment