[FFmpeg-devel] [PATCH] examples/muxing: zero AVPacket before av_read_frame()

Hendrik Leppkes h.leppkes at gmail.com
Tue Jan 28 16:02:22 CET 2014

On Tue, Jan 28, 2014 at 3:56 PM, Andrey Utkin
<andrey.krieger.utkin at gmail.com> wrote:
> 2014-01-28 Hendrik Leppkes <h.leppkes at gmail.com>:
>> All uses of pkt in av_read_frame either call av_init_packet first to
>> clear it, or completely overwrite it with another packet.
>> I don't see where the input data ever matters?
> av_init_packet() description says
>  * Note, this does not touch the data and size members, which have to be
>  * initialized separately.
> So it didn't really prepare uninitialized AVPacket before
> av_read_frame(), at last before, when data was stored by `data`
> pointer.
> I wrongly assumed that it does not also set `buf`. But as i see in
> code, it does set it to NULL.
> I'll redo this patch unsing av_init_packet().

Fact remains that ->data is never read by av_read_frame, only written
to. The API does NOT require you to init the AVPacket in any way.
If it would, it would be smarter to actually make it clear it itself.

The example should really not include unnecessary functions.

- Hendrik

More information about the ffmpeg-devel mailing list