[FFmpeg-devel] [PATCH 48/48] fftools/ffmpeg: use av_packet_alloc() to allocate packets
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Sat Mar 6 10:54:08 EET 2021
Jack Waller:
> On Sat, Mar 6, 2021 at 12:44 AM James Almer <jamrial at gmail.com> wrote:
>
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>> fftools/ffmpeg.c | 318 +++++++++++++++++++++++--------------------
>> fftools/ffmpeg.h | 4 +
>> fftools/ffmpeg_opt.c | 5 +-
>> 3 files changed, 177 insertions(+), 150 deletions(-)
>>
>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>> index 2abbc0ff29..46bb014de8 100644
>> --- a/fftools/ffmpeg.c
>> +++ b/fftools/ffmpeg.c
>>
>> @@ -610,9 +611,9 @@ static void ffmpeg_cleanup(int ret)
>>
>> if (ost->muxing_queue) {
>> while (av_fifo_size(ost->muxing_queue)) {
>> - AVPacket pkt;
>> + AVPacket *pkt;
>> av_fifo_generic_read(ost->muxing_queue, &pkt,
>> sizeof(pkt), NULL);
>>
>
> Should you modify av_fifo_generic_read() for its second arguments( &pkt) as
> well?
No, he is switching said FIFO to using pointers to AVPackets instead of
AVPackets. The code above makes pkt (which is now a pointer) point to a
separately allocated AVPacket. Said pointer is now the owner of this
AVPacket struct; the packet is freed immediately after its usage (which
I consider wasteful).
(Is this actually a real FIFO? It seems that something is put in there
and then the FIFO is completely drained and never used afterwards. The
cyclic nature of a FIFO is never used and using av_dynarray would be
easier.)
- Andreas
More information about the ffmpeg-devel
mailing list