[FFmpeg-devel] [RFC] Windows issues with av_destruct_packet_nofree

Art Clarke aclarke
Thu Feb 19 16:57:47 CET 2009


On Wed, Feb 18, 2009 at 6:44 PM, avcoder <ffmpeg at gmail.com> wrote:

> I am very curious, why do you call  av_destruct_packet_nofree()  outside of
> AVFORMAT DLL ?
>
> it should be OK if you only call av_init_packet(&pkt) which already
> includes
> the setting of av_destruct_packet_nofree() .


We never called it.  We just sometimes did the following (no longer):

// In non AVFORMAT.DLL
pkt->destruct = av_destruct_packet_nofree;

In those cases we, believing the API allowed this because it's in
avformat.h, were taking over memory management of a packet that would far
outlive FFMPEG's need to use it.

As Mans' pointed out, comparing function pointer across shared-object
boundaries is undefined.  It turns out to work fine for Linux and Mac OS's,
but on Windows, our copy of "av_destruct_packet_nofree" is actually a stub
pointing to the method in AVFORMAT.DLL, and inside libavutils/utils.c:316
av_dup_packet, the following code then return false when we expected true:

if (pkt->destruct == av_destruct_packet_nofree ...

My suggested patch is to change avformat.h to make it clear that setting
pkt->destruct to av_destruct_packet_nofree is NOT a part of the public API
to avoid this issue.

- Art

-- 
http://www.xuggle.com/
xu?ggle (z?' gl) v. To freely encode, decode, and experience audio and
video.

Use Xuggle to get the power of FFMPEG in Java.




More information about the ffmpeg-devel mailing list