[FFmpeg-devel] [PATCH] movenc.c fix (Was: Can av_write_frame() modify pkt.data?)

Luca Abeni lucabe72
Tue Jun 17 15:41:19 CEST 2008


Hi Michael,

Michael Niedermayer wrote:
>> I just discovered that the mov muxer can modify the
>> "data" field of the AVPacket structure that it receives
>> as parameter (in case of H.264 video, mov_write_packet()
>> calls ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size);
>> which frees pkt->data and allocates a new buffer).
[...]
>> So, should output_example.c be fixed, or should movenc.c
>> be fixed? (or is everything ok, since output_example does
>> not write H.264 in mov unless you modify it?)
> 
> movenc.c looks buggy, and a quick grep hints towards that its not
> the only one.
> pkt.data does not need to be a malloced() buffer. Thus a blind av_free()
> is always wrong. The correct way to kill a packet is with pkt->destruct()
> though that is of course not the muxers job to do.
> 
> Besides a packet could be passed to more than 1 muxer and thus its content
> must not be changed by any muxer.

Ok; I tried to fix this bug, but I do not know if the attached patch
is the best solution. It seems to work well here.


				Luca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Try-to-fix-the-muxer-modifying-pkt-data.patch
Type: text/x-diff
Size: 1802 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080617/2315f951/attachment.patch>



More information about the ffmpeg-devel mailing list