From fc3e28f1e9be65e4c41812a84e86fbade7317847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Fri, 30 Jun 2023 19:14:32 +0200 Subject: [PATCH] vd_lavc: fix delay_queue for videos with frames < max_delay_queue In case there are no packets from demuxer we cannot send EAGAIN, because we will not proceed and get stuck with one frame in queue and never output it. Just respect avcodec_receive_frame ret code and act accordingly. The only case to care about is EOF when we have to drain already queued frames. Fixes playback of 1-2 frame videos. --- video/decode/vd_lavc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index b18e06deb0..8c5c7e8af5 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -1215,11 +1215,11 @@ static int receive_frame(struct mp_filter *vd, struct mp_frame *out_frame) if (ret == AVERROR(EAGAIN) && ctx->num_requeue_packets) return 0; // force retry, so send_queued_packet() gets called - if (!ctx->num_delay_queue) + if (ctx->num_delay_queue <= ctx->max_delay_queue && ret != AVERROR_EOF) return ret; - if (ctx->num_delay_queue <= ctx->max_delay_queue && ret != AVERROR_EOF) - return AVERROR(EAGAIN); + if (!ctx->num_delay_queue) + return ret; struct mp_image *res = ctx->delay_queue[0]; MP_TARRAY_REMOVE_AT(ctx->delay_queue, ctx->num_delay_queue, 0);