[FFmpeg-devel] [PATCH] [RFC] libavcodec/h264_mp4toannexb_bsf.c: Copy const data

Benoit Fouet benoit.fouet
Mon Feb 16 17:44:02 CET 2009


On 02/16/2009 04:50 PM, Benjamin Larsson wrote:
> Benoit Fouet wrote:
>   
>>> ===================================================================
>>> --- libavcodec/h264_mp4toannexb_bsf.c	(revision 17373)
>>> +++ libavcodec/h264_mp4toannexb_bsf.c	(working copy)
>>> @@ -58,7 +58,7 @@
>>>  
>>>      /* nothing to filter */
>>>      if (!avctx->extradata || avctx->extradata_size < 6) {
>>> -        *poutbuf = (uint8_t*) buf;
>>> +        memcpy(*poutbuf, buf, buf_size);
>>>          *poutbuf_size = buf_size;
>>>          return 0;
>>>      }
>>>
>>>     
>>>       
>> Index: libavcodec/h264_mp4toannexb_bsf.c
>>
>> you are missing the fact that output buffer is not allocated at that time.
>> BTW, I don't think copying is a good idea, but the fact that output and input data can be the same should be documented, as already told someone else.
>>
>> Ben
>>
>>   
>>     
>
> Thus violating the const qualifier ?
>
>   

the BSF part is weird regarding that case.
If the input is not filtered, it just overwrites the output buffer
address...
I don't know what should be done:
 - let things as they are, but document them;
 - change the input to not const, and document why;
 - break the BSF API and use a special return value when no process has
been done, and user should use its input as output;
 - your ad here

really, I don't know, but I must admit this is not something that
bothers me that much ;)

Ben





More information about the ffmpeg-devel mailing list