[FFmpeg-cvslog] avcodec/encode: Avoid unreferencing blank AVFrames

Andreas Rheinhardt git at videolan.org
Sat Sep 3 16:48:43 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Aug 25 18:42:10 2022 +0200| [25ea90b733883d0cbfdb76014b619a1b37489fca] | committer: Andreas Rheinhardt

avcodec/encode: Avoid unreferencing blank AVFrames

ff_thread_video_encode_frame() already returns blank frames.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/encode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 2c02b24cf2..8c6d81286c 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -263,18 +263,17 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)
     av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE);
 
     if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder)
-        /* This might unref frame. */
+        /* This will unref frame. */
         ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
     else {
         ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet);
+        if (frame)
+            av_frame_unref(frame);
     }
 
     if (avci->draining && !got_packet)
         avci->draining_done = 1;
 
-    if (frame)
-        av_frame_unref(frame);
-
     return ret;
 }
 



More information about the ffmpeg-cvslog mailing list