diff mbox series

[FFmpeg-devel,v2,2/3] avcodec/decode: check the output frame for discard samples with all decoders

Message ID 20230709133917.5403-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,v2,1/3] avcodec/decode: move processing discard samples to its own function | 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

James Almer July 9, 2023, 1:39 p.m. UTC
And not just those with the old decode() API.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/decode.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

James Almer July 9, 2023, 7:37 p.m. UTC | #1
On 7/9/2023 10:39 AM, James Almer wrote:
> And not just those with the old decode() API.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/decode.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index a39af2d014..b3e4b066e5 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);

I'm withdrawing this patch for now. discard_samples() uses 
avci->last_pkt_props to fetch SKIP_SAMPLES packet side data which is not 
necessarily correct on receive_frame() decoders (like those setting 
FF_CODEC_CAP_SETS_FRAME_PROPS).
diff mbox series

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a39af2d014..b3e4b066e5 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);