[FFmpeg-cvslog] avcodec/decode: fetch packets from the pkt_props FIFO on every frame returned

James Almer git at videolan.org
Mon Jun 21 22:41:32 EEST 2021


ffmpeg | branch: release/4.4 | James Almer <jamrial at gmail.com> | Fri Jun 18 17:58:18 2021 -0300| [70157046402d5b7edca3fde6af78976bf4b5726a] | committer: James Almer

avcodec/decode: fetch packets from the pkt_props FIFO on every frame returned

Fixes memleaks on decoders that don't call ff_decode_frame_props(), like
libdav1d.

Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit a4fb03563ab918bf9641365d08b4363590ced1eb)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70157046402d5b7edca3fde6af78976bf4b5726a
---

 libavcodec/decode.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 5a00aeedae..5c57868568 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -548,6 +548,10 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
     if (ret == AVERROR_EOF)
         avci->draining_done = 1;
 
+    if (IS_EMPTY(avci->last_pkt_props) && av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props))
+        av_fifo_generic_read(avci->pkt_props,
+                             avci->last_pkt_props, sizeof(*avci->last_pkt_props), NULL);
+
     if (!ret) {
         frame->best_effort_timestamp = guess_correct_pts(avctx,
                                                          frame->pts,
@@ -1738,10 +1742,6 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
         { AV_PKT_DATA_S12M_TIMECODE,              AV_FRAME_DATA_S12M_TIMECODE },
     };
 
-    if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt))
-        av_fifo_generic_read(avctx->internal->pkt_props,
-                             pkt, sizeof(*pkt), NULL);
-
     frame->pts = pkt->pts;
 #if FF_API_PKT_PTS
 FF_DISABLE_DEPRECATION_WARNINGS



More information about the ffmpeg-cvslog mailing list