From e04db3b4f021971fbeeac3fabae8741f461efd96 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 08:35:10 +0100 Subject: [PATCH 1/4] media: apple: avd: use VP9 temporal MVs only from a frame of the same size VP9 predicts motion vectors from the previous frame only if that frame has the same size (UsePrevFrameMvs in compute_image_size(), libvpx's use_prev_frame_mvs). avd_vp9_uses_prev_mv() does not compare sizes, so after a size change the decoder reads the previous frame's MV buffer, which is laid out for the other size. Frames of different sizes already pass validate_dec_params() when they share the 64x16 aligned capture format, e.g. 1920x1080 and 1900x1080. Accepting frames smaller than the capture format, as aurora-silicon/linux#2136 does, makes this common: with that change alone, every VP9 stream that changes size on an inter frame without error resilience fails at the first frame of the new size with "open firmware error 0x8", a timeout and a decoder reset. With this patch no frame fails in the firmware. Record the size of each frame and require the previous one to match. The host test decodes a 1900x1080 frame after a 1920x1088 one and checks that the prior bank's MV buffer is not used. Signed-off-by: Thomas Glanzmann --- drivers/media/platform/apple/avd/avd-vp9.c | 30 ++++++++++++++----- .../platform/apple/avd/tests/vp9-test.py | 12 ++++++++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/apple/avd/avd-vp9.c b/drivers/media/platform/apple/avd/avd-vp9.c index 71b80796fd09..3d426655cc6a 100644 --- a/drivers/media/platform/apple/avd/avd-vp9.c +++ b/drivers/media/platform/apple/avd/avd-vp9.c @@ -160,6 +160,8 @@ struct avd_vp9_frame_info { u32 tx_mode : 3; u32 interpolation_filter : 3; u32 flags; + u32 width; + u32 height; u64 timestamp; dma_addr_t color; struct v4l2_vp9_segmentation seg; @@ -268,13 +270,25 @@ static void set_refs(struct avd_ctx *ctx, struct avd_vp9_run *run) } } -/* Temporal MV input is the previous shown inter picture, not the new bank. */ -static bool avd_vp9_uses_prev_mv(u32 flags, const struct avd_vp9_frame_info *last) +static bool avd_vp9_same_size(const struct v4l2_ctrl_vp9_frame *frame, + const struct avd_vp9_frame_info *last) { - return !(flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) && - !(flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME) && last->valid && + return last->width == frame->frame_width_minus_1 + 1 && + last->height == frame->frame_height_minus_1 + 1; +} + +/* + * Temporal MV input is the previous shown inter picture, not the new bank. + * VP9 uses it only if that picture has the same frame size. + */ +static bool avd_vp9_uses_prev_mv(const struct v4l2_ctrl_vp9_frame *frame, + const struct avd_vp9_frame_info *last) +{ + return !(frame->flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) && + !(frame->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME) && last->valid && (last->flags & V4L2_VP9_FRAME_FLAG_SHOW_FRAME) && - !(last->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME); + !(last->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME) && + avd_vp9_same_size(frame, last); } static u32 make_flags1(struct avd_ctx *ctx, struct avd_vp9_run *run) @@ -328,7 +342,7 @@ static u32 make_flags1(struct avd_ctx *ctx, struct avd_vp9_run *run) flags |= VP9_SEG_ENABLED(frame->seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED); - flags |= VP9_HAS_REF(avd_vp9_uses_prev_mv(frame->flags, &vp9_ctx->last)); + flags |= VP9_HAS_REF(avd_vp9_uses_prev_mv(frame, &vp9_ctx->last)); flags |= VP9_SEG_RESET( frame->seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED && @@ -426,7 +440,7 @@ static void set_header(struct avd_ctx *ctx, struct avd_vp9_run *run) pusha(vp9_ctx->b->bufs.seg.addr, "seg", 1); pusha(vp9_ctx->b->bufs.seg.addr, "seg", 2); pusha(vp9_ctx->b->bufs.color.addr, "color", 3); - pusha(avd_vp9_uses_prev_mv(frame->flags, &vp9_ctx->last) ? + pusha(avd_vp9_uses_prev_mv(frame, &vp9_ctx->last) ? vp9_ctx->last.color : vp9_ctx->b->bufs.color.addr, "color", 4); @@ -568,6 +582,8 @@ static void update_ctx_cur_info(struct avd_vp9_ctx *vp9_ctx, vp9_ctx->b->cur.reference_mode = dec_params->reference_mode; vp9_ctx->b->cur.interpolation_filter = dec_params->interpolation_filter; vp9_ctx->b->cur.flags = dec_params->flags; + vp9_ctx->b->cur.width = dec_params->frame_width_minus_1 + 1; + vp9_ctx->b->cur.height = dec_params->frame_height_minus_1 + 1; vp9_ctx->b->cur.timestamp = buf->base.vb.vb2_buf.timestamp; vp9_ctx->b->cur.color = vp9_ctx->b->bufs.color.addr; vp9_ctx->b->cur.seg = dec_params->seg; diff --git a/drivers/media/platform/apple/avd/tests/vp9-test.py b/drivers/media/platform/apple/avd/tests/vp9-test.py index 0ea406aae177..b575b2762fc7 100644 --- a/drivers/media/platform/apple/avd/tests/vp9-test.py +++ b/drivers/media/platform/apple/avd/tests/vp9-test.py @@ -234,6 +234,18 @@ def without_includes(s): assert(p->bank[0].busy&&p->bank[1].busy); avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE);avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE); } + /* After a frame size change the temporal-MV input is not the prior bank. */ + params=(struct v4l2_ctrl_vp9_frame){.flags=V4L2_VP9_FRAME_FLAG_SHOW_FRAME, + .frame_width_minus_1=1919,.frame_height_minus_1=1087,.bit_depth=8}; + current_dst=&dst[0].base.vb;frame.idx=0;assert(!avd_vp9_run(&ctx)); + struct avd_vp9_bank *shown=p->b; + params.frame_width_minus_1=1899;params.frame_height_minus_1=1079; + current_dst=&dst[1].base.vb;frame.idx=1;assert(!avd_vp9_run(&ctx)); + assert(p->b!=shown&&p->last.width==1900&&p->last.height==1080); + {bool prior_color=false;u32 *words=program.cpu; + for(size_t j=0;jbufs.color.addr>>8))prior_color=true; + assert(!prior_color);} + avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE);avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE); /* The firmware transport keeps the 64-pixel floor. */ ctx.decoded_fmt.fmt.pix_mp.width=64;ctx.decoded_fmt.fmt.pix_mp.height=64; ctx.decoded_fmt.fmt.pix_mp.plane_fmt[0].bytesperline=64; From 6fd057431b55e034a3b01e7f97d97e09ba55cb2a Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 08:35:33 +0100 Subject: [PATCH 2/4] media: apple: avd: put the VP9 reference scale in the right halves set_refs() packs the horizontal reference scale into the upper 16 bits and the vertical one into the lower 16 bits. The decoder reads them the other way round. A reference scaled the same in both directions (2:1, 4:3) decodes either way, so only references whose aspect ratio differs from the frame's were wrong. A frame whose size changes within its 64x16 aligned capture format (1920x1080 to 1900x1080) already predicts from such a reference. Once frames smaller than the capture format are accepted (aurora-silicon/linux#2136), libvpx's vp90-2-05-resize.ivf (352x288 to 282x173) and vp90-2-18-resize.ivf (310x230 to 248x138) do too, and decode bit-exact against libvpx's MD5s: 10 of 10 and 100 of 100 frames, up from 3 and 94. Pack the vertical scale with AVD_HDR_HEIGHT() and the horizontal one with AVD_HDR_WIDTH(), as the reference size above it is. The host test checks the word for a 1440x1088 reference of a 1920x1088 frame. Signed-off-by: Thomas Glanzmann --- drivers/media/platform/apple/avd/avd-vp9.c | 2 +- drivers/media/platform/apple/avd/tests/vp9-test.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/apple/avd/avd-vp9.c b/drivers/media/platform/apple/avd/avd-vp9.c index 3d426655cc6a..18a0717349f8 100644 --- a/drivers/media/platform/apple/avd/avd-vp9.c +++ b/drivers/media/platform/apple/avd/avd-vp9.c @@ -263,7 +263,7 @@ static void set_refs(struct avd_ctx *ctx, struct avd_vp9_run *run) dst->vp9.width; yscale = (ref_buf[i]->vp9.height << VP9_REF_SCALE_SHIFT) / dst->vp9.height; - push(AVD_HDR_HEIGHT(xscale) | AVD_HDR_WIDTH(yscale), + push(AVD_HDR_HEIGHT(yscale) | AVD_HDR_WIDTH(xscale), "ref_scale"); push_comp(ctx, addr, ref_buf[i]->comp.offsets); diff --git a/drivers/media/platform/apple/avd/tests/vp9-test.py b/drivers/media/platform/apple/avd/tests/vp9-test.py index b575b2762fc7..e3a57861830d 100644 --- a/drivers/media/platform/apple/avd/tests/vp9-test.py +++ b/drivers/media/platform/apple/avd/tests/vp9-test.py @@ -246,6 +246,13 @@ def without_includes(s): for(size_t j=0;jbufs.color.addr>>8))prior_color=true; assert(!prior_color);} avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE);avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE); + /* A 1440x1088 reference of a 1920x1088 frame: vertical scale high, horizontal low. */ + params.frame_width_minus_1=1919;params.frame_height_minus_1=1087;reference.vp9.width=1440; + current_dst=&dst[0].base.vb;frame.idx=0;assert(!avd_vp9_run(&ctx)); + {bool scale=false;u32 *words=program.cpu; + for(size_t j=0;j Date: Tue, 17 Nov 2026 08:36:13 +0100 Subject: [PATCH 3/4] media: apple: avd: reset the VP9 segmentation map when the frame size changes VP9 clears the segmentation map when the frame size changes (compute_image_size(); libvpx zeroes last_frame_seg_map). The driver sets VP9_SEG_RESET only for key frames and after an intra frame without segmentation, and the decoder keeps part of the map in the seg buffer across frames. After a size change, a frame that predicts its segment IDs from the previous frame or keeps them (update_map 0) used the old map, laid out for the other size. After a size change, set VP9_SEG_RESET for every frame that uses segmentation until one updates the map. The decoder does not carry a reset map forward: a frame that keeps the map (update_map 0) after one with VP9_SEG_RESET reads the old map again, so the reset is repeated until a frame has written a new map. Clear each bank's seg buffer before the bank next runs: a bank still busy with an earlier frame belongs to the hardware until it retires, so its buffer is cleared when it is next taken. Test streams from libvpx with internal scaling (VP8E_SET_SCALEMODE: full, half, full size on inter frames) and segmentation AQ, no error resilience, against libvpx-equivalent software decoding, with frames smaller than the capture format accepted (later in this series): 640x360 cyclic refresh (temporal map) 25/40 -> 40/40 variance, complexity (kept map) 10/40, 25/40 -> 40/40 1280x720 all three 40/40 1920x1080 all three 40/40 With the reset on the first frame of the new size only, the kept-map streams at 1280x720 and 1920x1080 went wrong from the second frame after the size grew back (26/40, 26/40, 28/40, 29/40). These streams ran on the legacy transport, which has one VP9 bank, and use segmentation on every frame. The host test checks, with two banks, that only a size change clears the buffers, that a busy bank's buffer waits until the bank is taken, and that the reset stays until a frame updates the map. Signed-off-by: Thomas Glanzmann --- drivers/media/platform/apple/avd/avd-vp9.c | 31 +++++++++++++++++ .../platform/apple/avd/tests/vp9-test.py | 34 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/drivers/media/platform/apple/avd/avd-vp9.c b/drivers/media/platform/apple/avd/avd-vp9.c index 18a0717349f8..3c69c9586cf4 100644 --- a/drivers/media/platform/apple/avd/avd-vp9.c +++ b/drivers/media/platform/apple/avd/avd-vp9.c @@ -200,6 +200,8 @@ struct avd_vp9_bank { struct avd_vp9_frame_info cur; struct avd_vp9_frame_info last; u8 submit_num; + /* The seg buffer holds a map laid out for another frame size. */ + bool seg_clear; }; struct avd_vp9_ctx { @@ -208,6 +210,8 @@ struct avd_vp9_ctx { unsigned int nbanks; struct avd_vp9_bank bank[AVD_VP9_BANKS]; struct avd_vp9_bank *b; + /* The size changed, and no frame has updated the segmentation map since. */ + bool seg_reset; }; static bool avd_vp9_needs_counts(u32 flags) @@ -347,6 +351,7 @@ static u32 make_flags1(struct avd_ctx *ctx, struct avd_vp9_run *run) flags |= VP9_SEG_RESET( frame->seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED && (frame->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME || + vp9_ctx->seg_reset || (vp9_ctx->last.valid && !(vp9_ctx->last.seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED) && @@ -593,6 +598,14 @@ static void update_ctx_cur_info(struct avd_vp9_ctx *vp9_ctx, static void update_ctx_last_info(struct avd_vp9_ctx *vp9_ctx) { vp9_ctx->last = vp9_ctx->b->cur; + /* + * The decoder does not carry a reset map forward: a frame that keeps the + * map after one with VP9_SEG_RESET reads the old map again. So the reset + * stays until a frame has written a new map. + */ + if ((vp9_ctx->last.seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLED) && + (vp9_ctx->last.seg.flags & V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP)) + vp9_ctx->seg_reset = false; } static void copy_vp9_frame_mv(struct avd_vp9_probs *avd_probs, @@ -909,6 +922,24 @@ static int avd_vp9_run_preamble(struct avd_ctx *ctx, struct avd_vp9_run *run) bank - vp9_ctx->bank + 1; } + /* + * VP9 clears the segmentation map when the frame size changes, and the + * decoder carries part of it over in the seg buffer. Every bank's buffer + * holds the old map, but a busy bank's belongs to the hardware until the + * frame retires: clear each bank's when it is next taken. The map reset + * goes to every frame that uses segmentation until one updates the map + * (make_flags1(), update_ctx_last_info()). + */ + if (vp9_ctx->last.valid && !avd_vp9_same_size(dec_params, &vp9_ctx->last)) { + for (unsigned int i = 0; i < vp9_ctx->nbanks; i++) + vp9_ctx->bank[i].seg_clear = true; + vp9_ctx->seg_reset = true; + } + if (vp9_ctx->b->seg_clear) { + memset(vp9_ctx->b->bufs.seg.cpu, 0, vp9_ctx->b->bufs.seg.size); + vp9_ctx->b->seg_clear = false; + } + vp9_ctx->b->cur.tx_mode = run->prob_updates->tx_mode; fctx_idx = v4l2_vp9_reset_frame_ctx(dec_params, vp9_ctx->frame_context); diff --git a/drivers/media/platform/apple/avd/tests/vp9-test.py b/drivers/media/platform/apple/avd/tests/vp9-test.py index e3a57861830d..01610c847a23 100644 --- a/drivers/media/platform/apple/avd/tests/vp9-test.py +++ b/drivers/media/platform/apple/avd/tests/vp9-test.py @@ -253,6 +253,40 @@ def without_includes(s): for(size_t j=0;jnbanks;i++)memset(p->bank[i].bufs.seg.cpu,0xa5,p->bank[i].bufs.seg.size); + /* Frame A writes a map, so no reset is owed from the earlier size changes. */ + params.seg.flags=V4L2_VP9_SEGMENTATION_FLAG_ENABLED|V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP; + current_dst=&dst[0].base.vb;frame.idx=0;assert(!avd_vp9_run(&ctx)); + assert(p->b==&p->bank[0]&&((u8 *)p->bank[0].bufs.seg.cpu)[0]==0xa5&&!p->seg_reset); + /* Bank 0 stays busy; the next frame is smaller and has no segmentation. */ + params.seg.flags=0;params.frame_width_minus_1=1899;params.frame_height_minus_1=1079; + current_dst=&dst[1].base.vb;frame.idx=1;assert(!avd_vp9_run(&ctx)); + assert(p->b==&p->bank[1]&&p->seg_reset&&p->bank[0].seg_clear&&!p->bank[1].seg_clear); + {u8 *seg=p->bank[1].bufs.seg.cpu;for(size_t j=0;jbank[1].bufs.seg.size;j++)assert(!seg[j]);} + assert(((u8 *)p->bank[0].bufs.seg.cpu)[0]==0xa5); + avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE); + avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE); + /* Same size again, segmentation on without a map update: the reset is still owed, and it stays + * owed after that frame, as the decoder would read the old map again. */ + params.seg.flags=V4L2_VP9_SEGMENTATION_FLAG_ENABLED;current_dst=&dst[0].base.vb; + {struct avd_vp9_run r={.decode_params=¶ms};r.base.bufs.dst=current_dst; + assert(make_flags1(&ctx,&r)&VP9_SEG_RESET(1));} + frame.idx=0;assert(!avd_vp9_run(&ctx)); + assert(p->b==&p->bank[0]&&!p->bank[0].seg_clear&&p->seg_reset); + {u8 *seg=p->bank[0].bufs.seg.cpu;for(size_t j=0;jbank[0].bufs.seg.size;j++)assert(!seg[j]);} + avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE); + /* The next frame updates the map: it still gets the reset, and after it the reset is gone. */ + params.seg.flags=V4L2_VP9_SEGMENTATION_FLAG_ENABLED|V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP; + current_dst=&dst[1].base.vb; + {struct avd_vp9_run r={.decode_params=¶ms};r.base.bufs.dst=current_dst; + assert(make_flags1(&ctx,&r)&VP9_SEG_RESET(1));} + frame.idx=1;assert(!avd_vp9_run(&ctx));assert(!p->seg_reset); + {struct avd_vp9_run r={.decode_params=¶ms};r.base.bufs.dst=current_dst; + assert(!(make_flags1(&ctx,&r)&VP9_SEG_RESET(1)));} + avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE);params.seg.flags=0; /* The firmware transport keeps the 64-pixel floor. */ ctx.decoded_fmt.fmt.pix_mp.width=64;ctx.decoded_fmt.fmt.pix_mp.height=64; ctx.decoded_fmt.fmt.pix_mp.plane_fmt[0].bytesperline=64; From a8e9047aac5025ec881cbe436a76663dfbbbd46e Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 08:41:32 +0100 Subject: [PATCH 4/4] media: apple: avd: decode VP9 frames smaller than the capture format VP9 inter frames can change the frame size and keep predicting from references of the old size. validate_dec_params() refuses every frame whose aligned size differs from the capture format, so userspace has to reallocate the capture buffers and loses those references. FFmpeg's V4L2 request VP9 hwaccel can instead keep the buffers and decode a frame that fits in place (FFmpeg PR 20847, fix 5), and the decoder already handles what this needs: each reference carries its own size and scale (set_refs()), the frame is written with the format's stride, and the scratch buffers are sized for the format. On the legacy transport, accept frames whose aligned size fits the capture format and keep refusing larger ones. The firmware transports (open-queue and the Apple backend) keep requiring the format's size, as they keep the 64-pixel floor: an input their firmware does not expect can reset the engine instead of failing the frame, and this has not been measured there yet. The host test runs a 960x540 frame in a 1920x1088 format on the legacy transport, refuses it on the firmware transport, and refuses a 1984x1088 one on both. On a J813 (legacy transport) with FFmpeg PR 20847 v2 (decoding in place) and the earlier patches of this series, the libvpx VP9 conformance vectors match libvpx's MD5s in 299 of 304 4:2:0 vectors, up from 273. The 26 are the 24 vp90-2-21-resize_inter vectors, vp90-2-05-resize and vp90-2-18-resize. No vector stopped matching, and no frame fails in the firmware. Userspace that renegotiates the format on every size change, such as FFmpeg's current code, decodes as before (273). H.264, HEVC, VP9 and AV1 test clips stay bit-exact. Signed-off-by: Thomas Glanzmann --- drivers/media/platform/apple/avd/avd-vp9.c | 17 ++++++++++++----- .../media/platform/apple/avd/tests/vp9-test.py | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/apple/avd/avd-vp9.c b/drivers/media/platform/apple/avd/avd-vp9.c index 3c69c9586cf4..93b6404ce593 100644 --- a/drivers/media/platform/apple/avd/avd-vp9.c +++ b/drivers/media/platform/apple/avd/avd-vp9.c @@ -698,7 +698,7 @@ static void init_probs(struct avd_ctx *ctx, const struct avd_vp9_run *run) static int validate_dec_params(struct avd_ctx *ctx, const struct v4l2_ctrl_vp9_frame *dec_params) { - unsigned int aligned_width, aligned_height; + unsigned int aligned_width, aligned_height, width, height; /* * The CAPTURE format is at least 64x64, the minimum of the VP9 frame @@ -721,11 +721,18 @@ static int validate_dec_params(struct avd_ctx *ctx, 64); /* - * Userspace should update the capture/decoded format when the - * resolution changes. + * A larger frame needs a new capture format. On the legacy transport + * a smaller one is decoded into the current buffers with their + * stride: VP9 inter frames can change size and keep predicting from + * references of the old size, which set_refs() scales, so userspace + * may keep the buffers. The firmware transports keep requiring the + * format's size until that is measured there, as for the floor above. */ - if (aligned_width != ctx->decoded_fmt.fmt.pix_mp.width || - aligned_height != ctx->decoded_fmt.fmt.pix_mp.height) { + width = ctx->decoded_fmt.fmt.pix_mp.width; + height = ctx->decoded_fmt.fmt.pix_mp.height; + if (avd_backend_is_open(ctx->dev) ? + (aligned_width > width || aligned_height > height) : + (aligned_width != width || aligned_height != height)) { dev_err(ctx->dev->dev, "unexpected bitstream resolution %dx%d\n", aligned_width, aligned_height); diff --git a/drivers/media/platform/apple/avd/tests/vp9-test.py b/drivers/media/platform/apple/avd/tests/vp9-test.py index 01610c847a23..13801c76ae12 100644 --- a/drivers/media/platform/apple/avd/tests/vp9-test.py +++ b/drivers/media/platform/apple/avd/tests/vp9-test.py @@ -287,6 +287,11 @@ def without_includes(s): {struct avd_vp9_run r={.decode_params=¶ms};r.base.bufs.dst=current_dst; assert(!(make_flags1(&ctx,&r)&VP9_SEG_RESET(1)));} avd_vp9_done(&ctx,&src,&dst[1].base.vb,VB2_BUF_STATE_DONE);params.seg.flags=0; + /* The firmware transport still needs the format's size: smaller and larger frames are refused. */ + params.frame_width_minus_1=959;params.frame_height_minus_1=539; + current_dst=&dst[0].base.vb;frame.idx=0;assert(avd_vp9_run(&ctx)==-EINVAL); + params.frame_width_minus_1=1983;params.frame_height_minus_1=1087; + current_dst=&dst[1].base.vb;frame.idx=1;assert(avd_vp9_run(&ctx)==-EINVAL); /* The firmware transport keeps the 64-pixel floor. */ ctx.decoded_fmt.fmt.pix_mp.width=64;ctx.decoded_fmt.fmt.pix_mp.height=64; ctx.decoded_fmt.fmt.pix_mp.plane_fmt[0].bytesperline=64; @@ -307,6 +312,18 @@ def without_includes(s): params.frame_width_minus_1=1919;params.frame_height_minus_1=1087; assert(avd_vp9_run(&ctx)==-EINVAL); avd_vp9_stop(&ctx); + /* On the legacy transport a frame smaller than the capture format runs in it, a larger one is refused. */ + ctx.decoded_fmt.fmt.pix_mp.width=1920;ctx.decoded_fmt.fmt.pix_mp.height=1088; + ctx.decoded_fmt.fmt.pix_mp.plane_fmt[0].bytesperline=1920; + dev.queued=false;vp_feature=false;assert(!avd_vp9_start(&ctx));p=ctx.priv; + params=(struct v4l2_ctrl_vp9_frame){.flags=V4L2_VP9_FRAME_FLAG_KEY_FRAME|V4L2_VP9_FRAME_FLAG_SHOW_FRAME, + .frame_width_minus_1=959,.frame_height_minus_1=539,.bit_depth=8}; + current_dst=&dst[0].base.vb;frame.idx=0;assert(!avd_vp9_run(&ctx)); + assert(dst[0].vp9.width==960&&dst[0].vp9.height==540); + avd_vp9_done(&ctx,&src,&dst[0].base.vb,VB2_BUF_STATE_DONE); + params.frame_width_minus_1=1983;params.frame_height_minus_1=1087; + current_dst=&dst[0].base.vb;frame.idx=0;assert(avd_vp9_run(&ctx)==-EINVAL); + avd_vp9_stop(&ctx); dev.queued=true;vp_feature=true;fail_alloc_after=13;allocating_ctx=&ctx; assert(avd_vp9_start(&ctx)==-ENOMEM);allocating_ctx=NULL; assert(!ctx.priv&&!avd_vp9_ready(&ctx)&&ctx.max_frames==1);