[Libav-user] Separating decoding and processing frames into threads

Nicolas George george at nsup.org
Tue Apr 25 17:03:56 EEST 2023


Nikita Vaňků (12023-04-25):
> > You probably need to copy the frame at least once.
> I do not understand what exactly you mean

The word copy appears only five times in the documentation of the frame
API, it is not that hard to find the right one.

> I ran the SW decoder for several hours and noticed no memory leak.

Ok.

> Out of frustration, I tried to minimize the code, I now know that if I
> keep reusing a single frame (allocate it once and never free it) the
> problem disappears. But as soon as I try to allocate new frames for
> each decoded frame while using HW acceleration I start running into
> these issues.
> 
> The code for this is very simple on the decoding side I simply:
> 
>             AVFrame* frame = av_frame_alloc();
>             ret = avcodec_receive_frame(m_codecContext, frame);
>             av_packet_unref(m_packet);
>             if (ret == AVERROR(EAGAIN)) {
>                 av_frame_free(&frame);
>                 continue;
>             } else if (ret == AVERROR_EOF) {
>                 av_frame_free(&frame);
>                 break;
>             } else if (ret != 0) {
>                 av_frame_free(&frame);
>                 break;
>             }
> 
> I skipped the processing and just call av_frame_free on the processing
> side. The queue for this purpose is a size of 4. Errors in linux
> differs from those experienced on Windows

Try copying the frame before adding it to the queue and see if it fixes
things.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20230425/6b79b44a/attachment.sig>


More information about the Libav-user mailing list