[FFmpeg-devel] [PATCH] libavformat/avc.c annexb parsing corrupts packets
Baptiste Coudurier
baptiste.coudurier
Mon Aug 24 22:25:10 CEST 2009
Hi Michael,
On 08/13/2009 05:00 PM, Michael Niedermayer wrote:
> 4On Mon, Jul 27, 2009 at 05:10:33PM +0200, matteo.elli at m-elli.it wrote:
>> Hi,
>>
>> code in libavformat/avc.c is seldom executed but it surely does when you transmux (vcodec=copy) from h264 in a ts container to h264 in an mp4/mov/mkv/avi container.
>>
>> The code there fails to handle annexb 00 00 01 NAL three byets prefixes properly and cuts the last byte in the previous NAL corrupting the whole frame.
>>
>> Here is my proposed fix.
>>
>> Index: libavformat/avc.c
>> ===================================================================
>> --- libavformat/avc.c (revision 19515)
>> +++ libavformat/avc.c (working copy)
>> @@ -39,15 +39,15 @@
>> if( (x - 0x01010101)& (~x)& 0x80808080 ) { // generic
>> if( p[1] == 0 ) {
>> if( p[0] == 0&& p[2] == 1 )
>> - return p-1;
>> + return p;
>> if( p[2] == 0&& p[3] == 1 )
>> - return p;
>> + return p+1;
>> }
>> if( p[3] == 0 ) {
>> if( p[2] == 0&& p[4] == 1 )
>> - return p+1;
>> + return p+2;
>> if( p[4] == 0&& p[5] == 1 )
>> - return p+2;
>> + return p+3;
>> }
>> }
>> }
>
> the code as is in svn is wrong but your change is as well
> there can be 0001 and 001 startcodes, the return value has to point
> to the first byte of either
Is it wrong or does it work only with 0001 startcodes ?
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list