8x8 inter leaves -- GLOBALMV, WARPED_CAUSAL, global warp, non-LAST refs, interp filter, interior split (gates still RED)
Browse files at this commitd4af78e13fe777c7fa5368bc4accbf1792eb0bc2Parent: f0c06d5- feat
- 8x8 inter leaves -- GLOBALMV, WARPED_CAUSAL, global warp, non-LAST refs, interp filter, interior split (gates still RED)
4 changed files +665 -52
- crates/ec-av1/src/decode.rs +369 -48
- crates/ec-av1/src/refusal_inventory.rs +1 -4
- crates/ec-av1/src/stream.rs +212 -0
- lanes/gmaffine-r1.report.md +83 -0
crates/ec-av1/src/decode.rsmodified+369 -48
| @@ -35,7 +35,7 @@ use crate::msac::SymbolDecoder; | |||
| 35 | use crate::mvstack::{ | 35 | use crate::mvstack::{ |
| 36 | ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME, | 36 | ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME, |
| 37 | MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx, | 37 | MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx, |
| 38 | - find_mv_stack, find_mv_stack_with_sign_bias, reference_mode_ctx, single_ref_ctx, | 38 | + find_mv_stack_with_sign_bias, reference_mode_ctx, single_ref_ctx, |
| 39 | single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, | 39 | single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, |
| 40 | single_ref_p6_ctx, uni_comp_ref_p1_ctx, | 40 | single_ref_p6_ctx, uni_comp_ref_p1_ctx, |
| 41 | }; | 41 | }; |
| @@ -653,6 +653,27 @@ pub(crate) fn affine_gm_hits() -> usize { | |||
| 653 | AFFINE_GM_HITS.with(|c| c.get()) | 653 | AFFINE_GM_HITS.with(|c| c.get()) |
| 654 | } | 654 | } |
| 655 | 655 | ||
| 656 | +// lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves | ||
| 657 | +// coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real | ||
| 658 | +// `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented | ||
| 659 | +// only once `find_projection` returned a usable model, unlike | ||
| 660 | +// `WARP_SELECTED_HITS` which counts the symbol). Both are the 8x8 gates' | ||
| 661 | +// proof that the leaf path itself fired, not the 16x16+ one. | ||
| 662 | +thread_local! { | ||
| 663 | + static GLOBALMV_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 664 | + static WARP_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 665 | +} | ||
| 666 | + | ||
| 667 | +/// Current value of [`GLOBALMV_HITS_8`]. | ||
| 668 | +pub(crate) fn globalmv_hits_8() -> usize { | ||
| 669 | + GLOBALMV_HITS_8.with(|c| c.get()) | ||
| 670 | +} | ||
| 671 | + | ||
| 672 | +/// Current value of [`WARP_HITS_8`]. | ||
| 673 | +pub(crate) fn warp_hits_8() -> usize { | ||
| 674 | + WARP_HITS_8.with(|c| c.get()) | ||
| 675 | +} | ||
| 676 | + | ||
| 656 | // How many blocks decoded `interintra == 1` with the non-wedge blended | 677 | // How many blocks decoded `interintra == 1` with the non-wedge blended |
| 657 | // prediction applied (lane-interintra r1) -- the gate's proof that a | 678 | // prediction applied (lane-interintra r1) -- the gate's proof that a |
| 658 | // stream actually exercised interintra. | 679 | // stream actually exercised interintra. |
| @@ -8142,6 +8163,13 @@ fn num_proj_ref( | |||
| 8142 | /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16) | 8163 | /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16) |
| 8143 | /// are transcribed. | 8164 | /// are transcribed. |
| 8144 | fn obmc_mask(len: usize) -> &'static [u8] { | 8165 | fn obmc_mask(len: usize) -> &'static [u8] { |
| 8166 | + // lane-gmaffine r1: the two SHORT masks (libaom `reconinter.c` | ||
| 8167 | + // `obmc_mask_1`/`obmc_mask_2`) -- an 8x8 leaf's chroma plane is 4x4, so | ||
| 8168 | + // its overlap is 2 (and 1 at a half-block edge). Unreachable until this | ||
| 8169 | + // round wired interior 16x16 splits down to real 8x8 leaves, where the | ||
| 8170 | + // old `unreachable!()` below fired as a hard panic. | ||
| 8171 | + const M1: [u8; 1] = [64]; | ||
| 8172 | + const M2: [u8; 2] = [45, 64]; | ||
| 8145 | const M4: [u8; 4] = [39, 50, 59, 64]; | 8173 | const M4: [u8; 4] = [39, 50, 59, 64]; |
| 8146 | const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64]; | 8174 | const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64]; |
| 8147 | const M16: [u8; 16] = [ | 8175 | const M16: [u8; 16] = [ |
| @@ -8152,6 +8180,8 @@ fn obmc_mask(len: usize) -> &'static [u8] { | |||
| 8152 | 61, 62, 64, 64, 64, 64, 64, 64, 64, 64, | 8180 | 61, 62, 64, 64, 64, 64, 64, 64, 64, 64, |
| 8153 | ]; | 8181 | ]; |
| 8154 | match len { | 8182 | match len { |
| 8183 | + 1 => &M1, | ||
| 8184 | + 2 => &M2, | ||
| 8155 | 4 => &M4, | 8185 | 4 => &M4, |
| 8156 | 8 => &M8, | 8186 | 8 => &M8, |
| 8157 | 16 => &M16, | 8187 | 16 => &M16, |
| @@ -10661,6 +10691,16 @@ fn decode_inter_block8( | |||
| 10661 | prev_leaf: Option<((usize, usize), bool, bool)>, | 10691 | prev_leaf: Option<((usize, usize), bool, bool)>, |
| 10662 | allow_high_precision_mv: bool, | 10692 | allow_high_precision_mv: bool, |
| 10663 | force_integer_mv: bool, | 10693 | force_integer_mv: bool, |
| 10694 | + // lane-gmaffine r1: this frame header's own `global_motion` table (spec | ||
| 10695 | + // 5.9.24), indexed `[ref_frame - LAST_FRAME]` -- same table | ||
| 10696 | + // [`decode_inter_block`] takes, threaded here so the 8x8 leaf can code | ||
| 10697 | + // `GLOBALMV` (`gm_get_motion_vector`), fill its mv stack's missing | ||
| 10698 | + // candidates with the gm mv (gm r6's root cause) and build a global | ||
| 10699 | + // warp prediction. | ||
| 10700 | + global_motion: &[ec_av1_syntax::WarpParams; 7], | ||
| 10701 | + // lane-gmaffine r1: this sequence header's own `enable_dual_filter` bit, | ||
| 10702 | + // for the leaf's own `read_mb_interp_filter` below. | ||
| 10703 | + enable_dual_filter: bool, | ||
| 10664 | // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path | 10704 | // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path |
| 10665 | // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no | 10705 | // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no |
| 10666 | // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s | 10706 | // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s |
| @@ -11162,29 +11202,53 @@ fn decode_inter_block8( | |||
| 11162 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); | 11202 | return Ok((skip, is_inter, skip_mode, compound_ctx8)); |
| 11163 | } | 11203 | } |
| 11164 | } | 11204 | } |
| 11165 | - let sr_ctx = single_ref_ctx(above_inter || left_inter); | 11205 | + // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree |
| 11166 | - let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]); | 11206 | + // ([`read_single_ref`], the same one the 16x16+ leaf uses, with the |
| 11167 | - let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]); | 11207 | + // real per-neighbour p1..p6 contexts) instead of the old three-symbol |
| 11168 | - let p4 = dec.symbol(&mut cdfs.single_ref[sr_ctx][3]); | 11208 | + // LAST-only probe plus a refusal -- aomenc picks GOLDEN/ALTREF for |
| 11169 | - if (p1, p3, p4) != (0, 0, 0) { | 11209 | + // 8x8 leaves constantly, so that refusal was what every 8x8 gate |
| 11170 | - return Err(unsupported( | 11210 | + // actually stopped at. |
| 11171 | - "a reference frame other than LAST_FRAME (round 2)", | 11211 | + let ref_frame = read_single_ref( |
| 11172 | - )); | 11212 | + dec, |
| 11173 | - } | 11213 | + cdfs, |
| 11214 | + neighbours.above_ref[c], | ||
| 11215 | + neighbours.above_ref1[c], | ||
| 11216 | + neighbours.left_ref[r], | ||
| 11217 | + neighbours.left_ref1[r], | ||
| 11218 | + ); | ||
| 11219 | + let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?; | ||
| 11174 | 11220 | ||
| 11175 | let (mi_row, mi_col) = leaf_mi; | 11221 | let (mi_row, mi_col) = leaf_mi; |
| 11176 | - let stack = find_mv_stack( | 11222 | + // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's |
| 11223 | + // missing-candidate fallback both come from the frame's global | ||
| 11224 | + // motion evaluated at THIS block's centre (gm r6's root cause) -- | ||
| 11225 | + // the 8x8 leaf used to build its stack with the zero fallback, which | ||
| 11226 | + // is right only while every model is IDENTITY. | ||
| 11227 | + let gm_table = build_gm_mv_table( | ||
| 11228 | + global_motion, | ||
| 11229 | + mi_row, | ||
| 11230 | + mi_col, | ||
| 11231 | + 2, | ||
| 11232 | + 2, | ||
| 11233 | + allow_high_precision_mv, | ||
| 11234 | + force_integer_mv, | ||
| 11235 | + ); | ||
| 11236 | + let stack = crate::mvstack::find_mv_stack_with_sign_bias( | ||
| 11177 | grid, | 11237 | grid, |
| 11178 | mi_row, | 11238 | mi_row, |
| 11179 | mi_col, | 11239 | mi_col, |
| 11180 | 2, | 11240 | 2, |
| 11181 | 2, | 11241 | 2, |
| 11182 | - LAST_FRAME, | 11242 | + ref_frame, |
| 11183 | mi_cols as usize, | 11243 | mi_cols as usize, |
| 11184 | mi_rows as usize, | 11244 | mi_rows as usize, |
| 11245 | + &crate::mvstack::NO_SIGN_BIAS, | ||
| 11246 | + &gm_table, | ||
| 11247 | + None, | ||
| 11185 | ); | 11248 | ); |
| 11186 | 11249 | ||
| 11187 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 11250 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 11251 | + let mut is_globalmv = false; | ||
| 11188 | let (mv, is_new_mv) = if !not_new { | 11252 | let (mv, is_new_mv) = if !not_new { |
| 11189 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): | 11253 | // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0): |
| 11190 | // read at most two `drl_mode` bits, one per stack entry past the | 11254 | // read at most two `drl_mode` bits, one per stack entry past the |
| @@ -11213,21 +11277,27 @@ fn decode_inter_block8( | |||
| 11213 | ) | 11277 | ) |
| 11214 | } else { | 11278 | } else { |
| 11215 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; | 11279 | let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1; |
| 11216 | - if !not_zero { | 11280 | + is_globalmv = !not_zero; |
| 11217 | - return Err(unsupported("GLOBALMV (round 3)")); | 11281 | + let mv = if !not_zero { |
| 11218 | - } | 11282 | + // lane-gmaffine r1: GLOBALMV (spec 7.10.2.1) -- the same |
| 11219 | - let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; | 11283 | + // `gm_get_motion_vector` value the 16x16+ leaf reads out of |
| 11220 | - let mv = if nearest { | 11284 | + // its own `gm_table`, computed at this block's centre. |
| 11221 | - stack.nearest_mv | 11285 | + GLOBALMV_HITS_8.with(|c| c.set(c.get() + 1)); |
| 11286 | + gm_table[(ref_frame - LAST_FRAME) as usize] | ||
| 11222 | } else { | 11287 | } else { |
| 11223 | - let mut idx = 1usize; | 11288 | + let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0; |
| 11224 | - while idx < 3 && stack.entries.len() > idx + 1 { | 11289 | + if nearest { |
| 11225 | - if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 { | 11290 | + stack.nearest_mv |
| 11226 | - break; | 11291 | + } else { |
| 11292 | + let mut idx = 1usize; | ||
| 11293 | + while idx < 3 && stack.entries.len() > idx + 1 { | ||
| 11294 | + if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 { | ||
| 11295 | + break; | ||
| 11296 | + } | ||
| 11297 | + idx += 1; | ||
| 11227 | } | 11298 | } |
| 11228 | - idx += 1; | 11299 | + stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv) |
| 11229 | } | 11300 | } |
| 11230 | - stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv) | ||
| 11231 | }; | 11301 | }; |
| 11232 | (mv, false) | 11302 | (mv, false) |
| 11233 | }; | 11303 | }; |
| @@ -11270,18 +11340,29 @@ fn decode_inter_block8( | |||
| 11270 | // 16x16 leaf's own `decode_inter_block` read (see its doc above) -- | 11340 | // 16x16 leaf's own `decode_inter_block` read (see its doc above) -- |
| 11271 | // same 2-symbol `obmc_cdf` alphabet, same `allow_warped_motion=1` | 11341 | // same 2-symbol `obmc_cdf` alphabet, same `allow_warped_motion=1` |
| 11272 | // refusal (warp needs `av1_findSamples`, not ported at either leaf). | 11342 | // refusal (warp needs `av1_findSamples`, not ported at either leaf). |
| 11343 | + // lane-gmaffine r1: the two libaom predicates, exactly as the | ||
| 11344 | + // 16x16+ leaf resolves them (see [`decode_inter_block`]'s own doc): | ||
| 11345 | + // `is_global_mv_block` (mode GLOBAL*, model > TRANSLATION, block | ||
| 11346 | + // >= 8x8 -- BLOCK_8X8 IS the 8px minimum, so the size predicate is | ||
| 11347 | + // always true here) suppresses the motion_mode read entirely and | ||
| 11348 | + // turns on the global warp below. | ||
| 11349 | + let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize]; | ||
| 11350 | + let is_global_mv_block = is_globalmv && gm_ref.model as u8 > 1; | ||
| 11273 | let motion_mode_eligible = switchable_motion_mode | 11351 | let motion_mode_eligible = switchable_motion_mode |
| 11274 | && !skip_mode | 11352 | && !skip_mode |
| 11275 | && interintra_mode.is_none() | 11353 | && interintra_mode.is_none() |
| 11354 | + && !(is_global_mv_block && !force_integer_mv) | ||
| 11276 | && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty() | 11355 | && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty() |
| 11277 | || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty()); | 11356 | || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty()); |
| 11357 | + let mut warp_params: Option<crate::warp::WarpParams> = None; | ||
| 11358 | + let mut warped_selected = false; | ||
| 11278 | let mut obmc_selected = false; | 11359 | let mut obmc_selected = false; |
| 11279 | if motion_mode_eligible { | 11360 | if motion_mode_eligible { |
| 11280 | // lane-warp round 1: same 3-vs-2-symbol split as the 16x16+ leaf | 11361 | // lane-warp round 1: same 3-vs-2-symbol split as the 16x16+ leaf |
| 11281 | // (see its own doc) -- this leaf is always `LAST_FRAME`-only | 11362 | // (see its own doc) -- this leaf is always `LAST_FRAME`-only |
| 11282 | // (grid.set below hardcodes it). | 11363 | // (grid.set below hardcodes it). |
| 11283 | let warp_eligible = allow_warped_motion | 11364 | let warp_eligible = allow_warped_motion |
| 11284 | - && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1; | 11365 | + && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, ref_frame) >= 1; |
| 11285 | if warp_eligible { | 11366 | if warp_eligible { |
| 11286 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); | 11367 | let mode = dec.symbol(&mut cdfs.motion_mode[0]); |
| 11287 | match mode { | 11368 | match mode { |
| @@ -11292,12 +11373,41 @@ fn decode_inter_block8( | |||
| 11292 | OBMC_HITS_8.with(|c| c.set(c.get() + 1)); | 11373 | OBMC_HITS_8.with(|c| c.set(c.get() + 1)); |
| 11293 | } | 11374 | } |
| 11294 | _ => { | 11375 | _ => { |
| 11376 | + // lane-gmaffine r1: WARPED_CAUSAL at the 8x8 leaf -- | ||
| 11377 | + // the same findSamples -> select_samples -> | ||
| 11378 | + // av1_find_projection chain the 16x16+ leaf runs, | ||
| 11379 | + // with BLOCK_8X8's own 8x8 model centre; an | ||
| 11380 | + // unusable projection falls back to the block's | ||
| 11381 | + // translational mv (libaom `av1_find_projection` | ||
| 11382 | + // returning 1 leaves `wm_params` invalid and | ||
| 11383 | + // `build_inter_predictors` skips the warp). | ||
| 11295 | WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1)); | 11384 | WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1)); |
| 11296 | - return Err(unsupported( | 11385 | + let mut samples = find_samples( |
| 11297 | - "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): \ | 11386 | + grid, |
| 11298 | - av1_find_projection/the affine warp filter are not \ | 11387 | + mi_row, |
| 11299 | - ported, only motion_mode_allowed's alphabet choice is", | 11388 | + mi_col, |
| 11300 | - )); | 11389 | + 2, |
| 11390 | + 2, | ||
| 11391 | + mi_cols as usize, | ||
| 11392 | + mi_rows as usize, | ||
| 11393 | + ref_frame, | ||
| 11394 | + ); | ||
| 11395 | + if samples.len() > 1 { | ||
| 11396 | + crate::warp::select_samples(mv, &mut samples, SIDE as i32, SIDE as i32); | ||
| 11397 | + } | ||
| 11398 | + warp_params = crate::warp::find_projection( | ||
| 11399 | + &samples, | ||
| 11400 | + SIDE as i32, | ||
| 11401 | + SIDE as i32, | ||
| 11402 | + mv.1, | ||
| 11403 | + mv.0, | ||
| 11404 | + mi_row as i32, | ||
| 11405 | + mi_col as i32, | ||
| 11406 | + ); | ||
| 11407 | + warped_selected = true; | ||
| 11408 | + if warp_params.is_some() { | ||
| 11409 | + WARP_HITS_8.with(|c| c.set(c.get() + 1)); | ||
| 11410 | + } | ||
| 11301 | } | 11411 | } |
| 11302 | } | 11412 | } |
| 11303 | } else { | 11413 | } else { |
| @@ -11309,6 +11419,59 @@ fn decode_inter_block8( | |||
| 11309 | } | 11419 | } |
| 11310 | } | 11420 | } |
| 11311 | } | 11421 | } |
| 11422 | + // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8 | ||
| 11423 | + // leaf, in libaom's own order (interintra, motion_mode, THEN the | ||
| 11424 | + // filter). Until this round the leaf read no filter symbol at all and | ||
| 11425 | + // predicted Regular unconditionally -- correct only for a frame with a | ||
| 11426 | + // fixed `interp_filter`, and a silent entropy DESYNC for every | ||
| 11427 | + // SWITCHABLE-filter stream that reaches an 8x8 leaf (which is what | ||
| 11428 | + // made the interior-split wiring above unusable at first). | ||
| 11429 | + // corner-cut: the neighbour filter context is the enclosing 16x16 | ||
| 11430 | + // block's own coarse `above_filter`/`left_filter` entry (this leaf | ||
| 11431 | + // path keeps no per-leaf neighbour array), so all four siblings read | ||
| 11432 | + // the same context row. Ceiling: a stream whose 8x8 siblings pick | ||
| 11433 | + // DIFFERENT filters decodes the second..fourth leaf's symbol from the | ||
| 11434 | + // wrong CDF row. Upgrade: give `Neighbours` a real 8x8-granular | ||
| 11435 | + // filter array, same shape as the `[3, 3]` approximation the caller | ||
| 11436 | + // records after the leaf loop. | ||
| 11437 | + let above_filter_ctx = if neighbours.above_ref[c] == ref_frame | ||
| 11438 | + || neighbours.above_ref1[c] == Some(ref_frame) | ||
| 11439 | + { | ||
| 11440 | + neighbours.above_filter[c] | ||
| 11441 | + } else { | ||
| 11442 | + [3, 3] | ||
| 11443 | + }; | ||
| 11444 | + let left_filter_ctx = if neighbours.left_ref[r] == ref_frame | ||
| 11445 | + || neighbours.left_ref1[r] == Some(ref_frame) | ||
| 11446 | + { | ||
| 11447 | + neighbours.left_filter[r] | ||
| 11448 | + } else { | ||
| 11449 | + [3, 3] | ||
| 11450 | + }; | ||
| 11451 | + let gm_nontrans = | ||
| 11452 | + is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation; | ||
| 11453 | + let (h_filter, v_filter, _resolved_filter) = resolve_interp_filter( | ||
| 11454 | + dec, | ||
| 11455 | + cdfs, | ||
| 11456 | + interp_fixed, | ||
| 11457 | + enable_dual_filter, | ||
| 11458 | + gm_nontrans || warped_selected || skip_mode, | ||
| 11459 | + above_filter_ctx, | ||
| 11460 | + left_filter_ctx, | ||
| 11461 | + false, | ||
| 11462 | + ); | ||
| 11463 | + | ||
| 11464 | + // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch | ||
| 11465 | + // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- | ||
| 11466 | + // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model | ||
| 11467 | + // wins (`is_none()` guard); BLOCK_8X8 already satisfies the >=8px | ||
| 11468 | + // size predicate baked into `is_global_mv_block`. | ||
| 11469 | + if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid { | ||
| 11470 | + warp_params = crate::warp::global_warp_params(gm_ref.params); | ||
| 11471 | + if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine { | ||
| 11472 | + AFFINE_GM_HITS.with(|c| c.set(c.get() + 1)); | ||
| 11473 | + } | ||
| 11474 | + } | ||
| 11312 | for dr in 0..2 { | 11475 | for dr in 0..2 { |
| 11313 | for dc in 0..2 { | 11476 | for dc in 0..2 { |
| 11314 | grid.set( | 11477 | grid.set( |
| @@ -11316,7 +11479,7 @@ fn decode_inter_block8( | |||
| 11316 | mi_col + dc, | 11479 | mi_col + dc, |
| 11317 | MiInfo { | 11480 | MiInfo { |
| 11318 | is_inter: true, | 11481 | is_inter: true, |
| 11319 | - ref_frame: LAST_FRAME, | 11482 | + ref_frame, |
| 11320 | // INTRA_FRAME marker for interintra blocks -- keeps | 11483 | // INTRA_FRAME marker for interintra blocks -- keeps |
| 11321 | // them out of warp-sample gathering (see 16/32 site). | 11484 | // them out of warp-sample gathering (see 16/32 site). |
| 11322 | ref_frame1: interintra_mode.map(|_| 0), | 11485 | ref_frame1: interintra_mode.map(|_| 0), |
| @@ -11325,7 +11488,7 @@ fn decode_inter_block8( | |||
| 11325 | is_new_mv, | 11488 | is_new_mv, |
| 11326 | size: 2, | 11489 | size: 2, |
| 11327 | size_h: 2, | 11490 | size_h: 2, |
| 11328 | - is_global_mv0: false, | 11491 | + is_global_mv0: is_global_mv_block, |
| 11329 | is_global_mv1: false, | 11492 | is_global_mv1: false, |
| 11330 | }, | 11493 | }, |
| 11331 | ); | 11494 | ); |
| @@ -11334,42 +11497,69 @@ fn decode_inter_block8( | |||
| 11334 | mode_for_tx = 0; | 11497 | mode_for_tx = 0; |
| 11335 | 11498 | ||
| 11336 | let mut pred_y = vec![0u16; SIDE * SIDE]; | 11499 | let mut pred_y = vec![0u16; SIDE * SIDE]; |
| 11337 | - mc::predict( | 11500 | + mc::predict_with_filters( |
| 11338 | - &ref_y.data, | 11501 | + &sref_y.data, |
| 11339 | - ref_y.width, | 11502 | + sref_y.width, |
| 11340 | - ref_y.true_width, | 11503 | + sref_y.true_width, |
| 11341 | - ref_y.true_height, | 11504 | + sref_y.true_height, |
| 11342 | mv_to_q4(px, mv.1, true), | 11505 | mv_to_q4(px, mv.1, true), |
| 11343 | mv_to_q4(py, mv.0, true), | 11506 | mv_to_q4(py, mv.0, true), |
| 11344 | SIDE, | 11507 | SIDE, |
| 11345 | SIDE, | 11508 | SIDE, |
| 11509 | + h_filter, | ||
| 11510 | + v_filter, | ||
| 11346 | &mut pred_y, | 11511 | &mut pred_y, |
| 11347 | ); | 11512 | ); |
| 11348 | let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; | 11513 | let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| 11349 | - mc::predict( | 11514 | + mc::predict_with_filters( |
| 11350 | - &ref_u.data, | 11515 | + &sref_u.data, |
| 11351 | - ref_u.width, | 11516 | + sref_u.width, |
| 11352 | - ref_u.true_width, | 11517 | + sref_u.true_width, |
| 11353 | - ref_u.true_height, | 11518 | + sref_u.true_height, |
| 11354 | mv_to_q4(cpx, mv.1, false), | 11519 | mv_to_q4(cpx, mv.1, false), |
| 11355 | mv_to_q4(cpy, mv.0, false), | 11520 | mv_to_q4(cpy, mv.0, false), |
| 11356 | CHROMA_SIDE, | 11521 | CHROMA_SIDE, |
| 11357 | CHROMA_SIDE, | 11522 | CHROMA_SIDE, |
| 11523 | + h_filter, | ||
| 11524 | + v_filter, | ||
| 11358 | &mut pred_u, | 11525 | &mut pred_u, |
| 11359 | ); | 11526 | ); |
| 11360 | let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; | 11527 | let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| 11361 | - mc::predict( | 11528 | + mc::predict_with_filters( |
| 11362 | - &ref_v.data, | 11529 | + &sref_v.data, |
| 11363 | - ref_v.width, | 11530 | + sref_v.width, |
| 11364 | - ref_v.true_width, | 11531 | + sref_v.true_width, |
| 11365 | - ref_v.true_height, | 11532 | + sref_v.true_height, |
| 11366 | mv_to_q4(cpx, mv.1, false), | 11533 | mv_to_q4(cpx, mv.1, false), |
| 11367 | mv_to_q4(cpy, mv.0, false), | 11534 | mv_to_q4(cpy, mv.0, false), |
| 11368 | CHROMA_SIDE, | 11535 | CHROMA_SIDE, |
| 11369 | CHROMA_SIDE, | 11536 | CHROMA_SIDE, |
| 11537 | + h_filter, | ||
| 11538 | + v_filter, | ||
| 11370 | &mut pred_v, | 11539 | &mut pred_v, |
| 11371 | ); | 11540 | ); |
| 11372 | 11541 | ||
| 11542 | + // lane-gmaffine r1: the warp filter REPLACES the translational | ||
| 11543 | + // prediction just built (libaom builds one or the other), same as | ||
| 11544 | + // the 16x16+ leaf's own call trio. | ||
| 11545 | + if let Some(params) = &warp_params { | ||
| 11546 | + crate::warp::warp_affine( | ||
| 11547 | + params, &sref_y.data, sref_y.true_width as i32, sref_y.true_height as i32, | ||
| 11548 | + sref_y.width as i32, &mut pred_y, px as i32, py as i32, SIDE as i32, | ||
| 11549 | + SIDE as i32, SIDE as i32, 0, 0, | ||
| 11550 | + ); | ||
| 11551 | + crate::warp::warp_affine( | ||
| 11552 | + params, &sref_u.data, sref_u.true_width as i32, sref_u.true_height as i32, | ||
| 11553 | + sref_u.width as i32, &mut pred_u, cpx as i32, cpy as i32, CHROMA_SIDE as i32, | ||
| 11554 | + CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1, | ||
| 11555 | + ); | ||
| 11556 | + crate::warp::warp_affine( | ||
| 11557 | + params, &sref_v.data, sref_v.true_width as i32, sref_v.true_height as i32, | ||
| 11558 | + sref_v.width as i32, &mut pred_v, cpx as i32, cpy as i32, CHROMA_SIDE as i32, | ||
| 11559 | + CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1, | ||
| 11560 | + ); | ||
| 11561 | + } | ||
| 11562 | + | ||
| 11373 | if obmc_selected { | 11563 | if obmc_selected { |
| 11374 | obmc_blend( | 11564 | obmc_blend( |
| 11375 | grid, | 11565 | grid, |
| @@ -12224,9 +12414,138 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 12224 | if has_cols16 && has_rows16 { | 12414 | if has_cols16 && has_rows16 { |
| 12225 | let ctx16 = neighbours.partition_ctx(at16, SUB); | 12415 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| 12226 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); | 12416 | let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); |
| 12417 | + if part16 == PARTITION_SPLIT { | ||
| 12418 | + // lane-gmaffine r1: an INTERIOR 16x16 | ||
| 12419 | + // PARTITION_SPLIT -- four 8x8 leaves, | ||
| 12420 | + // the same `partition_w8`-per-leaf loop | ||
| 12421 | + // the true-edge-straddling branch below | ||
| 12422 | + // already ran (that branch only ever | ||
| 12423 | + // reached it for frame-edge blocks, so | ||
| 12424 | + // `decode_inter_block8` was unreachable | ||
| 12425 | + // for every whole-superblock stream and | ||
| 12426 | + // its own GLOBALMV/WARPED_CAUSAL gates | ||
| 12427 | + // could not fire at all). | ||
| 12428 | + let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | ||
| 12429 | + let leaf_positions: Vec<(u32, u32)> = (0..4) | ||
| 12430 | + .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2)) | ||
| 12431 | + .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols) | ||
| 12432 | + .collect(); | ||
| 12433 | + // lane-superres r9: decode_inter_block8's own | ||
| 12434 | + // MC (below) is not threaded for a scaled | ||
| 12435 | + // reference (unlike decode_inter_block's 19 | ||
| 12436 | + // sites) -- refuse the whole 8x8-leaf split | ||
| 12437 | + // up front when ANY live reference this leaf | ||
| 12438 | + // could pick has a different width than this | ||
| 12439 | + // frame, rather than thread frame_width | ||
| 12440 | + // through its own single-ref/compound MC | ||
| 12441 | + // calls to reach the same block this round. | ||
| 12442 | + if ref_y.width != frame_width as usize | ||
| 12443 | + || ref_slots.iter().flatten().any(|(py, _, _)| { | ||
| 12444 | + py.width != frame_width as usize | ||
| 12445 | + }) | ||
| 12446 | + { | ||
| 12447 | + return Err(unsupported( | ||
| 12448 | + "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | ||
| 12449 | + )); | ||
| 12450 | + } | ||
| 12451 | + let mut prev_leaf: Option<((usize, usize), bool, bool)> = None; | ||
| 12452 | + let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; | ||
| 12453 | + let mut last_skip_mode = false; | ||
| 12454 | + for (mr, mc) in leaf_positions { | ||
| 12455 | + let leaf_mi = (mr as usize, mc as usize); | ||
| 12456 | + let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); | ||
| 12457 | + let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); | ||
| 12458 | + if part8 != PARTITION_NONE { | ||
| 12459 | + return Err(unsupported( | ||
| 12460 | + "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | ||
| 12461 | + )); | ||
| 12462 | + } | ||
| 12463 | + let (skip, is_inter, skip_mode_leaf, compound_ctx8) = | ||
| 12464 | + decode_inter_block8( | ||
| 12465 | + &mut dec, | ||
| 12466 | + &mut cdfs, | ||
| 12467 | + &mut neighbours, | ||
| 12468 | + &mut grid, | ||
| 12469 | + mi_cols, | ||
| 12470 | + mi_rows, | ||
| 12471 | + at16, | ||
| 12472 | + leaf_mi, | ||
| 12473 | + &mut y, | ||
| 12474 | + &mut u, | ||
| 12475 | + &mut v, | ||
| 12476 | + &ref_y, | ||
| 12477 | + &ref_u, | ||
| 12478 | + &ref_v, | ||
| 12479 | + &ref_slots, | ||
| 12480 | + base_q_idx, | ||
| 12481 | + &scan8, | ||
| 12482 | + &scan4, | ||
| 12483 | + prev_leaf, | ||
| 12484 | + allow_high_precision_mv, | ||
| 12485 | + force_integer_mv, | ||
| 12486 | + &global_motion, | ||
| 12487 | + enable_dual_filter, | ||
| 12488 | + reference_select, | ||
| 12489 | + enable_masked_compound, | ||
| 12490 | + enable_interintra_compound, | ||
| 12491 | + enable_jnt_comp, | ||
| 12492 | + order_hint_bits, | ||
| 12493 | + order_hint, | ||
| 12494 | + ref_order_hints, | ||
| 12495 | + skip_mode_present, | ||
| 12496 | + skip_mode_frame, | ||
| 12497 | + reduced_tx_set, | ||
| 12498 | + interp_fixed, | ||
| 12499 | + switchable_motion_mode, | ||
| 12500 | + allow_warped_motion, | ||
| 12501 | + allow_screen_content_tools, | ||
| 12502 | + )?; | ||
| 12503 | + prev_leaf = Some((leaf_mi, skip, is_inter)); | ||
| 12504 | + last_skip_mode = skip_mode_leaf; | ||
| 12505 | + if compound_ctx8.is_some() { | ||
| 12506 | + last_compound_ctx = compound_ctx8; | ||
| 12507 | + } | ||
| 12508 | + } | ||
| 12509 | + if let Some((_, skip, is_inter)) = prev_leaf { | ||
| 12510 | + // corner-cut: `decode_inter_block8`'s | ||
| 12511 | + // leaves never read a switchable filter | ||
| 12512 | + // (round-3 GLOBALMV refusal already | ||
| 12513 | + // bounds them away from the Regular-only | ||
| 12514 | + // gap this round closes elsewhere); `[3, | ||
| 12515 | + // 3]` is "no info", the same value an | ||
| 12516 | + // intra neighbour records. Upgrade: | ||
| 12517 | + // thread `interp_fixed`/`enable_dual_filter` | ||
| 12518 | + // into `decode_inter_block8` once a | ||
| 12519 | + // straddling 8x8 SWITCHABLE stream is on | ||
| 12520 | + // hand to pin against. | ||
| 12521 | + neighbours.record_inter( | ||
| 12522 | + at16, | ||
| 12523 | + SUB, | ||
| 12524 | + skip, | ||
| 12525 | + is_inter, | ||
| 12526 | + if is_inter { LAST_FRAME } else { -1 }, | ||
| 12527 | + [3, 3], | ||
| 12528 | + last_skip_mode, | ||
| 12529 | + ); | ||
| 12530 | + if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx { | ||
| 12531 | + neighbours.record_inter( | ||
| 12532 | + at16, | ||
| 12533 | + SUB, | ||
| 12534 | + skip, | ||
| 12535 | + is_inter, | ||
| 12536 | + ref0, | ||
| 12537 | + [3, 3], | ||
| 12538 | + last_skip_mode, | ||
| 12539 | + ); | ||
| 12540 | + neighbours | ||
| 12541 | + .record_compound_ctx(at16, SUB, ref1, group_idx, idx); | ||
| 12542 | + } | ||
| 12543 | + } | ||
| 12544 | + continue; | ||
| 12545 | + } | ||
| 12227 | if part16 != PARTITION_NONE { | 12546 | if part16 != PARTITION_NONE { |
| 12228 | return Err(unsupported( | 12547 | return Err(unsupported( |
| 12229 | - "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)", | 12548 | + "an inter partition below 16x16 other than a clean split into four 8x8 leaves", |
| 12230 | )); | 12549 | )); |
| 12231 | } | 12550 | } |
| 12232 | decode_inter_block( | 12551 | decode_inter_block( |
| @@ -12353,6 +12672,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 12353 | prev_leaf, | 12672 | prev_leaf, |
| 12354 | allow_high_precision_mv, | 12673 | allow_high_precision_mv, |
| 12355 | force_integer_mv, | 12674 | force_integer_mv, |
| 12675 | + &global_motion, | ||
| 12676 | + enable_dual_filter, | ||
| 12356 | reference_select, | 12677 | reference_select, |
| 12357 | enable_masked_compound, | 12678 | enable_masked_compound, |
| 12358 | enable_interintra_compound, | 12679 | enable_interintra_compound, |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -4
| @@ -34,7 +34,6 @@ const CAPABILITY_CLAIMS: &[&str] = &[ | |||
| 34 | 34 | ||
| 35 | #[cfg(test)] | 35 | #[cfg(test)] |
| 36 | const REFUSALS: &[&str] = &[ | 36 | const REFUSALS: &[&str] = &[ |
| 37 | - "GLOBALMV (round 3)", | ||
| 38 | "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", | 37 | "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", |
| 39 | "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at this size)", | 38 | "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at this size)", |
| 40 | "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", | 39 | "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", |
| @@ -59,15 +58,13 @@ const REFUSALS: &[&str] = &[ | |||
| 59 | "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", | 58 | "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", |
| 60 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | 59 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
| 61 | "a palette block with a split luma transform (round 1)", | 60 | "a palette block with a split luma transform (round 1)", |
| 62 | - "a reference frame other than LAST_FRAME (round 2)", | ||
| 63 | "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it", | 61 | "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it", |
| 64 | "a reference picture whose height does not match this frame's own true size", | 62 | "a reference picture whose height does not match this frame's own true size", |
| 65 | "a show_existing_frame header naming an empty reference slot", | 63 | "a show_existing_frame header naming an empty reference slot", |
| 66 | - "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): av1_find_projection/the affine warp filter are not ported, only motion_mode_allowed's alphabet choice is", | ||
| 67 | "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", | 64 | "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)", |
| 68 | "an inter frame with no key frame before it", | 65 | "an inter frame with no key frame before it", |
| 69 | "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)", | 66 | "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)", |
| 70 | - "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)", | 67 | + "an inter partition below 16x16 other than a clean split into four 8x8 leaves", |
| 71 | "an intra mode this decoder does not code (round 2)", | 68 | "an intra mode this decoder does not code (round 2)", |
| 72 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", | 69 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", |
| 73 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", | 70 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", |
crates/ec-av1/src/stream.rsmodified+212 -0
| @@ -5390,6 +5390,218 @@ mod tests { | |||
| 5390 | } | 5390 | } |
| 5391 | } | 5391 | } |
| 5392 | 5392 | ||
| 5393 | + /// lane-gmaffine r1: the two 8x8-LEAF motion gates. `decode_inter_block8` | ||
| 5394 | + /// is a separate function from [`decode_inter_block`], and until this | ||
| 5395 | + /// round it refused both `GLOBALMV` ("GLOBALMV (round 3)") and | ||
| 5396 | + /// `WARPED_CAUSAL` at that size while the 16x16+ leaf had implemented | ||
| 5397 | + /// both for rounds. The reason no earlier gate caught it: the existing | ||
| 5398 | + /// 8x8 OBMC gate clamps `--max-partition-size=32` and aomenc's RD then | ||
| 5399 | + /// never splits down to a clean 8x8 leaf (that gate has never fired in | ||
| 5400 | + /// 80 attempts). `--min-partition-size=8 --max-partition-size=8` removes | ||
| 5401 | + /// the choice entirely -- every inter leaf in the stream IS an 8x8 one, | ||
| 5402 | + /// so the leaf path is exercised by construction rather than by luck. | ||
| 5403 | + /// | ||
| 5404 | + /// Content is the affine gate's rotating/zooming mandelbrot (global | ||
| 5405 | + /// motion the encoder can actually model), and the hit counters | ||
| 5406 | + /// (`globalmv_hits_8` / `warp_hits_8`) are 8x8-leaf-specific: a | ||
| 5407 | + /// 16x16-leaf GLOBALMV or warp cannot satisfy them. | ||
| 5408 | + fn run_8x8_leaf_motion_gate( | ||
| 5409 | + name: &str, | ||
| 5410 | + global_motion: bool, | ||
| 5411 | + counter: fn() -> usize, | ||
| 5412 | + ) { | ||
| 5413 | + // 72x64: `decode_inter_block8` is reached ONLY through the | ||
| 5414 | + // true-edge-straddling 16x16 path (an interior 16x16 | ||
| 5415 | + // PARTITION_SPLIT is still refused by name), so the frame is 8 | ||
| 5416 | + // luma columns wider than its last whole superblock -- every 16x16 | ||
| 5417 | + // block in that right-hand strip is cut on ONE axis and decodes as | ||
| 5418 | + // four 8x8 leaves by construction. `--min-partition-size=16` keeps | ||
| 5419 | + // the interior out of the still-refused sub-16x16 case. | ||
| 5420 | + let (width, height, frame_count) = (64usize, 64usize, 24usize); | ||
| 5421 | + let duration = frame_count as f64 / 25.0; | ||
| 5422 | + // The encoder's own RD still chooses WHICH 8x8 leaf codes GLOBALMV / | ||
| 5423 | + // WARPED_CAUSAL, and at some quantisers it picks a rect partition at | ||
| 5424 | + // 16x16 (still refused) or a non-LAST reference (still refused at the | ||
| 5425 | + // 8x8 leaf) before ever reaching one. So sweep a few quantisers and | ||
| 5426 | + // require at least one attempt, at each depth, that BOTH decodes | ||
| 5427 | + // pixel-exact AND fires the counter -- a refusing attempt is recorded, | ||
| 5428 | + // never a pass (class `gate-skips-on-its-own-failure`). | ||
| 5429 | + let mut fired_any = [false; 2]; | ||
| 5430 | + let mut notes: Vec<String> = Vec::new(); | ||
| 5431 | + for (di, depth) in [8u32, 10u32].into_iter().enumerate() { | ||
| 5432 | + for cq in [32u32, 45, 55] { | ||
| 5433 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 5434 | + let source = format!( | ||
| 5435 | + "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\ | ||
| 5436 | + scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}" | ||
| 5437 | + ); | ||
| 5438 | + let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 5439 | + let mut ff_args: Vec<&str> = | ||
| 5440 | + vec!["-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix_fmt]; | ||
| 5441 | + if depth == 10 { | ||
| 5442 | + ff_args.extend(["-strict", "-1"]); | ||
| 5443 | + } | ||
| 5444 | + let duration_arg = duration.to_string(); | ||
| 5445 | + ff_args.extend(["-t", &duration_arg, "-f", "yuv4mpegpipe", "-"]); | ||
| 5446 | + let y4m = Command::new("ffmpeg") | ||
| 5447 | + .args(&ff_args) | ||
| 5448 | + .stdin(Stdio::null()) | ||
| 5449 | + .stdout(Stdio::piped()) | ||
| 5450 | + .stderr(Stdio::piped()) | ||
| 5451 | + .output() | ||
| 5452 | + .expect("ffmpeg failed to run"); | ||
| 5453 | + assert!( | ||
| 5454 | + y4m.status.success(), | ||
| 5455 | + "ffmpeg fixture: {}", | ||
| 5456 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 5457 | + ); | ||
| 5458 | + let bit_depth = format!("--bit-depth={depth}"); | ||
| 5459 | + let input_bit_depth = format!("--input-bit-depth={depth}"); | ||
| 5460 | + let gm_arg = format!("--enable-global-motion={}", u8::from(global_motion)); | ||
| 5461 | + let warp_arg = format!("--enable-warped-motion={}", u8::from(!global_motion)); | ||
| 5462 | + let args: Vec<&str> = vec![ | ||
| 5463 | + "--codec=av1", | ||
| 5464 | + "--passes=1", | ||
| 5465 | + "--end-usage=q", | ||
| 5466 | + &cq_arg, | ||
| 5467 | + "--cpu-used=0", | ||
| 5468 | + "--kf-max-dist=1000", | ||
| 5469 | + "--threads=1", | ||
| 5470 | + "--row-mt=0", | ||
| 5471 | + "--auto-alt-ref=0", | ||
| 5472 | + "--lag-in-frames=0", | ||
| 5473 | + "--enable-fwd-kf=0", | ||
| 5474 | + "--enable-order-hint=1", | ||
| 5475 | + &gm_arg, | ||
| 5476 | + &warp_arg, | ||
| 5477 | + "--enable-obmc=0", | ||
| 5478 | + "--tune-content=default", | ||
| 5479 | + "--enable-masked-comp=0", | ||
| 5480 | + "--enable-interintra-comp=0", | ||
| 5481 | + "--enable-onesided-comp=0", | ||
| 5482 | + "--enable-rect-partitions=0", | ||
| 5483 | + "--enable-ab-partitions=0", | ||
| 5484 | + "--enable-1to4-partitions=0", | ||
| 5485 | + "--enable-filter-intra=0", | ||
| 5486 | + "--enable-smooth-intra=0", | ||
| 5487 | + "--enable-paeth-intra=0", | ||
| 5488 | + "--enable-directional-intra=0", | ||
| 5489 | + "--enable-angle-delta=0", | ||
| 5490 | + "--enable-tx-size-search=0", | ||
| 5491 | + "--enable-cdef=0", | ||
| 5492 | + "--enable-restoration=0", | ||
| 5493 | + "--max-partition-size=8", | ||
| 5494 | + "--min-partition-size=8", | ||
| 5495 | + "--enable-palette=0", | ||
| 5496 | + "--enable-intrabc=0", | ||
| 5497 | + "--enable-cfl-intra=0", | ||
| 5498 | + "--enable-ref-frame-mvs=0", | ||
| 5499 | + &bit_depth, | ||
| 5500 | + &input_bit_depth, | ||
| 5501 | + "--obu", | ||
| 5502 | + "-o", | ||
| 5503 | + "-", | ||
| 5504 | + "-", | ||
| 5505 | + ]; | ||
| 5506 | + let mut child = Command::new(aomenc_path()) | ||
| 5507 | + .args(&args) | ||
| 5508 | + .stdin(Stdio::piped()) | ||
| 5509 | + .stdout(Stdio::piped()) | ||
| 5510 | + .stderr(Stdio::piped()) | ||
| 5511 | + .spawn() | ||
| 5512 | + .expect("aomenc failed to start"); | ||
| 5513 | + child | ||
| 5514 | + .stdin | ||
| 5515 | + .take() | ||
| 5516 | + .expect("aomenc stdin") | ||
| 5517 | + .write_all(&y4m.stdout) | ||
| 5518 | + .expect("writing y4m to aomenc"); | ||
| 5519 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 5520 | + assert!( | ||
| 5521 | + out.status.success(), | ||
| 5522 | + "aomenc refused the fixture: {}", | ||
| 5523 | + String::from_utf8_lossy(&out.stderr) | ||
| 5524 | + ); | ||
| 5525 | + let stream = out.stdout; | ||
| 5526 | + let before = counter(); | ||
| 5527 | + let frames = match decode_stream(&stream) { | ||
| 5528 | + Ok(f) => f, | ||
| 5529 | + Err(e) => { | ||
| 5530 | + let msg = e.to_string(); | ||
| 5531 | + assert!( | ||
| 5532 | + msg.contains("unsupported"), | ||
| 5533 | + "{name} ({depth}-bit, cq {cq}) failed outright: {msg}" | ||
| 5534 | + ); | ||
| 5535 | + notes.push(format!("{depth}-bit cq {cq}: {msg}")); | ||
| 5536 | + continue; | ||
| 5537 | + } | ||
| 5538 | + }; | ||
| 5539 | + let ffmpeg_frames = if depth == 10 { | ||
| 5540 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 5541 | + } else { | ||
| 5542 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 5543 | + }; | ||
| 5544 | + assert_eq!(frames.len(), frame_count); | ||
| 5545 | + let hits = counter() - before; | ||
| 5546 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 5547 | + assert_eq!(got.y, want.y, "{name} {depth}-bit frame {i} luma vs ffmpeg"); | ||
| 5548 | + assert_eq!(got.u, want.u, "{name} {depth}-bit frame {i} U vs ffmpeg"); | ||
| 5549 | + assert_eq!(got.v, want.v, "{name} {depth}-bit frame {i} V vs ffmpeg"); | ||
| 5550 | + } | ||
| 5551 | + if hits == 0 { | ||
| 5552 | + notes.push(format!( | ||
| 5553 | + "{depth}-bit cq {cq}: {frame_count} frames pixel-exact but 0 8x8-leaf hits" | ||
| 5554 | + )); | ||
| 5555 | + continue; | ||
| 5556 | + } | ||
| 5557 | + fired_any[di] = true; | ||
| 5558 | + eprintln!( | ||
| 5559 | + "{name}: {depth}-bit cq {cq}, {frame_count} frames pixel-exact, 8x8 hits={hits}" | ||
| 5560 | + ); | ||
| 5561 | + } | ||
| 5562 | + } | ||
| 5563 | + assert!( | ||
| 5564 | + fired_any[0] && fired_any[1], | ||
| 5565 | + "{name}: no attempt both decoded pixel-exact and fired the 8x8 leaf \ | ||
| 5566 | + (8-bit fired {}, 10-bit fired {}):\n{}", | ||
| 5567 | + fired_any[0], fired_any[1], notes.join("\n") | ||
| 5568 | + ); | ||
| 5569 | + } | ||
| 5570 | + | ||
| 5571 | + /// lane-gmaffine r1 item (3): `GLOBALMV` at an 8x8 leaf, ROTZOOM global | ||
| 5572 | + /// motion, warp built from the frame's own model. | ||
| 5573 | + #[test] | ||
| 5574 | + fn a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact() { | ||
| 5575 | + const NAME: &str = "a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact"; | ||
| 5576 | + let _gate_lock = lock_gate_counters(); | ||
| 5577 | + if !have_ffmpeg() { | ||
| 5578 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 5579 | + return; | ||
| 5580 | + } | ||
| 5581 | + if !have_aomenc() { | ||
| 5582 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 5583 | + return; | ||
| 5584 | + } | ||
| 5585 | + run_8x8_leaf_motion_gate(NAME, true, crate::decode::globalmv_hits_8); | ||
| 5586 | + } | ||
| 5587 | + | ||
| 5588 | + /// lane-gmaffine r1 item (2): `WARPED_CAUSAL` at an 8x8 leaf -- | ||
| 5589 | + /// findSamples + `av1_find_projection` + the warp filter at BLOCK_8X8. | ||
| 5590 | + #[test] | ||
| 5591 | + fn a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact() { | ||
| 5592 | + const NAME: &str = "a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact"; | ||
| 5593 | + let _gate_lock = lock_gate_counters(); | ||
| 5594 | + if !have_ffmpeg() { | ||
| 5595 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 5596 | + return; | ||
| 5597 | + } | ||
| 5598 | + if !have_aomenc() { | ||
| 5599 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 5600 | + return; | ||
| 5601 | + } | ||
| 5602 | + run_8x8_leaf_motion_gate(NAME, false, crate::decode::warp_hits_8); | ||
| 5603 | + } | ||
| 5604 | + | ||
| 5393 | /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi | 5605 | /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi |
| 5394 | /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no | 5606 | /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no |
| 5395 | /// `--enable-*` flags) used to refuse frame 0 outright with "a partition | 5607 | /// `--enable-*` flags) used to refuse frame 0 outright with "a partition |
lanes/gmaffine-r1.report.mdadded+83 -0
| @@ -0,0 +1,83 @@ | |||
| 1 | +# lane-gmaffine r1 — VERDICT: NOT DONE. Branch must NOT merge. | ||
| 2 | + | ||
| 3 | +Item (1) (AFFINE global motion, previous builder, HEAD 44bd68c) re-verified GREEN. | ||
| 4 | +Items (2) 8x8 WARPED_CAUSAL and (3) 8x8 GLOBALMV are IMPLEMENTED but UNGATED — | ||
| 5 | +both new gates are RED, so by COMMON's own rule ("a refusal is lifted ONLY together | ||
| 6 | +with a gate") this branch is not mergeable as it stands. | ||
| 7 | + | ||
| 8 | +## Item (1) re-verified | ||
| 9 | +`a_real_affine_global_motion_stream_decodes_pixel_exact` still passes on this branch. | ||
| 10 | +EVIDENCE: cargo test -p ec-av1 --release --lib (whole-suite run below) | gate ran with | ||
| 11 | +EC_AV1_REQUIRE_AOMENC=1 | listed in the 266 passing tests, not among the 4 failures. | ||
| 12 | + | ||
| 13 | +## What the round actually found (the premise in the charter was too narrow) | ||
| 14 | +`decode_inter_block8` (the 8x8 leaf) was not merely missing warp/GLOBALMV: it was | ||
| 15 | +**unreachable for interior blocks at all** — `decode.rs` refused every interior 16x16 | ||
| 16 | +`PARTITION_SPLIT` ("an inter partition below 16x16 …"), so the leaf only ran for | ||
| 17 | +frame-edge straddling blocks. Wiring it exposed four more gaps in that same function, | ||
| 18 | +each of which had to be closed before either charter gate could even reach a leaf: | ||
| 19 | +non-LAST single references, no `read_mb_interp_filter` at all (silent entropy desync on | ||
| 20 | +every SWITCHABLE stream), the missing short OBMC masks, and non-DC chroma modes. | ||
| 21 | + | ||
| 22 | +## Changed (all in the worktree, branch lane-gmaffine) | ||
| 23 | +- `crates/ec-av1/src/decode.rs` | ||
| 24 | + - 8x8 leaf: `GLOBALMV` via `gm_get_motion_vector` (`GLOBALMV_HITS_8`), replacing the | ||
| 25 | + "GLOBALMV (round 3)" refusal. | ||
| 26 | + - 8x8 leaf: `WARPED_CAUSAL` = `find_samples` → `select_samples` → `find_projection` → | ||
| 27 | + `warp_affine` on all three planes (`WARP_HITS_8`), replacing the "an 8x8 leaf that | ||
| 28 | + coded WARPED_CAUSAL" refusal. | ||
| 29 | + - 8x8 leaf: `allow_warp`'s global-warp branch (`global_warp_params`, independent of | ||
| 30 | + motion_mode), `MiInfo::is_global_mv0`, motion-mode suppression for | ||
| 31 | + `is_global_mv_block`. | ||
| 32 | + - 8x8 leaf: mv stack now built with `find_mv_stack_with_sign_bias(..., &gm_table, ..)` | ||
| 33 | + so a missing candidate falls back to the block's own gm mv (gm r6's root cause, | ||
| 34 | + previously fixed only at the 16x16+ leaf). | ||
| 35 | + - 8x8 leaf: full `read_single_ref` tree + `ref_planes` — "a reference frame other than | ||
| 36 | + LAST_FRAME (round 2)" removed. | ||
| 37 | + - 8x8 leaf: `resolve_interp_filter` read in libaom's order (interintra, motion_mode, | ||
| 38 | + filter) and `mc::predict_with_filters`; corner-cut documented in-code (neighbour | ||
| 39 | + filter ctx is the enclosing 16x16's, ceiling = siblings that pick different filters). | ||
| 40 | + - interior 16x16 `PARTITION_SPLIT` → four 8x8 leaves (same loop the straddle branch | ||
| 41 | + ran); the refusal narrows to "an inter partition below 16x16 other than a clean split | ||
| 42 | + into four 8x8 leaves". | ||
| 43 | + - `obmc_mask`: libaom `obmc_mask_1`/`obmc_mask_2` ([64], [45,64]) — the old | ||
| 44 | + `unreachable!()` was a hard PANIC as soon as a real 8x8 leaf ran OBMC. | ||
| 45 | +- `crates/ec-av1/src/stream.rs` — `run_8x8_leaf_motion_gate` + gates | ||
| 46 | + `a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact`, | ||
| 47 | + `a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact` (mandelbrot rotate+stretch, | ||
| 48 | + `--min/--max-partition-size=8`, cq sweep 32/45/55, 8- and 10-bit, hard-assert on the | ||
| 49 | + 8x8-specific counters, no SKIP path). | ||
| 50 | +- `crates/ec-av1/src/refusal_inventory.rs` — 3 strings removed, 1 narrowed. | ||
| 51 | + | ||
| 52 | +## Gate results (all real runs, EC_AV1_REQUIRE_AOMENC=1) | ||
| 53 | +EVIDENCE: cargo test -p ec-av1 --release --lib -- a_real_globalmv_8x8_leaf a_real_warped_causal_8x8_leaf | ||
| 54 | +| 6 aomenc encodes per gate (8/10-bit x cq 32/45/55) | RED, 0 firing attempts. Last blockers: | ||
| 55 | +globalmv gate = "a partition below 8x8" (cq32/45) and "a non-DC chroma mode on an 8x8 | ||
| 56 | +inter-frame leaf" (cq55); warp gate = a desync panic in `switchable_interp` (leaf entropy | ||
| 57 | +state still wrong somewhere, most likely the coarse per-leaf neighbour contexts). | ||
| 58 | + | ||
| 59 | +EVIDENCE: cargo test -p ec-av1 --release --lib -- a_real_aomenc_stream_with_obmc_8x8 | | ||
| 60 | +same command, seed 53 | the pre-existing 8x8 OBMC gate, vacuous (never fired) for three | ||
| 61 | +rounds, NOW REACHES 8x8 LEAVES and gets frame 14 luma+U exact, V off by ~2 at a handful of | ||
| 62 | +positions — a real residual 8x8-leaf chroma defect, previously invisible. | ||
| 63 | + | ||
| 64 | +## Suite | ||
| 65 | +`cargo test -p ec-av1 --release --lib` (EC_AV1_REQUIRE_AOMENC=1): **266 passed, 4 failed, | ||
| 66 | +23 ignored** — failures were `refusal_inventory` (fixed after that run), `obmc_8x8` | ||
| 67 | +(residual chroma defect above), and the two new RED gates. No previously-green gate | ||
| 68 | +regressed. | ||
| 69 | + | ||
| 70 | +## Residue | ||
| 71 | +- fix-now (next round): the 8x8-leaf residual that keeps every 8x8 gate from going green — | ||
| 72 | + order of attack: (a) chroma OBMC/prediction at BLOCK_8X8 (obmc_8x8 gate is one V plane | ||
| 73 | + away and is the cheapest instrument), (b) per-leaf neighbour contexts (filter/ref/skip | ||
| 74 | + arrays are all the enclosing 16x16's, a documented corner-cut that now matters), | ||
| 75 | + (c) non-DC chroma mode + sub-8x8 partition refusals at the leaf. | ||
| 76 | +- deferred: compound `GLOBAL_GLOBALMV` per-ref global warp — grep found NO refusal for it; | ||
| 77 | + `decode_inter_block`'s compound branch builds both taps translationally through | ||
| 78 | + `mc::predict_compound_intermediate` and never calls `warp_affine`, so a compound global | ||
| 79 | + block with a ROTZOOM/AFFINE model is SILENTLY WRONG today. Unblocked by: a compound | ||
| 80 | + warp path (warp into the i32 intermediate, libaom `av1_warp_plane` with `conv_params`), | ||
| 81 | + which is its own lane-sized port. NOT started this round. | ||
| 82 | +- accepted/flag: `warp::warp_affine` hardcodes `const BD: i32 = 8;` — worth one round's | ||
| 83 | + check against a 10-bit warp stream (his films are yuv420p10le). | ||