From 04aff50c3b6e793c26ceeaed4c1d604bde97612e Mon Sep 17 00:00:00 2001 From: seaweeduk <2912658+seaweeduk@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:50:52 +0000 Subject: [PATCH] 8K videos start again on SteamOS 0.5.10's new video driver --- .../frame/ffmpeg/libavcodec/v4l2_context.c | 93 +++++++++++++++++- .../frame/ffmpeg/libavcodec/v4l2_context.h | 8 +- packaging/frame/ffmpeg/libavcodec/v4l2_m2m.c | 28 +++++- packaging/frame/ffmpeg/libavcodec/v4l2_m2m.h | 6 ++ .../frame/ffmpeg/libavcodec/v4l2_m2m_dec.c | 3 + packaging/frame/mpv-v4l2-reset.patch | 98 ++++++++++++++----- 6 files changed, 206 insertions(+), 30 deletions(-) diff --git a/packaging/frame/ffmpeg/libavcodec/v4l2_context.c b/packaging/frame/ffmpeg/libavcodec/v4l2_context.c index 7815036..cba65e4 100644 --- a/packaging/frame/ffmpeg/libavcodec/v4l2_context.c +++ b/packaging/frame/ffmpeg/libavcodec/v4l2_context.c @@ -1040,6 +1040,52 @@ static int stuff_all_buffers(AVCodecContext * avctx, V4L2Context* ctx) return rv; } +// Adds the capture buffers create_buffers() left for after STREAMON, until +// the pool's total or, past the driver's minimum, until memory runs out. +static int add_late_buffers(AVCodecContext * const avctx, V4L2Context * const ctx) +{ + V4L2m2mContext * const s = ctx_to_m2mctx(ctx); + int tries = 0; + int ret = 0; + + while (ctx->num_buffers < ctx->late_target) { + struct v4l2_create_buffers create = {.count = 1, .memory = ctx->buf_mem, .format = ctx->format}; + if (ioctl(s->fd, VIDIOC_CREATE_BUFS, &create) < 0) { + const int err = errno; + if (err == EINTR) + continue; + // The old working memory goes when the firmware answers its + // release, shortly after STREAMON. + if (err == ENOMEM && ++tries < (ctx->num_buffers < ctx->late_minimum ? 50 : 5)) { + usleep(4000); + continue; + } + if (err == ENOMEM && ctx->num_buffers >= ctx->late_minimum) + break; + ret = AVERROR(err); + av_log(avctx, AV_LOG_ERROR, "%s VIDIOC_CREATE_BUFS failed with %d of %d buffers: %s\n", + ctx->name, ctx->num_buffers, ctx->late_minimum, av_err2str(ret)); + return ret; + } + if (create.count != 1 || create.index != (unsigned int)ctx->num_buffers) + return AVERROR(EINVAL); + ff_mutex_lock(&ctx->lock); + ret = ff_v4l2_buffer_initialize(&ctx->bufrefs[ctx->num_buffers], ctx->num_buffers, ctx, ctx->buf_mem); + if (!ret) { + V4L2Buffer * const buf = (V4L2Buffer *)ctx->bufrefs[ctx->num_buffers]->data; + ++ctx->num_buffers; + ret = ff_v4l2_buffer_enqueue(buf); + } + ff_mutex_unlock(&ctx->lock); + if (ret < 0) + return ret; + } + av_log(avctx, AV_LOG_INFO, "%s: driver minimum %d buffers, %d in all, made after streaming started\n", + ctx->name, ctx->late_minimum, ctx->num_buffers); + ctx->late_target = 0; + return 0; +} + static int set_streamon(AVCodecContext * const avctx, V4L2Context*const ctx) { int type = ctx->type; @@ -1055,6 +1101,17 @@ static int set_streamon(AVCodecContext * const avctx, V4L2Context*const ctx) ret = AVERROR(errno); av_log(avctx, AV_LOG_ERROR, "%s set status ON failed: err=%s\n", ctx->name, av_err2str(ret)); + + // The upstream Iris driver allocates its reference frames and working + // memory here, after the pool, all within the decoder's address + // range. The pool only holds frames for display there, so the caller + // can retry with the driver's minimum and a frame to spare. + if (ret == AVERROR(ENOMEM) && !V4L2_TYPE_IS_OUTPUT(ctx->type) && + ctx_to_m2mctx(ctx)->iris_reports_minimum) { + av_log(avctx, AV_LOG_WARNING, "%s: the driver refused a pool of %d buffers\n", + ctx->name, ctx->num_buffers); + ((V4L2m2mPriv *)ctx_to_m2mctx(ctx)->priv)->capture_start_refused = 1; + } return ret; } @@ -1063,6 +1120,8 @@ static int set_streamon(AVCodecContext * const avctx, V4L2Context*const ctx) ctx->flag_last = 0; ctx->actual_last = 0; av_log(avctx, AV_LOG_DEBUG, "%s set status ON OK\n", ctx->name); + if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx->late_target > ctx->num_buffers) + ret = add_late_buffers(avctx, ctx); return ret; } @@ -1374,7 +1433,37 @@ static int create_buffers(V4L2Context* const ctx, const unsigned int req_buffers req.count = spare >= 0 ? 1 : req_buffers; req.memory = mem; req.type = ctx->type; - while ((ret = ioctl(s->fd, VIDIOC_REQBUFS, &req)) == -1) { + ctx->late_target = ctx->late_minimum = 0; + // The upstream Iris driver allocates its reference frames and working + // memory at capture STREAMON, the new set before it frees the old, all in + // the decoder's address range. A pool allocated first can leave them no + // room (8K HEVC Main 10 with a minimum of 8 had none even at 8), so start + // with one buffer and add the rest once streaming (VIDIOC_CREATE_BUFS + // takes an exact count, VIDIOC_REQBUFS the driver's minimum). + if (spare >= 0 && s->iris_reports_minimum && !s->iris_startup) { + struct v4l2_control minimum = {.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE}; + struct v4l2_create_buffers create = {.count = 1, .memory = mem, .format = ctx->format}; + if (ioctl(s->fd, VIDIOC_G_CTRL, &minimum) < 0 || minimum.value < 1) { + av_log(logger(ctx), AV_LOG_ERROR, "%s: no capture minimum from the driver\n", ctx->name); + return AVERROR(EINVAL); + } + while ((ret = ioctl(s->fd, VIDIOC_CREATE_BUFS, &create)) == -1) { + if (errno != EINTR) { + ret = AVERROR(errno); + av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_CREATE_BUFS failed: %s\n", ctx->name, av_err2str(ret)); + return ret; + } + } + if (create.count != 1 || create.index != 0) { + ret = AVERROR(EINVAL); + goto fail_release; + } + ctx->late_minimum = minimum.value; + ctx->late_target = minimum.value + spare; + req.count = 1; + spare = 0; + } + else while ((ret = ioctl(s->fd, VIDIOC_REQBUFS, &req)) == -1) { if (errno != EINTR) { ret = AVERROR(errno); av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_REQBUFS failed: %s\n", ctx->name, av_err2str(ret)); @@ -1404,7 +1493,7 @@ static int create_buffers(V4L2Context* const ctx, const unsigned int req_buffers } ctx->num_buffers = req.count; - ctx->bufrefs = av_mallocz(ctx->num_buffers * sizeof(*ctx->bufrefs)); + ctx->bufrefs = av_mallocz(FFMAX(ctx->num_buffers, ctx->late_target) * sizeof(*ctx->bufrefs)); if (!ctx->bufrefs) { av_log(logger(ctx), AV_LOG_ERROR, "%s malloc enomem\n", ctx->name); ret = AVERROR(ENOMEM); diff --git a/packaging/frame/ffmpeg/libavcodec/v4l2_context.h b/packaging/frame/ffmpeg/libavcodec/v4l2_context.h index 4b5e05b..3e1c012 100644 --- a/packaging/frame/ffmpeg/libavcodec/v4l2_context.h +++ b/packaging/frame/ffmpeg/libavcodec/v4l2_context.h @@ -94,10 +94,16 @@ typedef struct V4L2Context { AVBufferRef **bufrefs; /** - * Readonly after init. + * Readonly after init, except while late_target adds capture buffers. */ int num_buffers; + /** + * Capture buffers made after STREAMON on the upstream Iris driver: the + * pool's total (bufrefs has room for it) and the driver's minimum. + */ + int late_target, late_minimum; + /** * Buffer memory type V4L2_MEMORY_MMAP or V4L2_MEMORY_DMABUF */ diff --git a/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.c b/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.c index 96fbd49..f0748a9 100644 --- a/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.c +++ b/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.c @@ -100,6 +100,14 @@ static int v4l2_prepare_contexts(V4L2m2mContext *s, int probe) v4l2_mplane_video(&cap) ? "mplane" : v4l2_splane_video(&cap) ? "splane" : "unknown"); + s->iris_reports_minimum = 0; + if (!probe && !strcmp((const char *)cap.driver, "iris_driver")) { + struct v4l2_queryctrl ctrl = {.id = V4L2_CID_MIN_BUFFERS_FOR_CAPTURE}; + s->iris_reports_minimum = !ioctl(s->fd, VIDIOC_QUERYCTRL, &ctrl); + av_log(log_ctx, AV_LOG_INFO, "Iris %s its capture minimum\n", + s->iris_reports_minimum ? "reports" : "doesn't report"); + } + if (v4l2_mplane_video(&cap)) { s->capture.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; s->output.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; @@ -255,6 +263,21 @@ static int v4l2_configure_contexts(V4L2m2mContext *s) cfmt.fmt.pix.pixelformat), av_get_pix_fmt_name(s->capture.av_pix_fmt) ?: "none"); + // The stateful decoder's input size is provisional: the stream's headers + // give the real one at the source change. Iris sizes the working memory + // it allocates before then from it, and at capture start allocates the + // real size's before freeing that: an 8K input format left 8K HEVC Main 10 + // no room to start. 4096x2560 still gets input buffers for 8K frames. + if (s->iris_reports_minimum && s->avctx && av_codec_is_decoder(s->avctx->codec) && + V4L2_TYPE_IS_MULTIPLANAR(s->output.format.type) && + (uint64_t)s->output.format.fmt.pix_mp.width * s->output.format.fmt.pix_mp.height > + 4096 * 2560) { + av_log(log_ctx, AV_LOG_INFO, "Iris: provisional input size 4096x2560 for %ux%u\n", + s->output.format.fmt.pix_mp.width, s->output.format.fmt.pix_mp.height); + s->output.format.fmt.pix_mp.width = 4096; + s->output.format.fmt.pix_mp.height = 2560; + } + ret = ff_v4l2_context_set_format(&s->output); if (ret) { av_log(log_ctx, AV_LOG_ERROR, "can't set v4l2 output format\n"); @@ -268,7 +291,10 @@ static int v4l2_configure_contexts(V4L2m2mContext *s) } ret = ff_v4l2_context_init(&s->output); - if (ret == AVERROR(ENOMEM) && s->avctx && av_codec_is_decoder(s->avctx->codec)) { + // The staged start relies on the old driver keeping the capture format + // through input format changes; the upstream driver replaces it. + if (ret == AVERROR(ENOMEM) && s->avctx && av_codec_is_decoder(s->avctx->codec) && + !s->iris_reports_minimum) { V4L2m2mPriv *priv = s->priv; struct v4l2_capability cap = {0}; const int iris = !ioctl(s->fd, VIDIOC_QUERYCAP, &cap) && !strcmp(cap.driver, "iris_driver"); diff --git a/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.h b/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.h index 49b9a98..1c84c18 100644 --- a/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.h +++ b/packaging/frame/ffmpeg/libavcodec/v4l2_m2m.h @@ -130,6 +130,11 @@ typedef struct V4L2m2mContext { enum IrisStartup iris_startup; int64_t iris_startup_deadline; int64_t iris_seek_deadline; + // Iris that reports its capture minimum (V4L2_CID_MIN_BUFFERS_FOR_CAPTURE), + // as the upstream driver in SteamOS 0.5.10 does: it decodes into private + // reference buffers and follows the stateful decoder sequence, so large + // streams start from a provisional input size, never the staged start. + int iris_reports_minimum; // No usable SPS in the codec header: the first packet's decides. int iris_sps_in_band; // H.264's DPB size for the staged pool; its reorder_size stays the @@ -201,6 +206,7 @@ typedef struct V4L2m2mPriv { int num_output_buffers; int num_capture_buffers; int capture_spare; + int capture_start_refused; int drain_seek_status; int capture_ubwc; int capture_10bit; diff --git a/packaging/frame/ffmpeg/libavcodec/v4l2_m2m_dec.c b/packaging/frame/ffmpeg/libavcodec/v4l2_m2m_dec.c index bb06334..2475e4f 100644 --- a/packaging/frame/ffmpeg/libavcodec/v4l2_m2m_dec.c +++ b/packaging/frame/ffmpeg/libavcodec/v4l2_m2m_dec.c @@ -1879,6 +1879,9 @@ static const AVOption options[] = { OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 20}, 2, INT_MAX, FLAGS }, { "capture_spare", "Capture buffers beyond the driver's minimum; replaces num_capture_buffers (-1: off)", OFFSET(capture_spare), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 32, FLAGS }, + { "capture_start_refused", "The driver refused to start capture with the fixed num_capture_buffers pool", + OFFSET(capture_start_refused), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, + FLAGS | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, { "drain_seek_status", "Result of the last same-session seek (1: kept, negative: reopen needed)", OFFSET(drain_seek_status), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, 1, FLAGS | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, diff --git a/packaging/frame/mpv-v4l2-reset.patch b/packaging/frame/mpv-v4l2-reset.patch index 06866ac..6bf1c17 100644 --- a/packaging/frame/mpv-v4l2-reset.patch +++ b/packaging/frame/mpv-v4l2-reset.patch @@ -2,18 +2,39 @@ # packaging/mpv/mpv-mvc.patch. --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c -@@ -55,6 +55,10 @@ +@@ -55,6 +55,31 @@ #include "video/out/vo.h" #include "vd_mvc.h" +// Frame converter (video/out/hwdec/dmabuf_ubwc.c): lets go of a closed +// V4L2 session's buffers. +void frame_ubwc_decoder_closed(void); ++ ++// Frame: the smallest picture area, by codec and bit depth, whose capture ++// pool the upstream Iris driver refused. Later sessions at least that large ++// take the smallest pool at once, so a seek or the next file doesn't fail first. ++static _Atomic int64_t v4l2_refused_area[2][2] = {{INT64_MAX, INT64_MAX}, {INT64_MAX, INT64_MAX}}; ++ ++static _Atomic int64_t *v4l2_refused(const AVCodecParameters *par) ++{ ++ const AVPixFmtDescriptor *source = av_pix_fmt_desc_get(par->format); ++ return &v4l2_refused_area[par->codec_id == AV_CODEC_ID_HEVC] ++ [source && source->comp[0].depth > 8]; ++} ++ ++static void v4l2_note_refused(const AVCodecParameters *par) ++{ ++ _Atomic int64_t *refused = v4l2_refused(par); ++ int64_t area = (int64_t)par->width * par->height; ++ int64_t old = atomic_load(refused); ++ while (area > 0 && area < old && !atomic_compare_exchange_weak(refused, &old, area)) { ++ } ++} + #include "options/m_option.h" static void init_avctx(struct mp_filter *vd); -@@ -147,6 +151,7 @@ struct hwdec_opts { +@@ -147,6 +172,7 @@ struct hwdec_opts { int hwdec_image_format; int hwdec_extra_frames; int hwdec_threads; @@ -21,7 +42,7 @@ }; const struct m_sub_options hwdec_conf = { -@@ -165,6 +170,9 @@ const struct m_sub_options hwdec_conf = +@@ -165,6 +191,9 @@ const struct m_sub_options hwdec_conf = .flags = UPDATE_HWDEC}, {"hwdec-threads", OPT_INT(hwdec_threads), M_RANGE(0, DBL_MAX)}, {"vd-lavc-software-fallback", OPT_REPLACED("hwdec-software-fallback")}, @@ -31,7 +52,7 @@ {0} }, .size = sizeof(struct hwdec_opts), -@@ -219,6 +227,12 @@ typedef struct lavc_ctx { +@@ -219,6 +248,13 @@ typedef struct lavc_ctx { bool hwdec_failed; bool hwdec_notified; bool force_eof; @@ -39,12 +60,13 @@ + bool v4l2_fed; // packets were sent since the session opened + bool retry_v4l2_allocation; + bool retried_v4l2_allocation; ++ bool v4l2_smallest_pool; // this session asked for the driver's minimum and one more + bool prefer_v4l2_ubwc; + bool v4l2_eof; bool intra_only; int framedrop_flags; -@@ -698,10 +712,23 @@ static void force_fallback(struct mp_fil +@@ -698,10 +734,23 @@ static void force_fallback(struct mp_fil { vd_ffmpeg_ctx *ctx = vd->priv; @@ -71,7 +93,7 @@ select_and_set_hwdec(vd); init_avctx(vd); } -@@ -711,6 +738,8 @@ static void reinit(struct mp_filter *vd) +@@ -711,6 +760,8 @@ static void reinit(struct mp_filter *vd) vd_ffmpeg_ctx *ctx = vd->priv; uninit_avctx(vd); @@ -80,17 +102,18 @@ /* * Reset attempted hwdecs so that if the hwdec list is reconfigured -@@ -738,6 +767,9 @@ static void init_avctx(struct mp_filter +@@ -738,6 +789,10 @@ static void init_avctx(struct mp_filter vd_ffmpeg_ctx *ctx = vd->priv; struct vd_lavc_params *lavc_param = ctx->opts; struct mp_codec_params *c = ctx->codec; + ctx->reopen_v4l2 = false; + ctx->v4l2_eof = false; + ctx->v4l2_fed = false; ++ ctx->v4l2_smallest_pool = false; m_config_cache_update(ctx->opts_cache); -@@ -753,6 +785,34 @@ static void init_avctx(struct mp_filter +@@ -753,6 +808,34 @@ static void init_avctx(struct mp_filter if (!lavc_codec) return; @@ -125,7 +148,7 @@ const AVCodecDescriptor *desc = avcodec_descriptor_get(lavc_codec->id); ctx->intra_only = desc && (desc->props & AV_CODEC_PROP_INTRA_ONLY); -@@ -768,6 +828,26 @@ static void init_avctx(struct mp_filter +@@ -768,6 +851,37 @@ static void init_avctx(struct mp_filter avctx->codec_id = lavc_codec->id; avctx->pkt_timebase = ctx->codec_timebase; @@ -146,13 +169,24 @@ + spare += 3; + av_opt_set_int(avctx->priv_data, "capture_spare", spare, 0); + } ++ // The upstream Iris driver (SteamOS 0.5.10) keeps its reference frames ++ // apart, and fits them, its working memory and the pool in one address ++ // range: 8K HEVC Main 10 starts with at most one frame beyond its minimum. ++ // Once it refused a pool, a stream that size takes that one. ++ if (wrapper && strcmp(wrapper, "v4l2m2m") == 0 && c->lav_codecpar && ++ (avctx->codec_id == AV_CODEC_ID_HEVC || avctx->codec_id == AV_CODEC_ID_H264)) { ++ const AVCodecParameters *par = c->lav_codecpar; ++ ctx->v4l2_smallest_pool = (int64_t)par->width * par->height >= atomic_load(v4l2_refused(par)); ++ if (ctx->v4l2_smallest_pool) ++ av_opt_set_int(avctx->priv_data, "capture_spare", 1, 0); ++ } + if (wrapper && strcmp(wrapper, "v4l2m2m") == 0 && (ctx->prefer_v4l2_ubwc || q08c)) + av_opt_set_int(avctx->priv_data, "capture_ubwc", 1, 0); + ctx->pic = av_frame_alloc(); if (!ctx->pic) goto error; -@@ -917,8 +997,20 @@ static void reset_avctx(struct mp_filter +@@ -917,8 +1031,20 @@ static void reset_avctx(struct mp_filter { vd_ffmpeg_ctx *ctx = vd->priv; @@ -175,7 +209,7 @@ ctx->flushing = false; ctx->hwdec_request_reinit = false; } -@@ -957,7 +1049,13 @@ static void uninit_avctx(struct mp_filte +@@ -957,7 +1083,13 @@ static void uninit_avctx(struct mp_filte mp_free_av_packet(&ctx->avpkt); av_buffer_unref(&ctx->cached_hw_frames_ctx); @@ -189,7 +223,7 @@ av_buffer_unref(&ctx->hwdec_dev); -@@ -1195,7 +1293,7 @@ static void prepare_decoding(struct mp_f +@@ -1195,7 +1327,7 @@ static void prepare_decoding(struct mp_f reset_avctx(vd); } @@ -198,7 +232,7 @@ { vd_ffmpeg_ctx *ctx = vd->priv; struct hwdec_opts *hwdec_opts = ctx->hwdec_opts; -@@ -1204,6 +1302,15 @@ static void handle_err(struct mp_filter +@@ -1204,6 +1336,27 @@ static void handle_err(struct mp_filter ctx->use_hwdec ? " (hardware decoding)" : ""); if (ctx->use_hwdec) { @@ -207,14 +241,26 @@ + // Both send_packet and receive_frame can start V4L2 capture. + // Replay the saved startup packets once in a fresh session. Iris + // can also refuse a compressed capture start once after a seek. ++ // A refused pool gets its own retry with the smallest pool, even ++ // after an earlier allocation failure took the first. ++ const AVCodecParameters *par = ctx->codec->lav_codecpar; ++ int64_t refused = 0; ++ bool smaller = false; ++ if (par && (par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_H264) && ++ av_opt_get_int(ctx->avctx->priv_data, "capture_start_refused", 0, &refused) >= 0 && ++ refused) { ++ v4l2_note_refused(par); ++ smaller = !ctx->v4l2_smallest_pool; ++ MP_WARN(vd, "V4L2 refused the capture pool; using the driver's minimum and one more.\n"); ++ } + ctx->retry_v4l2_allocation = ctx->hw_probing && -+ !ctx->retried_v4l2_allocation; ++ (!ctx->retried_v4l2_allocation || smaller); + ctx->hwdec_failed = true; + } ctx->hwdec_fail_count += 1; if (ctx->hwdec_fail_count >= hwdec_opts->software_fallback) ctx->hwdec_failed = true; -@@ -1253,7 +1360,7 @@ static bool send_mvc_queue(struct mp_fil +@@ -1253,7 +1406,7 @@ static bool send_mvc_queue(struct mp_fil if (ret == AVERROR(EAGAIN)) return true; if (ret < 0 && ret != AVERROR_EOF) @@ -223,7 +269,7 @@ vd_mvc_pop(ctx->mvc); } return false; -@@ -1262,6 +1369,29 @@ static bool send_mvc_queue(struct mp_fil +@@ -1262,6 +1415,29 @@ static bool send_mvc_queue(struct mp_fil static int send_packet(struct mp_filter *vd, struct demux_packet *pkt) { vd_ffmpeg_ctx *ctx = vd->priv; @@ -253,7 +299,7 @@ if (ctx->num_requeue_packets && ctx->requeue_packets[0] != pkt) return AVERROR(EAGAIN); // cannot consume the packet -@@ -1291,6 +1421,7 @@ static int send_packet(struct mp_filter +@@ -1291,6 +1467,7 @@ static int send_packet(struct mp_filter return 0; int ret; @@ -261,7 +307,7 @@ if (ctx->mvc) { if (!vd_mvc_send(ctx->mvc, pkt)) { // The rewrite can't take this stream: carry on in 2D, from a -@@ -1328,7 +1459,7 @@ static int send_packet(struct mp_filter +@@ -1328,7 +1505,7 @@ static int send_packet(struct mp_filter } if (ret < 0) @@ -270,7 +316,7 @@ return ret; } -@@ -1352,6 +1483,8 @@ static int decode_frame(struct mp_filter +@@ -1352,6 +1529,8 @@ static int decode_frame(struct mp_filter if (!avctx || ctx->force_eof) return AVERROR_EOF; @@ -279,7 +325,7 @@ prepare_decoding(vd); -@@ -1362,9 +1495,20 @@ static int decode_frame(struct mp_filter +@@ -1362,9 +1541,20 @@ static int decode_frame(struct mp_filter if (ctx->mvc) send_mvc_queue(vd); @@ -300,7 +346,7 @@ // If flushing was initialized earlier and has ended now, make it // start over in case we get new packets at some point in the future. // This must take the delay queue into account, so avctx returns EOF -@@ -1374,11 +1518,23 @@ static int decode_frame(struct mp_filter +@@ -1374,11 +1564,23 @@ static int decode_frame(struct mp_filter } else if (ret == AVERROR(EAGAIN)) { // just retry after caller writes a packet } else { @@ -325,7 +371,7 @@ mp_codec_info_from_av(avctx, ctx->codec); // If something was decoded successfully, it must return a frame with valid -@@ -1394,7 +1550,7 @@ static int decode_frame(struct mp_filter +@@ -1394,7 +1596,7 @@ static int decode_frame(struct mp_filter if (mpi->imgfmt == IMGFMT_CUDA && !mpi->planes[0]) { MP_ERR(vd, "CUDA frame without data. This is a FFmpeg bug.\n"); talloc_free(mpi); @@ -334,7 +380,7 @@ return AVERROR_BUG; } -@@ -1415,7 +1571,7 @@ static int decode_frame(struct mp_filter +@@ -1415,7 +1617,7 @@ static int decode_frame(struct mp_filter if (!sw) { MP_ERR(vd, "Could not copy back hardware decoded frame.\n"); ctx->hwdec_fail_count = INT_MAX - 1; // force fallback @@ -343,7 +389,7 @@ return AVERROR_UNKNOWN; } mpi = sw; -@@ -1426,6 +1582,21 @@ static int decode_frame(struct mp_filter +@@ -1426,6 +1628,21 @@ static int decode_frame(struct mp_filter return ret; } @@ -365,7 +411,7 @@ MP_TARRAY_APPEND(ctx, ctx->delay_queue, ctx->num_delay_queue, mpi); return ret; } -@@ -1490,7 +1661,7 @@ static int receive_frame(struct mp_filte +@@ -1490,7 +1707,7 @@ static int receive_frame(struct mp_filte if (!res) { MP_ERR(vd, "Could not copy back hardware decoded frame.\n"); ctx->hwdec_fail_count = INT_MAX - 1; // force fallback @@ -374,7 +420,7 @@ return AVERROR_UNKNOWN; } } -@@ -1571,6 +1742,10 @@ static void vd_lavc_reset(struct mp_filt +@@ -1571,6 +1788,10 @@ static void vd_lavc_reset(struct mp_filt flush_all(vd);