diff mbox series

[FFmpeg-devel,2/4] avcodec/avcodec: Avoid av_frame_unref(NULL)

Message ID AS8PR01MB7944B4E3D6940DA43A3B6D9A8FEC9@AS8PR01MB7944.eurprd01.prod.exchangelabs.com
State Accepted
Commit 3649051dc4e1ede5999a7c688864e5a616f985ee
Headers show
Series [FFmpeg-devel,1/4] avcodec/encode: Fix check for encoders impl. encode-simple API | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 13, 2022, 2:49 p.m. UTC
It works, but it is not documented to work.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/avcodec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index e0f38ac42a..ded6b5b307 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -420,6 +420,8 @@  void avcodec_flush_buffers(AVCodecContext *avctx)
                    "that doesn't support it\n");
             return;
         }
+        if (avci->in_frame)
+            av_frame_unref(avci->in_frame);
     }
 
     avci->draining      = 0;
@@ -432,7 +434,6 @@  void avcodec_flush_buffers(AVCodecContext *avctx)
     while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0)
         av_packet_unref(avci->last_pkt_props);
 
-    av_frame_unref(avci->in_frame);
     av_packet_unref(avci->in_pkt);
 
     if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)