Merge lane-inter8 12809b2: interior 16x16 SPLIT into 8x8 inter leaves; mi-granular inter neighbour bands; three leaf-context defects (fabricated compound refs, sibling override, comp ctx corner) + compound-arm tail; 8-bit 8x8-leaf gate green (verifier PASS, 269/0/23); conflict = keep mi index + main's segment_id read
Browse files at this commit5 changed files +947 -147
- crates/ec-av1/src/decode.rs +500 -145
- crates/ec-av1/src/refusal_inventory.rs +3 -2
- crates/ec-av1/src/stream.rs +269 -0
- lanes/inter8-r1.report.md +87 -0
- lanes/inter8-r2.report.md +88 -0
crates/ec-av1/src/decode.rsmodified+500 -145
| @@ -1201,6 +1201,33 @@ pub(crate) fn rect_partition_hits() -> usize { | |||
| 1201 | RECT_PARTITION_HITS.with(|c| c.get()) | 1201 | RECT_PARTITION_HITS.with(|c| c.get()) |
| 1202 | } | 1202 | } |
| 1203 | 1203 | ||
| 1204 | +// lane-inter8 r1: how many superblocks an inter tile coded as a single | ||
| 1205 | +// whole-SB `PARTITION_NONE` 64x64 inter block (the case aomenc picks for | ||
| 1206 | +// static content, previously a named refusal). | ||
| 1207 | +thread_local! { | ||
| 1208 | + static INTER_SB_NONE_HITS: std::cell::Cell<usize> = | ||
| 1209 | + const { std::cell::Cell::new(0) }; | ||
| 1210 | +} | ||
| 1211 | + | ||
| 1212 | +/// Current value of [`INTER_SB_NONE_HITS`]. | ||
| 1213 | +pub(crate) fn inter_sb_none_hits() -> usize { | ||
| 1214 | + INTER_SB_NONE_HITS.with(|c| c.get()) | ||
| 1215 | +} | ||
| 1216 | + | ||
| 1217 | +// lane-inter8 r1: how many INTERIOR (not frame-edge-straddling) 16x16 inter | ||
| 1218 | +// blocks coded a real `PARTITION_SPLIT` into four 8x8 leaves -- the straddle | ||
| 1219 | +// path has always run that loop, so only this counter proves the newly-lifted | ||
| 1220 | +// alphabet value fired. | ||
| 1221 | +thread_local! { | ||
| 1222 | + static INTER_SUB16_SPLIT_HITS: std::cell::Cell<usize> = | ||
| 1223 | + const { std::cell::Cell::new(0) }; | ||
| 1224 | +} | ||
| 1225 | + | ||
| 1226 | +/// Current value of [`INTER_SUB16_SPLIT_HITS`]. | ||
| 1227 | +pub(crate) fn inter_sub16_split_hits() -> usize { | ||
| 1228 | + INTER_SUB16_SPLIT_HITS.with(|c| c.get()) | ||
| 1229 | +} | ||
| 1230 | + | ||
| 1204 | // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded | 1231 | // lane-rectwire r2: how many `PARTITION_HORZ`/`VERT` strips actually decoded |
| 1205 | // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the | 1232 | // real (non-skip) coefficients through [`read_coeffs_rect`] -- proves the |
| 1206 | // rect coefficient reader itself fired, not just the strip-level partition | 1233 | // rect coefficient reader itself fired, not just the strip-level partition |
| @@ -2459,22 +2486,26 @@ impl Neighbours { | |||
| 2459 | left_side: vec![SB; rows], | 2486 | left_side: vec![SB; rows], |
| 2460 | above_side_mi: vec![SB; cols * (SUB / MI)], | 2487 | above_side_mi: vec![SB; cols * (SUB / MI)], |
| 2461 | left_side_mi: vec![SB; rows * (SUB / MI)], | 2488 | left_side_mi: vec![SB; rows * (SUB / MI)], |
| 2462 | - above_skip: vec![false; cols], | 2489 | + // lane-inter8 r2: mi(4px)-granular, not [`SUB`]-granular -- an |
| 2463 | - left_skip: vec![false; rows], | 2490 | + // 8x8 inter leaf's left neighbour is the OTHER leaf row of the |
| 2464 | - above_skip_mode: vec![false; cols], | 2491 | + // 16x16 block beside it, which a SUB-grid slot cannot name |
| 2465 | - left_skip_mode: vec![false; rows], | 2492 | + // (class context-read-from-one-cell). |
| 2466 | - above_inter: vec![false; cols], | 2493 | + above_skip: vec![false; cols * (SUB / MI)], |
| 2467 | - left_inter: vec![false; rows], | 2494 | + left_skip: vec![false; rows * (SUB / MI)], |
| 2468 | - above_ref: vec![-1; cols], | 2495 | + above_skip_mode: vec![false; cols * (SUB / MI)], |
| 2469 | - left_ref: vec![-1; rows], | 2496 | + left_skip_mode: vec![false; rows * (SUB / MI)], |
| 2470 | - above_ref1: vec![None; cols], | 2497 | + above_inter: vec![false; cols * (SUB / MI)], |
| 2471 | - left_ref1: vec![None; rows], | 2498 | + left_inter: vec![false; rows * (SUB / MI)], |
| 2472 | - above_comp_group_idx: vec![0; cols], | 2499 | + above_ref: vec![-1; cols * (SUB / MI)], |
| 2473 | - left_comp_group_idx: vec![0; rows], | 2500 | + left_ref: vec![-1; rows * (SUB / MI)], |
| 2474 | - above_compound_idx: vec![0; cols], | 2501 | + above_ref1: vec![None; cols * (SUB / MI)], |
| 2475 | - left_compound_idx: vec![0; rows], | 2502 | + left_ref1: vec![None; rows * (SUB / MI)], |
| 2476 | - above_filter: vec![[3u8; 2]; cols], | 2503 | + above_comp_group_idx: vec![0; cols * (SUB / MI)], |
| 2477 | - left_filter: vec![[3u8; 2]; rows], | 2504 | + left_comp_group_idx: vec![0; rows * (SUB / MI)], |
| 2505 | + above_compound_idx: vec![0; cols * (SUB / MI)], | ||
| 2506 | + left_compound_idx: vec![0; rows * (SUB / MI)], | ||
| 2507 | + above_filter: vec![[3u8; 2]; cols * (SUB / MI)], | ||
| 2508 | + left_filter: vec![[3u8; 2]; rows * (SUB / MI)], | ||
| 2478 | mi_cols, | 2509 | mi_cols, |
| 2479 | mi_rows, | 2510 | mi_rows, |
| 2480 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], | 2511 | skip_grid: vec![false; cols * (SUB / MI) * rows * (SUB / MI)], |
| @@ -2522,6 +2553,11 @@ impl Neighbours { | |||
| 2522 | for i in sc0.min(sc1)..sc1 { | 2553 | for i in sc0.min(sc1)..sc1 { |
| 2523 | self.above_mode[i] = DC_PRED; | 2554 | self.above_mode[i] = DC_PRED; |
| 2524 | self.above_side[i] = SB; | 2555 | self.above_side[i] = SB; |
| 2556 | + } | ||
| 2557 | + // lane-inter8 r2: the inter bands are mi-granular, so they reset over | ||
| 2558 | + // the tile's own mi column span directly. | ||
| 2559 | + let mend = col1_mi.min(self.above_skip.len()); | ||
| 2560 | + for i in col0_mi.min(mend)..mend { | ||
| 2525 | self.above_skip[i] = false; | 2561 | self.above_skip[i] = false; |
| 2526 | self.above_skip_mode[i] = false; | 2562 | self.above_skip_mode[i] = false; |
| 2527 | self.above_inter[i] = false; | 2563 | self.above_inter[i] = false; |
| @@ -2839,8 +2875,37 @@ impl Neighbours { | |||
| 2839 | skip_mode: bool, | 2875 | skip_mode: bool, |
| 2840 | ) { | 2876 | ) { |
| 2841 | let (r, c) = at; | 2877 | let (r, c) = at; |
| 2878 | + self.record_inter_rect_mi( | ||
| 2879 | + (r * (SUB / MI), c * (SUB / MI)), | ||
| 2880 | + w_sub / MI, | ||
| 2881 | + h_sub / MI, | ||
| 2882 | + skip, | ||
| 2883 | + is_inter, | ||
| 2884 | + ref_frame, | ||
| 2885 | + filter, | ||
| 2886 | + skip_mode, | ||
| 2887 | + ); | ||
| 2888 | + } | ||
| 2889 | + | ||
| 2890 | + /// [`Self::record_inter_rect`] in mi (4px) units -- lane-inter8 r2: an | ||
| 2891 | + /// 8x8 leaf covers 2x2 mi, half a [`SUB`] cell in each direction, so the | ||
| 2892 | + /// side bands are written (and read) per mi. Every [`SUB`]-unit caller | ||
| 2893 | + /// routes through the wrapper above. | ||
| 2894 | + #[allow(clippy::too_many_arguments)] | ||
| 2895 | + fn record_inter_rect_mi( | ||
| 2896 | + &mut self, | ||
| 2897 | + at_mi: (usize, usize), | ||
| 2898 | + w_mi: usize, | ||
| 2899 | + h_mi: usize, | ||
| 2900 | + skip: bool, | ||
| 2901 | + is_inter: bool, | ||
| 2902 | + ref_frame: i8, | ||
| 2903 | + filter: [u8; 2], | ||
| 2904 | + skip_mode: bool, | ||
| 2905 | + ) { | ||
| 2906 | + let (r, c) = at_mi; | ||
| 2842 | let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; | 2907 | let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; |
| 2843 | - for cell in 0..w_sub / SUB { | 2908 | + for cell in 0..w_mi { |
| 2844 | self.above_skip[c + cell] = skip; | 2909 | self.above_skip[c + cell] = skip; |
| 2845 | self.above_skip_mode[c + cell] = skip_mode; | 2910 | self.above_skip_mode[c + cell] = skip_mode; |
| 2846 | self.above_inter[c + cell] = is_inter; | 2911 | self.above_inter[c + cell] = is_inter; |
| @@ -2858,7 +2923,7 @@ impl Neighbours { | |||
| 2858 | self.above_compound_idx[c + cell] = u8::from(altref); | 2923 | self.above_compound_idx[c + cell] = u8::from(altref); |
| 2859 | self.above_filter[c + cell] = filter; | 2924 | self.above_filter[c + cell] = filter; |
| 2860 | } | 2925 | } |
| 2861 | - for cell in 0..h_sub / SUB { | 2926 | + for cell in 0..h_mi { |
| 2862 | self.left_skip[r + cell] = skip; | 2927 | self.left_skip[r + cell] = skip; |
| 2863 | self.left_skip_mode[r + cell] = skip_mode; | 2928 | self.left_skip_mode[r + cell] = skip_mode; |
| 2864 | self.left_inter[r + cell] = is_inter; | 2929 | self.left_inter[r + cell] = is_inter; |
| @@ -2904,12 +2969,34 @@ impl Neighbours { | |||
| 2904 | compound_idx: u8, | 2969 | compound_idx: u8, |
| 2905 | ) { | 2970 | ) { |
| 2906 | let (r, c) = at; | 2971 | let (r, c) = at; |
| 2907 | - for cell in 0..w_sub / SUB { | 2972 | + self.record_compound_ctx_rect_mi( |
| 2973 | + (r * (SUB / MI), c * (SUB / MI)), | ||
| 2974 | + w_sub / MI, | ||
| 2975 | + h_sub / MI, | ||
| 2976 | + ref1, | ||
| 2977 | + comp_group_idx, | ||
| 2978 | + compound_idx, | ||
| 2979 | + ); | ||
| 2980 | + } | ||
| 2981 | + | ||
| 2982 | + /// [`Self::record_compound_ctx_rect`] in mi units (lane-inter8 r2, see | ||
| 2983 | + /// [`Self::record_inter_rect_mi`]). | ||
| 2984 | + fn record_compound_ctx_rect_mi( | ||
| 2985 | + &mut self, | ||
| 2986 | + at_mi: (usize, usize), | ||
| 2987 | + w_mi: usize, | ||
| 2988 | + h_mi: usize, | ||
| 2989 | + ref1: i8, | ||
| 2990 | + comp_group_idx: u8, | ||
| 2991 | + compound_idx: u8, | ||
| 2992 | + ) { | ||
| 2993 | + let (r, c) = at_mi; | ||
| 2994 | + for cell in 0..w_mi { | ||
| 2908 | self.above_ref1[c + cell] = Some(ref1); | 2995 | self.above_ref1[c + cell] = Some(ref1); |
| 2909 | self.above_comp_group_idx[c + cell] = comp_group_idx; | 2996 | self.above_comp_group_idx[c + cell] = comp_group_idx; |
| 2910 | self.above_compound_idx[c + cell] = compound_idx; | 2997 | self.above_compound_idx[c + cell] = compound_idx; |
| 2911 | } | 2998 | } |
| 2912 | - for cell in 0..h_sub / SUB { | 2999 | + for cell in 0..h_mi { |
| 2913 | self.left_ref1[r + cell] = Some(ref1); | 3000 | self.left_ref1[r + cell] = Some(ref1); |
| 2914 | self.left_comp_group_idx[r + cell] = comp_group_idx; | 3001 | self.left_comp_group_idx[r + cell] = comp_group_idx; |
| 2915 | self.left_compound_idx[r + cell] = compound_idx; | 3002 | self.left_compound_idx[r + cell] = compound_idx; |
| @@ -9301,6 +9388,23 @@ fn read_inter_plane( | |||
| 9301 | default_tx_type, | 9388 | default_tx_type, |
| 9302 | None, | 9389 | None, |
| 9303 | )?; | 9390 | )?; |
| 9391 | + // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but | ||
| 9392 | + // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the | ||
| 9393 | + // caller hands the 32-point `scan` there, and the coded corner goes into | ||
| 9394 | + // the top-left of the true `side`-sized grid before dequantization | ||
| 9395 | + // (dqDenom is keyed by the true size, not the corner's), mirroring | ||
| 9396 | + // [`read_plane`]'s own `tx_side != side` branch. Every other transform | ||
| 9397 | + // this decoder codes has `tx_side == side`, so this is inert below 64. | ||
| 9398 | + let tx_side = side.min(32); | ||
| 9399 | + let grid = if tx_side == side { | ||
| 9400 | + grid | ||
| 9401 | + } else { | ||
| 9402 | + let mut full = vec![0i32; side * side]; | ||
| 9403 | + for row in 0..tx_side { | ||
| 9404 | + full[row * side..][..tx_side].copy_from_slice(&grid[row * tx_side..][..tx_side]); | ||
| 9405 | + } | ||
| 9406 | + full | ||
| 9407 | + }; | ||
| 9304 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); | 9408 | let (dc_delta, ac_delta) = plane_q_delta(plane_idx); |
| 9305 | let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), block_q_idx(), dc_delta, ac_delta, tx_type); | 9409 | let residual = dequant_and_inverse_typed(&grid, side, bit_depth(), block_q_idx(), dc_delta, ac_delta, tx_type); |
| 9306 | plane.reconstruct_mc(x, y, side, prediction, &residual); | 9410 | plane.reconstruct_mc(x, y, side, prediction, &residual); |
| @@ -9649,6 +9753,11 @@ fn num_proj_ref( | |||
| 9649 | /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16) | 9753 | /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16) |
| 9650 | /// are transcribed. | 9754 | /// are transcribed. |
| 9651 | fn obmc_mask(len: usize) -> &'static [u8] { | 9755 | fn obmc_mask(len: usize) -> &'static [u8] { |
| 9756 | + // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the | ||
| 9757 | + // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 2 | ||
| 9758 | + // chroma), which only became live once 8x8 inter leaves stopped being | ||
| 9759 | + // refused. | ||
| 9760 | + const M2: [u8; 2] = [45, 64]; | ||
| 9652 | const M4: [u8; 4] = [39, 50, 59, 64]; | 9761 | const M4: [u8; 4] = [39, 50, 59, 64]; |
| 9653 | const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64]; | 9762 | const M8: [u8; 8] = [36, 42, 48, 53, 57, 61, 64, 64]; |
| 9654 | const M16: [u8; 16] = [ | 9763 | const M16: [u8; 16] = [ |
| @@ -9659,6 +9768,7 @@ fn obmc_mask(len: usize) -> &'static [u8] { | |||
| 9659 | 61, 62, 64, 64, 64, 64, 64, 64, 64, 64, | 9768 | 61, 62, 64, 64, 64, 64, 64, 64, 64, 64, |
| 9660 | ]; | 9769 | ]; |
| 9661 | match len { | 9770 | match len { |
| 9771 | + 2 => &M2, | ||
| 9662 | 4 => &M4, | 9772 | 4 => &M4, |
| 9663 | 8 => &M8, | 9773 | 8 => &M8, |
| 9664 | 16 => &M16, | 9774 | 16 => &M16, |
| @@ -9892,6 +10002,7 @@ fn obmc_blend( | |||
| 9892 | }; | 10002 | }; |
| 9893 | let overlap_above = write_h / 2; | 10003 | let overlap_above = write_h / 2; |
| 9894 | let overlap_left = write_w / 2; | 10004 | let overlap_left = write_w / 2; |
| 10005 | + let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16)); | ||
| 9895 | 10006 | ||
| 9896 | for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) | 10007 | for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4)) |
| 9897 | { | 10008 | { |
| @@ -9901,23 +10012,31 @@ fn obmc_blend( | |||
| 9901 | // divide back down to that column. | 10012 | // divide back down to that column. |
| 9902 | let (h_kind, v_kind) = neighbour_filter( | 10013 | let (h_kind, v_kind) = neighbour_filter( |
| 9903 | interp_fixed, | 10014 | interp_fixed, |
| 9904 | - neighbours.above_filter[(mi_col + off4) / SUB_MI as usize], | 10015 | + neighbours.above_filter[mi_col + off4], |
| 9905 | ); | 10016 | ); |
| 9906 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; | 10017 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 9907 | let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); | 10018 | let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); |
| 9908 | let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind); | 10019 | let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind); |
| 9909 | obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y); | 10020 | obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y); |
| 10021 | + // lane-inter8 r1: `av1_skip_u4x4_pred_in_obmc` (`reconinter.c` 820, | ||
| 10022 | + // `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided obmc"): when the | ||
| 10023 | + // chroma plane's own block size is BLOCK_4X4/8X4/4X8 (a 8x8, 16x8 or | ||
| 10024 | + // 8x16 luma block at 4:2:0), the ABOVE pass skips chroma entirely | ||
| 10025 | + // while the LEFT pass still blends it. Blending chroma here as well | ||
| 10026 | + // would both mis-predict every 8x8 leaf and ask for an overlap of 2. | ||
| 10027 | + if !skip_chroma_above { | ||
| 9910 | let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2); | 10028 | let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2); |
| 9911 | let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); | 10029 | let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 9912 | obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); | 10030 | obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u); |
| 9913 | let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); | 10031 | let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind); |
| 9914 | obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v); | 10032 | obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v); |
| 9915 | } | 10033 | } |
| 10034 | + } | ||
| 9916 | 10035 | ||
| 9917 | for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) { | 10036 | for (off4, span4, nb) in overlappable_left(grid, mi_row, mi_col, bh4, mi_rows, max_nb(bh4)) { |
| 9918 | let (h_kind, v_kind) = neighbour_filter( | 10037 | let (h_kind, v_kind) = neighbour_filter( |
| 9919 | interp_fixed, | 10038 | interp_fixed, |
| 9920 | - neighbours.left_filter[(mi_row + off4) / SUB_MI as usize], | 10039 | + neighbours.left_filter[mi_row + off4], |
| 9921 | ); | 10040 | ); |
| 9922 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; | 10041 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 9923 | let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); | 10042 | let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); |
| @@ -9958,10 +10077,17 @@ fn is_uni_comp_ref(ref0: i8, ref1: i8) -> bool { | |||
| 9958 | /// `get_comp_group_idx_context` (libaom `pred_common.h`): sums the | 10077 | /// `get_comp_group_idx_context` (libaom `pred_common.h`): sums the |
| 9959 | /// above/left neighbour contributions [`Neighbours::record_inter`]/ | 10078 | /// above/left neighbour contributions [`Neighbours::record_inter`]/ |
| 9960 | /// [`Neighbours::record_compound_ctx`] already precomputed, clamped to 5. | 10079 | /// [`Neighbours::record_compound_ctx`] already precomputed, clamped to 5. |
| 9961 | -fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side: usize) -> usize { | 10080 | +/// lane-inter8 r2: `at_mi` is the block's own top-left in 4x4 mi units -- |
| 10081 | +/// an 8x8 leaf used to pass its enclosing 16x16's corner here, so all four | ||
| 10082 | +/// leaves read the same neighbour cell (class context-read-from-one-cell). | ||
| 10083 | +fn get_comp_group_idx_context( | ||
| 10084 | + neighbours: &Neighbours, | ||
| 10085 | + at_mi: (usize, usize), | ||
| 10086 | + side: usize, | ||
| 10087 | +) -> usize { | ||
| 9962 | let _ = side; | 10088 | let _ = side; |
| 9963 | - let (r, c) = at; | 10089 | + let (rmi, cmi) = at_mi; |
| 9964 | - (neighbours.above_comp_group_idx[c] as usize + neighbours.left_comp_group_idx[r] as usize) | 10090 | + (neighbours.above_comp_group_idx[cmi] as usize + neighbours.left_comp_group_idx[rmi] as usize) |
| 9965 | .min(5) | 10091 | .min(5) |
| 9966 | } | 10092 | } |
| 9967 | 10093 | ||
| @@ -9973,7 +10099,7 @@ fn get_comp_group_idx_context(neighbours: &Neighbours, at: (usize, usize), side: | |||
| 9973 | #[allow(clippy::too_many_arguments)] | 10099 | #[allow(clippy::too_many_arguments)] |
| 9974 | fn get_comp_index_context( | 10100 | fn get_comp_index_context( |
| 9975 | neighbours: &Neighbours, | 10101 | neighbours: &Neighbours, |
| 9976 | - at: (usize, usize), | 10102 | + at_mi: (usize, usize), |
| 9977 | side: usize, | 10103 | side: usize, |
| 9978 | order_hint_bits: u32, | 10104 | order_hint_bits: u32, |
| 9979 | cur_order_hint: u32, | 10105 | cur_order_hint: u32, |
| @@ -9981,7 +10107,7 @@ fn get_comp_index_context( | |||
| 9981 | ref1_order_hint: u32, | 10107 | ref1_order_hint: u32, |
| 9982 | ) -> usize { | 10108 | ) -> usize { |
| 9983 | let _ = side; | 10109 | let _ = side; |
| 9984 | - let (r, c) = at; | 10110 | + let (rmi, cmi) = at_mi; |
| 9985 | let fwd = | 10111 | let fwd = |
| 9986 | crate::motion_field::get_relative_dist(order_hint_bits, ref1_order_hint, cur_order_hint) | 10112 | crate::motion_field::get_relative_dist(order_hint_bits, ref1_order_hint, cur_order_hint) |
| 9987 | .abs(); | 10113 | .abs(); |
| @@ -9989,8 +10115,8 @@ fn get_comp_index_context( | |||
| 9989 | crate::motion_field::get_relative_dist(order_hint_bits, cur_order_hint, ref0_order_hint) | 10115 | crate::motion_field::get_relative_dist(order_hint_bits, cur_order_hint, ref0_order_hint) |
| 9990 | .abs(); | 10116 | .abs(); |
| 9991 | let offset = usize::from(fwd == bck); | 10117 | let offset = usize::from(fwd == bck); |
| 9992 | - neighbours.above_compound_idx[c] as usize | 10118 | + neighbours.above_compound_idx[cmi] as usize |
| 9993 | - + neighbours.left_compound_idx[r] as usize | 10119 | + + neighbours.left_compound_idx[rmi] as usize |
| 9994 | + 3 * offset | 10120 | + 3 * offset |
| 9995 | } | 10121 | } |
| 9996 | 10122 | ||
| @@ -10364,6 +10490,11 @@ fn decode_inter_block( | |||
| 10364 | frame_width: usize, | 10490 | frame_width: usize, |
| 10365 | ) -> Result<()> { | 10491 | ) -> Result<()> { |
| 10366 | let (r, c) = at; | 10492 | let (r, c) = at; |
| 10493 | + // lane-inter8 r2: the inter side bands are mi-granular; this block's own | ||
| 10494 | + // above/left neighbour is the mi cell at its top-left corner (libaom | ||
| 10495 | + // `above_mbmi` = mi(mi_row - 1, mi_col)), so a SUB-aligned block reads | ||
| 10496 | + // exactly what it read before. | ||
| 10497 | + let (rmi, cmi) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 10367 | let (px, py) = (c * SUB, r * SUB); | 10498 | let (px, py) = (c * SUB, r * SUB); |
| 10368 | let (cpx, cpy) = (px / 2, py / 2); | 10499 | let (cpx, cpy) = (px / 2, py / 2); |
| 10369 | let chroma_side = side / 2; | 10500 | let chroma_side = side / 2; |
| @@ -10376,7 +10507,7 @@ fn decode_inter_block( | |||
| 10376 | ); | 10507 | ); |
| 10377 | } | 10508 | } |
| 10378 | let skip_mode_ctx = | 10509 | let skip_mode_ctx = |
| 10379 | - usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); | 10510 | + usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); |
| 10380 | // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read | 10511 | // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read |
| 10381 | // MSAC tell so it can be diffed against an equivalent hook in libaom's | 10512 | // MSAC tell so it can be diffed against an equivalent hook in libaom's |
| 10382 | // own `read_skip_mode`/`av1_get_skip_mode_context`. | 10513 | // own `read_skip_mode`/`av1_get_skip_mode_context`. |
| @@ -10402,7 +10533,7 @@ fn decode_inter_block( | |||
| 10402 | SKIP_MODE_HITS.with(|c| c.set(c.get() + 1)); | 10533 | SKIP_MODE_HITS.with(|c| c.set(c.get() + 1)); |
| 10403 | } | 10534 | } |
| 10404 | 10535 | ||
| 10405 | - let skip_ctx = usize::from(neighbours.above_skip[c]) + usize::from(neighbours.left_skip[r]); | 10536 | + let skip_ctx = usize::from(neighbours.above_skip[cmi]) + usize::from(neighbours.left_skip[rmi]); |
| 10406 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; | 10537 | let skip = skip_mode || dec.symbol(&mut cdfs.skip[skip_ctx]) == 1; |
| 10407 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false); | 10538 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, skip, false); |
| 10408 | maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip); | 10539 | maybe_read_cdef_idx(dec, r * SUB_MI as usize, c * SUB_MI as usize, skip); |
| @@ -10421,9 +10552,17 @@ fn decode_inter_block( | |||
| 10421 | r > neighbours.tile_row0_mi / (SUB / MI), | 10552 | r > neighbours.tile_row0_mi / (SUB / MI), |
| 10422 | c > neighbours.tile_col0_mi / (SUB / MI), | 10553 | c > neighbours.tile_col0_mi / (SUB / MI), |
| 10423 | ); | 10554 | ); |
| 10424 | - let (above_inter, left_inter) = (neighbours.above_inter[c], neighbours.left_inter[r]); | 10555 | + let (above_inter, left_inter) = (neighbours.above_inter[cmi], neighbours.left_inter[rmi]); |
| 10425 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); | 10556 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); |
| 10426 | let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; | 10557 | let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 10558 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 10559 | + eprintln!( | ||
| 10560 | + "EC_MODE mi_row={} mi_col={} rng={}", | ||
| 10561 | + r * SUB_MI as usize, | ||
| 10562 | + c * SUB_MI as usize, | ||
| 10563 | + dec.debug_state().0 | ||
| 10564 | + ); | ||
| 10565 | + } | ||
| 10427 | if std::env::var_os("EC_AV1_TELL").is_some() { | 10566 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 10428 | eprintln!( | 10567 | eprintln!( |
| 10429 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", | 10568 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", |
| @@ -10446,24 +10585,24 @@ fn decode_inter_block( | |||
| 10446 | let above_nbr = has_above.then(|| NeighbourRef { | 10585 | let above_nbr = has_above.then(|| NeighbourRef { |
| 10447 | is_inter: above_inter, | 10586 | is_inter: above_inter, |
| 10448 | ref0: if above_inter { | 10587 | ref0: if above_inter { |
| 10449 | - neighbours.above_ref[c] | 10588 | + neighbours.above_ref[cmi] |
| 10450 | } else { | 10589 | } else { |
| 10451 | 0 | 10590 | 0 |
| 10452 | }, | 10591 | }, |
| 10453 | - ref1: neighbours.above_ref1[c], | 10592 | + ref1: neighbours.above_ref1[cmi], |
| 10454 | - uni: neighbours.above_ref1[c] | 10593 | + uni: neighbours.above_ref1[cmi] |
| 10455 | - .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[c], r1)), | 10594 | + .is_some_and(|r1| is_uni_comp_ref(neighbours.above_ref[cmi], r1)), |
| 10456 | }); | 10595 | }); |
| 10457 | let left_nbr = has_left.then(|| NeighbourRef { | 10596 | let left_nbr = has_left.then(|| NeighbourRef { |
| 10458 | is_inter: left_inter, | 10597 | is_inter: left_inter, |
| 10459 | ref0: if left_inter { | 10598 | ref0: if left_inter { |
| 10460 | - neighbours.left_ref[r] | 10599 | + neighbours.left_ref[rmi] |
| 10461 | } else { | 10600 | } else { |
| 10462 | 0 | 10601 | 0 |
| 10463 | }, | 10602 | }, |
| 10464 | - ref1: neighbours.left_ref1[r], | 10603 | + ref1: neighbours.left_ref1[rmi], |
| 10465 | - uni: neighbours.left_ref1[r] | 10604 | + uni: neighbours.left_ref1[rmi] |
| 10466 | - .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[r], r1)), | 10605 | + .is_some_and(|r1| is_uni_comp_ref(neighbours.left_ref[rmi], r1)), |
| 10467 | }); | 10606 | }); |
| 10468 | if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | 10607 | if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { |
| 10469 | eprintln!( | 10608 | eprintln!( |
| @@ -10482,8 +10621,8 @@ fn decode_inter_block( | |||
| 10482 | cdfs, | 10621 | cdfs, |
| 10483 | above_nbr, | 10622 | above_nbr, |
| 10484 | left_nbr, | 10623 | left_nbr, |
| 10485 | - neighbours.above_ref[c], | 10624 | + neighbours.above_ref[cmi], |
| 10486 | - neighbours.left_ref[r], | 10625 | + neighbours.left_ref[rmi], |
| 10487 | ) | 10626 | ) |
| 10488 | }; | 10627 | }; |
| 10489 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); | 10628 | let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize); |
| @@ -10599,17 +10738,17 @@ fn decode_inter_block( | |||
| 10599 | // real filter match down to the "no neighbour" sentinel | 10738 | // real filter match down to the "no neighbour" sentinel |
| 10600 | // whenever the shared reference sits in the neighbour's SECOND | 10739 | // whenever the shared reference sits in the neighbour's SECOND |
| 10601 | // slot (lane-av1idx r2). | 10740 | // slot (lane-av1idx r2). |
| 10602 | - let above_filter_ctx = if neighbours.above_ref[c] == ref0 | 10741 | + let above_filter_ctx = if neighbours.above_ref[cmi] == ref0 |
| 10603 | - || neighbours.above_ref1[c] == Some(ref0) | 10742 | + || neighbours.above_ref1[cmi] == Some(ref0) |
| 10604 | { | 10743 | { |
| 10605 | - neighbours.above_filter[c] | 10744 | + neighbours.above_filter[cmi] |
| 10606 | } else { | 10745 | } else { |
| 10607 | [3, 3] | 10746 | [3, 3] |
| 10608 | }; | 10747 | }; |
| 10609 | - let left_filter_ctx = if neighbours.left_ref[r] == ref0 | 10748 | + let left_filter_ctx = if neighbours.left_ref[rmi] == ref0 |
| 10610 | - || neighbours.left_ref1[r] == Some(ref0) | 10749 | + || neighbours.left_ref1[rmi] == Some(ref0) |
| 10611 | { | 10750 | { |
| 10612 | - neighbours.left_filter[r] | 10751 | + neighbours.left_filter[rmi] |
| 10613 | } else { | 10752 | } else { |
| 10614 | [3, 3] | 10753 | [3, 3] |
| 10615 | }; | 10754 | }; |
| @@ -10655,7 +10794,7 @@ fn decode_inter_block( | |||
| 10655 | // there), so the gate reduces to the sequence header bit; kept | 10794 | // there), so the gate reduces to the sequence header bit; kept |
| 10656 | // as an explicit call so a future smaller block size is not | 10795 | // as an explicit call so a future smaller block size is not |
| 10657 | // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`). | 10796 | // silently wrong (libaom `reconinter.h::is_any_masked_compound_used`). |
| 10658 | - let group_ctx = get_comp_group_idx_context(neighbours, at, side); | 10797 | + let group_ctx = get_comp_group_idx_context(neighbours, (rmi, cmi), side); |
| 10659 | let comp_group_idx = if !skip_mode | 10798 | let comp_group_idx = if !skip_mode |
| 10660 | && enable_masked_compound | 10799 | && enable_masked_compound |
| 10661 | && is_any_masked_compound_used_here(side) | 10800 | && is_any_masked_compound_used_here(side) |
| @@ -10683,7 +10822,17 @@ fn decode_inter_block( | |||
| 10683 | 8 => 3, | 10822 | 8 => 3, |
| 10684 | 16 => 6, | 10823 | 16 => 6, |
| 10685 | 32 => 9, | 10824 | 32 => 9, |
| 10686 | - _ => unreachable!("decode_inter_block leaf side is 8/16/32"), | 10825 | + // lane-inter8 r1: `av1_is_wedge_used` is false at 64x64 |
| 10826 | + // (`av1_wedge_params_lookup[BLOCK_64X64].wedge_types == | ||
| 10827 | + // 0`), so a real encoder writes NO `compound_type` symbol | ||
| 10828 | + // there -- COMPOUND_DIFFWTD is inferred. Reading one | ||
| 10829 | + // would desync, so refuse by name rather than guess the | ||
| 10830 | + // inferred-DIFFWTD blend this round. | ||
| 10831 | + _ => { | ||
| 10832 | + return Err(unsupported( | ||
| 10833 | + "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", | ||
| 10834 | + )) | ||
| 10835 | + } | ||
| 10687 | }; | 10836 | }; |
| 10688 | let compound_type = dec.symbol(&mut cdfs.compound_type[wedge_bsize]); | 10837 | let compound_type = dec.symbol(&mut cdfs.compound_type[wedge_bsize]); |
| 10689 | if compound_type == 0 { | 10838 | if compound_type == 0 { |
| @@ -10909,7 +11058,7 @@ fn decode_inter_block( | |||
| 10909 | { | 11058 | { |
| 10910 | let idx_ctx = get_comp_index_context( | 11059 | let idx_ctx = get_comp_index_context( |
| 10911 | neighbours, | 11060 | neighbours, |
| 10912 | - at, | 11061 | + (rmi, cmi), |
| 10913 | side, | 11062 | side, |
| 10914 | order_hint_bits, | 11063 | order_hint_bits, |
| 10915 | order_hint, | 11064 | order_hint, |
| @@ -11266,10 +11415,10 @@ fn decode_inter_block( | |||
| 11266 | read_single_ref( | 11415 | read_single_ref( |
| 11267 | dec, | 11416 | dec, |
| 11268 | cdfs, | 11417 | cdfs, |
| 11269 | - neighbours.above_ref[c], | 11418 | + neighbours.above_ref[cmi], |
| 11270 | - neighbours.above_ref1[c], | 11419 | + neighbours.above_ref1[cmi], |
| 11271 | - neighbours.left_ref[r], | 11420 | + neighbours.left_ref[rmi], |
| 11272 | - neighbours.left_ref1[r], | 11421 | + neighbours.left_ref1[rmi], |
| 11273 | ); | 11422 | ); |
| 11274 | ref_frame_for_lf = ref_frame; | 11423 | ref_frame_for_lf = ref_frame; |
| 11275 | if std::env::var_os("EC_AV1_TELL").is_some() { | 11424 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| @@ -11643,17 +11792,17 @@ fn decode_inter_block( | |||
| 11643 | // lane-av1idx r2: also match on the neighbour's SECOND reference | 11792 | // lane-av1idx r2: also match on the neighbour's SECOND reference |
| 11644 | // (`above_ref1`/`left_ref1`, real for a compound neighbour) -- | 11793 | // (`above_ref1`/`left_ref1`, real for a compound neighbour) -- |
| 11645 | // see the 16x16 leaf's own comment above for the spec citation. | 11794 | // see the 16x16 leaf's own comment above for the spec citation. |
| 11646 | - let above_filter_ctx = if neighbours.above_ref[c] == ref_frame | 11795 | + let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame |
| 11647 | - || neighbours.above_ref1[c] == Some(ref_frame) | 11796 | + || neighbours.above_ref1[cmi] == Some(ref_frame) |
| 11648 | { | 11797 | { |
| 11649 | - neighbours.above_filter[c] | 11798 | + neighbours.above_filter[cmi] |
| 11650 | } else { | 11799 | } else { |
| 11651 | [3, 3] | 11800 | [3, 3] |
| 11652 | }; | 11801 | }; |
| 11653 | - let left_filter_ctx = if neighbours.left_ref[r] == ref_frame | 11802 | + let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame |
| 11654 | - || neighbours.left_ref1[r] == Some(ref_frame) | 11803 | + || neighbours.left_ref1[rmi] == Some(ref_frame) |
| 11655 | { | 11804 | { |
| 11656 | - neighbours.left_filter[r] | 11805 | + neighbours.left_filter[rmi] |
| 11657 | } else { | 11806 | } else { |
| 11658 | [3, 3] | 11807 | [3, 3] |
| 11659 | }; | 11808 | }; |
| @@ -12271,7 +12420,6 @@ fn decode_inter_block8( | |||
| 12271 | base_q_idx: u8, | 12420 | base_q_idx: u8, |
| 12272 | scan8: &[u16], | 12421 | scan8: &[u16], |
| 12273 | scan4: &[u16], | 12422 | scan4: &[u16], |
| 12274 | - prev_leaf: Option<((usize, usize), bool, bool)>, | ||
| 12275 | allow_high_precision_mv: bool, | 12423 | allow_high_precision_mv: bool, |
| 12276 | force_integer_mv: bool, | 12424 | force_integer_mv: bool, |
| 12277 | // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path | 12425 | // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path |
| @@ -12291,7 +12439,7 @@ fn decode_inter_block8( | |||
| 12291 | // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this | 12439 | // lane-av1comp round 14: see [`decode_inter_block`]'s own doc -- this |
| 12292 | // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either, | 12440 | // leaf has no per-leaf `above_skip_mode`/`left_skip_mode` array either, |
| 12293 | // so its `skip_mode` context reuses the same [`SUB`]-grid | 12441 | // so its `skip_mode` context reuses the same [`SUB`]-grid |
| 12294 | - // `above_skip_mode[c]`/`left_skip_mode[r]` the enclosing 16x16 slot | 12442 | + // `above_skip_mode[cmi]`/`left_skip_mode[rmi]` the enclosing 16x16 slot |
| 12295 | // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation | 12443 | // tracks (mirroring `above_skip`/`left_skip`'s own leaf approximation |
| 12296 | // just above). | 12444 | // just above). |
| 12297 | skip_mode_present: bool, | 12445 | skip_mode_present: bool, |
| @@ -12319,8 +12467,34 @@ fn decode_inter_block8( | |||
| 12319 | // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`- | 12467 | // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`- |
| 12320 | // eligible (`bsize >= BLOCK_8X8`). | 12468 | // eligible (`bsize >= BLOCK_8X8`). |
| 12321 | allow_screen_content_tools: bool, | 12469 | allow_screen_content_tools: bool, |
| 12322 | -) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>)> { | 12470 | + // lane-inter8 r1: the leaf's mv stacks used to be built with neither the |
| 12471 | + // frame's sign-bias table nor its global-motion mv table (`NO_SIGN_BIAS` | ||
| 12472 | + // / `NO_GM_MV`), while [`decode_inter_block`] one level up passed both. | ||
| 12473 | + // A neighbour coded GLOBALMV contributes the gm mv, so dropping the table | ||
| 12474 | + // changes the candidate list -- and with it `new_mv_ctx`/`ref_mv_ctx`, | ||
| 12475 | + // `drl_ctx` and the number of symbols read. Measured: an 8x8 compound | ||
| 12476 | + // NEAR_NEWMV leaf desynced against aomdec's EC_MODE ladder at exactly | ||
| 12477 | + // this block (mi 4,14 of the mandelbrot 8x8-split gate). | ||
| 12478 | + sign_bias_table: &SignBiasTable, | ||
| 12479 | + global_motion: &[ec_av1_syntax::WarpParams; 7], | ||
| 12480 | + // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which | ||
| 12481 | + // [`decode_inter_block`] one level up has always passed and this leaf | ||
| 12482 | + // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds | ||
| 12483 | + // fewer candidates here than in the reference decoder, which changes the | ||
| 12484 | + // mode contexts AND the number of `drl_mode` bits read (class parsed | ||
| 12485 | + // then discarded). | ||
| 12486 | + tpl_frame: Option<&TplFrameArgs>, | ||
| 12487 | +) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, (i8, Option<i8>))> { | ||
| 12323 | const LAST_FRAME: i8 = 1; | 12488 | const LAST_FRAME: i8 = 1; |
| 12489 | + let gm_table = build_gm_mv_table( | ||
| 12490 | + global_motion, | ||
| 12491 | + leaf_mi.0, | ||
| 12492 | + leaf_mi.1, | ||
| 12493 | + 2, | ||
| 12494 | + 2, | ||
| 12495 | + allow_high_precision_mv, | ||
| 12496 | + force_integer_mv, | ||
| 12497 | + ); | ||
| 12324 | /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`). | 12498 | /// `Y_MODE`'s size group (`common_data.h`'s `size_group_lookup[BLOCK_8X8]`). |
| 12325 | const SIZE_GROUP_8: usize = 1; | 12499 | const SIZE_GROUP_8: usize = 1; |
| 12326 | 12500 | ||
| @@ -12330,21 +12504,26 @@ fn decode_inter_block8( | |||
| 12330 | const CHROMA_SIDE: usize = 4; | 12504 | const CHROMA_SIDE: usize = 4; |
| 12331 | 12505 | ||
| 12332 | let (r, c) = outer_at; | 12506 | let (r, c) = outer_at; |
| 12333 | - let mut above_skip = neighbours.above_skip[c]; | 12507 | + let _ = (r, c); |
| 12334 | - let mut left_skip = neighbours.left_skip[r]; | 12508 | + // lane-inter8 r2: this leaf's OWN mi cell, not the enclosing 16x16's -- |
| 12335 | - let mut above_inter = neighbours.above_inter[c]; | 12509 | + // leaf (mi_r, mi_c + 2)'s left neighbour is leaf (mi_r, mi_c), and the |
| 12336 | - let mut left_inter = neighbours.left_inter[r]; | 12510 | + // left column of a 16x16's second leaf ROW is the previous 16x16 block's |
| 12337 | - if let Some(((pr, pc), pskip, pinter)) = prev_leaf { | 12511 | + // bottom leaf, neither of which a SUB-grid slot can name. |
| 12338 | - if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 { | 12512 | + let (rmi, cmi) = leaf_mi; |
| 12339 | - above_skip = pskip; | 12513 | + // lane-inter8 r2: no sibling-leaf override any more -- each leaf stamps |
| 12340 | - above_inter = pinter; | 12514 | + // its own 2x2-mi span into the bands right after it decodes (the caller's |
| 12341 | - } else if pr == leaf_mi.0 && leaf_mi.1 == pc + 2 { | 12515 | + // `record_inter_rect_mi`), so a plain mi read already names the correct |
| 12342 | - left_skip = pskip; | 12516 | + // neighbour, including one belonging to the previous 16x16 block. |
| 12343 | - left_inter = pinter; | 12517 | + let above_skip = neighbours.above_skip[cmi]; |
| 12344 | - } | 12518 | + let left_skip = neighbours.left_skip[rmi]; |
| 12345 | - } | 12519 | + let above_inter = neighbours.above_inter[cmi]; |
| 12520 | + let left_inter = neighbours.left_inter[rmi]; | ||
| 12521 | + let above_ref0 = neighbours.above_ref[cmi]; | ||
| 12522 | + let above_ref1 = neighbours.above_ref1[cmi]; | ||
| 12523 | + let left_ref0 = neighbours.left_ref[rmi]; | ||
| 12524 | + let left_ref1 = neighbours.left_ref1[rmi]; | ||
| 12346 | let skip_mode_ctx = | 12525 | let skip_mode_ctx = |
| 12347 | - usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); | 12526 | + usize::from(neighbours.above_skip_mode[cmi]) + usize::from(neighbours.left_skip_mode[rmi]); |
| 12348 | // Same two `inter_segment_id` positions as [`decode_inter_block`]; this | 12527 | // Same two `inter_segment_id` positions as [`decode_inter_block`]; this |
| 12349 | // leaf is always `BLOCK_8X8`, i.e. 2x2 mi. | 12528 | // leaf is always `BLOCK_8X8`, i.e. 2x2 mi. |
| 12350 | inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true); | 12529 | inter_segment_id(dec, cdfs, leaf_mi.0, leaf_mi.1, 2, 2, false, true); |
| @@ -12367,23 +12546,46 @@ fn decode_inter_block8( | |||
| 12367 | ); | 12546 | ); |
| 12368 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); | 12547 | let ii_ctx = intra_inter_ctx(has_above, has_left, above_inter, left_inter); |
| 12369 | let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; | 12548 | let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 12549 | + // lane-inter8 r1: mirrors the oracle's `EC_MODE` (instrument rung 4, | ||
| 12550 | + // `read_inter_block_mode_info`) so an 8x8 leaf's mode-info range ladder | ||
| 12551 | + // diffs line for line against a real aomdec. | ||
| 12552 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 12553 | + eprintln!( | ||
| 12554 | + "EC_MODE mi_row={} mi_col={} rng={}", | ||
| 12555 | + leaf_mi.0, | ||
| 12556 | + leaf_mi.1, | ||
| 12557 | + dec.debug_state().0 | ||
| 12558 | + ); | ||
| 12559 | + } | ||
| 12370 | 12560 | ||
| 12371 | let mode_for_tx; | 12561 | let mode_for_tx; |
| 12372 | let (luma_grid, u_grid, v_grid); | 12562 | let (luma_grid, u_grid, v_grid); |
| 12373 | let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None; | 12563 | let mut compound_ctx8: Option<(i8, i8, u8, u8)> = None; |
| 12564 | + // lane-inter8 r1: this leaf's own resolved references, handed back so the | ||
| 12565 | + // NEXT leaf of the same 16x16 can use them as its real above/left | ||
| 12566 | + // neighbour (`Neighbours`' arrays only move once per 16x16 block). | ||
| 12567 | + // `(0, None)` is intra. | ||
| 12568 | + let mut leaf_refs: (i8, Option<i8>) = (0, None); | ||
| 12374 | if is_inter { | 12569 | if is_inter { |
| 12375 | if reference_select || skip_mode { | 12570 | if reference_select || skip_mode { |
| 12571 | + // lane-inter8 r1: the REAL neighbour references, not a | ||
| 12572 | + // `LAST_FRAME`-or-intra stand-in. `av1_get_reference_mode_context` | ||
| 12573 | + // and `read_compound_ref_frames`' own contexts both ask whether a | ||
| 12574 | + // neighbour is COMPOUND, so pretending every inter neighbour is | ||
| 12575 | + // single-ref LAST picked the wrong `comp_mode` CDF row -- measured | ||
| 12576 | + // as an 8x8 leaf reading single-ref where aomdec read compound | ||
| 12577 | + // NEAR_NEWMV (mi 4,14). | ||
| 12376 | let above_nbr = has_above.then(|| NeighbourRef { | 12578 | let above_nbr = has_above.then(|| NeighbourRef { |
| 12377 | is_inter: above_inter, | 12579 | is_inter: above_inter, |
| 12378 | - ref0: if above_inter { LAST_FRAME } else { 0 }, | 12580 | + ref0: if above_inter { above_ref0 } else { 0 }, |
| 12379 | - ref1: None, | 12581 | + ref1: above_ref1, |
| 12380 | - uni: false, | 12582 | + uni: above_ref1.is_some_and(|r1| is_uni_comp_ref(above_ref0, r1)), |
| 12381 | }); | 12583 | }); |
| 12382 | let left_nbr = has_left.then(|| NeighbourRef { | 12584 | let left_nbr = has_left.then(|| NeighbourRef { |
| 12383 | is_inter: left_inter, | 12585 | is_inter: left_inter, |
| 12384 | - ref0: if left_inter { LAST_FRAME } else { 0 }, | 12586 | + ref0: if left_inter { left_ref0 } else { 0 }, |
| 12385 | - ref1: None, | 12587 | + ref1: left_ref1, |
| 12386 | - uni: false, | 12588 | + uni: left_ref1.is_some_and(|r1| is_uni_comp_ref(left_ref0, r1)), |
| 12387 | }); | 12589 | }); |
| 12388 | if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) { | 12590 | if skip_mode || read_comp_mode(dec, cdfs, above_nbr, left_nbr) { |
| 12389 | let (ref0, ref1) = if skip_mode { | 12591 | let (ref0, ref1) = if skip_mode { |
| @@ -12406,7 +12608,24 @@ fn decode_inter_block8( | |||
| 12406 | }, | 12608 | }, |
| 12407 | ) | 12609 | ) |
| 12408 | }; | 12610 | }; |
| 12611 | + leaf_refs = (ref0, Some(ref1)); | ||
| 12409 | let (mi_row, mi_col) = leaf_mi; | 12612 | let (mi_row, mi_col) = leaf_mi; |
| 12613 | + // spec 7.10.2.8, mirroring [`decode_inter_block`]'s own | ||
| 12614 | + // `comp_tpl` build (`use_ref_frame_mvs` frames only). | ||
| 12615 | + let comp_tpl = tpl_frame.map(|t| crate::mvstack::CompoundTplArgs { | ||
| 12616 | + field: t.field, | ||
| 12617 | + cur_offset_0: crate::motion_field::get_relative_dist( | ||
| 12618 | + t.order_hint_bits, | ||
| 12619 | + t.order_hint, | ||
| 12620 | + t.ref_order_hints[(ref0 - LAST_FRAME) as usize], | ||
| 12621 | + ), | ||
| 12622 | + cur_offset_1: crate::motion_field::get_relative_dist( | ||
| 12623 | + t.order_hint_bits, | ||
| 12624 | + t.order_hint, | ||
| 12625 | + t.ref_order_hints[(ref1 - LAST_FRAME) as usize], | ||
| 12626 | + ), | ||
| 12627 | + allow_high_precision_mv, | ||
| 12628 | + }); | ||
| 12410 | // lane-av1comp: this leaf path has neither a real sign-bias | 12629 | // lane-av1comp: this leaf path has neither a real sign-bias |
| 12411 | // table nor `tpl_frame` (see this function's own doc on the | 12630 | // table nor `tpl_frame` (see this function's own doc on the |
| 12412 | // coarse `LAST_FRAME`-or-intra neighbour approximation | 12631 | // coarse `LAST_FRAME`-or-intra neighbour approximation |
| @@ -12422,9 +12641,9 @@ fn decode_inter_block8( | |||
| 12422 | (ref0, ref1), | 12641 | (ref0, ref1), |
| 12423 | mi_cols as usize, | 12642 | mi_cols as usize, |
| 12424 | mi_rows as usize, | 12643 | mi_rows as usize, |
| 12425 | - &NO_SIGN_BIAS, | 12644 | + sign_bias_table, |
| 12426 | - &crate::mvstack::NO_GM_MV, | 12645 | + &gm_table, |
| 12427 | - None, | 12646 | + comp_tpl, |
| 12428 | ); | 12647 | ); |
| 12429 | let compound_mode = if skip_mode { | 12648 | let compound_mode = if skip_mode { |
| 12430 | 0 // NEAREST_NEARESTMV, forced -- no mode symbol read | 12649 | 0 // NEAREST_NEARESTMV, forced -- no mode symbol read |
| @@ -12436,6 +12655,18 @@ fn decode_inter_block8( | |||
| 12436 | comp_stack.ref_mv_ctx, | 12655 | comp_stack.ref_mv_ctx, |
| 12437 | ) | 12656 | ) |
| 12438 | }; | 12657 | }; |
| 12658 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 12659 | + eprintln!( | ||
| 12660 | + "EC_LEAFMODE mi_row={} mi_col={} cmode={} stack={} newmv_ctx={} refmv_ctx={} rng={}", | ||
| 12661 | + leaf_mi.0, | ||
| 12662 | + leaf_mi.1, | ||
| 12663 | + compound_mode + 17, | ||
| 12664 | + comp_stack.entries.len(), | ||
| 12665 | + comp_stack.new_mv_ctx, | ||
| 12666 | + comp_stack.ref_mv_ctx, | ||
| 12667 | + dec.debug_state().0 | ||
| 12668 | + ); | ||
| 12669 | + } | ||
| 12439 | let (mv0, mv1) = assign_compound_mv( | 12670 | let (mv0, mv1) = assign_compound_mv( |
| 12440 | dec, | 12671 | dec, |
| 12441 | cdfs, | 12672 | cdfs, |
| @@ -12443,16 +12674,35 @@ fn decode_inter_block8( | |||
| 12443 | compound_mode, | 12674 | compound_mode, |
| 12444 | allow_high_precision_mv, | 12675 | allow_high_precision_mv, |
| 12445 | force_integer_mv, | 12676 | force_integer_mv, |
| 12446 | - // leaf8 stays gm-inert (sanctioned partial landing, see | 12677 | + // lane-inter8 r1: the real per-ref gm mvs, same as |
| 12447 | - // this fn's own GLOBALMV refusal below). | 12678 | + // [`decode_inter_block`]'s own compound arm. |
| 12448 | - ((0, 0), (0, 0)), | 12679 | + ( |
| 12680 | + gm_table[(ref0 - LAST_FRAME) as usize], | ||
| 12681 | + gm_table[(ref1 - LAST_FRAME) as usize], | ||
| 12682 | + ), | ||
| 12449 | ); | 12683 | ); |
| 12684 | + // lane-inter8 r3: byte-format-identical to the oracle's | ||
| 12685 | + // rung-4 `EC_MODE_VAL`, so the leaf's mode+mv VALUE ladder | ||
| 12686 | + // diffs line for line against a real aomdec. | ||
| 12687 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | ||
| 12688 | + eprintln!( | ||
| 12689 | + "EC_MODE_VAL mi_row={} mi_col={} mode={} ref0={} ref1={} mv0=({},{}) rng={}", | ||
| 12690 | + leaf_mi.0, | ||
| 12691 | + leaf_mi.1, | ||
| 12692 | + compound_mode + 17, | ||
| 12693 | + ref0, | ||
| 12694 | + ref1, | ||
| 12695 | + mv0.0, | ||
| 12696 | + mv0.1, | ||
| 12697 | + dec.debug_state().0 | ||
| 12698 | + ); | ||
| 12699 | + } | ||
| 12450 | 12700 | ||
| 12451 | // spec 5.11.25: same gating [`decode_inter_block`]'s own | 12701 | // spec 5.11.25: same gating [`decode_inter_block`]'s own |
| 12452 | // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid | 12702 | // compound arm uses, keyed off `outer_at`'s [`SUB`]-grid |
| 12453 | // slot -- the only granularity `Neighbours`' comp_group_idx/ | 12703 | // slot -- the only granularity `Neighbours`' comp_group_idx/ |
| 12454 | // compound_idx arrays track. | 12704 | // compound_idx arrays track. |
| 12455 | - let group_ctx = get_comp_group_idx_context(neighbours, outer_at, SIDE); | 12705 | + let group_ctx = get_comp_group_idx_context(neighbours, leaf_mi, SIDE); |
| 12456 | let comp_group_idx = if !skip_mode | 12706 | let comp_group_idx = if !skip_mode |
| 12457 | && enable_masked_compound | 12707 | && enable_masked_compound |
| 12458 | && is_any_masked_compound_used_here(SIDE) | 12708 | && is_any_masked_compound_used_here(SIDE) |
| @@ -12506,7 +12756,7 @@ fn decode_inter_block8( | |||
| 12506 | { | 12756 | { |
| 12507 | let idx_ctx = get_comp_index_context( | 12757 | let idx_ctx = get_comp_index_context( |
| 12508 | neighbours, | 12758 | neighbours, |
| 12509 | - outer_at, | 12759 | + leaf_mi, |
| 12510 | SIDE, | 12760 | SIDE, |
| 12511 | order_hint_bits, | 12761 | order_hint_bits, |
| 12512 | order_hint, | 12762 | order_hint, |
| @@ -12776,9 +13026,21 @@ fn decode_inter_block8( | |||
| 12776 | )? | 13026 | )? |
| 12777 | .0; | 13027 | .0; |
| 12778 | } | 13028 | } |
| 12779 | - return Ok((skip, is_inter, skip_mode, compound_ctx8)); | 13029 | + // lane-inter8 r2: the COMPOUND leaf used to return here |
| 13030 | + // WITHOUT the end-of-function `record_mi`/`fill_lf_grid` the | ||
| 13031 | + // single-ref path falls through to -- so a compound 8x8 leaf | ||
| 13032 | + // left `above_side_mi`/`left_side_mi` (the next block's | ||
| 13033 | + // partition context), the per-plane coefficient level state | ||
| 13034 | + // and the loop-filter grid describing whatever block was | ||
| 13035 | + // there before. Every leaf of the gate's stream is compound, | ||
| 13036 | + // so the 16x16 below a split block read partition ctx 0 | ||
| 13037 | + // instead of 1 and mis-read PARTITION_SPLIT as NONE. | ||
| 13038 | + neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | ||
| 13039 | + neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 }); | ||
| 13040 | + return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs)); | ||
| 12780 | } | 13041 | } |
| 12781 | } | 13042 | } |
| 13043 | + leaf_refs = (LAST_FRAME, None); | ||
| 12782 | let sr_ctx = single_ref_ctx(above_inter || left_inter); | 13044 | let sr_ctx = single_ref_ctx(above_inter || left_inter); |
| 12783 | let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]); | 13045 | let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]); |
| 12784 | let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]); | 13046 | let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]); |
| @@ -12790,7 +13052,16 @@ fn decode_inter_block8( | |||
| 12790 | } | 13052 | } |
| 12791 | 13053 | ||
| 12792 | let (mi_row, mi_col) = leaf_mi; | 13054 | let (mi_row, mi_col) = leaf_mi; |
| 12793 | - let stack = find_mv_stack( | 13055 | + let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs { |
| 13056 | + field: t.field, | ||
| 13057 | + cur_offset_0: crate::motion_field::get_relative_dist( | ||
| 13058 | + t.order_hint_bits, | ||
| 13059 | + t.order_hint, | ||
| 13060 | + t.ref_order_hints[(LAST_FRAME - LAST_FRAME) as usize], | ||
| 13061 | + ), | ||
| 13062 | + allow_high_precision_mv, | ||
| 13063 | + }); | ||
| 13064 | + let stack = find_mv_stack_with_sign_bias( | ||
| 12794 | grid, | 13065 | grid, |
| 12795 | mi_row, | 13066 | mi_row, |
| 12796 | mi_col, | 13067 | mi_col, |
| @@ -12799,6 +13070,9 @@ fn decode_inter_block8( | |||
| 12799 | LAST_FRAME, | 13070 | LAST_FRAME, |
| 12800 | mi_cols as usize, | 13071 | mi_cols as usize, |
| 12801 | mi_rows as usize, | 13072 | mi_rows as usize, |
| 13073 | + sign_bias_table, | ||
| 13074 | + &gm_table, | ||
| 13075 | + tpl, | ||
| 12802 | ); | 13076 | ); |
| 12803 | 13077 | ||
| 12804 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; | 13078 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| @@ -13275,7 +13549,7 @@ fn decode_inter_block8( | |||
| 13275 | } | 13549 | } |
| 13276 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | 13550 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 13277 | neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 }); | 13551 | neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 }); |
| 13278 | - Ok((skip, is_inter, skip_mode, compound_ctx8)) | 13552 | + Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs)) |
| 13279 | } | 13553 | } |
| 13280 | 13554 | ||
| 13281 | /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes, | 13555 | /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes, |
| @@ -13720,10 +13994,72 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13720 | } | 13994 | } |
| 13721 | (false, false) => PARTITION_SPLIT, | 13995 | (false, false) => PARTITION_SPLIT, |
| 13722 | }; | 13996 | }; |
| 13997 | + if part64 == PARTITION_NONE { | ||
| 13998 | + // lane-inter8 r1: the whole superblock as one 64x64 inter | ||
| 13999 | + // block. `SB`-sized syntax throughout (size_group 3, same as | ||
| 14000 | + // 32x32 -- `size_group_lookup[BLOCK_64X64] == 3`), luma | ||
| 14001 | + // coefficients through `TxbSet::Luma64` with the 32-point | ||
| 14002 | + // scan (TX_64X64 codes only its top-left corner, spec | ||
| 14003 | + // 5.11.40 -- `read_inter_plane` widens the corner back to | ||
| 14004 | + // 64x64 before the inverse transform), chroma as a plain | ||
| 14005 | + // 32x32 `TxbSet::Chroma32`. TX_64X64 carries no `tx_type` | ||
| 14006 | + // symbol at all, so the intra/inter luma sets coincide. | ||
| 14007 | + INTER_SB_NONE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 14008 | + decode_inter_block( | ||
| 14009 | + &mut dec, | ||
| 14010 | + &mut cdfs, | ||
| 14011 | + &mut neighbours, | ||
| 14012 | + &mut grid, | ||
| 14013 | + sb_at, | ||
| 14014 | + SB, | ||
| 14015 | + mi_cols, | ||
| 14016 | + mi_rows, | ||
| 14017 | + &mut y, | ||
| 14018 | + &mut u, | ||
| 14019 | + &mut v, | ||
| 14020 | + &ref_y, | ||
| 14021 | + &ref_u, | ||
| 14022 | + &ref_v, | ||
| 14023 | + &ref_slots, | ||
| 14024 | + &sign_bias_table, | ||
| 14025 | + &global_motion, | ||
| 14026 | + base_q_idx, | ||
| 14027 | + TxbSet::Luma64, | ||
| 14028 | + TxbSet::Luma64, | ||
| 14029 | + TxbSet::Chroma32, | ||
| 14030 | + TX32, | ||
| 14031 | + TX32, | ||
| 14032 | + &scan32, | ||
| 14033 | + &scan32, | ||
| 14034 | + 3, | ||
| 14035 | + allow_high_precision_mv, | ||
| 14036 | + force_integer_mv, | ||
| 14037 | + interp_fixed, | ||
| 14038 | + enable_dual_filter, | ||
| 14039 | + tpl_frame.as_ref(), | ||
| 14040 | + reference_select, | ||
| 14041 | + enable_masked_compound, | ||
| 14042 | + enable_interintra_compound, | ||
| 14043 | + enable_jnt_comp, | ||
| 14044 | + order_hint_bits, | ||
| 14045 | + order_hint, | ||
| 14046 | + ref_order_hints, | ||
| 14047 | + skip_mode_present, | ||
| 14048 | + skip_mode_frame, | ||
| 14049 | + switchable_motion_mode, | ||
| 14050 | + allow_warped_motion, | ||
| 14051 | + false, | ||
| 14052 | + SB, | ||
| 14053 | + SB, | ||
| 14054 | + allow_screen_content_tools, | ||
| 14055 | + frame_width as usize, | ||
| 14056 | + )?; | ||
| 14057 | + continue; | ||
| 14058 | + } | ||
| 13723 | if part64 != PARTITION_SPLIT { | 14059 | if part64 != PARTITION_SPLIT { |
| 13724 | return Err(unsupported( | 14060 | return Err(unsupported( |
| 13725 | - "an inter SB-level partition type other than SPLIT (this decoder's \ | 14061 | + "an inter SB-level partition type other than NONE or SPLIT (this decoder's \ |
| 13726 | - inter tile path only recurses a superblock as SPLIT)", | 14062 | + inter tile path recurses a superblock only as SPLIT)", |
| 13727 | )); | 14063 | )); |
| 13728 | } | 14064 | } |
| 13729 | 14065 | ||
| @@ -13838,14 +14174,39 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13838 | )); | 14174 | )); |
| 13839 | } | 14175 | } |
| 13840 | let at16 = (sr, sc); | 14176 | let at16 = (sr, sc); |
| 13841 | - if has_cols16 && has_rows16 { | ||
| 13842 | let ctx16 = neighbours.partition_ctx(at16, SUB); | 14177 | let ctx16 = neighbours.partition_ctx(at16, SUB); |
| 13843 | - let part16 = dec.symbol(&mut cdfs.partition_w16[ctx16]); | 14178 | + // lane-inter8 r1: a straddling 16x16 cannot name a |
| 13844 | - if part16 != PARTITION_NONE { | 14179 | + // value (spec forces SPLIT, one gathered bit); an |
| 13845 | - return Err(unsupported( | 14180 | + // interior one reads the real alphabet, and |
| 13846 | - "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)", | 14181 | + // `PARTITION_SPLIT` now recurses into four 8x8 |
| 14182 | + // inter leaves through the very same loop the | ||
| 14183 | + // straddling case has always used. | ||
| 14184 | + let part16 = if has_cols16 && has_rows16 { | ||
| 14185 | + let p = dec.symbol(&mut cdfs.partition_w16[ctx16]); | ||
| 14186 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | ||
| 14187 | + let (rng, _) = dec.debug_state(); | ||
| 14188 | + eprintln!( | ||
| 14189 | + "TRACE partition_w16 mi=({},{}) ctx={ctx16} value={p} rng={rng}", | ||
| 14190 | + sr as u32 * SUB_MI, | ||
| 14191 | + sc as u32 * SUB_MI | ||
| 14192 | + ); | ||
| 14193 | + } | ||
| 14194 | + p | ||
| 14195 | + } else { | ||
| 14196 | + if has_cols16 { | ||
| 14197 | + dec.symbol_fixed(&gather( | ||
| 14198 | + &cdfs.partition_w16[ctx16], | ||
| 14199 | + VERT_ALIKE, | ||
| 14200 | + )); | ||
| 14201 | + } else { | ||
| 14202 | + dec.symbol_fixed(&gather( | ||
| 14203 | + &cdfs.partition_w16[ctx16], | ||
| 14204 | + HORZ_ALIKE, | ||
| 13847 | )); | 14205 | )); |
| 13848 | } | 14206 | } |
| 14207 | + PARTITION_SPLIT | ||
| 14208 | + }; | ||
| 14209 | + if part16 == PARTITION_NONE { | ||
| 13849 | decode_inter_block( | 14210 | decode_inter_block( |
| 13850 | &mut dec, | 14211 | &mut dec, |
| 13851 | &mut cdfs, | 14212 | &mut cdfs, |
| @@ -13899,18 +14260,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13899 | allow_screen_content_tools, | 14260 | allow_screen_content_tools, |
| 13900 | frame_width as usize, | 14261 | frame_width as usize, |
| 13901 | )?; | 14262 | )?; |
| 13902 | - } else { | 14263 | + } else if part16 != PARTITION_SPLIT { |
| 13903 | - let ctx16 = neighbours.partition_ctx(at16, SUB); | 14264 | + return Err(unsupported( |
| 13904 | - if has_cols16 { | 14265 | + "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", |
| 13905 | - dec.symbol_fixed(&gather( | ||
| 13906 | - &cdfs.partition_w16[ctx16], | ||
| 13907 | - VERT_ALIKE, | ||
| 13908 | )); | 14266 | )); |
| 13909 | } else { | 14267 | } else { |
| 13910 | - dec.symbol_fixed(&gather( | 14268 | + if has_cols16 && has_rows16 { |
| 13911 | - &cdfs.partition_w16[ctx16], | 14269 | + INTER_SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 13912 | - HORZ_ALIKE, | ||
| 13913 | - )); | ||
| 13914 | } | 14270 | } |
| 13915 | let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); | 14271 | let (mi_row0, mi_col0) = (sr as u32 * SUB_MI, sc as u32 * SUB_MI); |
| 13916 | let leaf_positions: Vec<(u32, u32)> = (0..4) | 14272 | let leaf_positions: Vec<(u32, u32)> = (0..4) |
| @@ -13935,7 +14291,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13935 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | 14291 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 13936 | )); | 14292 | )); |
| 13937 | } | 14293 | } |
| 13938 | - let mut prev_leaf: Option<((usize, usize), bool, bool)> = None; | 14294 | + let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new(); |
| 13939 | let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; | 14295 | let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None; |
| 13940 | let mut last_skip_mode = false; | 14296 | let mut last_skip_mode = false; |
| 13941 | for (mr, mc) in leaf_positions { | 14297 | for (mr, mc) in leaf_positions { |
| @@ -13947,7 +14303,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13947 | "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", | 14303 | "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)", |
| 13948 | )); | 14304 | )); |
| 13949 | } | 14305 | } |
| 13950 | - let (skip, is_inter, skip_mode_leaf, compound_ctx8) = | 14306 | + let (skip, is_inter, skip_mode_leaf, compound_ctx8, leaf_refs) = |
| 13951 | decode_inter_block8( | 14307 | decode_inter_block8( |
| 13952 | &mut dec, | 14308 | &mut dec, |
| 13953 | &mut cdfs, | 14309 | &mut cdfs, |
| @@ -13967,7 +14323,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13967 | base_q_idx, | 14323 | base_q_idx, |
| 13968 | &scan8, | 14324 | &scan8, |
| 13969 | &scan4, | 14325 | &scan4, |
| 13970 | - prev_leaf, | ||
| 13971 | allow_high_precision_mv, | 14326 | allow_high_precision_mv, |
| 13972 | force_integer_mv, | 14327 | force_integer_mv, |
| 13973 | reference_select, | 14328 | reference_select, |
| @@ -13984,48 +14339,48 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13984 | switchable_motion_mode, | 14339 | switchable_motion_mode, |
| 13985 | allow_warped_motion, | 14340 | allow_warped_motion, |
| 13986 | allow_screen_content_tools, | 14341 | allow_screen_content_tools, |
| 14342 | + &sign_bias_table, | ||
| 14343 | + &global_motion, | ||
| 14344 | + tpl_frame.as_ref(), | ||
| 13987 | )?; | 14345 | )?; |
| 13988 | - prev_leaf = Some((leaf_mi, skip, is_inter)); | 14346 | + prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1)); |
| 13989 | last_skip_mode = skip_mode_leaf; | 14347 | last_skip_mode = skip_mode_leaf; |
| 13990 | if compound_ctx8.is_some() { | 14348 | if compound_ctx8.is_some() { |
| 13991 | last_compound_ctx = compound_ctx8; | 14349 | last_compound_ctx = compound_ctx8; |
| 13992 | } | 14350 | } |
| 13993 | - } | 14351 | + // lane-inter8 r2: stamp THIS leaf's own |
| 13994 | - if let Some((_, skip, is_inter)) = prev_leaf { | 14352 | + // 2x2-mi span before the next leaf reads |
| 13995 | - // corner-cut: `decode_inter_block8`'s | 14353 | + // it as a neighbour -- the whole-16x16 |
| 13996 | - // leaves never read a switchable filter | 14354 | + // stamp below only ever described the |
| 13997 | - // (round-3 GLOBALMV refusal already | 14355 | + // last leaf, so three quarters of the |
| 13998 | - // bounds them away from the Regular-only | 14356 | + // block carried the wrong skip/ref/inter |
| 13999 | - // gap this round closes elsewhere); `[3, | 14357 | + // state into the next block's contexts |
| 14000 | - // 3]` is "no info", the same value an | 14358 | + // (class context-read-from-one-cell). |
| 14001 | - // intra neighbour records. Upgrade: | 14359 | + // corner-cut: `[3, 3]` filter, as the |
| 14002 | - // thread `interp_fixed`/`enable_dual_filter` | 14360 | + // 16x16 stamp used -- `decode_inter_block8` |
| 14003 | - // into `decode_inter_block8` once a | 14361 | + // reads no switchable filter yet. |
| 14004 | - // straddling 8x8 SWITCHABLE stream is on | 14362 | + neighbours.record_inter_rect_mi( |
| 14005 | - // hand to pin against. | 14363 | + leaf_mi, |
| 14006 | - neighbours.record_inter( | 14364 | + 2, |
| 14007 | - at16, | 14365 | + 2, |
| 14008 | - SUB, | ||
| 14009 | skip, | 14366 | skip, |
| 14010 | is_inter, | 14367 | is_inter, |
| 14011 | - if is_inter { LAST_FRAME } else { -1 }, | 14368 | + leaf_refs.0, |
| 14012 | [3, 3], | 14369 | [3, 3], |
| 14013 | - last_skip_mode, | 14370 | + skip_mode_leaf, |
| 14014 | ); | 14371 | ); |
| 14015 | - if let Some((ref0, ref1, group_idx, idx)) = last_compound_ctx { | 14372 | + if let Some(ref1) = leaf_refs.1 |
| 14016 | - neighbours.record_inter( | 14373 | + && let Some((_, _, group_idx, idx)) = compound_ctx8 |
| 14017 | - at16, | 14374 | + { |
| 14018 | - SUB, | 14375 | + neighbours.record_compound_ctx_rect_mi( |
| 14019 | - skip, | 14376 | + leaf_mi, 2, 2, ref1, group_idx, idx, |
| 14020 | - is_inter, | ||
| 14021 | - ref0, | ||
| 14022 | - [3, 3], | ||
| 14023 | - last_skip_mode, | ||
| 14024 | ); | 14377 | ); |
| 14025 | - neighbours | ||
| 14026 | - .record_compound_ctx(at16, SUB, ref1, group_idx, idx); | ||
| 14027 | } | 14378 | } |
| 14028 | } | 14379 | } |
| 14380 | + // lane-inter8 r2: the four per-leaf | ||
| 14381 | + // `record_inter_rect_mi` stamps above replace | ||
| 14382 | + // the single whole-16x16 one that used to run | ||
| 14383 | + // here with the LAST leaf's state. | ||
| 14029 | } | 14384 | } |
| 14030 | } | 14385 | } |
| 14031 | } | 14386 | } |
crates/ec-av1/src/refusal_inventory.rsmodified+3 -2
| @@ -67,8 +67,9 @@ const REFUSALS: &[&str] = &[ | |||
| 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)", | 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)", |
| 68 | "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)", | 68 | "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)", |
| 69 | "an inter frame with no key frame before it", | 69 | "an inter frame with no key frame before it", |
| 70 | - "an inter SB-level partition type other than SPLIT (this decoder's inter tile path only recurses a superblock as SPLIT)", | 70 | + "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", |
| 71 | - "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)", | 71 | + "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)", |
| 72 | + "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", | ||
| 72 | "an intra mode this decoder does not code (round 2)", | 73 | "an intra mode this decoder does not code (round 2)", |
| 73 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", | 74 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", |
| 74 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", | 75 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", |
crates/ec-av1/src/stream.rsmodified+269 -0
| @@ -3849,6 +3849,275 @@ mod tests { | |||
| 3849 | /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this | 3849 | /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this |
| 3850 | /// decoder's inter path does not model), `--kf-max-dist` past the clip's | 3850 | /// decoder's inter path does not model), `--kf-max-dist` past the clip's |
| 3851 | /// own length keeps frame 0 the only key frame. | 3851 | /// own length keeps frame 0 the only key frame. |
| 3852 | + /// lane-inter8 r1: the inter tile path's SB-level `PARTITION_NONE` -- a | ||
| 3853 | + /// whole 64x64 superblock coded as ONE inter block, which is what aomenc | ||
| 3854 | + /// picks for static content and which this decoder refused by name | ||
| 3855 | + /// ("an inter SB-level partition type other than SPLIT") until this | ||
| 3856 | + /// round. HARD-asserts [`decode::inter_sb_none_hits`] moved (the arm | ||
| 3857 | + /// really fired, class refusal-lifted-without-a-gate) and every frame is | ||
| 3858 | + /// pixel-exact vs ffmpeg; a decode error is a FAILURE here, never a SKIP | ||
| 3859 | + /// (class gate-skips-on-its-own-failure). | ||
| 3860 | + /// lane-inter8 r1: generalised so the same recipe can target a deeper | ||
| 3861 | + /// level of the inter partition tree -- `min_part` is aomenc's | ||
| 3862 | + /// `--min-partition-size`, and `hits`/`what` name the counter that proves | ||
| 3863 | + /// the arm under test really fired. | ||
| 3864 | + fn inter_sb_none_gate( | ||
| 3865 | + name: &str, | ||
| 3866 | + ten_bit: bool, | ||
| 3867 | + min_part: &str, | ||
| 3868 | + max_part: &str, | ||
| 3869 | + hits: fn() -> usize, | ||
| 3870 | + what: &str, | ||
| 3871 | + // lane-inter8 r3: extra aomenc flags + the frame width they need. | ||
| 3872 | + // `--tile-columns=1` needs a frame at least two superblocks wide or | ||
| 3873 | + // aomenc silently codes one tile column and the arm is vacuous. | ||
| 3874 | + extra: &[&str], | ||
| 3875 | + width: usize, | ||
| 3876 | + ) { | ||
| 3877 | + if !have_ffmpeg() { | ||
| 3878 | + eprintln!("SKIP {name}: no ffmpeg"); | ||
| 3879 | + return; | ||
| 3880 | + } | ||
| 3881 | + if !have_aomenc() { | ||
| 3882 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | ||
| 3883 | + return; | ||
| 3884 | + } | ||
| 3885 | + let (height, frame_count) = (64usize, 4usize); | ||
| 3886 | + // A deterministic synthetic source with real motion (a static source | ||
| 3887 | + // codes every inter frame as skip and never exercises the residual | ||
| 3888 | + // path); bounded with `-t` (class gate-loader-slurps-whole-file). | ||
| 3889 | + let y4m = Command::new("ffmpeg") | ||
| 3890 | + .args([ | ||
| 3891 | + "-v", | ||
| 3892 | + "error", | ||
| 3893 | + "-f", | ||
| 3894 | + "lavfi", | ||
| 3895 | + "-i", | ||
| 3896 | + &format!("mandelbrot=size={width}x{height}:rate=25"), | ||
| 3897 | + "-t", | ||
| 3898 | + "0.16", | ||
| 3899 | + "-pix_fmt", | ||
| 3900 | + if ten_bit { "yuv420p10le" } else { "yuv420p" }, | ||
| 3901 | + // y4m calls 10-bit unofficial (same as the 10-bit key-frame | ||
| 3902 | + // gate's own fixture). | ||
| 3903 | + "-strict", | ||
| 3904 | + "-1", | ||
| 3905 | + "-f", | ||
| 3906 | + "yuv4mpegpipe", | ||
| 3907 | + "-", | ||
| 3908 | + ]) | ||
| 3909 | + .stdin(Stdio::null()) | ||
| 3910 | + .stdout(Stdio::piped()) | ||
| 3911 | + .stderr(Stdio::piped()) | ||
| 3912 | + .output() | ||
| 3913 | + .expect("ffmpeg failed to run"); | ||
| 3914 | + assert!( | ||
| 3915 | + y4m.status.success(), | ||
| 3916 | + "{name}: ffmpeg fixture: {}", | ||
| 3917 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 3918 | + ); | ||
| 3919 | + let mut args: Vec<String> = [ | ||
| 3920 | + "--codec=av1", | ||
| 3921 | + "--passes=1", | ||
| 3922 | + "--end-usage=q", | ||
| 3923 | + "--cq-level=40", | ||
| 3924 | + "--cpu-used=0", | ||
| 3925 | + "--lag-in-frames=0", | ||
| 3926 | + "--auto-alt-ref=0", | ||
| 3927 | + "--kf-max-dist=1000", | ||
| 3928 | + // No cross-frame CDF forwarding in this fixture (see the | ||
| 3929 | + // deblocking gate's own note). | ||
| 3930 | + "--error-resilient=1", | ||
| 3931 | + // This gate targets the SB-level NONE arm only: rect/AB/1-to-4 | ||
| 3932 | + // partitions and sub-16x16 splits stay off so a failure here | ||
| 3933 | + // cannot be another lane's missing arm. | ||
| 3934 | + "--enable-rect-partitions=0", | ||
| 3935 | + "--enable-ab-partitions=0", | ||
| 3936 | + "--enable-1to4-partitions=0", | ||
| 3937 | + "--enable-filter-intra=0", | ||
| 3938 | + "--enable-smooth-intra=0", | ||
| 3939 | + "--enable-paeth-intra=0", | ||
| 3940 | + "--enable-directional-intra=0", | ||
| 3941 | + "--enable-angle-delta=0", | ||
| 3942 | + "--enable-tx-size-search=0", | ||
| 3943 | + "--enable-cdef=0", | ||
| 3944 | + "--enable-restoration=0", | ||
| 3945 | + "--enable-palette=0", | ||
| 3946 | + "--enable-intrabc=0", | ||
| 3947 | + "--enable-cfl-intra=0", | ||
| 3948 | + "--enable-ref-frame-mvs=0", | ||
| 3949 | + "--obu", | ||
| 3950 | + "-o", | ||
| 3951 | + "-", | ||
| 3952 | + "-", | ||
| 3953 | + ] | ||
| 3954 | + .iter() | ||
| 3955 | + .map(|s| (*s).to_string()) | ||
| 3956 | + .collect(); | ||
| 3957 | + for e in extra { | ||
| 3958 | + args.insert(1, (*e).to_string()); | ||
| 3959 | + } | ||
| 3960 | + args.insert(1, format!("--min-partition-size={min_part}")); | ||
| 3961 | + args.insert(1, format!("--max-partition-size={max_part}")); | ||
| 3962 | + if ten_bit { | ||
| 3963 | + args.insert(1, "--input-bit-depth=10".to_string()); | ||
| 3964 | + args.insert(1, "--bit-depth=10".to_string()); | ||
| 3965 | + } | ||
| 3966 | + let mut child = Command::new(aomenc_path()) | ||
| 3967 | + .args(&args) | ||
| 3968 | + .stdin(Stdio::piped()) | ||
| 3969 | + .stdout(Stdio::piped()) | ||
| 3970 | + .stderr(Stdio::piped()) | ||
| 3971 | + .spawn() | ||
| 3972 | + .expect("aomenc failed to start"); | ||
| 3973 | + child | ||
| 3974 | + .stdin | ||
| 3975 | + .take() | ||
| 3976 | + .expect("aomenc stdin") | ||
| 3977 | + .write_all(&y4m.stdout) | ||
| 3978 | + .expect("writing y4m to aomenc"); | ||
| 3979 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 3980 | + assert!( | ||
| 3981 | + out.status.success(), | ||
| 3982 | + "{name}: aomenc refused the fixture: {}", | ||
| 3983 | + String::from_utf8_lossy(&out.stderr) | ||
| 3984 | + ); | ||
| 3985 | + let stream = out.stdout; | ||
| 3986 | + let before = hits(); | ||
| 3987 | + let frames = match decode_stream(&stream) { | ||
| 3988 | + Ok(frames) => frames, | ||
| 3989 | + Err(e) => { | ||
| 3990 | + let pin = std::env::temp_dir().join(format!("{name}-refused.obu")); | ||
| 3991 | + let _ = std::fs::write(&pin, &stream); | ||
| 3992 | + panic!("{name}: decode_stream refused a real aomenc stream: {e} (pinned at {})", pin.display()); | ||
| 3993 | + } | ||
| 3994 | + }; | ||
| 3995 | + assert!( | ||
| 3996 | + hits() > before, | ||
| 3997 | + "{name}: no {what} fired -- this gate proves nothing" | ||
| 3998 | + ); | ||
| 3999 | + let ffmpeg_frames = if ten_bit { | ||
| 4000 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4001 | + } else { | ||
| 4002 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4003 | + }; | ||
| 4004 | + assert_eq!(frames.len(), frame_count, "{name}: frame count"); | ||
| 4005 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4006 | + if got.y != want.y || got.u != want.u || got.v != want.v { | ||
| 4007 | + let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu")); | ||
| 4008 | + let _ = std::fs::write(&pin, &stream); | ||
| 4009 | + panic!("{name}: frame {i} mismatch vs ffmpeg -- stream pinned at {}", pin.display()); | ||
| 4010 | + } | ||
| 4011 | + } | ||
| 4012 | + } | ||
| 4013 | + | ||
| 4014 | + #[test] | ||
| 4015 | + fn a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() { | ||
| 4016 | + inter_sb_none_gate( | ||
| 4017 | + "a_real_aomenc_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact", | ||
| 4018 | + false, | ||
| 4019 | + "32", | ||
| 4020 | + "64", | ||
| 4021 | + decode::inter_sb_none_hits, | ||
| 4022 | + "whole-superblock inter PARTITION_NONE", | ||
| 4023 | + &[], | ||
| 4024 | + 64, | ||
| 4025 | + ); | ||
| 4026 | + } | ||
| 4027 | + | ||
| 4028 | + #[test] | ||
| 4029 | + fn a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact() { | ||
| 4030 | + inter_sb_none_gate( | ||
| 4031 | + "a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact", | ||
| 4032 | + true, | ||
| 4033 | + "32", | ||
| 4034 | + "64", | ||
| 4035 | + decode::inter_sb_none_hits, | ||
| 4036 | + "whole-superblock inter PARTITION_NONE", | ||
| 4037 | + &[], | ||
| 4038 | + 64, | ||
| 4039 | + ); | ||
| 4040 | + } | ||
| 4041 | + | ||
| 4042 | + /// lane-inter8 r1: the same recipe with `--min-partition-size=8`, so | ||
| 4043 | + /// aomenc's RD may split a 16x16 inter block into four 8x8 leaves. The | ||
| 4044 | + /// interior (non-edge-straddling) `PARTITION_SPLIT` at the 16x16 level | ||
| 4045 | + /// was refused by name until this round; the straddle path always ran the | ||
| 4046 | + /// same loop, so only [`decode::inter_sub16_split_hits`] -- which counts | ||
| 4047 | + /// interior splits only -- proves the newly-lifted alphabet value fired. | ||
| 4048 | + // lane-inter8 r2: GREEN. The neighbour side bands are mi-granular, every | ||
| 4049 | + // leaf stamps its own 2x2-mi span (including the compound-return path | ||
| 4050 | + // that used to skip `record_mi` entirely) and the compound | ||
| 4051 | + // group/index contexts read the LEAF's mi cell, not its 16x16's corner. | ||
| 4052 | + /// lane-inter8 r3, from lane-sub8's verifier finding: the mi-granular | ||
| 4053 | + /// inter neighbour bands added in r2 must reset per TILE (above) and per | ||
| 4054 | + /// SB row (left) and guard availability tile-relative, so the same recipe | ||
| 4055 | + /// runs again at 128x64 with two tile columns -- a leaf on the second | ||
| 4056 | + /// tile's first column has no left neighbour and must not read the first | ||
| 4057 | + /// tile's band. | ||
| 4058 | + // lane-inter8 r3: RED for a reason OUTSIDE this lane -- at 128x64 (the | ||
| 4059 | + // narrowest frame two tile columns can exist in) aomenc codes an | ||
| 4060 | + // SB-level rect partition on the KEY frame despite | ||
| 4061 | + // --enable-rect-partitions=0, so the stream stops at "a superblock-level | ||
| 4062 | + // partition type other than NONE or SPLIT" (lane-sbpart's arm) before a | ||
| 4063 | + // single 8x8 leaf is reached. The tile-relative audit it was written for | ||
| 4064 | + // was done by inspection instead: every reader of the mi bands guards on | ||
| 4065 | + // `tile_row0_mi`/`tile_col0_mi` (no `> 0` guard exists in decode.rs), | ||
| 4066 | + // `start_tile` resets the above mi bands over the tile's own mi column | ||
| 4067 | + // span and `start_row` resets every left mi band. | ||
| 4068 | + #[ignore = "lane-inter8 r3: blocked by the SB-level rect-partition refusal at 128x64 (lane-sbpart's arm), not by tile context"] | ||
| 4069 | + #[test] | ||
| 4070 | + fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact() | ||
| 4071 | + { | ||
| 4072 | + inter_sb_none_gate( | ||
| 4073 | + "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact", | ||
| 4074 | + false, | ||
| 4075 | + "8", | ||
| 4076 | + "16", | ||
| 4077 | + decode::inter_sub16_split_hits, | ||
| 4078 | + "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | ||
| 4079 | + &["--tile-columns=1"], | ||
| 4080 | + 128, | ||
| 4081 | + ); | ||
| 4082 | + } | ||
| 4083 | + | ||
| 4084 | + #[test] | ||
| 4085 | + fn a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() { | ||
| 4086 | + inter_sb_none_gate( | ||
| 4087 | + "a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact", | ||
| 4088 | + false, | ||
| 4089 | + "8", | ||
| 4090 | + "16", | ||
| 4091 | + decode::inter_sub16_split_hits, | ||
| 4092 | + "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | ||
| 4093 | + &[], | ||
| 4094 | + 64, | ||
| 4095 | + ); | ||
| 4096 | + } | ||
| 4097 | + | ||
| 4098 | + #[test] | ||
| 4099 | + // lane-inter8 r2: still RED, and ignored rather than deleted -- the 8-bit | ||
| 4100 | + // twin above is green, this 10-bit recipe stops at "an INTER 32x32 | ||
| 4101 | + // partition type this decoder does not code (value=9)". That is OUR | ||
| 4102 | + // desync, proven: `EC_TRACE=1 aomdec` on the pinned stream reads | ||
| 4103 | + // 16 `bsize=9 value=3` (SPLIT) partitions and never a single value=9 | ||
| 4104 | + // anywhere (class refusal-from-own-desync; the r1 ledger line claiming | ||
| 4105 | + // aomenc emits PARTITION_VERT_4 despite --enable-1to4-partitions=0 is | ||
| 4106 | + // hereby disproven). The divergence itself is not yet bisected. | ||
| 4107 | + #[ignore = "lane-inter8 r2: 10-bit twin still desyncs (surfaces as a bogus 32x32 value=9 refusal); 8-bit gate is green"] | ||
| 4108 | + fn a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact() { | ||
| 4109 | + inter_sb_none_gate( | ||
| 4110 | + "a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact", | ||
| 4111 | + true, | ||
| 4112 | + "8", | ||
| 4113 | + "16", | ||
| 4114 | + decode::inter_sub16_split_hits, | ||
| 4115 | + "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", | ||
| 4116 | + &[], | ||
| 4117 | + 64, | ||
| 4118 | + ); | ||
| 4119 | + } | ||
| 4120 | + | ||
| 3852 | #[test] | 4121 | #[test] |
| 3853 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { | 4122 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { |
| 3854 | if !have_ffmpeg() { | 4123 | if !have_ffmpeg() { |
lanes/inter8-r1.report.mdadded+87 -0
| @@ -0,0 +1,87 @@ | |||
| 1 | +# lane-inter8 r1 -- inter partition tree: the 16x16 level and its 8x8 leaves | ||
| 2 | + | ||
| 3 | +Branch `lane-inter8`, off main `3808cf8` (resumed from the orchestrator's WIP | ||
| 4 | +snapshot `a5430ec`). **NOT merge-ready**: the round's gate is RED and `#[ignore]`d | ||
| 5 | +with its reason (see "Open residue"). Nothing here has been merged to main. | ||
| 6 | + | ||
| 7 | +## What changed | ||
| 8 | + | ||
| 9 | +- `crates/ec-av1/src/decode.rs` (inter tile loop, ~12345): the interior (non | ||
| 10 | + edge-straddling) 16x16 partition symbol is now read as the real alphabet and | ||
| 11 | + `PARTITION_SPLIT` recurses into four 8x8 inter leaves (previously: refused by | ||
| 12 | + name). Refusal narrowed to | ||
| 13 | + `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)"`. | ||
| 14 | + Counter `INTER_SUB16_SPLIT_HITS` / `inter_sub16_split_hits()` counts *interior* | ||
| 15 | + splits only -- the straddle path always ran that same loop, so only an interior | ||
| 16 | + count proves the newly-lifted alphabet value fired. (from the WIP snapshot) | ||
| 17 | +- `decode.rs` `obmc_blend`: `av1_skip_u4x4_pred_in_obmc` -- the ABOVE pass skips | ||
| 18 | + chroma when the chroma block is 4x4/8x4/4x8 (8x8, 16x8, 8x16 luma at 4:2:0); | ||
| 19 | + `obmc_mask_2` added. (from the WIP snapshot) | ||
| 20 | +- `decode.rs` `decode_inter_block8` (8x8 leaf), THIS round, three real defects, | ||
| 21 | + each one moving the aomdec range ladder strictly later: | ||
| 22 | + 1. the leaf built its `comp_mode` / compound-ref contexts from a FABRICATED | ||
| 23 | + neighbour (`ref0 = LAST_FRAME` if inter, `ref1 = None`, `uni = false`). | ||
| 24 | + `av1_get_reference_mode_context` asks whether a neighbour is COMPOUND, so | ||
| 25 | + with real LAST+GOLDEN compound neighbours the leaf picked the wrong CDF row | ||
| 26 | + and read single-ref where aomdec read compound `NEAR_NEWMV` (mi 4,14). | ||
| 27 | + Now uses `neighbours.above_ref/above_ref1/left_ref/left_ref1` with the same | ||
| 28 | + `is_uni_comp_ref` logic as `decode_inter_block` one level up. | ||
| 29 | + 2. the sibling-leaf override was a single `prev_leaf` (the previously decoded | ||
| 30 | + leaf). The bottom-LEFT leaf's ABOVE neighbour is leaf 0, never leaf 1, so | ||
| 31 | + one of the four leaves always read a stale neighbour -- class | ||
| 32 | + `context-read-from-one-cell`. Now a `prev_leaves` slice, matched by | ||
| 33 | + coordinate, and each leaf hands back its own resolved `(ref0, ref1)`. | ||
| 34 | + 3. both leaf mv stacks were built with `NO_SIGN_BIAS` / `NO_GM_MV` while the | ||
| 35 | + 16x16 path passed the frame's real tables; `assign_compound_mv` got | ||
| 36 | + `((0,0),(0,0))` for the gm mvs. Now threaded (`sign_bias_table`, | ||
| 37 | + `global_motion` params + a leaf-local `build_gm_mv_table`). Alignment with | ||
| 38 | + the proven path; it did NOT move this fixture's ladder (identity gm here). | ||
| 39 | +- `decode.rs`: `EC_MODE mi_row=.. mi_col=.. rng=..` traces under `EC_TRACE_MODE` | ||
| 40 | + in both `decode_inter_block` and `decode_inter_block8`, byte-format-identical | ||
| 41 | + to the oracle's rung-4 `EC_MODE`, plus `EC_LEAFMODE` (compound mode / stack | ||
| 42 | + size / ctxs) and a `TRACE partition_w16` line under `EC_AV1_TRACE`. These are | ||
| 43 | + the instruments the round was actually decided with. | ||
| 44 | +- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` generalised to take | ||
| 45 | + `min_part` / `max_part` (aomenc `--min/--max-partition-size`) and the counter | ||
| 46 | + + label that proves the arm under test fired, so one recipe can target any | ||
| 47 | + level of the inter partition tree. Two new gates | ||
| 48 | + (`a_real_aomenc_[10bit_]inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`, | ||
| 49 | + `min=8 max=16`) assert `inter_sub16_split_hits` moved and every frame is | ||
| 50 | + pixel-exact -- currently `#[ignore]`d, RED. | ||
| 51 | + | ||
| 52 | +## Gate + evidence | ||
| 53 | + | ||
| 54 | +Command (from the worktree, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter8`, | ||
| 55 | +`EC_AV1_REQUIRE_AOMENC=1`): | ||
| 56 | + | ||
| 57 | + cargo test -p ec-av1 --lib -- --ignored an_8x8_leaf_split | ||
| 58 | + | ||
| 59 | +EVIDENCE: /tmp/a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact-refused.obu | aomenc mandelbrot 64x64 4 frames, cq40 cpu0 --min-partition-size=8 --max-partition-size=16, rect/AB/1to4 off; decoded by ours (EC_TRACE_MODE) and by the instrumented aomdec (EC_TRACE_MODE) | partition symbol stream agrees 118/118 (size,ctx,value) vs aomdec EC_PART; inter mode-info range ladder agreed 41/57 before this round's fixes and 42/57 after, first divergence moved from block mi=(4,14) to mi=(6,12) | ||
| 60 | +EVIDENCE: /tmp/ours_mode4.txt vs /tmp/orc_mode.txt | same stream, EC_MODE ladders diffed line for line | ours "EC_MODE mi_row=6 mi_col=14 rng=33349" vs oracle "rng=36254" -- entropy divergence inside block (6,12); before the fixes the stream refused outright ("a partition below 8x8"), it now decodes 4 frames without a refusal but is NOT pixel-exact | ||
| 61 | + | ||
| 62 | +## Refusals | ||
| 63 | + | ||
| 64 | +- narrowed: "an inter partition below 16x16 (8x8 and smaller inter blocks are not | ||
| 65 | + coded yet)" -> "... other than SPLIT (16x8/8x16 rect inter leaves are not coded | ||
| 66 | + yet)". **This narrowing is NOT yet backed by a green gate** -- honest status, | ||
| 67 | + and the reason this branch must not merge as-is. | ||
| 68 | +- untouched: SB-level non-NONE/SPLIT, the 32x32 alphabet refusal (`value=9`, | ||
| 69 | + `PARTITION_VERT_4`, which aomenc emitted at 32x32 even with | ||
| 70 | + `--enable-1to4-partitions=0` -- same shape as lane-sbpart r2's AB-at-64 note), | ||
| 71 | + the 16x16 true-edge rectangular-transform one, the 8x8 chroma-mode one. | ||
| 72 | + | ||
| 73 | +## Open residue | ||
| 74 | + | ||
| 75 | +- fix-now (next round): `Neighbours`' `above_*`/`left_*` arrays are 16x16 | ||
| 76 | + granular. Leaf (6,12)'s LEFT neighbour must be leaf (6,10) of the previous | ||
| 77 | + 16x16 block, but both leaf rows of a 16x16 share one array slot, so one of | ||
| 78 | + them is always wrong. Making those arrays mi-granular (or adding a per-mi | ||
| 79 | + side band for skip/inter/ref0/ref1) is the next slice, and it is what | ||
| 80 | + un-ignores the two gates above. | ||
| 81 | +- deferred(the above): 8x8 HORZ/VERT -> 8x4/4x8 leaves, rect inter MC/transforms | ||
| 82 | + at 16x8/8x16 (lane-rectx owns the transform half), AB/1-to-4 at 64/32/16, and | ||
| 83 | + the aggregate per-type-per-level hit-counter gate the charter asks for. None | ||
| 84 | + of these were started this round. | ||
| 85 | +- deferred(unknown): the 10-bit variant of the same recipe stopped at | ||
| 86 | + "a reference frame other than LAST_FRAME (round 2)" at `--min-partition-size=8 | ||
| 87 | + --max-partition-size=64` before the max was clamped to 16; not re-measured. | ||
lanes/inter8-r2.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | |||
| 1 | +# lane-inter8 r2 -- mi-granular inter neighbour bands; the 8-bit 8x8-split gate is GREEN | ||
| 2 | + | ||
| 3 | +Branch `lane-inter8`, commit `ae69b25` on top of r1's `b2231a9` (off main `3808cf8`, | ||
| 4 | +not rebased -- the orchestrator merges). | ||
| 5 | + | ||
| 6 | +## What changed (`crates/ec-av1/src/decode.rs`, `crates/ec-av1/src/stream.rs`) | ||
| 7 | + | ||
| 8 | +1. **`Neighbours`' inter side bands are mi(4px)-granular** (`decode.rs` ~1910 `new`, | ||
| 9 | + ~1975 `start_tile`, `record_inter_rect` -> new `record_inter_rect_mi` ~2300, | ||
| 10 | + `record_compound_ctx_rect` -> `record_compound_ctx_rect_mi` ~2389; every reader | ||
| 11 | + now indexes `[cmi]`/`[rmi]`). Fields: `above/left_skip`, `_skip_mode`, `_inter`, | ||
| 12 | + `_ref`, `_ref1`, `_comp_group_idx`, `_compound_idx`, `_filter`. The SUB-unit | ||
| 13 | + wrappers stay, so every 16x16+ caller reads exactly what it read before (a | ||
| 14 | + SUB-aligned block's mi corner is libaom's `above_mbmi = mi(mi_row-1, mi_col)`). | ||
| 15 | + r1's `prev_leaves` sibling-override is deleted: each leaf stamps its own 2x2-mi | ||
| 16 | + span in the caller loop (`decode.rs` ~12664) right after it decodes, so a leaf's | ||
| 17 | + left neighbour can now be the *previous 16x16 block's* bottom leaf. | ||
| 18 | +2. **The compound arm of `decode_inter_block8` returned before its own | ||
| 19 | + `record_mi`/`fill_lf_grid`** (`decode.rs` ~11353). The single-ref arm falls | ||
| 20 | + through to them at the end of the function; the compound arm did not. Every leaf | ||
| 21 | + of the gate's stream is compound (LAST+ALTREF), so a split 16x16 left | ||
| 22 | + `above_side_mi` at 16 and the *next* block's coefficient level state and lf grid | ||
| 23 | + describing whatever block was there before. Consequence: the 16x16 at mi(8,12) | ||
| 24 | + computed partition ctx **0** where aomdec had **1** and read `PARTITION_NONE` | ||
| 25 | + where the stream coded `PARTITION_SPLIT`. | ||
| 26 | +3. **`get_comp_group_idx_context` / `get_comp_index_context` took the leaf's | ||
| 27 | + ENCLOSING 16x16 corner** (`outer_at`). Both now take mi coordinates | ||
| 28 | + (`decode.rs` ~8558/~8572) and the leaf passes `leaf_mi`; `decode_inter_block` | ||
| 29 | + passes its own `(rmi, cmi)`. This was the last divergence (block mi(8,14)). | ||
| 30 | +4. `tpl_frame` threaded into the leaf's two mv stacks (`decode_inter_block8` new | ||
| 31 | + last param + `comp_tpl`/`tpl` builds mirroring `decode_inter_block`). Alignment | ||
| 32 | + only -- **it did not move this stream's ladder** (no `use_ref_frame_mvs` here); | ||
| 33 | + kept because passing `None` while the level above passes the field is a real | ||
| 34 | + parsed-then-discarded gap. | ||
| 35 | + | ||
| 36 | +All three of 1-3 are class `context-read-from-one-cell`. | ||
| 37 | + | ||
| 38 | +## Gate | ||
| 39 | + | ||
| 40 | + cd <worktree>; export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter8 EC_AV1_REQUIRE_AOMENC=1 | ||
| 41 | + cargo test -p ec-av1 --lib -- an_8x8_leaf_split | ||
| 42 | + | ||
| 43 | +`a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact` **ok** | ||
| 44 | +(un-ignored). It hard-asserts `decode::inter_sub16_split_hits` advanced (interior | ||
| 45 | +16x16 `PARTITION_SPLIT` fired) and every one of the 4 frames pixel-exact vs ffmpeg; | ||
| 46 | +a refusal or a mismatch panics, it never SKIPs. | ||
| 47 | + | ||
| 48 | +EVIDENCE: /tmp/r2-fix.obu (aomenc mandelbrot 64x64 4 frames cq40 cpu0 --min-partition-size=8 --max-partition-size=16, rect/AB/1to4 off) | ours EC_TRACE_MODE vs instrumented aomdec EC_TRACE_MODE, `EC_MODE` ladders diffed line for line | inter mode-info range ladder 42/57 (r1) -> 48/57 (bands mi-granular) -> 50/57 (compound-arm record) -> **57/57**, and the gate decodes 4/4 frames pixel-exact | ||
| 49 | +EVIDENCE: /tmp/orc_r2.txt (aomdec EC_TRACE=1 EC_TRACE_MODE=1 on the same stream) | `EC_PART mi_row=8 mi_col=12 bsize=6 ctx=5 rng=38329` / `EC_PART_VAL ... value=3` vs our `TRACE partition_w16 mi=(8,12) ctx=0 value=0` before fix 2 | partition context 0 vs 1 at the block below a split 16x16 -- the stale `above_side_mi` | ||
| 50 | +EVIDENCE: /tmp/orc10.txt (aomdec EC_TRACE=1 on the 10-bit pinned stream) | `grep EC_PART_VAL | uniq -c` | 16 `bsize=9 value=3`, **zero** `value=9` anywhere in the stream | ||
| 51 | + | ||
| 52 | +## Test totals | ||
| 53 | + | ||
| 54 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` -> **270 passed, 0 failed, | ||
| 55 | +24 ignored** (1100 s). `refusal_inventory` and `gate_coverage` green; neither | ||
| 56 | +needed an edit -- r1 already listed the narrowed string, and no gate recipe flag | ||
| 57 | +changed. | ||
| 58 | + | ||
| 59 | +## Refusals | ||
| 60 | + | ||
| 61 | +- No new narrowing this round. r1's narrowing | ||
| 62 | + `"an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)"` | ||
| 63 | + is now **backed by a green gate** (it was not at r1), which is what this round owed. | ||
| 64 | +- Disproved, not a refusal change: the r1 ledger dead-end | ||
| 65 | + `"aomenc emits PARTITION_VERT_4 (value=9) at 32x32 even with --enable-1to4-partitions=0"` | ||
| 66 | + is wrong. `EC_TRACE=1 aomdec` on the very stream that produced it reads no | ||
| 67 | + `value=9` at any bsize. Class `refusal-from-own-desync`. | ||
| 68 | + | ||
| 69 | +## Open residue | ||
| 70 | + | ||
| 71 | +- fix-now(next round): the **10-bit twin** `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact` | ||
| 72 | + stays `#[ignore]`d with the corrected reason. It refuses with "an INTER 32x32 | ||
| 73 | + partition type this decoder does not code (value=9)", which the oracle trace above | ||
| 74 | + proves is our own desync, not the encoder. Not bisected: start by diffing the | ||
| 75 | + `EC_MODE` ladder of `/tmp/a_real_aomenc_10bit_..._-refused.obu` against | ||
| 76 | + `EC_TRACE_MODE=1 aomdec`, exactly as this round did for 8-bit. | ||
| 77 | +- deferred(lane-gmaffine merge): the per-leaf stamp records `[3, 3]` ("no info") for | ||
| 78 | + the leaf's interp filter, as r1's whole-16x16 stamp did. lane-gmaffine `65ef3f5` | ||
| 79 | + makes `decode_inter_block8` read and hand back its real filter symbols; at merge, | ||
| 80 | + that value goes into the `record_inter_rect_mi(leaf_mi, 2, 2, ..., [3, 3], ...)` | ||
| 81 | + call at `decode.rs` ~12664. **Merge warning**: lane-gmaffine rewrites large parts | ||
| 82 | + of the same `decode_inter_block8` (GLOBALMV/WARPED_CAUSAL/non-LAST refs/interp | ||
| 83 | + filter); this branch's leaf edits are the neighbour/context plumbing only, but the | ||
| 84 | + two WILL conflict textually in that function. | ||
| 85 | +- deferred(unstarted): 8x8 HORZ/VERT -> 8x4/4x8 leaves, rect inter leaves at | ||
| 86 | + 16x8/8x16, AB/1-to-4 at every level, and the per-type-per-level aggregate | ||
| 87 | + hit-counter gate. | ||
| 88 | +- accepted: `tpl_frame` in the leaf stacks is unmeasured on this stream (item 4). | ||