From beb8d27912cb8d831962ac386b26d7b02929307d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 4 Feb 2018 19:00:28 +0100 Subject: vd_lavc: fix recently broken hardware decode fallback This is a dataflow issue caused by the filters change. When the fallback happens, vd_lavc does not return a frame, but also does not accept a new packet, which confuses lavc_process(). Fix this by immediately retrying to feed the buffered packet and decode a frame on fallback. Fixes #5489. --- video/decode/vd_lavc.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 1aaca6b335..b306e57ffa 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -976,18 +976,24 @@ static bool do_send_packet(struct mp_filter *vd, struct demux_packet *pkt) return true; } -static bool send_packet(struct mp_filter *vd, struct demux_packet *pkt) +static bool send_queued(struct mp_filter *vd) { vd_ffmpeg_ctx *ctx = vd->priv; - if (ctx->num_requeue_packets) { - if (do_send_packet(vd, ctx->requeue_packets[0])) { - talloc_free(ctx->requeue_packets[0]); - MP_TARRAY_REMOVE_AT(ctx->requeue_packets, ctx->num_requeue_packets, 0); - } - return false; + while (ctx->num_requeue_packets && do_send_packet(vd, ctx->requeue_packets[0])) + { + talloc_free(ctx->requeue_packets[0]); + MP_TARRAY_REMOVE_AT(ctx->requeue_packets, ctx->num_requeue_packets, 0); } + return ctx->num_requeue_packets == 0; +} + +static bool send_packet(struct mp_filter *vd, struct demux_packet *pkt) +{ + if (!send_queued(vd)) + return false; + return do_send_packet(vd, pkt); } @@ -1052,6 +1058,9 @@ static bool receive_frame(struct mp_filter *vd, struct mp_frame *out_frame) ctx->requeue_packets = pkts; ctx->num_requeue_packets = num_pkts; + + send_queued(vd); + progress = decode_frame(vd); } if (!ctx->num_delay_queue) -- cgit v1.2.3