[FFmpeg-cvslog] avcodec/decode: check the output frame for discard samples with all decoders

James Almer git at videolan.org
Fri Jul 14 19:58:27 EEST 2023


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Jul  9 10:39:16 2023 -0300| [94ac6475597ea4b5bf93d2072f518aaf25ef32b7] | committer: James Almer

avcodec/decode: check the output frame for discard samples with all decoders

And not just those with the old decode() API.

Signed-off-by: James Almer <jamrial at gmail.com>

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

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

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 7bf54b95d1..e2aebbbde4 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -597,6 +597,14 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
     if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) {
         ret = codec->cb.receive_frame(avctx, frame);
         emms_c();
+        if (!ret) {
+            if (avctx->codec->type == AVMEDIA_TYPE_VIDEO)
+                ret = (frame->flags & AV_FRAME_FLAG_DISCARD) ? AVERROR(EAGAIN) : 0;
+            else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
+                int64_t discarded_samples = 0;
+                ret = discard_samples(avctx, frame, &discarded_samples);
+            }
+        }
     } else
         ret = decode_simple_receive_frame(avctx, frame);
 



More information about the ffmpeg-cvslog mailing list