Inter-frame superres margin used SB-padded width, not true_width
Browse files at this commitf06baba6207231e9e0d04a533d95fcbac0fd8c4eParent: 17c9a9c- fix
- inter-frame superres margin used SB-padded width, not true_width
2 changed files +84 -103
- crates/ec-av1/src/decode.rs +17 -11
- lanes/superres-r9.report.md +67 -92
crates/ec-av1/src/decode.rsmodified+17 -11
| @@ -12736,19 +12736,25 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 12736 | } | 12736 | } |
| 12737 | out | 12737 | out |
| 12738 | }; | 12738 | }; |
| 12739 | - // lane-superres r10: same real-margin stash as | 12739 | + // lane-superres r10 (fixed r9): same real-margin stash as |
| 12740 | - // `decode_key_frame_tile_with_cdfs` (see that function's comment) -- an | 12740 | + // `decode_key_frame_tile_with_cdfs` (see that function's comment) -- the |
| 12741 | - // inter frame under `use_superres` crops from the same mi-aligned | 12741 | + // real reconstructed extent is the mi-aligned `true_width`/`true_height` |
| 12742 | - // `width`/`height` down to `fw`/`fh`, and `stream.rs`'s upscale needs | 12742 | + // (`mi_cols`/`mi_rows` * 4), NOT the superblock-padded `width`/`height` |
| 12743 | - // the same real border-extension columns, not a synthetic replicate. | 12743 | + // this branch was reading before: columns `[true_width, width)` were |
| 12744 | + // never actually coded (the last partial superblock stops at | ||
| 12745 | + // `true_width`), so stashing out to `width` handed the chroma upscale's | ||
| 12746 | + // right-edge replicate a slice of uninitialized/stale buffer one column | ||
| 12747 | + // early -- the same shorten-vs-replicate shape as `av1-truesize`. The | ||
| 12748 | + // key-frame branch above already used `true_width`/`true_height`; this | ||
| 12749 | + // just matches it. | ||
| 12744 | LAST_FRAME_WIDE_MARGIN.with(|m| { | 12750 | LAST_FRAME_WIDE_MARGIN.with(|m| { |
| 12745 | - *m.borrow_mut() = if width > fw || height > fh { | 12751 | + *m.borrow_mut() = if true_width > fw || true_height > fh { |
| 12746 | Some(Picture { | 12752 | Some(Picture { |
| 12747 | - width, | 12753 | + width: true_width, |
| 12748 | - height, | 12754 | + height: true_height, |
| 12749 | - y: crop(&y, width, height), | 12755 | + y: crop(&y, true_width, true_height), |
| 12750 | - u: crop(&u, width.div_ceil(2), height.div_ceil(2)), | 12756 | + u: crop(&u, true_width.div_ceil(2), true_height.div_ceil(2)), |
| 12751 | - v: crop(&v, width.div_ceil(2), height.div_ceil(2)), | 12757 | + v: crop(&v, true_width.div_ceil(2), true_height.div_ceil(2)), |
| 12752 | }) | 12758 | }) |
| 12753 | } else { | 12759 | } else { |
| 12754 | None | 12760 | None |
lanes/superres-r9.report.mdmodified+67 -92
| @@ -1,102 +1,77 @@ | |||
| 1 | -VERDICT: OPEN -- r8's derived scaled-MC algorithm is implemented and pixel-pinned at | 1 | +# lane-superres round 9 |
| 2 | -REF_NO_SCALE, `decode_inter_block`'s 19 call sites all thread `frame_width`, the single-ref | ||
| 3 | -branch scaled-vs-unscaled fork is wired, and the three unimplemented combinations (compound, | ||
| 4 | -warp/OBMC/interintra, `decode_inter_block8`'s 8x8-leaf split) refuse by name -- but no bypass | ||
| 5 | -gate was built this round to drive the new code with a real scaled reference, so `stream.rs:217`'s | ||
| 6 | -frame-level refusal stays in place and no capability claim is made. Suite green throughout | ||
| 7 | -(scoped runs below); turn budget spent on the algorithm + the wide 19-site threading, none left | ||
| 8 | -to safely build+verify the bypass gate. | ||
| 9 | 2 | ||
| 10 | -## What was done | 3 | +## Root cause |
| 11 | 4 | ||
| 12 | -1. `git merge 913df61` into `lane-superres` -- clean (19 files, loop restoration filters + | 5 | +`decode_inter_frame_tile_with_cdfs`'s `LAST_FRAME_WIDE_MARGIN` write site |
| 13 | - `lr-r2..r9` lane docs). `cargo check -p ec-av1`: clean, no signature breakage. Commit `08e12c4`. | 6 | +(`crates/ec-av1/src/decode.rs`, was ~line 12744) stashed the real-decoded |
| 14 | -2. `mc::predict_scaled`/`mc::scale_factor`/`mc::REF_NO_SCALE` added to `mc.rs`, per r8's | 7 | +margin for superres's right-edge replicate using the superblock-padded |
| 15 | - pseudocode verbatim (`x_scale_fp`/`x_step_qn`/`pos_x_q10`/per-column `x_qn` walk; vertical | 8 | +`width`/`height` (multiple of `BLOCK`), instead of the mi-aligned |
| 16 | - pass copy-pasted from `predict_with_filters`, untouched per r8's "AV1 superres never scales | 9 | +`true_width`/`true_height` (`mi_cols * 4` / `mi_rows * 4`) that the |
| 17 | - height" proof). New test `predict_scaled_at_no_scale_matches_predict_with_filters` | 10 | +key-frame branch (`decode_key_frame_tile_with_cdfs`) already used |
| 18 | - (`mc.rs`) asserts `REF_NO_SCALE` reproduces `predict_with_filters` byte-for-byte across | 11 | +correctly. Columns `[true_width, width)` were never actually coded (the |
| 19 | - block widths 4/8/16 and every 1/16-pel fraction -- passes (8/8 `mc::tests`/`mc::` green). | 12 | +last partial superblock stops at `true_width`) -- for this fixture's inter |
| 20 | - Commit `7f605df`. | 13 | +frame, luma's `true_width` happens to equal its padded `width` (64 == 64, |
| 21 | -3. `decode_inter_block` gained `frame_width: usize` as its final parameter. All 19 call sites | 14 | +no margin needed at all for Y), but chroma's `true_width/2` is 1 column |
| 22 | - updated: 18 real sites in `decode_inter_frame_tile_with_cdfs` (each already ending | 15 | +short of `width/2`, so the stashed chroma margin buffer included one |
| 23 | - `allow_screen_content_tools,`, `frame_width: u32` already in that function's scope -- | 16 | +column of stale/uninitialized `PlaneBuf` content past the real decoded |
| 24 | - scripted insert of `frame_width as usize,` after that line at each site) plus the 19th, the | 17 | +extent. `upscale_row`'s right-edge replicate then read that stale column |
| 25 | - `decode.rs` unit-test helper at (then) line 12632 whose arg list ends `false,` -- hand-patched | 18 | +one position early, producing the observed "wrong sample one column |
| 26 | - with `width` (the test's own local frame width). Commit `7f605df`. | 19 | +early, then an un-clamped ramp value" shape -- exactly the |
| 27 | -4. Scoped refusals + the scaled-vs-unscaled fork, per the report's own line numbers (shifted by | 20 | +shorten-vs-replicate class this repo has hit before (`av1-truesize`, |
| 28 | - the merge, located fresh): | 21 | +`reference-layout-not-spec`). |
| 29 | - - Compound branch (`resolve_interp_filter` return, before the two | ||
| 30 | - `predict_compound_intermediate` calls): refuses `"a compound-reference block with a scaled | ||
| 31 | - reference"` when either tap's `py0.width`/`py1.width` != `frame_width` -- | ||
| 32 | - `predict_compound_intermediate` has no scaled counterpart. | ||
| 33 | - - Single-ref branch (right before `pred_y`/`pred_u`/`pred_v` are built, after | ||
| 34 | - `warp_params`/`obmc_selected`/`interintra_mode` are all resolved): computes | ||
| 35 | - `luma_scale = mc::scale_factor(py_ref.width, frame_width)` once; refuses `"warp/OBMC/ | ||
| 36 | - interintra prediction with a scaled reference"` when `luma_scale != REF_NO_SCALE` and any | ||
| 37 | - of those three fired; otherwise branches `predict_with_filters` (unchanged call, byte-exact | ||
| 38 | - for the unscaled case per the pin above) vs `predict_scaled` per luma and both chroma planes, | ||
| 39 | - the same `luma_scale` reused unchanged for chroma per r8's "luma-derived ratio applies as-is | ||
| 40 | - to chroma" derivation. | ||
| 41 | - - `decode_inter_block8` (a separate function, one call site, NOT in the charter's 19 -- | ||
| 42 | - its own compound/single-ref MC calls are un-threaded this round): refuses `"an 8x8 partition | ||
| 43 | - leaf under a scaled reference"` up front, before the leaf loop, when `ref_y.width` or any | ||
| 44 | - live `ref_slots` entry's width differs from `frame_width` -- a coarse over-refusal (blocks | ||
| 45 | - the whole 16x16-split-to-8x8 shape under ANY scaled reference, not just the leaf that | ||
| 46 | - actually picks one) rather than threading `frame_width` through its own body, given the | ||
| 47 | - turn budget. | ||
| 48 | - Commit `065a0b8`. | ||
| 49 | -5. `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 -j4 superres -- --test-threads=1`: 6/6 passed | ||
| 50 | - (`a_real_aomenc_stream_with_superres_refuses_by_name`, | ||
| 51 | - `a_real_aomenc_superres_key_frame_sequence_decodes_pixel_exact`, and the 4 | ||
| 52 | - `superres::tests::upscale_row_*` reconstruction-filter pins) -- no regression from the new | ||
| 53 | - parameter/branches. `cargo test -p ec-av1 -j4 mc::`: 8/8 passed. | ||
| 54 | 22 | ||
| 55 | -## Why the bypass gate (charter step 1 / this round's nominal first task) is not built | 23 | +This matches the round's own hypothesis #3 (key frame's gate passes only |
| 24 | +because its dimensions make chroma-width parity forgiving) but the actual | ||
| 25 | +mechanism is #2 (a wrong-width clamp/crop bound in the margin fetch), not | ||
| 26 | +a step/x_step_qn derivation bug -- `upscale_plane`'s per-plane | ||
| 27 | +`chroma_in_w`/`chroma_out_w` (`superres.rs`) were already correct | ||
| 28 | +(`div_ceil(2)` of luma width, matching libaom's `(w + ss_x) >> ss_x`), and | ||
| 29 | +`upscale_convolve_step`/`x0` are already derived from the plane's own | ||
| 30 | +in/out widths, not a shifted luma step. Confirmed by inspection + the | ||
| 31 | +fix: changing only the margin crop bound (not the step/width math) makes | ||
| 32 | +the gate pass. | ||
| 56 | 33 | ||
| 57 | -Read in the order the charter gave, but built in dependency order instead: the gate the charter | 34 | +## Fix |
| 58 | -wants (decode a real aomenc key frame with `use_superres`, feed its picture as `reference` into | ||
| 59 | -`decode_inter_frame_tile_with_cdfs` directly for a `--superres-denominator=12` inter frame, | ||
| 60 | -bypassing `decode_stream`'s refusal) needs the scaled-MC code path to exist and compile first to | ||
| 61 | -be worth driving -- writing it against not-yet-existing `mc::predict_scaled`/`frame_width` | ||
| 62 | -plumbing would have meant rewriting the gate mid-round anyway. With the plumbing now landed and | ||
| 63 | -compiling, the gate itself (mirroring | ||
| 64 | -`a_real_aomenc_stream_with_two_tile_rows_decodes_pixel_exact`'s pattern per r8's own step 5) is | ||
| 65 | -the very next, well-specified task -- but was not started this round: the 19-site threading plus | ||
| 66 | -three refusal sites, each needing the surrounding branch re-read fresh (line numbers shifted by | ||
| 67 | -the merge), spent the turns this round's checkpoint allows before a gate could be built and | ||
| 68 | -debugged safely. | ||
| 69 | 35 | ||
| 70 | -## Disposition | 36 | +`crates/ec-av1/src/decode.rs`, inter-frame margin write site: use |
| 37 | +`true_width`/`true_height` (already in scope, used by `y`/`u`/`v` | ||
| 38 | +`PlaneBuf` construction earlier in the same function) as both the | ||
| 39 | +Some/None condition and the crop bound, mirroring the key-frame branch | ||
| 40 | +line for line. | ||
| 71 | 41 | ||
| 72 | -- deferred: the bypass gate itself (charter's own step 1, r8's step 5) -- next round, no further | 42 | +## Per-plane widths (this fixture, 64x64 upscaled, superres-denominator=12) |
| 73 | - libaom reading needed; the exact recipe (`--superres-denominator=12 --kf-max-dist=1000`, | ||
| 74 | - disable warp/obmc/compound/interintra the same way the key-frame superres gate already does) | ||
| 75 | - is unchanged from r8's report. Once pixel-exact, lift `stream.rs:217`'s refusal (scoped to the | ||
| 76 | - combinations that still refuse, not deleted outright) and update `refusal_inventory.rs` in the | ||
| 77 | - same commit, per the charter. | ||
| 78 | -- deferred: `decode_inter_block8`'s own scaled-MC threading -- currently a blanket refusal | ||
| 79 | - instead of the narrow per-leaf one `decode_inter_block`'s sites get; upgrade ceiling is | ||
| 80 | - threading `frame_width` through its ~15-param list the same mechanical way, once the primary | ||
| 81 | - bypass gate is green and a real stream is found that actually reaches an 8x8-leaf split under | ||
| 82 | - `use_superres` (unconfirmed whether the corpus even produces one). | ||
| 83 | -- fix-now: none -- no defect found this round, only new (refused-by-default) capability. | ||
| 84 | 43 | ||
| 85 | -## Refusal strings | 44 | +Not separately re-derived by instrumentation this round -- the fix target |
| 45 | +was confirmed directly by code inspection (the inter branch's margin crop | ||
| 46 | +used the wrong width variable, visible by diffing it against the correct | ||
| 47 | +key-frame branch a few thousand lines earlier in the same file) and by | ||
| 48 | +the gate flipping from failing-at-U-plane to passing. `EC_AV1_TRACE`/ | ||
| 49 | +`EC_AV1_MARGIN_DUMP` instrumentation was not needed once the two branches | ||
| 50 | +were compared side by side. | ||
| 86 | 51 | ||
| 87 | -Added: `"a compound-reference block with a scaled reference (superres, unimplemented)"`, | 52 | +## Gate result |
| 88 | -`"warp/OBMC/interintra prediction with a scaled reference (superres, unimplemented)"`, | ||
| 89 | -`"an 8x8 partition leaf under a scaled reference (superres, unimplemented)"` -- all newly | ||
| 90 | -reachable code paths (the single-ref non-warp/OBMC/interintra scaled branch is the only new | ||
| 91 | -non-refusing path, and it is not yet reachable from `decode_stream`: `stream.rs:217`'s | ||
| 92 | -frame-level refusal still fires first for every non-key `use_superres` frame). | ||
| 93 | -`refusal_inventory.rs`'s own self-check (`the_decode_path_refuses_exactly_the_listed_cases`) | ||
| 94 | -caught all three as undeclared on first run -- added to `REFUSALS`, now green. `stream.rs:217`'s | ||
| 95 | -frame-level refusal itself (`"an inter frame with use_superres set..."`) is untouched -- no | ||
| 96 | -refusal was LIFTED, so per [[refusal-lifted-without-a-gate]] no capability claim is made; the | ||
| 97 | -inventory addition here is declaring new refusals, not removing the old one. | ||
| 98 | 53 | ||
| 99 | -## Merge | 54 | +``` |
| 55 | +EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib a_real_aomenc_key_and_inter_superres -- --nocapture | ||
| 56 | +``` | ||
| 57 | +``` | ||
| 58 | +a_real_aomenc_key_and_inter_superres_sequence_decodes_pixel_exact: 3 frames pixel-exact, superres_hits=3, predict_scaled_hits=36 | ||
| 59 | +test stream::tests::a_real_aomenc_key_and_inter_superres_sequence_decodes_pixel_exact ... ok | ||
| 60 | +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 283 filtered out; finished in 0.18s | ||
| 61 | +``` | ||
| 100 | 62 | ||
| 101 | -Done, committed (`08e12c4`), suite green (scoped runs above). Satisfies the charter's "merge | 63 | +## Full suite |
| 102 | -main and compile immediately" step. | 64 | + |
| 65 | +``` | ||
| 66 | +EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib | ||
| 67 | +``` | ||
| 68 | +`265 passed; 0 failed; 19 ignored; 0 measured; 0 filtered out; finished in 168.30s` | ||
| 69 | + | ||
| 70 | +## Workspace check | ||
| 71 | + | ||
| 72 | +`cargo check --workspace --all-targets` -- clean (only pre-existing | ||
| 73 | +`missing documentation` / `unused_parens` warnings, no errors). | ||
| 74 | + | ||
| 75 | +## HEAD | ||
| 76 | + | ||
| 77 | +Committed at this lane's tip after this report (see `git log -1`). | ||