diff mbox series

[FFmpeg-devel,v1] lavc/av1dec: drop redundant frame

Message ID 20211029024514.86945-1-fei.w.wang@intel.com
State New
Headers show
Series [FFmpeg-devel,v1] lavc/av1dec: drop redundant frame | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Fei Wang Oct. 29, 2021, 2:45 a.m. UTC
For some non-standard clip which contains multiple display frame
data in a ivf packet, drop the redundant frame can make the decode
continuously with some warning message shown. Otherwise decode will
interrupt with unexpected error.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavcodec/av1dec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c
index db110c50c7..58d10672c1 100644
--- a/libavcodec/av1dec.c
+++ b/libavcodec/av1dec.c
@@ -916,6 +916,16 @@  static int set_output_frame(AVCodecContext *avctx, AVFrame *frame,
         av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
         return 0;
 
+    /**
+     * Drop redundant frame data if there already exist one. Return 0 will
+     * make sure all frames can be decoded and maintainers a correct reference
+     * list.
+     */
+    if (*got_frame) {
+        av_log(avctx, AV_LOG_WARNING, "Redundant frame data dropped!\n");
+        return 0;
+    }
+
     ret = av_frame_ref(frame, srcframe);
     if (ret < 0)
         return ret;