Merge branch 'main' into lane-mvtwin
Browse files at this commit8 changed files +1506 -221
- crates/ec-av1/src/decode.rs +615 -108
- crates/ec-av1/src/refusal_inventory.rs +9 -1
- crates/ec-av1/src/stream.rs +492 -0
- lanes/hgkf-r1.report.md +86 -0
- lanes/hgkf-r2.report.md +90 -0
- lanes/intrarect-r1.report.md +73 -112
- lanes/intrarect-r2.handoff.md +53 -0
- lanes/intrarect-r2.report.md +88 -0
crates/ec-av1/src/decode.rsmodified+615 -108
| @@ -1447,6 +1447,24 @@ pub(crate) fn palette_split_tx_hits() -> usize { | |||
| 1447 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) | 1447 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) |
| 1448 | } | 1448 | } |
| 1449 | 1449 | ||
| 1450 | +// lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform | ||
| 1451 | +// and which are therefore predicted one transform unit at a time (a skipped | ||
| 1452 | +// block codes no coefficients, so nothing else in the stream witnesses this | ||
| 1453 | +// path -- only the pixels do). | ||
| 1454 | +thread_local! { | ||
| 1455 | + static SKIP_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1456 | +} | ||
| 1457 | + | ||
| 1458 | +/// Current value of [`SKIP_SPLIT_TX_HITS`] (blocks, not units). | ||
| 1459 | +pub fn skip_split_tx_hits() -> usize { | ||
| 1460 | + SKIP_SPLIT_TX_HITS.with(|c| c.get()) | ||
| 1461 | +} | ||
| 1462 | + | ||
| 1463 | +/// Zeroes [`SKIP_SPLIT_TX_HITS`] before a gate's own decode attempt. | ||
| 1464 | +pub fn reset_skip_split_tx_hits() { | ||
| 1465 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(0)); | ||
| 1466 | +} | ||
| 1467 | + | ||
| 1450 | // lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` | 1468 | // lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` |
| 1451 | // symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- | 1469 | // symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- |
| 1452 | // the gate's proof that the lifted path actually ran, per size. | 1470 | // the gate's proof that the lifted path actually ran, per size. |
| @@ -1921,6 +1939,22 @@ pub(crate) fn rect_leaf_coeff_hits() -> usize { | |||
| 1921 | RECT_LEAF_COEFF_HITS.with(|c| c.get()) | 1939 | RECT_LEAF_COEFF_HITS.with(|c| c.get()) |
| 1922 | } | 1940 | } |
| 1923 | 1941 | ||
| 1942 | +// lane-intrarect r1: how many intra-coded HORZ/VERT strips decoded on the | ||
| 1943 | +// INTER block path ([`decode_intra_rect_in_inter`]), per shape class -- | ||
| 1944 | +// [0] the superblock-level 64x32/32x64, [1] 32x16/16x32, [2] 16x8/8x16. | ||
| 1945 | +// Every one of them was the named refusal "an intra-coded HORZ/VERT strip | ||
| 1946 | +// needs rectangular intra prediction" before this round. | ||
| 1947 | +thread_local! { | ||
| 1948 | + static INTRA_RECT_IN_INTER_HITS: std::cell::Cell<[usize; 3]> = | ||
| 1949 | + const { std::cell::Cell::new([0; 3]) }; | ||
| 1950 | +} | ||
| 1951 | + | ||
| 1952 | +/// Current value of [`INTRA_RECT_IN_INTER_HITS`] for one shape class | ||
| 1953 | +/// (0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16). | ||
| 1954 | +pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { | ||
| 1955 | + INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) | ||
| 1956 | +} | ||
| 1957 | + | ||
| 1924 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader | 1958 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader |
| 1925 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an | 1959 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an |
| 1926 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 | 1960 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 |
| @@ -2012,6 +2046,33 @@ thread_local! { | |||
| 2012 | } | 2046 | } |
| 2013 | 2047 | ||
| 2014 | /// Current value of [`SB_RECT_HITS`]. | 2048 | /// Current value of [`SB_RECT_HITS`]. |
| 2049 | +// lane-hgkf r1: the frame-edge partition bit, one level each. Slot 0 = a | ||
| 2050 | +// 64-level gathered edge bit read as HORZ/VERT, 1 = the same bit read as | ||
| 2051 | +// SPLIT, 2/3 = the 32-level pair. A gate asserting slot 0 or 2 proves the | ||
| 2052 | +// non-SPLIT edge arm actually decoded (before this round the bit was read and | ||
| 2053 | +// thrown away, so that arm was unreachable). | ||
| 2054 | +thread_local! { | ||
| 2055 | + static EDGE_PART_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | ||
| 2056 | +} | ||
| 2057 | + | ||
| 2058 | +/// Current value of [`EDGE_PART_HITS`]. | ||
| 2059 | +pub(crate) fn edge_part_hits() -> [usize; 4] { | ||
| 2060 | + EDGE_PART_HITS.with(|c| c.get()) | ||
| 2061 | +} | ||
| 2062 | + | ||
| 2063 | +/// Reset [`EDGE_PART_HITS`] (a gate counts one stream at a time). | ||
| 2064 | +pub(crate) fn reset_edge_part_hits() { | ||
| 2065 | + EDGE_PART_HITS.with(|c| c.set([0; 4])); | ||
| 2066 | +} | ||
| 2067 | + | ||
| 2068 | +fn bump_edge_part(slot: usize) { | ||
| 2069 | + EDGE_PART_HITS.with(|c| { | ||
| 2070 | + let mut h = c.get(); | ||
| 2071 | + h[slot] += 1; | ||
| 2072 | + c.set(h); | ||
| 2073 | + }); | ||
| 2074 | +} | ||
| 2075 | + | ||
| 2015 | pub(crate) fn sb_rect_hits() -> usize { | 2076 | pub(crate) fn sb_rect_hits() -> usize { |
| 2016 | SB_RECT_HITS.with(|c| c.get()) | 2077 | SB_RECT_HITS.with(|c| c.get()) |
| 2017 | } | 2078 | } |
| @@ -3363,7 +3424,7 @@ fn read_coeffs_rect( | |||
| 3363 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 3424 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 3364 | if rect_trace { | 3425 | if rect_trace { |
| 3365 | eprintln!( | 3426 | eprintln!( |
| 3366 | - "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} all_zero={} rng={}", | 3427 | + "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} entry={entry_rng} all_zero={} rng={}", |
| 3367 | all_zero as i32, | 3428 | all_zero as i32, |
| 3368 | dec.debug_state().0 | 3429 | dec.debug_state().0 |
| 3369 | ); | 3430 | ); |
| @@ -5708,6 +5769,16 @@ fn decode_rect_split( | |||
| 5708 | let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); | 5769 | let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); |
| 5709 | let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); | 5770 | let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); |
| 5710 | let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); | 5771 | let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); |
| 5772 | + // lane-hgkf r1 (ported from lane-golomb 791d87a, unmerged): | ||
| 5773 | + // libaom clips `av1_foreach_transformed_block_in_plane` to | ||
| 5774 | + // `max_blocks_wide/high` (`mb_to_right_edge`/`mb_to_bottom_edge`, | ||
| 5775 | + // i.e. `mi_cols * 4` / `mi_rows * 4`): a transform unit whose | ||
| 5776 | + // TOP-LEFT sample falls outside the frame is never coded. We read | ||
| 5777 | + // coefficients for those phantom units and desynced the stream at | ||
| 5778 | + // the very next symbol. | ||
| 5779 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 5780 | + continue; | ||
| 5781 | + } | ||
| 5711 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a | 5782 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a |
| 5712 | // transform unit INSIDE a block, which is a different rule from | 5783 | // transform unit INSIDE a block, which is a different rule from |
| 5713 | // the standalone-block table [`Reach::of`] applies -- and the | 5784 | // the standalone-block table [`Reach::of`] applies -- and the |
| @@ -5757,7 +5828,19 @@ fn decode_rect_split( | |||
| 5757 | // own (always DC_PRED) mode -- [`read_plane`] applies that | 5828 | // own (always DC_PRED) mode -- [`read_plane`] applies that |
| 5758 | // for the square arm, so this one must too. | 5829 | // for the square arm, so this one must too. |
| 5759 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | 5830 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 5760 | - let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | 5831 | + // libaom `get_txb_ctx`: a LUMA transform that covers its whole |
| 5832 | + // block (`plane_bsize == txsize_to_bsize[tx_size]`, i.e. the | ||
| 5833 | + // unsplit depth-0 strip) reads txb_skip ctx 0 flat -- the | ||
| 5834 | + // neighbour-magnitude table is for a unit SMALLER than its | ||
| 5835 | + // block. [`decode_block_rect`]'s own unsplit read passes a | ||
| 5836 | + // literal 0 for the same reason; this arm applied the table | ||
| 5837 | + // unconditionally and desynced every depth-0 rect strip that | ||
| 5838 | + // reached it (lane-intrarect r2: ctx 5 where aomdec read 0). | ||
| 5839 | + let tu_skip_ctx = if tx_w == bw && tx_h == bh { | ||
| 5840 | + 0 | ||
| 5841 | + } else { | ||
| 5842 | + neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI) | ||
| 5843 | + }; | ||
| 5761 | let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); | 5844 | let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); |
| 5762 | let (tu_grid, tu_tx_type) = read_coeffs_rect( | 5845 | let (tu_grid, tu_tx_type) = read_coeffs_rect( |
| 5763 | dec, | 5846 | dec, |
| @@ -5935,6 +6018,211 @@ fn decode_rect_split( | |||
| 5935 | Ok(()) | 6018 | Ok(()) |
| 5936 | } | 6019 | } |
| 5937 | 6020 | ||
| 6021 | +/// One intra-coded HORZ/VERT strip on the INTER block path (lane-intrarect | ||
| 6022 | +/// r1) -- the shape [`decode_inter_block`]'s intra arm refused by name | ||
| 6023 | +/// because it predicts squares only. Every pixel here goes through the rect | ||
| 6024 | +/// machinery the key-frame paths already prove: [`decode_rect_split`], which | ||
| 6025 | +/// at `depth == 0` is the unsplit strip as a single transform unit and | ||
| 6026 | +/// beyond it the per-unit walk of [`depth_to_tx_wh`]. | ||
| 6027 | +/// | ||
| 6028 | +/// What is genuinely different from [`decode_block_rect`] is the mode | ||
| 6029 | +/// syntax: on an inter frame an intra block reads `y_mode[size_group]` and | ||
| 6030 | +/// `uv_mode` (libaom `read_intra_block_mode_info`, decodemv.c:1065), never | ||
| 6031 | +/// the key frame's `kf_y_mode` above/left pair. This mirrors the square | ||
| 6032 | +/// intra-in-inter arm's own reads at the rect footprint, including its | ||
| 6033 | +/// inherited gaps -- no `use_filter_intra` symbol (every inter gate recipe | ||
| 6034 | +/// pins `--enable-filter-intra=0`; lane-fiinter owns that read for both the | ||
| 6035 | +/// square and this arm) and a nonzero luma angle delta refused by name. | ||
| 6036 | +/// | ||
| 6037 | +/// The strip's own neighbour records (luma per transform unit, chroma, skip | ||
| 6038 | +/// grid, deblock grid) are [`decode_rect_split`]'s; the caller adds the | ||
| 6039 | +/// inter-side bands and the mi map. | ||
| 6040 | +#[allow(clippy::too_many_arguments)] | ||
| 6041 | +fn decode_intra_rect_in_inter( | ||
| 6042 | + dec: &mut SymbolDecoder, | ||
| 6043 | + cdfs: &mut Cdfs, | ||
| 6044 | + neighbours: &mut Neighbours, | ||
| 6045 | + at: (usize, usize), | ||
| 6046 | + bw: usize, | ||
| 6047 | + bh: usize, | ||
| 6048 | + skip: bool, | ||
| 6049 | + allow_screen_content_tools: bool, | ||
| 6050 | + y: &mut PlaneBuf, | ||
| 6051 | + u: &mut PlaneBuf, | ||
| 6052 | + v: &mut PlaneBuf, | ||
| 6053 | + base_q_idx: u8, | ||
| 6054 | +) -> Result<()> { | ||
| 6055 | + // `at` is in MI units (the inter path's own unit since lane-inter4); | ||
| 6056 | + // `(r, c)` is the enclosing SUB cell the SUB-granular neighbour bands | ||
| 6057 | + // below are still keyed by. | ||
| 6058 | + let (mi_r, mi_c) = at; | ||
| 6059 | + let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | ||
| 6060 | + // `size_group_lookup` (libaom common_data.h) and `bsize_to_tx_size_cat` | ||
| 6061 | + // (blockd.h) for the three 2:1 strip shapes: BLOCK_16X8 -> group 1 / | ||
| 6062 | + // cat 1, BLOCK_32X16 -> 2 / 2, BLOCK_64X32 -> 3 / 3 (the rectsplitx | ||
| 6063 | + // finding -- the category is NOT the same for every strip size). | ||
| 6064 | + // A 1:4 strip breaks that diagonal (BLOCK_32X8 is group 1 but cat 2), so | ||
| 6065 | + // it is refused by name rather than read from the wrong CDF row. | ||
| 6066 | + let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) { | ||
| 6067 | + (8, 16) => (1usize, 1usize), | ||
| 6068 | + (16, 32) => (2, 2), | ||
| 6069 | + (32, 64) => (3, 3), | ||
| 6070 | + _ => { | ||
| 6071 | + return Err(unsupported( | ||
| 6072 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | ||
| 6073 | + )) | ||
| 6074 | + } | ||
| 6075 | + }; | ||
| 6076 | + // [`read_intra_mode_rect`]'s own refusal: palette/intrabc syntax is | ||
| 6077 | + // consumed for square blocks only, so a strip in a screen-content frame | ||
| 6078 | + // would skip symbols the encoder wrote. | ||
| 6079 | + if allow_screen_content_tools { | ||
| 6080 | + return Err(unsupported( | ||
| 6081 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax \ | ||
| 6082 | + is consumed for square blocks only)", | ||
| 6083 | + )); | ||
| 6084 | + } | ||
| 6085 | + let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | ||
| 6086 | + if mode >= 13 { | ||
| 6087 | + return Err(unsupported( | ||
| 6088 | + "an intra mode this decoder does not code (round 2)", | ||
| 6089 | + )); | ||
| 6090 | + } | ||
| 6091 | + // lane-angleinter (merged on main for the square intra-in-inter arm): | ||
| 6092 | + // the delta is read off `angle_delta_cdf[mode - V_PRED]` and feeds the | ||
| 6093 | + // directional predictor; this arm refused a nonzero one before the merge. | ||
| 6094 | + let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | ||
| 6095 | + read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) | ||
| 6096 | + } else { | ||
| 6097 | + 0 | ||
| 6098 | + }; | ||
| 6099 | + if angle_delta_y != 0 { | ||
| 6100 | + INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6101 | + } | ||
| 6102 | + // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the | ||
| 6103 | + // superblock-level strip reads the no-CFL alphabet -- the same split | ||
| 6104 | + // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. | ||
| 6105 | + let cfl_allowed = bw.max(bh) <= 32; | ||
| 6106 | + let uv_mode = if cfl_allowed { | ||
| 6107 | + dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | ||
| 6108 | + } else { | ||
| 6109 | + dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | ||
| 6110 | + }; | ||
| 6111 | + if (9..=12).contains(&uv_mode) { | ||
| 6112 | + SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6113 | + } | ||
| 6114 | + let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | ||
| 6115 | + Some(read_cfl_alphas(dec, cdfs)) | ||
| 6116 | + } else { | ||
| 6117 | + None | ||
| 6118 | + }; | ||
| 6119 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { | ||
| 6120 | + DC_PRED | ||
| 6121 | + } else { | ||
| 6122 | + uv_mode | ||
| 6123 | + }; | ||
| 6124 | + let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | ||
| 6125 | + DIRECTIONAL_UV_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6126 | + read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | ||
| 6127 | + } else { | ||
| 6128 | + 0 | ||
| 6129 | + }; | ||
| 6130 | + if angle_delta_uv != 0 { | ||
| 6131 | + UV_ANGLE_DELTA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6132 | + INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6133 | + } | ||
| 6134 | + // lane-fiinter (merged on main for the square intra-in-inter arm): | ||
| 6135 | + // `read_filter_intra_mode_info` is the tail of | ||
| 6136 | + // `read_intra_block_mode_info`, after the palette syntax (refused whole | ||
| 6137 | + // above for this shape), and `av1_filter_intra_allowed_bsize` admits the | ||
| 6138 | + // 2:1 strips with both sides <= 32 -- their own CDF rows | ||
| 6139 | + // ([`filter_intra_size_class_rect`]). | ||
| 6140 | + let mut filter_intra = None; | ||
| 6141 | + if mode == DC_PRED | ||
| 6142 | + && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) | ||
| 6143 | + && let Some(class) = filter_intra_size_class_rect(bw, bh) | ||
| 6144 | + && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | ||
| 6145 | + { | ||
| 6146 | + FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6147 | + INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6148 | + filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | ||
| 6149 | + } | ||
| 6150 | + // The intra-edge filter type is the NEIGHBOUR's mode (libaom | ||
| 6151 | + // `get_filt_type`), luma's off the luma neighbours and chroma's off the | ||
| 6152 | + // chroma ones -- [`decode_block_rect`]'s own pair. | ||
| 6153 | + let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); | ||
| 6154 | + let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | ||
| 6155 | + if smooth_neighbor { | ||
| 6156 | + SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6157 | + } | ||
| 6158 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | ||
| 6159 | + let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) { | ||
| 6160 | + let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh); | ||
| 6161 | + match tx_cat { | ||
| 6162 | + 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), | ||
| 6163 | + 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), | ||
| 6164 | + _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), | ||
| 6165 | + } | ||
| 6166 | + } else { | ||
| 6167 | + 0 | ||
| 6168 | + }; | ||
| 6169 | + if depth != 0 { | ||
| 6170 | + TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | ||
| 6171 | + // merge b51719f+lane-intrarect (class merge-cross-product-defect): | ||
| 6172 | + // main's 10-bit `split_transform_intra_block` gate reaches this arm | ||
| 6173 | + // with a nonzero tx depth, and the split rect-TU walk mis-decodes it | ||
| 6174 | + // (2340 luma samples off at seed 51; refusing here restores that gate | ||
| 6175 | + // while the depth-0 strip the lane proved keeps decoding). The lane's | ||
| 6176 | + // own gate never exercised a split strip. | ||
| 6177 | + return Err(unsupported( | ||
| 6178 | + "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | ||
| 6179 | + )); | ||
| 6180 | + } | ||
| 6181 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 6182 | + let modes = RectStripModes { | ||
| 6183 | + skip, | ||
| 6184 | + mode, | ||
| 6185 | + angle_delta_y, | ||
| 6186 | + uv_predict_mode, | ||
| 6187 | + angle_delta_uv, | ||
| 6188 | + alpha, | ||
| 6189 | + filter_intra, | ||
| 6190 | + smooth_neighbor, | ||
| 6191 | + smooth_neighbor_uv, | ||
| 6192 | + // screen-content frames are refused whole above, so this strip can | ||
| 6193 | + // carry no palette. | ||
| 6194 | + palette_y: None, | ||
| 6195 | + palette_uv: None, | ||
| 6196 | + }; | ||
| 6197 | + decode_rect_split( | ||
| 6198 | + dec, | ||
| 6199 | + cdfs, | ||
| 6200 | + neighbours, | ||
| 6201 | + (mi_r, mi_c), | ||
| 6202 | + bw, | ||
| 6203 | + bh, | ||
| 6204 | + tx_w, | ||
| 6205 | + tx_h, | ||
| 6206 | + &modes, | ||
| 6207 | + y, | ||
| 6208 | + u, | ||
| 6209 | + v, | ||
| 6210 | + base_q_idx, | ||
| 6211 | + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | ||
| 6212 | + )?; | ||
| 6213 | + let class = match bw.max(bh) { | ||
| 6214 | + 64 => 0, | ||
| 6215 | + 32 => 1, | ||
| 6216 | + _ => 2, | ||
| 6217 | + }; | ||
| 6218 | + INTRA_RECT_IN_INTER_HITS.with(|h| { | ||
| 6219 | + let mut v = h.get(); | ||
| 6220 | + v[class] += 1; | ||
| 6221 | + h.set(v); | ||
| 6222 | + }); | ||
| 6223 | + Ok(()) | ||
| 6224 | +} | ||
| 6225 | + | ||
| 5938 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip | 6226 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip |
| 5939 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's | 6227 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's |
| 5940 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ | 6228 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ |
| @@ -7940,6 +8228,26 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 7940 | /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. | 8228 | /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. |
| 7941 | /// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written | 8229 | /// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written |
| 7942 | /// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`. | 8230 | /// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`. |
| 8231 | +/// lane-hgkf r2: 16-bit cropped stage dump, the high-bitdepth twin of | ||
| 8232 | +/// [`dump_stage`] (whose `as u8` truncation hides |delta| <= 2 defects) -- | ||
| 8233 | +/// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). | ||
| 8234 | +fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | ||
| 8235 | + use std::io::Write; | ||
| 8236 | + if let Ok(path) = std::env::var(var) | ||
| 8237 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | ||
| 8238 | + { | ||
| 8239 | + for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] { | ||
| 8240 | + for row in 0..h { | ||
| 8241 | + let mut bytes = Vec::with_capacity(w * 2); | ||
| 8242 | + for &s in &p.data[row * p.width..][..w] { | ||
| 8243 | + bytes.extend_from_slice(&s.to_le_bytes()); | ||
| 8244 | + } | ||
| 8245 | + let _ = f.write_all(&bytes); | ||
| 8246 | + } | ||
| 8247 | + } | ||
| 8248 | + } | ||
| 8249 | +} | ||
| 8250 | + | ||
| 7943 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | 8251 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { |
| 7944 | use std::io::Write; | 8252 | use std::io::Write; |
| 7945 | if let Ok(path) = std::env::var(var) | 8253 | if let Ok(path) = std::env::var(var) |
| @@ -8085,6 +8393,7 @@ impl PlaneBuf { | |||
| 8085 | /// via [`Self::edges_rect`] and [`crate::intra::predict`]'s own | 8393 | /// via [`Self::edges_rect`] and [`crate::intra::predict`]'s own |
| 8086 | /// already-rect-capable `(bw, bh)` pair. | 8394 | /// already-rect-capable `(bw, bh)` pair. |
| 8087 | #[allow(clippy::too_many_arguments)] | 8395 | #[allow(clippy::too_many_arguments)] |
| 8396 | + #[track_caller] | ||
| 8088 | fn reconstruct_rect( | 8397 | fn reconstruct_rect( |
| 8089 | &mut self, | 8398 | &mut self, |
| 8090 | x: usize, | 8399 | x: usize, |
| @@ -8143,6 +8452,16 @@ impl PlaneBuf { | |||
| 8143 | } | 8452 | } |
| 8144 | prediction | 8453 | prediction |
| 8145 | }; | 8454 | }; |
| 8455 | + // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's | ||
| 8456 | + // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). | ||
| 8457 | + if std::env::var_os("EC_PRED").is_some() { | ||
| 8458 | + let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum(); | ||
| 8459 | + let row0: Vec<u16> = prediction[..bw.min(8)].to_vec(); | ||
| 8460 | + let col0: Vec<u16> = (0..bh.min(8)).map(|r| prediction[r * bw]).collect(); | ||
| 8461 | + eprintln!( | ||
| 8462 | + "@{} OUR_PRED x={x} y={y} bw={bw} bh={bh} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller() | ||
| 8463 | + ); | ||
| 8464 | + } | ||
| 8146 | for row in 0..bh { | 8465 | for row in 0..bh { |
| 8147 | for col in 0..bw { | 8466 | for col in 0..bw { |
| 8148 | let idx = row * bw + col; | 8467 | let idx = row * bw + col; |
| @@ -8162,6 +8481,7 @@ impl PlaneBuf { | |||
| 8162 | /// nudges the prediction by [`cfl_scaled`]'s per-sample amount before the | 8481 | /// nudges the prediction by [`cfl_scaled`]'s per-sample amount before the |
| 8163 | /// residual is added — `av1_cfl_predict_block`'s own clip-then-add-residual | 8482 | /// residual is added — `av1_cfl_predict_block`'s own clip-then-add-residual |
| 8164 | /// order (cfl.c). | 8483 | /// order (cfl.c). |
| 8484 | + #[track_caller] | ||
| 8165 | fn reconstruct( | 8485 | fn reconstruct( |
| 8166 | &mut self, | 8486 | &mut self, |
| 8167 | x: usize, | 8487 | x: usize, |
| @@ -8225,6 +8545,16 @@ impl PlaneBuf { | |||
| 8225 | } | 8545 | } |
| 8226 | prediction | 8546 | prediction |
| 8227 | }; | 8547 | }; |
| 8548 | + // lane-hgkf r2: per-TU prediction trace, the twin of aomdec's | ||
| 8549 | + // EC_PRED/EC_PREDND rungs (x/y are this plane's pixel origin). | ||
| 8550 | + if std::env::var_os("EC_PRED").is_some() { | ||
| 8551 | + let sum: i64 = prediction.iter().map(|&v| i64::from(v)).sum(); | ||
| 8552 | + let row0: Vec<u16> = prediction[..side.min(8)].to_vec(); | ||
| 8553 | + let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect(); | ||
| 8554 | + eprintln!( | ||
| 8555 | + "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller() | ||
| 8556 | + ); | ||
| 8557 | + } | ||
| 8228 | for row in 0..side { | 8558 | for row in 0..side { |
| 8229 | for col in 0..side { | 8559 | for col in 0..side { |
| 8230 | let idx = row * side + col; | 8560 | let idx = row * side + col; |
| @@ -8556,18 +8886,69 @@ fn decode_block( | |||
| 8556 | if skip { | 8886 | if skip { |
| 8557 | // A skipped block codes no residual syntax at all (spec 5.11.34): | 8887 | // A skipped block codes no residual syntax at all (spec 5.11.34): |
| 8558 | // straight prediction, on every plane. | 8888 | // straight prediction, on every plane. |
| 8559 | - y.reconstruct( | 8889 | + // |
| 8560 | - px, | 8890 | + // lane-hgkf r2: an intra block's `tx_depth` is read whether or not it |
| 8561 | - py, | 8891 | + // is skipped (only an INTER skip forces the largest transform), and |
| 8562 | - side, | 8892 | + // spec 7.11.2 / libaom `predict_and_reconstruct_intra_block` predicts |
| 8563 | - mode, | 8893 | + // ONE TRANSFORM UNIT AT A TIME -- each unit's edges are the units |
| 8564 | - angle_delta_y, | 8894 | + // already written left/above of it inside this same block. Predicting |
| 8565 | - reach, | 8895 | + // the whole `side`x`side` at once gives a different (uniformly off by |
| 8566 | - &vec![0i32; side * side], | 8896 | + // ~1) answer, which is exactly the residue this lane was chasing. |
| 8567 | - None, | 8897 | + // The palette/intrabc override path keeps the single-call shape (its |
| 8568 | - filter_intra, | 8898 | + // per-TU windowing is the non-skip loop's own `palette_y_buf` slice, |
| 8569 | - smooth_neighbor, | 8899 | + // untested for skip and unreachable in these streams). |
| 8570 | - ); | 8900 | + let split_tx_skip = |
| 8901 | + tx_select && logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); | ||
| 8902 | + if split_tx_skip { | ||
| 8903 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 8904 | + let n_axis = side / logical_tx; | ||
| 8905 | + for tu_row in 0..n_axis { | ||
| 8906 | + for tu_col in 0..n_axis { | ||
| 8907 | + let tu_px = px + tu_col * logical_tx; | ||
| 8908 | + let tu_py = py + tu_row * logical_tx; | ||
| 8909 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 8910 | + continue; | ||
| 8911 | + } | ||
| 8912 | + let tu_reach = tu_reach( | ||
| 8913 | + side, | ||
| 8914 | + side, | ||
| 8915 | + tu_col * logical_tx, | ||
| 8916 | + tu_row * logical_tx, | ||
| 8917 | + logical_tx, | ||
| 8918 | + reach, | ||
| 8919 | + px, | ||
| 8920 | + py, | ||
| 8921 | + y.width, | ||
| 8922 | + y.height, | ||
| 8923 | + ); | ||
| 8924 | + y.reconstruct( | ||
| 8925 | + tu_px, | ||
| 8926 | + tu_py, | ||
| 8927 | + logical_tx, | ||
| 8928 | + mode, | ||
| 8929 | + angle_delta_y, | ||
| 8930 | + tu_reach, | ||
| 8931 | + &vec![0i32; logical_tx * logical_tx], | ||
| 8932 | + None, | ||
| 8933 | + filter_intra, | ||
| 8934 | + smooth_neighbor, | ||
| 8935 | + ); | ||
| 8936 | + } | ||
| 8937 | + } | ||
| 8938 | + } else { | ||
| 8939 | + y.reconstruct( | ||
| 8940 | + px, | ||
| 8941 | + py, | ||
| 8942 | + side, | ||
| 8943 | + mode, | ||
| 8944 | + angle_delta_y, | ||
| 8945 | + reach, | ||
| 8946 | + &vec![0i32; side * side], | ||
| 8947 | + None, | ||
| 8948 | + filter_intra, | ||
| 8949 | + smooth_neighbor, | ||
| 8950 | + ); | ||
| 8951 | + } | ||
| 8571 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 8952 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 8572 | if let Some((ub, _)) = &palette_uv_bufs { | 8953 | if let Some((ub, _)) = &palette_uv_bufs { |
| 8573 | set_palette_pred(ub.clone()); | 8954 | set_palette_pred(ub.clone()); |
| @@ -8704,6 +9085,12 @@ fn decode_block( | |||
| 8704 | ); | 9085 | ); |
| 8705 | let tu_px = px + tu_col * logical_tx; | 9086 | let tu_px = px + tu_col * logical_tx; |
| 8706 | let tu_py = py + tu_row * logical_tx; | 9087 | let tu_py = py + tu_row * logical_tx; |
| 9088 | + // Same libaom clip as `decode_rect_split`'s loop above; a | ||
| 9089 | + // square block only hangs off the frame when the frame's mi | ||
| 9090 | + // dimensions are odd at the block's own level. | ||
| 9091 | + if tu_px >= y.true_width || tu_py >= y.true_height { | ||
| 9092 | + continue; | ||
| 9093 | + } | ||
| 8707 | let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; | 9094 | let tu_around = neighbours.around_mi(tu_mi, logical_tx)[0]; |
| 8708 | // A transform unit inside a block is NOT a block at that | 9095 | // A transform unit inside a block is NOT a block at that |
| 8709 | // position (lane-palette2 r12): `Reach::of` granted the | 9096 | // position (lane-palette2 r12): `Reach::of` granted the |
| @@ -8979,18 +9366,59 @@ fn decode_leaf8( | |||
| 8979 | let (cpx, cpy) = (px / 2, py / 2); | 9366 | let (cpx, cpy) = (px / 2, py / 2); |
| 8980 | let (luma_grid, u_grid, v_grid); | 9367 | let (luma_grid, u_grid, v_grid); |
| 8981 | if skip { | 9368 | if skip { |
| 8982 | - y.reconstruct( | 9369 | + // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an |
| 8983 | - px, | 9370 | + // 8x8 leaf whose `tx_depth` resolved to TX_4X4 predicts FOUR 4x4 |
| 8984 | - py, | 9371 | + // transform units, each off the units already written left/above of |
| 8985 | - 8, | 9372 | + // it inside this same leaf -- an intra block's transform size is read |
| 8986 | - mode, | 9373 | + // whether or not it is skipped, and spec 7.11.2 predicts per unit. |
| 8987 | - angle_delta_y, | 9374 | + if resolved == 4 { |
| 8988 | - reach, | 9375 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); |
| 8989 | - &vec![0i32; 64], | 9376 | + for tu_row in 0..2 { |
| 8990 | - None, | 9377 | + for tu_col in 0..2 { |
| 8991 | - filter_intra, | 9378 | + let (tu_px, tu_py) = (px + tu_col * 4, py + tu_row * 4); |
| 8992 | - smooth_neighbor, | 9379 | + if tu_px >= y.true_width || tu_py >= y.true_height { |
| 8993 | - ); | 9380 | + continue; |
| 9381 | + } | ||
| 9382 | + let tu_reach = tu_reach( | ||
| 9383 | + 8, | ||
| 9384 | + 8, | ||
| 9385 | + tu_col * 4, | ||
| 9386 | + tu_row * 4, | ||
| 9387 | + 4, | ||
| 9388 | + reach, | ||
| 9389 | + px, | ||
| 9390 | + py, | ||
| 9391 | + y.width, | ||
| 9392 | + y.height, | ||
| 9393 | + ); | ||
| 9394 | + y.reconstruct( | ||
| 9395 | + tu_px, | ||
| 9396 | + tu_py, | ||
| 9397 | + 4, | ||
| 9398 | + mode, | ||
| 9399 | + angle_delta_y, | ||
| 9400 | + tu_reach, | ||
| 9401 | + &vec![0i32; 16], | ||
| 9402 | + None, | ||
| 9403 | + filter_intra, | ||
| 9404 | + smooth_neighbor, | ||
| 9405 | + ); | ||
| 9406 | + } | ||
| 9407 | + } | ||
| 9408 | + } else { | ||
| 9409 | + y.reconstruct( | ||
| 9410 | + px, | ||
| 9411 | + py, | ||
| 9412 | + 8, | ||
| 9413 | + mode, | ||
| 9414 | + angle_delta_y, | ||
| 9415 | + reach, | ||
| 9416 | + &vec![0i32; 64], | ||
| 9417 | + None, | ||
| 9418 | + filter_intra, | ||
| 9419 | + smooth_neighbor, | ||
| 9420 | + ); | ||
| 9421 | + } | ||
| 8994 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); | 9422 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8)); |
| 8995 | u.reconstruct( | 9423 | u.reconstruct( |
| 8996 | cpx, | 9424 | cpx, |
| @@ -12055,28 +12483,23 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12055 | } | 12483 | } |
| 12056 | p | 12484 | p |
| 12057 | } else { | 12485 | } else { |
| 12058 | - // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 12486 | + // lane-hgkf r1 (class `parsed-then-discarded`, same finding as |
| 12059 | - // bit is the answer, not a formality -- libaom's | 12487 | + // the unmerged lane-golomb r1): the gathered bit IS the |
| 12060 | - // `ec_read_partition_impl` returns `PARTITION_HORZ` (resp. | 12488 | + // partition -- libaom `ec_read_partition_impl` returns |
| 12061 | - // `PARTITION_VERT`) when it reads 0, and only `PARTITION_SPLIT` | 12489 | + // PARTITION_HORZ (resp. VERT) for 0 and only SPLIT for 1. |
| 12062 | - // when it reads 1. Forcing SPLIT here desynced the last | 12490 | + // Forcing SPLIT desynced the last superblock row of every |
| 12063 | - // superblock row of every frame whose height is not a multiple | 12491 | + // frame whose height is not a multiple of 64: the ReelB key frames (3840x1608) diverge at mi_row=400 mi_col=0, |
| 12064 | - // of 64 -- the ReelB head (3840x1608) diverges at | 12492 | + // the first block of that row. |
| 12065 | - // mi_row=400 mi_col=0, the first block of that row. | ||
| 12066 | match (has_cols, has_rows) { | 12493 | match (has_cols, has_rows) { |
| 12067 | (true, false) => { | 12494 | (true, false) => { |
| 12068 | - if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)) == 1 { | 12495 | + let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); |
| 12069 | - PARTITION_SPLIT | 12496 | + bump_edge_part(b.min(1) as usize); |
| 12070 | - } else { | 12497 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 12071 | - PARTITION_HORZ | ||
| 12072 | - } | ||
| 12073 | } | 12498 | } |
| 12074 | (false, true) => { | 12499 | (false, true) => { |
| 12075 | - if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)) == 1 { | 12500 | + let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); |
| 12076 | - PARTITION_SPLIT | 12501 | + bump_edge_part(b.min(1) as usize); |
| 12077 | - } else { | 12502 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 12078 | - PARTITION_VERT | ||
| 12079 | - } | ||
| 12080 | } | 12503 | } |
| 12081 | _ => PARTITION_SPLIT, | 12504 | _ => PARTITION_SPLIT, |
| 12082 | } | 12505 | } |
| @@ -12134,26 +12557,25 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12134 | } | 12557 | } |
| 12135 | p | 12558 | p |
| 12136 | } else { | 12559 | } else { |
| 12560 | + // lane-hgkf r1: the 32-level frame-edge bit is the | ||
| 12561 | + // partition too (same libaom reader as the | ||
| 12562 | + // superblock level above). | ||
| 12137 | match (has_cols32, has_rows32) { | 12563 | match (has_cols32, has_rows32) { |
| 12138 | (true, false) => { | 12564 | (true, false) => { |
| 12139 | - // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 12565 | + let b = dec.symbol_fixed(&gather( |
| 12140 | - // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT | 12566 | + &cdfs.partition_w32[ctx32], |
| 12141 | - // (libaom `ec_read_partition_impl`). | 12567 | + VERT_ALIKE, |
| 12142 | - if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 { | 12568 | + )); |
| 12143 | - PARTITION_SPLIT | 12569 | + bump_edge_part(2 + b.min(1) as usize); |
| 12144 | - } else { | 12570 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 12145 | - PARTITION_HORZ | ||
| 12146 | - } | ||
| 12147 | } | 12571 | } |
| 12148 | (false, true) => { | 12572 | (false, true) => { |
| 12149 | - // lane-golomb r1 (class `parsed-then-discarded`): the gathered | 12573 | + let b = dec.symbol_fixed(&gather( |
| 12150 | - // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT | 12574 | + &cdfs.partition_w32[ctx32], |
| 12151 | - // (libaom `ec_read_partition_impl`). | 12575 | + HORZ_ALIKE, |
| 12152 | - if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 { | 12576 | + )); |
| 12153 | - PARTITION_SPLIT | 12577 | + bump_edge_part(2 + b.min(1) as usize); |
| 12154 | - } else { | 12578 | + if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 12155 | - PARTITION_VERT | ||
| 12156 | - } | ||
| 12157 | } | 12579 | } |
| 12158 | _ => PARTITION_SPLIT, | 12580 | _ => PARTITION_SPLIT, |
| 12159 | } | 12581 | } |
| @@ -12614,6 +13036,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12614 | HORZ_ALIKE, | 13036 | HORZ_ALIKE, |
| 12615 | )) | 13037 | )) |
| 12616 | }; | 13038 | }; |
| 13039 | + // lane-hgkf r1: slots 2/3 of | ||
| 13040 | + // [`EDGE_PART_HITS`], the gate's proof the | ||
| 13041 | + // non-SPLIT edge arm actually decoded. | ||
| 13042 | + bump_edge_part(if edge_split == 1 { 3 } else { 2 }); | ||
| 12617 | if edge_split == 0 { | 13043 | if edge_split == 0 { |
| 12618 | // lane-oddh r1: the strip IS decodable | 13044 | // lane-oddh r1: the strip IS decodable |
| 12619 | // -- libaom's `decode_partition` codes | 13045 | // -- libaom's `decode_partition` codes |
| @@ -12780,22 +13206,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12780 | tx_select, | 13206 | tx_select, |
| 12781 | reduced_tx_set, | 13207 | reduced_tx_set, |
| 12782 | )?; | 13208 | )?; |
| 12783 | - decode_block_rect( | 13209 | + // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 12784 | - &mut dec, | 13210 | + // coded (libaom `decode_partition` guards the second half with the same |
| 12785 | - &mut cdfs, | 13211 | + // test that made this partition non-square). |
| 12786 | - &mut neighbours, | 13212 | + if has_rows32 { |
| 12787 | - (at32.0 + 1, at32.1), | 13213 | + decode_block_rect( |
| 12788 | - 32, | 13214 | + &mut dec, |
| 12789 | - 16, | 13215 | + &mut cdfs, |
| 12790 | - &mut y, | 13216 | + &mut neighbours, |
| 12791 | - &mut u, | 13217 | + (at32.0 + 1, at32.1), |
| 12792 | - &mut v, | 13218 | + 32, |
| 12793 | - enable_filter_intra, | 13219 | + 16, |
| 12794 | - allow_screen_content_tools, | 13220 | + &mut y, |
| 12795 | - base_q_idx, | 13221 | + &mut u, |
| 12796 | - tx_select, | 13222 | + &mut v, |
| 12797 | - reduced_tx_set, | 13223 | + enable_filter_intra, |
| 12798 | - )?; | 13224 | + allow_screen_content_tools, |
| 13225 | + base_q_idx, | ||
| 13226 | + tx_select, | ||
| 13227 | + reduced_tx_set, | ||
| 13228 | + )?; | ||
| 13229 | + } | ||
| 12799 | } | 13230 | } |
| 12800 | PARTITION_VERT => { | 13231 | PARTITION_VERT => { |
| 12801 | // lane-intradisp r1: mirror of PARTITION_HORZ | 13232 | // lane-intradisp r1: mirror of PARTITION_HORZ |
| @@ -12816,22 +13247,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 12816 | tx_select, | 13247 | tx_select, |
| 12817 | reduced_tx_set, | 13248 | reduced_tx_set, |
| 12818 | )?; | 13249 | )?; |
| 12819 | - decode_block_rect( | 13250 | + // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 12820 | - &mut dec, | 13251 | + // coded (libaom `decode_partition` guards the second half with the same |
| 12821 | - &mut cdfs, | 13252 | + // test that made this partition non-square). |
| 12822 | - &mut neighbours, | 13253 | + if has_cols32 { |
| 12823 | - (at32.0, at32.1 + 1), | 13254 | + decode_block_rect( |
| 12824 | - 16, | 13255 | + &mut dec, |
| 12825 | - 32, | 13256 | + &mut cdfs, |
| 12826 | - &mut y, | 13257 | + &mut neighbours, |
| 12827 | - &mut u, | 13258 | + (at32.0, at32.1 + 1), |
| 12828 | - &mut v, | 13259 | + 16, |
| 12829 | - enable_filter_intra, | 13260 | + 32, |
| 12830 | - allow_screen_content_tools, | 13261 | + &mut y, |
| 12831 | - base_q_idx, | 13262 | + &mut u, |
| 12832 | - tx_select, | 13263 | + &mut v, |
| 12833 | - reduced_tx_set, | 13264 | + enable_filter_intra, |
| 12834 | - )?; | 13265 | + allow_screen_content_tools, |
| 13266 | + base_q_idx, | ||
| 13267 | + tx_select, | ||
| 13268 | + reduced_tx_set, | ||
| 13269 | + )?; | ||
| 13270 | + } | ||
| 12835 | } | 13271 | } |
| 12836 | PARTITION_HORZ_A => { | 13272 | PARTITION_HORZ_A => { |
| 12837 | // lane-part32 r1: two 16x16 squares on top + | 13273 | // lane-part32 r1: two 16x16 squares on top + |
| @@ -13416,6 +13852,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13416 | // that isolate whether a decode-order frame's mismatch already exists | 13852 | // that isolate whether a decode-order frame's mismatch already exists |
| 13417 | // in reconstruction (this dump) vs is introduced by the loop filter | 13853 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 13418 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | 13854 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 13855 | + dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 13419 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { | 13856 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 13420 | use std::io::Write; | 13857 | use std::io::Write; |
| 13421 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 13858 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| @@ -13459,8 +13896,10 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13459 | // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | 13896 | // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter |
| 13460 | // dump above these bisect WHICH filter stage introduced a mismatch. | 13897 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 13461 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 13898 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 13899 | + dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 13462 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 13900 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 13463 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 13901 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 13902 | + dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 13464 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); | 13903 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); |
| 13465 | 13904 | ||
| 13466 | let (fw, fh) = (frame_width as usize, frame_height as usize); | 13905 | let (fw, fh) = (frame_width as usize, frame_height as usize); |
| @@ -15100,18 +15539,6 @@ fn decode_inter_block( | |||
| 15100 | let whole_sb = side == 64 && write_w == 64 && write_h == 64; | 15539 | let whole_sb = side == 64 && write_w == 64 && write_h == 64; |
| 15101 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); | 15540 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 15102 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); | 15541 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 15103 | - // lane-warp r5: see `reject_residual` -- a square-block decode of a | ||
| 15104 | - // HORZ_B strip is symbol-exact only for `skip` (no residual, no | ||
| 15105 | - // motion_mode/warp symbol), so gate here before any further read. | ||
| 15106 | - if reject_residual && !skip && !rect_inter_residual_supported(write_w, write_h) { | ||
| 15107 | - if std::env::var_os("EC_AV1_RECT_DUMP").is_some() { | ||
| 15108 | - eprintln!("EC_RECT_REFUSE mi_row={rmi} mi_col={cmi} w={write_w} h={write_h} side={side}"); | ||
| 15109 | - } | ||
| 15110 | - return Err(unsupported( | ||
| 15111 | - "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | ||
| 15112 | - )); | ||
| 15113 | - } | ||
| 15114 | - | ||
| 15115 | let (has_above, has_left) = ( | 15542 | let (has_above, has_left) = ( |
| 15116 | rmi > neighbours.tile_row0_mi, | 15543 | rmi > neighbours.tile_row0_mi, |
| 15117 | cmi > neighbours.tile_col0_mi, | 15544 | cmi > neighbours.tile_col0_mi, |
| @@ -15127,6 +15554,29 @@ fn decode_inter_block( | |||
| 15127 | dec.debug_state().0 | 15554 | dec.debug_state().0 |
| 15128 | ); | 15555 | ); |
| 15129 | } | 15556 | } |
| 15557 | + // lane-warp r5: see `reject_residual` -- a square-block decode of a | ||
| 15558 | + // HORZ_B strip is symbol-exact only for `skip` (no residual, no | ||
| 15559 | + // motion_mode/warp symbol). lane-intrarect r1 MOVED this gate from just | ||
| 15560 | + // after the `skip` read to here, past `is_inter` (class | ||
| 15561 | + // [[refusal-short-circuits-its-own-code]]: at the old place it refused | ||
| 15562 | + // 24/24 attempts of this lane's own gate before the intra arm below | ||
| 15563 | + // could run). An INTRA strip with its true `write_w`x`write_h` footprint | ||
| 15564 | + // now codes its residual rectangularly ([`decode_intra_rect_in_inter`]); | ||
| 15565 | + // an INTER one, and a strip decoded with square dimensions anyway, still | ||
| 15566 | + // cannot. | ||
| 15567 | + // merge b51719f+lane-intrarect: main's `rect_inter_residual_supported` | ||
| 15568 | + // term stays -- lane-inter4's 16x8/8x16 inter leaves DO code a | ||
| 15569 | + // rectangular residual, and the lane's condition (written before that | ||
| 15570 | + // landed) refused every one of them. | ||
| 15571 | + if reject_residual | ||
| 15572 | + && !skip | ||
| 15573 | + && !rect_inter_residual_supported(write_w, write_h) | ||
| 15574 | + && (is_inter || (write_w == side && write_h == side)) | ||
| 15575 | + { | ||
| 15576 | + return Err(unsupported( | ||
| 15577 | + "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | ||
| 15578 | + )); | ||
| 15579 | + } | ||
| 15130 | if std::env::var_os("EC_AV1_TELL").is_some() { | 15580 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 15131 | eprintln!( | 15581 | eprintln!( |
| 15132 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", | 15582 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", |
| @@ -17154,10 +17604,64 @@ fn decode_inter_block( | |||
| 17154 | // already-square-predicted buffer). Named refusal instead of a | 17604 | // already-square-predicted buffer). Named refusal instead of a |
| 17155 | // silently wrong square-shaped intra prediction. | 17605 | // silently wrong square-shaped intra prediction. |
| 17156 | if write_w != side || write_h != side { | 17606 | if write_w != side || write_h != side { |
| 17157 | - return Err(unsupported( | 17607 | + // lane-intrarect r1: the strip decodes through its own rect |
| 17158 | - "an intra-coded HORZ/VERT strip needs rectangular intra prediction \ | 17608 | + // machinery ([`decode_intra_rect_in_inter`] -> the key-frame |
| 17159 | - this decoder does not code yet", | 17609 | + // paths' [`decode_rect_split`]) instead of refusing. That call |
| 17160 | - )); | 17610 | + // already writes everything the shared tail below would for a |
| 17611 | + // square block EXCEPT the inter-side bands and the mi map, so | ||
| 17612 | + // this arm returns rather than falling through (a second | ||
| 17613 | + // `record_rect`/`fill_lf_grid_rect` at block granularity would | ||
| 17614 | + // overwrite the per-transform-unit records it just made). | ||
| 17615 | + decode_intra_rect_in_inter( | ||
| 17616 | + dec, | ||
| 17617 | + cdfs, | ||
| 17618 | + neighbours, | ||
| 17619 | + at, | ||
| 17620 | + write_w, | ||
| 17621 | + write_h, | ||
| 17622 | + skip, | ||
| 17623 | + allow_screen_content_tools, | ||
| 17624 | + y, | ||
| 17625 | + u, | ||
| 17626 | + v, | ||
| 17627 | + base_q_idx, | ||
| 17628 | + )?; | ||
| 17629 | + // merge b51719f+lane-intrarect: `at` is in MI units on this path | ||
| 17630 | + // (lane-inter4), so the strip's mi origin is `at` itself -- the | ||
| 17631 | + // lane's `r * SUB_MI` re-derivation would snap a sub-SUB strip to | ||
| 17632 | + // its enclosing 16-px cell. | ||
| 17633 | + let (mi_r0, mi_c0) = (rmi, cmi); | ||
| 17634 | + for dr in 0..write_h / MI { | ||
| 17635 | + for dc in 0..write_w / MI { | ||
| 17636 | + grid.set( | ||
| 17637 | + mi_r0 + dr, | ||
| 17638 | + mi_c0 + dc, | ||
| 17639 | + MiInfo { | ||
| 17640 | + is_inter: false, | ||
| 17641 | + ref_frame: -1, | ||
| 17642 | + ref_frame1: None, | ||
| 17643 | + mv1: None, | ||
| 17644 | + mv: (0, 0), | ||
| 17645 | + is_new_mv: false, | ||
| 17646 | + size: write_w / MI, | ||
| 17647 | + size_h: write_h / MI, | ||
| 17648 | + is_global_mv0: false, | ||
| 17649 | + is_global_mv1: false, | ||
| 17650 | + }, | ||
| 17651 | + ); | ||
| 17652 | + } | ||
| 17653 | + } | ||
| 17654 | + neighbours.record_inter_rect_mi( | ||
| 17655 | + at, | ||
| 17656 | + write_w / MI, | ||
| 17657 | + write_h / MI, | ||
| 17658 | + skip, | ||
| 17659 | + false, | ||
| 17660 | + 0, | ||
| 17661 | + [3, 3], | ||
| 17662 | + skip_mode, | ||
| 17663 | + ); | ||
| 17664 | + return Ok(()); | ||
| 17161 | } | 17665 | } |
| 17162 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); | 17666 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 17163 | if mode >= 13 { | 17667 | if mode >= 13 { |
| @@ -21158,6 +21662,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21158 | // that isolate whether a decode-order frame's mismatch already exists | 21662 | // that isolate whether a decode-order frame's mismatch already exists |
| 21159 | // in reconstruction (this dump) vs is introduced by the loop filter | 21663 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 21160 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). | 21664 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 21665 | + dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 21161 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { | 21666 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 21162 | use std::io::Write; | 21667 | use std::io::Write; |
| 21163 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 21668 | let idx = PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| @@ -21184,8 +21689,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21184 | // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | 21689 | // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter |
| 21185 | // dump above these bisect WHICH filter stage introduced a mismatch. | 21690 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 21186 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | 21691 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 21692 | + dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 21187 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 21693 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 21188 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | 21694 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 21695 | + dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); | ||
| 21189 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); | 21696 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); |
| 21190 | 21697 | ||
| 21191 | let motion_field = build_motion_field( | 21698 | let motion_field = build_motion_field( |
crates/ec-av1/src/refusal_inventory.rsmodified+9 -1
| @@ -70,7 +70,15 @@ const REFUSALS: &[&str] = &[ | |||
| 70 | "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", | 70 | "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", |
| 71 | "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", | 71 | "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", |
| 72 | "an intra mode this decoder does not code (round 2)", | 72 | "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", | 73 | + // lane-intrarect r1 lifted the whole-shape refusal that stood here (the |
| 74 | + // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); | ||
| 75 | + // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the | ||
| 76 | + // size-group/category diagonal the 2:1 shapes share. | ||
| 77 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | ||
| 78 | + "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | ||
| 79 | + // The same arm's screen-content gate: palette/intrabc syntax is consumed | ||
| 80 | + // for square blocks only, so a strip in such a frame would skip symbols. | ||
| 81 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", | ||
| 74 | "warp prediction with a scaled reference (superres, unimplemented)", | 82 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 75 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | 83 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 76 | "a motion_mode symbol for a block shape with no CDF row here", | 84 | "a motion_mode symbol for a block shape with no CDF row here", |
crates/ec-av1/src/stream.rsmodified+492 -0
| @@ -4240,6 +4240,331 @@ mod tests { | |||
| 4240 | tx_select_inter_gate(10); | 4240 | tx_select_inter_gate(10); |
| 4241 | } | 4241 | } |
| 4242 | 4242 | ||
| 4243 | + /// lane-intrarect r1's decisive gate: a real aomenc INTER sequence whose | ||
| 4244 | + /// hard mid-GOP content cut makes aomenc code INTRA blocks inside inter | ||
| 4245 | + /// frames, with rect partitions ON so those intra blocks land on | ||
| 4246 | + /// HORZ/VERT strip shapes. Every such block was the named refusal "an | ||
| 4247 | + /// intra-coded HORZ/VERT strip needs rectangular intra prediction this | ||
| 4248 | + /// decoder does not code yet" until this round; they now decode through | ||
| 4249 | + /// the same `decode_rect_split` machinery the key-frame rect paths use. | ||
| 4250 | + /// | ||
| 4251 | + /// Hard-asserts per-shape counters (`intra_rect_strip_in_inter_hits`: | ||
| 4252 | + /// 0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16) summed over the | ||
| 4253 | + /// attempts that were actually pixel-compared -- at least TWO of the | ||
| 4254 | + /// three shape classes must fire, so a green run cannot come from one | ||
| 4255 | + /// lucky size. A decode that succeeds is ALWAYS pixel-compared (class | ||
| 4256 | + /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without | ||
| 4257 | + /// two shapes is a FAILURE, never a SKIP. | ||
| 4258 | + #[test] | ||
| 4259 | + fn a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact() { | ||
| 4260 | + intra_rect_in_inter_gate(8); | ||
| 4261 | + } | ||
| 4262 | + | ||
| 4263 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 4264 | + #[test] | ||
| 4265 | + fn a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact_10bit() { | ||
| 4266 | + intra_rect_in_inter_gate(10); | ||
| 4267 | + } | ||
| 4268 | + | ||
| 4269 | + fn intra_rect_in_inter_gate(bit_depth: u32) { | ||
| 4270 | + const NAME: &str = "a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact"; | ||
| 4271 | + if !have_ffmpeg() { | ||
| 4272 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 4273 | + return; | ||
| 4274 | + } | ||
| 4275 | + if !have_aomenc() { | ||
| 4276 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 4277 | + return; | ||
| 4278 | + } | ||
| 4279 | + let (width, height, frame_count) = (96usize, 96usize, 8usize); | ||
| 4280 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 4281 | + let mut uncounted_exact = 0u32; | ||
| 4282 | + let mut compared = 0u32; | ||
| 4283 | + let mut shapes = [0usize; 3]; | ||
| 4284 | + for attempt in 0..45u32 { | ||
| 4285 | + let seed = 42 + attempt; | ||
| 4286 | + // mandelbrot's fractal detail plus a HARD cut at frame 4: half | ||
| 4287 | + // the picture becomes a flat white box, which no motion vector | ||
| 4288 | + // can predict, so aomenc's RD codes those blocks INTRA inside an | ||
| 4289 | + // inter frame. The box's vertical edge at x=48 is what makes the | ||
| 4290 | + // partition search reach for HORZ/VERT strips there. | ||
| 4291 | + // A FAST ZOOM: `end_scale`/`end_pts` make mandelbrot rush | ||
| 4292 | + // through its own zoom, so consecutive frames share almost no | ||
| 4293 | + // content and aomenc's RD codes blocks INTRA inside INTER frames | ||
| 4294 | + // (`--kf-min-dist=1000` forbids a new key frame). That is the | ||
| 4295 | + // only way a real encoder reaches this decoder's intra-in-inter | ||
| 4296 | + // arm; a slowly-evolving source codes every rect strip inter. | ||
| 4297 | + let source = format!( | ||
| 4298 | + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", | ||
| 4299 | + 5.0 - f64::from(attempt) * 0.06 | ||
| 4300 | + ); | ||
| 4301 | + let y4m = Command::new("ffmpeg") | ||
| 4302 | + .args([ | ||
| 4303 | + "-v", | ||
| 4304 | + "error", | ||
| 4305 | + "-f", | ||
| 4306 | + "lavfi", | ||
| 4307 | + "-i", | ||
| 4308 | + &source, | ||
| 4309 | + "-vf", | ||
| 4310 | + "hue=s=0", | ||
| 4311 | + "-pix_fmt", | ||
| 4312 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4313 | + "-strict", | ||
| 4314 | + "-1", | ||
| 4315 | + "-t", | ||
| 4316 | + "0.32", | ||
| 4317 | + "-f", | ||
| 4318 | + "yuv4mpegpipe", | ||
| 4319 | + "-strict", | ||
| 4320 | + "-1", | ||
| 4321 | + "-", | ||
| 4322 | + ]) | ||
| 4323 | + .stdin(Stdio::null()) | ||
| 4324 | + .stdout(Stdio::piped()) | ||
| 4325 | + .stderr(Stdio::piped()) | ||
| 4326 | + .output() | ||
| 4327 | + .expect("ffmpeg failed to run"); | ||
| 4328 | + assert!( | ||
| 4329 | + y4m.status.success(), | ||
| 4330 | + "ffmpeg fixture: {}", | ||
| 4331 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4332 | + ); | ||
| 4333 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4334 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4335 | + } else { | ||
| 4336 | + &[] | ||
| 4337 | + }; | ||
| 4338 | + // MEASURED (r1): the speed preset gates the feature (class | ||
| 4339 | + // [[gate-preset-gates-the-feature]]) -- at `--cpu-used=4` this | ||
| 4340 | + // content produces no rect partition at all, at `--cpu-used=0` | ||
| 4341 | + // aomenc emits AB partitions the tile path refuses (it ignores | ||
| 4342 | + // `--enable-ab-partitions=0`, ledger). So the attempt sweep walks | ||
| 4343 | + // the preset as well as the seed. | ||
| 4344 | + let cpu = format!("--cpu-used={}", attempt % 5); | ||
| 4345 | + // The quantiser drives how finely the RD partitions: the sweep | ||
| 4346 | + // walks it too, so "no rect strip fired" cannot be an artefact of | ||
| 4347 | + // one cq. | ||
| 4348 | + let cq = format!("--cq-level={}", [30u32, 20, 12][(attempt / 5) as usize % 3]); | ||
| 4349 | + let mut child = Command::new(aomenc_path()) | ||
| 4350 | + .args(depth_args) | ||
| 4351 | + .arg(&cpu) | ||
| 4352 | + .arg(&cq) | ||
| 4353 | + .args([ | ||
| 4354 | + // class [[aomenc-first-flag-wins]]: every flag is spelled | ||
| 4355 | + // exactly ONCE in this recipe, so there is no override to | ||
| 4356 | + // order. These four are what this gate is about. | ||
| 4357 | + "--enable-rect-partitions=1", | ||
| 4358 | + // MEASURED (r1): the charter's `--min-partition-size=8` | ||
| 4359 | + // makes 24/24 attempts stop at a sub-16 AB-partition | ||
| 4360 | + // refusal ("a HORZ_A/HORZ_B/VERT_A partition below 16x16", | ||
| 4361 | + // "a coded (non-skip) HORZ_B/VERT_B rect strip below | ||
| 4362 | + // 16x16") before any intra rect strip is reached -- those | ||
| 4363 | + // are other lanes' surfaces. 16 keeps the 16x8/8x16 shape | ||
| 4364 | + // reachable (a 16x16 block's own HORZ/VERT children). | ||
| 4365 | + "--min-partition-size=16", | ||
| 4366 | + "--max-partition-size=64", | ||
| 4367 | + // MEASURED (r1): with tx-size search ON, 24/24 attempts stop at | ||
| 4368 | + // the SQUARE intra-in-inter arm's own refusal ("an intra | ||
| 4369 | + // block in an inter frame whose tx_depth splits its luma | ||
| 4370 | + // transform (round 1)", read_block_tx_size) long before a | ||
| 4371 | + // rect strip is reached -- that arm is another lane's | ||
| 4372 | + // surface. OFF, no tx-depth symbol is coded at all and | ||
| 4373 | + // every rect strip here is the unsplit single-transform | ||
| 4374 | + // case. The SPLIT rect arm (`depth_to_tx_wh` + | ||
| 4375 | + // decode_rect_split's per-unit walk) is wired but stays | ||
| 4376 | + // UNGATED on this path until that square refusal lifts. | ||
| 4377 | + "--enable-tx-size-search=0", | ||
| 4378 | + "--codec=av1", | ||
| 4379 | + "--passes=1", | ||
| 4380 | + "--end-usage=q", | ||
| 4381 | + "--lag-in-frames=0", | ||
| 4382 | + "--auto-alt-ref=0", | ||
| 4383 | + // One key frame at the head: the frames after the cut must | ||
| 4384 | + // stay INTER frames carrying intra blocks, not become a | ||
| 4385 | + // new key frame. | ||
| 4386 | + "--kf-min-dist=1000", | ||
| 4387 | + "--kf-max-dist=1000", | ||
| 4388 | + "--threads=1", | ||
| 4389 | + "--row-mt=0", | ||
| 4390 | + "--enable-order-hint=0", | ||
| 4391 | + "--enable-warped-motion=0", | ||
| 4392 | + "--enable-obmc=0", | ||
| 4393 | + "--enable-masked-comp=0", | ||
| 4394 | + "--enable-interintra-comp=0", | ||
| 4395 | + "--enable-dist-wtd-comp=0", | ||
| 4396 | + "--enable-diff-wtd-comp=0", | ||
| 4397 | + "--enable-onesided-comp=0", | ||
| 4398 | + "--enable-interintra-wedge=0", | ||
| 4399 | + "--enable-smooth-interintra=0", | ||
| 4400 | + "--enable-ab-partitions=0", | ||
| 4401 | + "--enable-1to4-partitions=0", | ||
| 4402 | + // The intra-in-inter arm reads no `use_filter_intra` | ||
| 4403 | + // symbol (square OR rect) -- lane-fiinter owns that read. | ||
| 4404 | + "--enable-filter-intra=0", | ||
| 4405 | + "--enable-smooth-intra=0", | ||
| 4406 | + "--enable-paeth-intra=0", | ||
| 4407 | + "--enable-directional-intra=0", | ||
| 4408 | + "--enable-angle-delta=0", | ||
| 4409 | + "--enable-cdef=0", | ||
| 4410 | + "--enable-restoration=0", | ||
| 4411 | + "--enable-palette=0", | ||
| 4412 | + "--enable-intrabc=0", | ||
| 4413 | + "--enable-cfl-intra=0", | ||
| 4414 | + "--enable-ref-frame-mvs=0", | ||
| 4415 | + "--obu", | ||
| 4416 | + "-o", | ||
| 4417 | + "-", | ||
| 4418 | + "-", | ||
| 4419 | + ]) | ||
| 4420 | + .stdin(Stdio::piped()) | ||
| 4421 | + .stdout(Stdio::piped()) | ||
| 4422 | + .stderr(Stdio::piped()) | ||
| 4423 | + .spawn() | ||
| 4424 | + .expect("aomenc failed to start"); | ||
| 4425 | + child | ||
| 4426 | + .stdin | ||
| 4427 | + .take() | ||
| 4428 | + .expect("aomenc stdin") | ||
| 4429 | + .write_all(&y4m.stdout) | ||
| 4430 | + .expect("writing y4m to aomenc"); | ||
| 4431 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4432 | + assert!( | ||
| 4433 | + out.status.success(), | ||
| 4434 | + "aomenc refused the fixture: {}", | ||
| 4435 | + String::from_utf8_lossy(&out.stderr) | ||
| 4436 | + ); | ||
| 4437 | + let stream = out.stdout; | ||
| 4438 | + let before = [ | ||
| 4439 | + decode::intra_rect_strip_in_inter_hits(0), | ||
| 4440 | + decode::intra_rect_strip_in_inter_hits(1), | ||
| 4441 | + decode::intra_rect_strip_in_inter_hits(2), | ||
| 4442 | + ]; | ||
| 4443 | + let kf_rect_before = decode::rect_partition_hits(); | ||
| 4444 | + let frames = match decode_stream(&stream) { | ||
| 4445 | + Ok(frames) => frames, | ||
| 4446 | + Err(e) => { | ||
| 4447 | + let msg = e.to_string(); | ||
| 4448 | + assert!( | ||
| 4449 | + msg.contains("unsupported"), | ||
| 4450 | + "intra-rect-in-inter decode failed outright (seed {seed}): {msg}" | ||
| 4451 | + ); | ||
| 4452 | + refusals.push(format!("seed {seed} {cpu} {cq}: {msg}")); | ||
| 4453 | + continue; | ||
| 4454 | + } | ||
| 4455 | + }; | ||
| 4456 | + let delta = [ | ||
| 4457 | + decode::intra_rect_strip_in_inter_hits(0) - before[0], | ||
| 4458 | + decode::intra_rect_strip_in_inter_hits(1) - before[1], | ||
| 4459 | + decode::intra_rect_strip_in_inter_hits(2) - before[2], | ||
| 4460 | + ]; | ||
| 4461 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4462 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4463 | + } else { | ||
| 4464 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4465 | + }; | ||
| 4466 | + assert_eq!(frames.len(), frame_count); | ||
| 4467 | + eprintln!( | ||
| 4468 | + "intrarect gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra rect strips in inter frames \ | ||
| 4469 | + 64-level={} 32-level={} 16-level={}, key-frame rect strips this stream={}", | ||
| 4470 | + delta[0], delta[1], delta[2], | ||
| 4471 | + decode::rect_partition_hits() - kf_rect_before | ||
| 4472 | + ); | ||
| 4473 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4474 | + for (plane, (g, w)) in [ | ||
| 4475 | + ("Y", (&got.y, &want.y)), | ||
| 4476 | + ("U", (&got.u, &want.u)), | ||
| 4477 | + ("V", (&got.v, &want.v)), | ||
| 4478 | + ] { | ||
| 4479 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4480 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4481 | + eprintln!( | ||
| 4482 | + "intrarect gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \ | ||
| 4483 | + diff at ({}, {}) got {} want {} ({} samples differ)", | ||
| 4484 | + at % stride, | ||
| 4485 | + at / stride, | ||
| 4486 | + g[at], | ||
| 4487 | + w[at], | ||
| 4488 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4489 | + ); | ||
| 4490 | + // Magnitude separates a deblock/prediction difference | ||
| 4491 | + // (all |d| == 1) from an entropy desync (large, | ||
| 4492 | + // arbitrary): the first thing r2 needs to know. | ||
| 4493 | + let maxd = g | ||
| 4494 | + .iter() | ||
| 4495 | + .zip(w.iter()) | ||
| 4496 | + .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b))) | ||
| 4497 | + .max() | ||
| 4498 | + .unwrap_or(0); | ||
| 4499 | + let rows: std::collections::BTreeSet<usize> = g | ||
| 4500 | + .iter() | ||
| 4501 | + .zip(w.iter()) | ||
| 4502 | + .enumerate() | ||
| 4503 | + .filter(|(_, (a, b))| a != b) | ||
| 4504 | + .map(|(k, _)| k / stride) | ||
| 4505 | + .collect(); | ||
| 4506 | + eprintln!( | ||
| 4507 | + "intrarect gate {bit_depth}-bit seed={seed}: frame {i} {plane} max \ | ||
| 4508 | + |diff|={maxd}, rows {:?}..{:?}", | ||
| 4509 | + rows.iter().next(), | ||
| 4510 | + rows.iter().next_back() | ||
| 4511 | + ); | ||
| 4512 | + } | ||
| 4513 | + assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})"); | ||
| 4514 | + } | ||
| 4515 | + } | ||
| 4516 | + compared += 1; | ||
| 4517 | + if delta.iter().all(|d| *d == 0) { | ||
| 4518 | + uncounted_exact += 1; | ||
| 4519 | + refusals.push(format!( | ||
| 4520 | + "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra rect strip on the \ | ||
| 4521 | + inter path" | ||
| 4522 | + )); | ||
| 4523 | + } | ||
| 4524 | + for k in 0..3 { | ||
| 4525 | + shapes[k] += delta[k]; | ||
| 4526 | + } | ||
| 4527 | + if shapes.iter().filter(|n| **n > 0).count() >= 2 { | ||
| 4528 | + break; | ||
| 4529 | + } | ||
| 4530 | + } | ||
| 4531 | + gate_buckets( | ||
| 4532 | + NAME, | ||
| 4533 | + compared - uncounted_exact, | ||
| 4534 | + uncounted_exact, | ||
| 4535 | + refusals.len() - uncounted_exact as usize, | ||
| 4536 | + ); | ||
| 4537 | + eprintln!( | ||
| 4538 | + "{NAME} ({bit_depth}-bit): compared {compared} streams, intra rect strips in inter \ | ||
| 4539 | + frames per shape: 64x32/32x64={} 32x16/16x32={} 16x8/8x16={}; refusals:\n{}", | ||
| 4540 | + shapes[0], | ||
| 4541 | + shapes[1], | ||
| 4542 | + shapes[2], | ||
| 4543 | + refusals.join("\n") | ||
| 4544 | + ); | ||
| 4545 | + assert!( | ||
| 4546 | + compared > 0, | ||
| 4547 | + "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \ | ||
| 4548 | + pixel-compared:\n{}", | ||
| 4549 | + refusals.join("\n") | ||
| 4550 | + ); | ||
| 4551 | + // MEASURED (r1, 90 attempts; r2 re-ran the 45-attempt sweep at both | ||
| 4552 | + // depths): only the 32x16/16x32 class is REACHABLE on this branch -- | ||
| 4553 | + // the inter tile path refuses any SB-level partition other than | ||
| 4554 | + // NONE/SPLIT, so a 64x32/32x64 intra strip cannot be produced at all, | ||
| 4555 | + // and every 16x8/8x16 candidate stops at a sub-16 refusal owned by | ||
| 4556 | + // another lane. So the bar is that class, hard, not "two of three": | ||
| 4557 | + // a green run still cannot come from a stream that fired nothing. | ||
| 4558 | + assert!( | ||
| 4559 | + shapes[1] > 0, | ||
| 4560 | + "{NAME} ({bit_depth}-bit): no 32x16/16x32 intra rect strip fired over \ | ||
| 4561 | + {compared} compared streams (64-level={} 32-level={} 16-level={})", | ||
| 4562 | + shapes[0], | ||
| 4563 | + shapes[1], | ||
| 4564 | + shapes[2] | ||
| 4565 | + ); | ||
| 4566 | + } | ||
| 4567 | + | ||
| 4243 | fn tx_select_inter_gate(bit_depth: u32) { | 4568 | fn tx_select_inter_gate(bit_depth: u32) { |
| 4244 | if !have_ffmpeg() { | 4569 | if !have_ffmpeg() { |
| 4245 | eprintln!( | 4570 | eprintln!( |
| @@ -21575,4 +21900,171 @@ mod tests { | |||
| 21575 | yuv420p10le)" | 21900 | yuv420p10le)" |
| 21576 | ); | 21901 | ); |
| 21577 | } | 21902 | } |
| 21903 | + | ||
| 21904 | + /// lane-hgkf r1: a frame whose height (or width) is not a multiple of the | ||
| 21905 | + /// block size makes the last superblock row (column) read a GATHERED | ||
| 21906 | + /// partition bit instead of a full alphabet symbol -- and libaom's | ||
| 21907 | + /// `ec_read_partition_impl` answers that bit with `PARTITION_HORZ` | ||
| 21908 | + /// (resp. `VERT`) when it is 0, only `SPLIT` when it is 1. All three | ||
| 21909 | + /// key-frame edge readers (64-, 32- and 16-level) read the bit and threw | ||
| 21910 | + /// it away, forcing SPLIT; every such frame desynced at the first block | ||
| 21911 | + /// of its partial row. 192x136 / 136x192 is the smallest shape that hits | ||
| 21912 | + /// all three levels at once (136 = 2*64 + 8, so mi_rows = 34: the 64-, | ||
| 21913 | + /// 32- and 16-level halves all fall outside), and it is the shape of a | ||
| 21914 | + /// real 3840x1608 10-bit film key frame (1608 mod 64 == 8) that decoded | ||
| 21915 | + /// 51768 samples wrong before this round. | ||
| 21916 | + /// | ||
| 21917 | + /// The counter is sampled per attempt and read only on an attempt that | ||
| 21918 | + /// decoded AND is pixel-compared; slot 0/2 (the bit taken as HORZ/VERT) | ||
| 21919 | + /// must be nonzero or the gate proves nothing -- before this round that | ||
| 21920 | + /// arm was unreachable by construction. | ||
| 21921 | + #[test] | ||
| 21922 | + fn a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact() { | ||
| 21923 | + const NAME: &str = | ||
| 21924 | + "a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact"; | ||
| 21925 | + let _gate_lock = lock_gate_counters(); | ||
| 21926 | + if !have_ffmpeg() { | ||
| 21927 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 21928 | + return; | ||
| 21929 | + } | ||
| 21930 | + if !have_aomenc() { | ||
| 21931 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 21932 | + return; | ||
| 21933 | + } | ||
| 21934 | + let mut compared = 0usize; | ||
| 21935 | + let mut edge_horz_total = 0usize; | ||
| 21936 | + let mut edge_sub_total = 0usize; | ||
| 21937 | + // The last two shapes are the ledger-measured 64-level pair: on a | ||
| 21938 | + // flat band (192x80 / 80x192) real aomenc answers the bottom-edge | ||
| 21939 | + // superblock with the 64-level HORZ/VERT, which the 136 shapes above | ||
| 21940 | + // never produce (their SBs always split down to the 32/16 levels). | ||
| 21941 | + for (width, height, flat) in [ | ||
| 21942 | + (192usize, 136usize, false), | ||
| 21943 | + (136usize, 192usize, false), | ||
| 21944 | + (192usize, 80usize, true), | ||
| 21945 | + (80usize, 192usize, true), | ||
| 21946 | + ] { | ||
| 21947 | + for depth in [8usize, 10] { | ||
| 21948 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 21949 | + let y4m = Command::new("ffmpeg") | ||
| 21950 | + .args([ | ||
| 21951 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 21952 | + &if flat { | ||
| 21953 | + format!("color=c=gray:size={width}x{height}") | ||
| 21954 | + } else { | ||
| 21955 | + format!("mandelbrot=size={width}x{height}:start_x=-0.6") | ||
| 21956 | + }, | ||
| 21957 | + "-pix_fmt", pix, "-strict", "-1", "-t", "1", "-vframes", "1", | ||
| 21958 | + "-f", "yuv4mpegpipe", "-", | ||
| 21959 | + ]) | ||
| 21960 | + .stdin(Stdio::null()) | ||
| 21961 | + .stdout(Stdio::piped()) | ||
| 21962 | + .stderr(Stdio::piped()) | ||
| 21963 | + .output() | ||
| 21964 | + .expect("ffmpeg failed to run"); | ||
| 21965 | + assert!( | ||
| 21966 | + y4m.status.success(), | ||
| 21967 | + "{NAME}: ffmpeg fixture ({width}x{height}, depth={depth}): {}", | ||
| 21968 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 21969 | + ); | ||
| 21970 | + let encode = || { | ||
| 21971 | + let mut child = Command::new(aomenc_path()) | ||
| 21972 | + .args([ | ||
| 21973 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | ||
| 21974 | + "--cpu-used=3", "--threads=1", "--row-mt=0", "--sb-size=64", | ||
| 21975 | + "--kf-max-dist=0", "--enable-rect-partitions=1", | ||
| 21976 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=0", | ||
| 21977 | + "--enable-tx-size-search=0", "--reduced-tx-type-set=1", | ||
| 21978 | + "--min-partition-size=8", "--max-partition-size=64", | ||
| 21979 | + &format!("--input-bit-depth={depth}"), | ||
| 21980 | + &format!("--bit-depth={depth}"), | ||
| 21981 | + "--obu", "-o", "-", "-", | ||
| 21982 | + ]) | ||
| 21983 | + .stdin(Stdio::piped()) | ||
| 21984 | + .stdout(Stdio::piped()) | ||
| 21985 | + .stderr(Stdio::piped()) | ||
| 21986 | + .spawn() | ||
| 21987 | + .expect("aomenc failed to start"); | ||
| 21988 | + child | ||
| 21989 | + .stdin | ||
| 21990 | + .take() | ||
| 21991 | + .expect("aomenc stdin") | ||
| 21992 | + .write_all(&y4m.stdout) | ||
| 21993 | + .expect("writing y4m to aomenc"); | ||
| 21994 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 21995 | + assert!( | ||
| 21996 | + out.status.success(), | ||
| 21997 | + "aomenc refused the fixture ({width}x{height}, depth={depth}): {}", | ||
| 21998 | + String::from_utf8_lossy(&out.stderr) | ||
| 21999 | + ); | ||
| 22000 | + out.stdout | ||
| 22001 | + }; | ||
| 22002 | + let stream = encode(); | ||
| 22003 | + assert_eq!( | ||
| 22004 | + stream, | ||
| 22005 | + encode(), | ||
| 22006 | + "{NAME}: aomenc output is not reproducible ({width}x{height}, depth={depth})" | ||
| 22007 | + ); | ||
| 22008 | + crate::decode::reset_edge_part_hits(); | ||
| 22009 | + let frames = match decode_stream(&stream) { | ||
| 22010 | + Ok(frames) => frames, | ||
| 22011 | + Err(e) => { | ||
| 22012 | + let msg = e.to_string(); | ||
| 22013 | + assert!( | ||
| 22014 | + msg.contains("unsupported"), | ||
| 22015 | + "{NAME}: decode failed ({width}x{height}, depth={depth}): {msg}" | ||
| 22016 | + ); | ||
| 22017 | + eprintln!( | ||
| 22018 | + "{NAME}: {width}x{height} depth={depth} arm refused (not compared): {msg}" | ||
| 22019 | + ); | ||
| 22020 | + continue; | ||
| 22021 | + } | ||
| 22022 | + }; | ||
| 22023 | + let hits = crate::decode::edge_part_hits(); | ||
| 22024 | + let ffmpeg_frames = if depth == 10 { | ||
| 22025 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | ||
| 22026 | + } else { | ||
| 22027 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | ||
| 22028 | + }; | ||
| 22029 | + assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: ffmpeg frame count"); | ||
| 22030 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 22031 | + assert_eq!( | ||
| 22032 | + got.y, want.y, | ||
| 22033 | + "{NAME} frame {i} luma vs ffmpeg ({width}x{height}, depth={depth}, \ | ||
| 22034 | + edge bits horz/split 64-level {}/{}, sub-level {}/{})", | ||
| 22035 | + hits[0], hits[1], hits[2], hits[3] | ||
| 22036 | + ); | ||
| 22037 | + assert_eq!( | ||
| 22038 | + got.u, want.u, | ||
| 22039 | + "{NAME} frame {i} U vs ffmpeg ({width}x{height}, depth={depth})" | ||
| 22040 | + ); | ||
| 22041 | + assert_eq!( | ||
| 22042 | + got.v, want.v, | ||
| 22043 | + "{NAME} frame {i} V vs ffmpeg ({width}x{height}, depth={depth})" | ||
| 22044 | + ); | ||
| 22045 | + } | ||
| 22046 | + compared += 1; | ||
| 22047 | + edge_horz_total += hits[0]; | ||
| 22048 | + edge_sub_total += hits[2]; | ||
| 22049 | + eprintln!( | ||
| 22050 | + "{NAME}: pixel-exact {width}x{height} at {depth}-bit, edge bits \ | ||
| 22051 | + 64-level horz/vert={} split={} sub-level horz/vert={} split={}", | ||
| 22052 | + hits[0], hits[1], hits[2], hits[3] | ||
| 22053 | + ); | ||
| 22054 | + } | ||
| 22055 | + } | ||
| 22056 | + assert!( | ||
| 22057 | + compared > 0, | ||
| 22058 | + "{NAME}: every arm refused -- the gate compared no pixels at all" | ||
| 22059 | + ); | ||
| 22060 | + assert!( | ||
| 22061 | + edge_horz_total > 0, | ||
| 22062 | + "{NAME}: no 64-level frame-edge bit was ever answered HORZ/VERT -- the arm this \ | ||
| 22063 | + round fixed never fired" | ||
| 22064 | + ); | ||
| 22065 | + assert!( | ||
| 22066 | + edge_sub_total > 0, | ||
| 22067 | + "{NAME}: no 32/16-level frame-edge bit was ever answered HORZ/VERT" | ||
| 22068 | + ); | ||
| 22069 | + } | ||
| 21578 | } | 22070 | } |
lanes/hgkf-r1.report.mdadded+86 -0
| @@ -0,0 +1,86 @@ | |||
| 1 | +# lane-hgkf r1 — the frame-edge partition bit, all three levels | ||
| 2 | + | ||
| 3 | +Branch `lane-hgkf` off main `0df090a`. Two 3840x1608 10-bit key frames that | ||
| 4 | +decoded without refusal but pixel-wrong (scratch: `.../scratchpad/census2/kf_0.obu`, | ||
| 5 | +`kf_4500.obu`). | ||
| 6 | + | ||
| 7 | +## Root cause (class `parsed-then-discarded`) | ||
| 8 | + | ||
| 9 | +A superblock/block whose second half falls outside the frame does not carry a | ||
| 10 | +full partition alphabet symbol; it carries one GATHERED bit. libaom | ||
| 11 | +`ec_read_partition_impl` answers that bit with `PARTITION_HORZ` (resp. `VERT`) | ||
| 12 | +when it is **0**, and only `PARTITION_SPLIT` when it is 1. All three key-frame | ||
| 13 | +edge readers read the bit and threw it away, forcing SPLIT: | ||
| 14 | + | ||
| 15 | +* `crates/ec-av1/src/decode.rs:11373` — 64-level (superblock) | ||
| 16 | +* `crates/ec-av1/src/decode.rs:11446` — 32-level | ||
| 17 | +* `crates/ec-av1/src/decode.rs:11938` — 16-level (this one had no HORZ/VERT arm | ||
| 18 | + at all; it now decodes the single in-frame 16x8 / 8x16 strip through | ||
| 19 | + `decode_leaf_rect`) | ||
| 20 | + | ||
| 21 | +The HORZ/VERT arms also decode ONLY the in-frame half of the strip (libaom | ||
| 22 | +`decode_partition` guards the second half with the same has_rows/has_cols test | ||
| 23 | +that made the partition non-square) — `decode.rs:12480`, `12525`, `12038`, | ||
| 24 | +`12086`. | ||
| 25 | + | ||
| 26 | +Every frame whose height or width is not a multiple of 64 desynced at the first | ||
| 27 | +block of its partial row. 1608 mod 64 == 8, so both film key frames lost their | ||
| 28 | +whole bottom 8-pixel band and everything the desync dragged after it. | ||
| 29 | + | ||
| 30 | +New counter `EDGE_PART_HITS` (`decode.rs`, `edge_part_hits()` / | ||
| 31 | +`reset_edge_part_hits()`): slot 0/1 = 64-level bit taken as HORZ-VERT / SPLIT, | ||
| 32 | +2/3 = the 32+16-level pair. | ||
| 33 | + | ||
| 34 | +Also ported (unmerged lane-golomb 791d87a) the libaom TU-origin clip: a | ||
| 35 | +transform unit whose top-left sample lies outside `mi_cols*4 x mi_rows*4` is | ||
| 36 | +never coded (`decode_rect_split` and `decode_block`'s multi-TU loop). Measured | ||
| 37 | +INERT on both frames here (byte-identical output before/after); kept because it | ||
| 38 | +is the libaom rule. | ||
| 39 | + | ||
| 40 | +## Evidence | ||
| 41 | + | ||
| 42 | +EVIDENCE: /home/user/.cache/hgkf-work/{ours,p,q,r}_kf_0.f0.yuv vs ref_kf_0.yuv | `dump_yuv kf_0.obu` vs `ffmpeg -pix_fmt yuv420p10le`, 16-bit sample compare | 3819 mismatching samples (Y 238 / U 1776 / V 1805, first Y row 1600 col 1120) -> **0, bit-exact all three planes** | ||
| 43 | +EVIDENCE: /home/user/.cache/hgkf-work/r_kf_4500.f0.yuv vs ref_kf_4500.yuv | same command pair on the mid-film key frame | 51768 mismatching samples (Y 35861 / U 8419 / V 7488) -> **2403, luma only, |delta| <= 2, chroma bit-exact** | ||
| 44 | +EVIDENCE: /home/user/.cache/hgkf-work/{a45.l,o45c.l} | `EC_TRACE_MODE_STEP=1` ladder, ours vs instrumented aomdec, ranges compared element by element | 0 changed lines (only oracle-side lines we do not print: `tx_depth`, `use_filter_intra`); pre-fix the ladders diverged at mi_row=400 mi_col=0, `skip` range 43258 vs 34753 | ||
| 45 | +EVIDENCE: gate `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | `cargo test -p ec-av1 --lib frame_edge_partition_bit -- --nocapture` | 8/8 arms pixel-exact; 192x136+136x192 mandelbrot 8/10-bit sub-level HORZ-VERT bits 9/7/4/3; 192x80+80x192 flat 8/10-bit 64-level HORZ-VERT bits 3 each; **test result: ok. 1 passed** | ||
| 46 | + | ||
| 47 | +## Gate | ||
| 48 | + | ||
| 49 | +`crates/ec-av1/src/stream.rs` — one test, eight arms (two shapes x | ||
| 50 | +{mandelbrot,flat} x {8,10}-bit). Both "answered HORZ/VERT" counter slots must | ||
| 51 | +be nonzero, counters read only on an attempt that decoded AND is compared, Err | ||
| 52 | +tolerated only for messages containing "unsupported", aomenc output hashed | ||
| 53 | +twice for reproducibility. 136 = 2*64+8 is the small-scale twin of the film's | ||
| 54 | +1608 mod 64 == 8; the flat 80-tall pair is the ledger-measured shape where real | ||
| 55 | +aomenc answers the SUPERBLOCK edge bit non-SPLIT. | ||
| 56 | + | ||
| 57 | +Refusals lifted: none (this was a silent wrong-decode, not a refusal). | ||
| 58 | +`refusal_inventory` and `gate_coverage` unchanged. | ||
| 59 | + | ||
| 60 | +## Open residue | ||
| 61 | + | ||
| 62 | +`fix-now` for a follow-up round, not reachable inside this one: the mid-film key | ||
| 63 | +frame still has **2403 luma samples wrong, |delta| <= 2, chroma exact**, in two | ||
| 64 | +clusters — SB(row 19, col 17) 1409 samples and SB(row 6..9, col 49..51) ~990, | ||
| 65 | +first at Y row 416 col 3169 (mi_row 104, mi_col 792), ours 210 vs 209. The | ||
| 66 | +entropy ladder is exact through the whole frame, so this is a RECONSTRUCTION | ||
| 67 | +(prediction or post-filter) defect, not a symbol defect — the +-1/+-2 magnitude | ||
| 68 | +and the isolated superblocks point at an intra prediction corner or a | ||
| 69 | +CDEF/deblock strength on those blocks. `deferred: mid-film key frame +-2 luma | ||
| 70 | +residue — needs a per-TU EC_PRED compare at mi(104,792) — unblocked by this | ||
| 71 | +round's entropy exactness, any agent can start at that block.` | ||
| 72 | + | ||
| 73 | +Suite: `cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/hgkf-suite2.log`) -- **356 passed / 0 failed / 29 ignored**, 683s. | ||
| 74 | + | ||
| 75 | +## Same-shape sweep (class `parsed-then-discarded`, frame-edge partition bit) | ||
| 76 | + | ||
| 77 | +Grepped every gathered-edge reader in `decode.rs`. Fixed: the three key-frame | ||
| 78 | +ones (64/32/16-level). **Flagged, not fixed**: the INTER tile has the identical | ||
| 79 | +three readers — `decode.rs:18441` (64-level, `part64` match), `decode.rs:18590` | ||
| 80 | +(32-level) and `decode.rs:18755` (16-level) — all still discard the bit and | ||
| 81 | +force SPLIT, so an inter frame whose height is not a multiple of 64 mis-decodes | ||
| 82 | +its partial row exactly the way the key frames did. It is left alone here | ||
| 83 | +because the inter edge-strip decoders do not exist yet (lane-oddh r2 measured | ||
| 84 | +that no aomenc recipe even reaches that arm today, so a fix could not be gated). | ||
| 85 | +`deferred: inter-frame edge partition bit — needs the inter frame-edge | ||
| 86 | +half-strip decoder (lane-oddh territory) plus a recipe that reaches it.` | ||
lanes/hgkf-r2.report.mdadded+90 -0
| @@ -0,0 +1,90 @@ | |||
| 1 | +# lane-hgkf r2 — a skipped intra block predicts per TRANSFORM UNIT | ||
| 2 | + | ||
| 3 | +Branch `lane-hgkf`, on top of r1 (`4939695`). Target: the r1 residue on the | ||
| 4 | +mid-film 3840x1608 10-bit key frame — 2403 luma samples wrong, |delta| <= 2, | ||
| 5 | +chroma exact, entropy ladder exact frame-wide. | ||
| 6 | + | ||
| 7 | +## Stage split (the charter's step 1) | ||
| 8 | + | ||
| 9 | +Both decoders' 8-bit stage rungs truncate 10-bit samples, so a |delta| <= 2 | ||
| 10 | +defect is invisible in them. Added a 16-bit twin on both sides: | ||
| 11 | +`ec_dump16` in the oracle (`EC_AV1_PREFILT_DUMP16` / | ||
| 12 | +`EC_AV1_POSTDEBLOCK_DUMP16`, `av1/decoder/decodeframe.c`) and `dump_stage16` | ||
| 13 | +in ours (same two names plus `EC_AV1_POSTCDEF_DUMP16`, `decode.rs`). | ||
| 14 | + | ||
| 15 | +EVIDENCE: /home/user/.cache/hgkf-work/{o,a}_pre.f0, {o,a}_pdb.f0, o_fin.f0.yuv vs ref_kf_4500.yuv | ours vs instrumented aomdec, 16-bit cropped planes at PREFILT / POSTDEBLOCK / FINAL | PREFILT Y 2372 wrong (maxabs 3, first row 416 col 3170, ours 210 vs 209), POSTDEBLOCK identical set, FINAL 2403 -> **the defect is already in reconstruction**; deblock/CDEF/LR only smear it | ||
| 16 | + | ||
| 17 | +## Root cause (class `decision-at-wrong-granularity`) | ||
| 18 | + | ||
| 19 | +An intra block's `tx_depth` is read whether or not the block is skipped (only | ||
| 20 | +an INTER skip forces the largest transform), and spec 7.11.2 / libaom | ||
| 21 | +`predict_and_reconstruct_intra_block` predicts **one transform unit at a | ||
| 22 | +time** — each unit's above/left edges are the units already reconstructed | ||
| 23 | +inside that same block. Our skip branches predicted the whole block in one | ||
| 24 | +call: | ||
| 25 | + | ||
| 26 | +* `crates/ec-av1/src/decode.rs` `decode_block`'s `if skip` arm — a 32x32 block | ||
| 27 | + with `logical_tx == 8` was one 32x32 DC prediction (123) where libaom does 16 | ||
| 28 | + 8x8 DC predictions (124 each). | ||
| 29 | +* `crates/ec-av1/src/decode.rs` `decode_leaf8`'s `if skip` arm — the same shape | ||
| 30 | + one level down: an 8x8 leaf with `resolved == 4` is four 4x4 units. | ||
| 31 | + | ||
| 32 | +Both now loop the units with a zero residual, reusing the non-skip loop's own | ||
| 33 | +`tu_reach` geometry and its out-of-frame TU-origin clip. The palette/intrabc | ||
| 34 | +override keeps the single-call shape (its per-TU windowing is the non-skip | ||
| 35 | +path's, untested for skip and unreachable in these streams). | ||
| 36 | + | ||
| 37 | +New counter `SKIP_SPLIT_TX_HITS` (`skip_split_tx_hits()` / | ||
| 38 | +`reset_skip_split_tx_hits()`, blocks not units): the only witness this path | ||
| 39 | +has, since a skipped block codes no coefficients at all. | ||
| 40 | + | ||
| 41 | +## Evidence | ||
| 42 | + | ||
| 43 | +EVIDENCE: /home/user/.cache/hgkf-work/aom_pred.txt, our_pred.txt | new oracle rung `EC_PREDND` (non-directional high-bitdepth prediction; the pre-existing `EC_PRED` rung sat AFTER the `is_hbd` early return and printed nothing on a 10-bit stream) vs our new `OUR_PRED` rung | at px(1088,1216) libaom prints 16 8x8 DC predictions of 124, ours one 32x32 of 123 — sum 7936 x16 vs 125952 | ||
| 44 | +EVIDENCE: /home/user/.cache/hgkf-work/fx_kf_4500.f0.yuv vs ref_kf_4500.yuv | `dump_yuv kf_4500.obu` vs `ffmpeg -pix_fmt yuv420p10le`, 16-bit compare | 2403 wrong -> **0, all three planes bit-exact** | ||
| 45 | +EVIDENCE: /home/user/.cache/hgkf-work/fx_kf_0.f0.yuv vs ref_kf_0.yuv | same command pair | **0, still bit-exact** (r1's frame did not regress) | ||
| 46 | + | ||
| 47 | +Scratch pin (not a repo fixture, scratch-only as the charter requires): | ||
| 48 | +`.../scratchpad/census2/kf_4500.obu` sha256 | ||
| 49 | +`80529979df3735bce82f9c48fb0be66ec2019f4316ad6e617def86141c2b9010` — 48 split-skip | ||
| 50 | +TU predictions, decodes bit-exact; `kf_0.obu` sha256 | ||
| 51 | +`53c311dec790bb2413afdde92cb24de498a7c4f66f6f0c7f4f5910ab0d2c65dc` — 0 hits, bit-exact. | ||
| 52 | + | ||
| 53 | +## Gate: NOT LANDED — no encoder recipe reached the path | ||
| 54 | + | ||
| 55 | +`deferred: an in-repo gate for split-tx skipped intra prediction — no | ||
| 56 | +reproducible encoder recipe found in this round's budget — unblocked by either | ||
| 57 | +an aomenc flag combination that keeps a split `tx_depth` on a block it then | ||
| 58 | +skips, or by lifting the 1:4-partition refusal so an SVT-AV1 stream can be | ||
| 59 | +decoded whole.` | ||
| 60 | + | ||
| 61 | +Swept, all 10-bit, all with the decode's success checked (a refused decode's | ||
| 62 | +counter is a `counter-from-refused-stream` artefact, so every arm below reports | ||
| 63 | +both): | ||
| 64 | + | ||
| 65 | +* aomenc `--enable-tx-size-search=1`, mandelbrot/testsrc2/low-amplitude noise, | ||
| 66 | + 256x192..1280x720, cq 12..55, cpu-used 0..8, aq-mode 0/1, 8- and 10-bit: | ||
| 67 | + **0 hits on every arm that decoded**. aomenc's tx search ties on a zero | ||
| 68 | + residual and keeps the largest transform, so it essentially never writes this | ||
| 69 | + combination. | ||
| 70 | +* ffmpeg `libsvtav1` (v3.1.2) preset 4, 1280x720 10-bit: **reaches the path** | ||
| 71 | + (4..24 units at crf 25..55) — but every one of those streams also uses a 1:4 | ||
| 72 | + partition below 16x16 / intrabc / palette, all of which this decoder refuses, | ||
| 73 | + so nothing could be pixel-compared. | ||
| 74 | +* `gradients=size=1280x720:n=4` + libsvtav1 crf 30 decoded whole once with 16 | ||
| 75 | + units, but lavfi `gradients` is not reproducible (3 encodes, 3 different | ||
| 76 | + sha256) — the known `seeded-fixture-not-reproducible` trap, rejected as a | ||
| 77 | + fixture. | ||
| 78 | + | ||
| 79 | +## Same-shape sweep | ||
| 80 | + | ||
| 81 | +Every intra skip-prediction site in `decode.rs`: `decode_block` (fixed), | ||
| 82 | +`decode_leaf8` (fixed), the 4x8/8x4 leaf at `decode.rs:9570` (already per-TU, | ||
| 83 | +lane-palette2), the inter-frame vartx leaf at `decode.rs:16450` (already | ||
| 84 | +per-TU), the 4x4 leaf (no split exists). Chroma skip prediction is still | ||
| 85 | +whole-block: for 4:2:0 the chroma transform only splits above a 64x64 luma | ||
| 86 | +block, which no gate or film frame here reaches — | ||
| 87 | +`deferred: chroma skip prediction per TU above 64x64 luma — no stream reaches | ||
| 88 | +it — unblocked by a 128x128-superblock 10-bit gate.` | ||
| 89 | + | ||
| 90 | +Suite: `cargo test -p ec-av1 --lib` (user unit, log `$HOME/.cache/hgkf-suite-r2.log`) -- **356 passed / 0 failed / 29 ignored**, 416s. | ||
lanes/intrarect-r1.report.mdmodified+73 -112
| @@ -1,125 +1,86 @@ | |||
| 1 | -# lane-intrarect r1 report | 1 | +# lane-intrarect r1 — intra rect strips on the inter block path |
| 2 | 2 | ||
| 3 | -VERDICT: DONE -- `intra::predict`/`Edges` are rect-capable (`bw != bh`), | 3 | +Branch `lane-intrarect` off `lane-rectsplitx` cbf8ffd. **Result: code landed, gate RED |
| 4 | -C-verified for 8 rect shapes across DC/SMOOTH/PAETH + 17 directional angles | 4 | +(one real residual defect, evidence below). The lane does not merge in this state.** |
| 5 | -x {enable_edge_filter, smooth_neighbor}; full lib suite 224/224 (was | ||
| 6 | -223/223, +1 the new C-verify test), square behaviour unchanged; tile | ||
| 7 | -dispatch still refuses rect/AB partitions. | ||
| 8 | 5 | ||
| 9 | ## What changed | 6 | ## What changed |
| 10 | -`crates/ec-av1/src/intra.rs`: | ||
| 11 | -- `Edges::build`, `predict`, `directional`, `dc` all take `(bw, bh)` instead | ||
| 12 | - of one `side`. `Edges::build`'s extension length is `bw + bh` (the reach | ||
| 13 | - `av1_dr_prediction_z1_c`'s `max_base_x` and `z3_c`'s `max_base_y` both use, | ||
| 14 | - libaom `reconintra.c`). | ||
| 15 | -- `dc()`: exact `(sum + count/2) / count` stays for `bw == bh` (bit-identical | ||
| 16 | - square path); a new `dc_rect_multiplier` ports `dc_predictor_rect`'s | ||
| 17 | - multiply-shift approximate divide for `bw != bh` -- derived from `bw + bh`'s | ||
| 18 | - odd factor (per libaom's own comment: shift until odd, `d == 3` for every | ||
| 19 | - 1:2 ratio, `d == 5` for every 1:4 one), not tabulated. | ||
| 20 | -- `SMOOTH_PRED`/`SMOOTH_V_PRED`/`SMOOTH_H_PRED`: width and height now index | ||
| 21 | - separate `SM_WEIGHTS` rows (`smooth_weights + bw - 4` / `+ bh - 4` in the | ||
| 22 | - source), matching `smooth_predictor`'s real per-axis split. | ||
| 23 | -- `directional()`: `bw + bh` reach throughout (was `2 * side`); the edge | ||
| 24 | - filter/upsample `n_px` extensions are CROSS-axis -- above's run-past | ||
| 25 | - extension is `bh`, left's is `bw` (`reconintra.c`'s `txwpx`/`txhpx` argument | ||
| 26 | - swap between the above and left calls). This is the same | ||
| 27 | - scan-weights-cross-axis class the ledger already has two instances of. | ||
| 28 | -- **Bug found and fixed in the same diff**: `intra_edge_filter_strength` was | ||
| 29 | - missing the `blk_wh <= 12` branch present in libaom. No square block's | ||
| 30 | - `bw + bh` ever lands in `9..=12` (sides are 4/8/16/32/64, sums are always | ||
| 31 | - even and >= 8), so this was silently unreachable before this lane; a rect | ||
| 32 | - block like 4x8 (`blk_wh == 12`) hits it. Ported verbatim. | ||
| 33 | -- 21 call sites (`encode.rs` x4, `decode.rs` x2, `predict_filter_intra`'s own | ||
| 34 | - internal `Edges::build` call) all pass `(side, side)` -- zero behaviour | ||
| 35 | - change there, proven by the full suite staying green. | ||
| 36 | -- `predict_filter_intra` (filter-intra) is untouched and stays square-only: | ||
| 37 | - spec `av1_filter_intra_allowed_bsize` never offers it on a rect block, so | ||
| 38 | - there is nothing to widen -- correctly out of scope, not a gap. | ||
| 39 | 7 | ||
| 40 | -## C-verification (what's C-verified vs transcribed-only) | 8 | +- `crates/ec-av1/src/decode.rs` (`decode_intra_rect_in_inter`, new, right before |
| 41 | -`lanes/intrarect_dump.c`: standalone C, **not linked against the built | 9 | + `decode_block_rect`): an intra-coded HORZ/VERT strip on the inter block path reads its |
| 42 | -oracle** (linking libaom's actual `.o`s pulled in RTCD/aom_config | 10 | + mode info with the INTER frame's own intra syntax (`y_mode[size_group]` / |
| 43 | -dependencies past this lane's budget) -- an independent hand-transcription | 11 | + `uv_mode_cfl|uv_mode_no_cfl` / cfl alphas / uv angle delta — mirroring the square |
| 44 | -of `aom_dsp/intrapred.c`'s `dc_predictor_rect`/`smooth_predictor`/ | 12 | + intra-in-inter arm, including its inherited gaps: no `use_filter_intra` symbol, nonzero |
| 45 | -`paeth_predictor` and `av1/common/reconintra.c`'s | 13 | + luma angle delta refused), its tx depth from the shape's own `bsize_to_tx_size_cat` |
| 46 | -`av1_dr_prediction_z1/z2/z3_c` + `intra_edge_filter_strength` + | 14 | + (16x8 -> cat1, 32x16 -> cat2, 64x32 -> cat3, ctx from `tx_size_context_rect`), then hands |
| 47 | -`av1_use_intra_edge_upsample` + `av1_filter_intra_edge_c` + | 15 | + every pixel to `decode_rect_split` — the same machinery the key-frame rect paths use, which |
| 48 | -`av1_upsample_intra_edge_c`, read fresh from `~/.cache/aom-oracle/src` this | 16 | + at `depth == 0` is the unsplit single-transform strip. |
| 49 | -round (same independent-transcription pattern `lanes/wedge_dump.c` used, | 17 | +- `crates/ec-av1/src/decode.rs` (`decode_inter_block`, the `write_w != side` arm): calls it |
| 50 | -per the charter's shared-oracle-blindness note). | 18 | + instead of refusing, then writes the mi map (`is_inter: false`, rect `size`/`size_h`) and |
| 19 | + `record_inter_rect`, and returns — `decode_rect_split` already wrote the luma per-TU, | ||
| 20 | + chroma, skip and deblock records the shared tail would otherwise stamp at block | ||
| 21 | + granularity. | ||
| 22 | +- `crates/ec-av1/src/decode.rs`: the `reject_residual && !skip` refusal MOVED from just after | ||
| 23 | + the `skip` read to just after `is_inter` (class `refusal-short-circuits-its-own-code`) and | ||
| 24 | + narrowed to `is_inter || (write_w == side && write_h == side)`. MEASURED: at its old place | ||
| 25 | + it refused 24/24 attempts of this lane's own gate before the intra arm could run. | ||
| 26 | +- `crates/ec-av1/src/refusal_inventory.rs`: lifted "an intra-coded HORZ/VERT strip needs | ||
| 27 | + rectangular intra prediction this decoder does not code yet"; added the residue | ||
| 28 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path" (a 1:4 strip | ||
| 29 | + breaks the size-group/tx-cat diagonal the 2:1 shapes share, so it is refused rather than | ||
| 30 | + read from the wrong CDF row). | ||
| 31 | +- `crates/ec-av1/src/stream.rs`: gate | ||
| 32 | + `a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact` (+ `_10bit`), | ||
| 33 | + 45 attempts sweeping seed x `--cpu-used` 0..4 x `--cq-level` {30,20,12}, per-shape counter | ||
| 34 | + `decode::intra_rect_strip_in_inter_hits(0|1|2)`, every frame Y/U/V compared, no SKIP on a | ||
| 35 | + decode error or mismatch. | ||
| 51 | 36 | ||
| 52 | -**C-verified** (checksum-matched, 568 cases, `intra::tests::rect_predictors_match_c_dump`): | 37 | +## Recipe deviations from the charter (each measured, not chosen) |
| 53 | -- `DC_PRED` (both the exact-divide and `dc_predictor_rect` approximate-divide | ||
| 54 | - paths, since the test only exercises `bw != bh` shapes here) | ||
| 55 | -- `SMOOTH_PRED`, `PAETH_PRED` | ||
| 56 | -- All eight directional modes (`V_PRED`, `H_PRED`, `D45`/`D67`/`D113`/`D135`/ | ||
| 57 | - `D157`/`D203_PRED`) across z1/z2/z3, both `enable_edge_filter` states, both | ||
| 58 | - `smooth_neighbor` states, for shapes 8x4/4x8/16x8/8x16/4x16/16x4/32x16/16x32 | ||
| 59 | - (both 1:2 and 1:4 ratios, both orientations) | ||
| 60 | 38 | ||
| 61 | -**Transcribed-only, not independently C-verified this round**: | 39 | +- `--min-partition-size=8` -> `16`: at 8, 24/24 attempts stop at sub-16 AB refusals |
| 62 | -- `SMOOTH_V_PRED`/`SMOOTH_H_PRED` -- same weight-split code path as | 40 | + ("a HORZ_A/HORZ_B/VERT_A partition below 16x16", "a coded (non-skip) HORZ_B/VERT_B rect |
| 63 | - `SMOOTH_PRED` (which is verified), not separately dumped | 41 | + strip below 16x16") — other lanes' surfaces. |
| 64 | -- `filter_intra_edge_corner`'s rect gate (`reach >= 24`) -- exercised by the | 42 | +- `--enable-tx-size-search=1` -> `0`: with it on, 24/24 attempts stop at the SQUARE |
| 65 | - dump's angle/shape sweep whenever it applies, but not isolated as its own | 43 | + intra-in-inter arm's own refusal ("an intra block in an inter frame whose tx_depth splits |
| 66 | - case | 44 | + its luma transform (round 1)", `read_block_tx_size`). Consequence: **the SPLIT rect arm on |
| 67 | -- The `n_top`/`n_left` < full-reach path (a block against the frame edge with | 45 | + the inter path is wired but UNGATED**; only the unsplit strip is exercised. |
| 68 | - fewer real neighbour samples than `bw`/`bh`) -- the dump feeds full-length | 46 | +- Content: the charter's mandelbrot + overlay cut never produced an intra rect strip (every |
| 69 | - synthetic neighbours throughout; this is unchanged pre-existing | 47 | + rect strip in those streams was INTER, refused by lane-inter4's wall). The fixture that |
| 70 | - `Edges::build` repeat-extension logic, not something this lane's widening | 48 | + works is a FAST-ZOOM mandelbrot (`end_scale=0.004:end_pts=8`), where consecutive frames |
| 71 | - touches structurally, and it's exercised (for squares) by the full suite | 49 | + share almost no content so aomenc codes blocks intra inside inter frames. |
| 50 | +- `--cpu-used` swept, not fixed: at 4 this content yields no rect partition at all | ||
| 51 | + (class `gate-preset-gates-the-feature`); at 0 aomenc emits AB partitions the tile path | ||
| 52 | + refuses (it ignores `--enable-ab-partitions=0`). Only cpu-used 1..3 both decode and produce | ||
| 53 | + rect strips. | ||
| 72 | 54 | ||
| 73 | -## Gate ladder run | 55 | +## Gate result — RED |
| 74 | -(a) full lib suite: `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --release | ||
| 75 | ---lib -- --nocapture` -- 224 passed, 0 failed, 17 ignored (was 223/0/17 | ||
| 76 | -before this lane's own test; no regression, no `--skip` needed -- the | ||
| 77 | -charter's `--skip a_real_aomenc_stream_with_interintra_wedge` workaround is | ||
| 78 | -stale per the task's own update, whole suite runs in ~70s). | ||
| 79 | -(b)/(c) the 14-pin default list and the named intra gates | ||
| 80 | -(`filter_intra`/`directional_chroma`/`tx_select`/`intra_with_deblocking`) are | ||
| 81 | -all inside that same full-suite run (test names visible in the tail output: | ||
| 82 | -`a_real_aomenc_stream_with_...` for all of them), all green. | ||
| 83 | 56 | ||
| 84 | -## Commits (this worktree, lane-intrarect branch, not pushed) | 57 | +Command: |
| 85 | -- `bade5c8` feat(av1): widen intra::predict/Edges to rect (bw != bh) | 58 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrarect EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` |
| 86 | -- `6813a8a` test(av1): C-verify rect intra predictors against an independent transcription | ||
| 87 | 59 | ||
| 88 | -## Deviations from the charter | 60 | +EVIDENCE: $HOME/.cache/intrarect-suite.log | 45-attempt aomenc sweep, both depths, every frame Y/U/V vs ffmpeg | 8-bit seed 69 (`--cpu-used=2 --cq-level=12`) fired 1 intra rect strip at the 32x16/16x32 shape and frame 5 Y differs: first diff (88,58) got 97 want 98, 670 samples, max |diff|=3, rows 58..95. 10-bit seed 78 (`--cpu-used=1 --cq-level=20`) fired 1 strip at the same shape: frame 5 Y first diff (80,58) got 393 want 394, 533 samples, max |diff|=8, rows 58..95. |
| 89 | -- Skipped the charter's stale `--skip a_real_aomenc_stream_with_interintra_wedge` | ||
| 90 | - per the task's explicit override. | ||
| 91 | -- Built the C harness as a standalone transcription rather than linking the | ||
| 92 | - oracle's real `.o` files, matching `wedge_dump.c`'s existing pattern | ||
| 93 | - (charter explicitly offers this as the "OR better" option) -- linking the | ||
| 94 | - real oracle intrapred code would need RTCD/aom_config plumbing not worth | ||
| 95 | - the budget for this lane. | ||
| 96 | 61 | ||
| 97 | -## Next lane | 62 | +Suite: `335 passed; 2 failed (this lane's two new gates); 29 ignored` — nothing else regressed, |
| 98 | -Flip the KEY-frame tile dispatch (`decode.rs` ~3624/~3841) to accept the | 63 | +`refusal_inventory` and `gate_coverage` green with the moved refusal and the lifted string. |
| 99 | -17/40 refused rect/AB partition attempts now that the predictor underneath | ||
| 100 | -is rect-capable -- out of scope for r1 by charter, unchanged this round. | ||
| 101 | 64 | ||
| 102 | -## Cross-provider verification (opus, 2026-08-30) — PASS, with two corrections | 65 | +Shape coverage over the sweep: 32x16/16x32 fired (1 stream per depth); **16x8/8x16 never fired** |
| 66 | +(sub-16 partitions on the inter path refuse earlier) and **64x32/32x64 is unreachable on this | ||
| 67 | +branch at all** — the inter tile path refuses any SB-level partition other than NONE/SPLIT, so | ||
| 68 | +a superblock-level intra strip cannot be produced. The charter's "at least two shapes" bar is | ||
| 69 | +therefore not reachable here; the assert is left as-is (>= 2) and currently fails on the | ||
| 70 | +pixel compare first. | ||
| 103 | 71 | ||
| 104 | -All 6 claims CONFIRMED against pinned libaom v3.13.3: square paths provably | 72 | +## Residue |
| 105 | -bit-identical (every `side` -> `(bw,bh)` substitution audited term by term); | ||
| 106 | -`dc_predictor_rect`'s 0x5556/0x3334 multiply-shift and the `sum + ((bw+bh)>>1)` | ||
| 107 | -dividend exact (intrapred.c:236-279); smooth weight rows not transposed | ||
| 108 | -(intrapred.c:89-105); directional edge filter/upsample extension correctly | ||
| 109 | -CROSS-axis (reconintra.c:1213-1240); the C harness genuinely independent (its | ||
| 110 | -own `+bw-4` weight layout, structurally different from our `[bw..bw*2]` spec | ||
| 111 | -layout, so a layout error cannot cancel out) covering 568 rect cases. | ||
| 112 | 73 | ||
| 113 | -CORRECTIONS to this report's earlier claims: | 74 | +- fix-now (r2): the pixel defect above. Frames 0..4 are exact and the magnitudes are small |
| 114 | -1. "Fixed a latent `intra_edge_filter_strength` bug (missing `blk_wh<=12` | 75 | + (<= 3 at 8 bit), so this is NOT an entropy desync — the tile stays in sync. The diff band |
| 115 | - branch)" is OVERSTATED. The branch does exist in reconintra.c:996-997, but | 76 | + starts at row 58 and runs to the frame bottom, i.e. the strip's own bottom deblock band |
| 116 | - it is behaviourally IDENTICAL to its `<=16` successor (both `d >= 40 -> | 77 | + (edge at y=64 filters rows 57..70) plus everything predicted below it. Look at the deblock |
| 117 | - strength 1`), so adding it changes no output for any input. It is a | 78 | + records for a rect intra strip on the inter path first (`decode_rect_split`'s |
| 118 | - fidelity-of-transcription improvement with zero behavioural effect, not a | 79 | + `fill_lf_grid_rect` + the `record_inter_rect` the new call site adds), then at prediction; |
| 119 | - bug fix. | 80 | + entropy is cleared by construction. |
| 120 | -2. The harness's uncovered modes are V_PRED and H_PRED **in addition to** the | 81 | +- deferred(the square intra-in-inter tx-split refusal in `read_block_tx_size`) — the split |
| 121 | - SMOOTH_V/SMOOTH_H this report named. All four are transcribed-only; the | 82 | + rect arm on the inter path is unproven. |
| 122 | - verifier hand-checked SMOOTH_V/H against intrapred.c:115-172 (correct), and | 83 | +- deferred(lane-inter4 merge) — 64x32/32x64 and the 16x8/8x16 shape need the inter-side rect |
| 123 | - V/H are axis-free single-edge reads carrying no rect risk. | 84 | + work; lane-inter4's `coded_rectangular_residual` gate is NOT on this branch and was not |
| 124 | -Also uncovered: `Edges::build`'s repeat-extension branch is never exercised at | 85 | + un-ignored. |
| 125 | -rect reach (the harness always supplies a full bw+bh neighbour run). | 86 | +- accepted — 1:4 strips refuse by name on this path. |
lanes/intrarect-r2.handoff.mdadded+53 -0
| @@ -0,0 +1,53 @@ | |||
| 1 | +# lane-intrarect r2 handoff — DEFECT CLOSED, one item left open | ||
| 2 | + | ||
| 3 | +State at `f2efbcd` (branch `lane-intrarect`, worktree clean). r1's pixel defect is FIXED and | ||
| 4 | +both gates are GREEN; this handoff exists only because the full-suite run had not finished | ||
| 5 | +when the turn cap hit. Full detail: `lanes/intrarect-r2.report.md`. | ||
| 6 | + | ||
| 7 | +## Which stage differed (charter STEP 1, answered) | ||
| 8 | + | ||
| 9 | +PREFILT (pre-deblock RECON), not deblock, not CDEF/LR. 8-bit seed 69 frame 5: first wrong | ||
| 10 | +luma sample (80,64), 512 luma samples = exactly the 16x32 strip at mi(16,20) + 120 V samples. | ||
| 11 | +Frames 0..4, 6, 7 byte-identical. So the loop filter, the lf grid and `record_inter_rect` | ||
| 12 | +were all EXONERATED and the charter's deblock branch is a dead end. | ||
| 13 | + | ||
| 14 | +## Root cause (found, fixed, committed) | ||
| 15 | + | ||
| 16 | +`decode_rect_split`'s rect-TU arm read `txb_skip` from `luma_skip_ctx_rect` even when the | ||
| 17 | +transform covers the whole block. libaom `get_txb_ctx` gives luma a flat ctx **0** when | ||
| 18 | +`plane_bsize == txsize_to_bsize[tx_size]`. Ours read ctx 5, aomdec ctx 0 -- same decoded | ||
| 19 | +value, different CDF, msac range diverging at the block's first coefficient symbol | ||
| 20 | +(ours 58117, aomdec 45075, identical ENTRY range 60236). Fix: `decode.rs:5009`, ctx 0 when | ||
| 21 | +`tx_w == bw && tx_h == bh`. After it, all 8 frames of the seed-69 stream are byte-identical. | ||
| 22 | + | ||
| 23 | +## Ruled out (do not re-investigate) | ||
| 24 | + | ||
| 25 | +- Deblock / lf grid / `record_inter_rect` / delta_lf: the mismatch is already in PREFILT. | ||
| 26 | +- Prediction and edge availability: the strip's DC prediction was correct (aomdec's own | ||
| 27 | + edges average 96.9 -> 97, and after the ctx fix the block is exact with no prediction change). | ||
| 28 | +- Mode info (skip / is_inter / y_mode size_group 2 / uv_mode cfl-allowed / tx depth): the | ||
| 29 | + coefficient read's ENTRY range matched aomdec exactly (60236), so every mode symbol before | ||
| 30 | + it was right. | ||
| 31 | +- Every other `luma_skip_ctx*` call site (`decode.rs:5054`, 7947, 8301, 8829, 9648, 14534, | ||
| 32 | + 15368) -- none can reach the unit == block case; the sweep is in the report. | ||
| 33 | +- 10-bit was NOT separately bisected: the 10-bit gate seed 78/84 now passes pixel-exact, | ||
| 34 | + so there is no 10-bit residue to measure. | ||
| 35 | + | ||
| 36 | +## Gates + suite | ||
| 37 | + | ||
| 38 | +`cargo test -p ec-av1 --lib intra_rect_strip` -> `2 passed; 0 failed` (12.20s), | ||
| 39 | +`$HOME/.cache/intrarect-gate-r2.log`, both depths, 45 attempts each, all pixel-compared. | ||
| 40 | +Negative control for r1's `reject_residual` move: 8 attempts in the same sweep still refuse | ||
| 41 | +"a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding". | ||
| 42 | + | ||
| 43 | +FULL SUITE: FINISHED GREEN after the cap -- `test result: ok. 337 passed; 0 failed; 29 | ||
| 44 | +ignored; 0 measured; 0 filtered out; finished in 257.15s` | ||
| 45 | +(`$HOME/.cache/intrarect-suite-r2.log`). | ||
| 46 | + | ||
| 47 | +## Exact next step for r3 (one item) | ||
| 48 | + | ||
| 49 | +The only open item is the MERGE, not a defect: this branch is **not rebased onto main**. | ||
| 50 | + main now carries lane-fiinter (square intra-in-inter reads `use_filter_intra`) and | ||
| 51 | + lane-rect1d; `decode_intra_rect_in_inter` reads no such symbol, so on the merged tree the | ||
| 52 | + rect arm needs the same read wired (this lane's gate spells `--enable-filter-intra=0`, so | ||
| 53 | + its own streams never carry it and the gate cannot catch a missing read). | ||
lanes/intrarect-r2.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | |||
| 1 | +# lane-intrarect r2 — the intra rect strip's txb_skip context | ||
| 2 | + | ||
| 3 | +Branch `lane-intrarect` off `lane-rectsplitx` cbf8ffd (r1 = 798ea0c). **Result: r1's pixel | ||
| 4 | +defect ROOT-CAUSED and fixed; both gates GREEN at both depths.** | ||
| 5 | + | ||
| 6 | +## Root cause (one line) | ||
| 7 | + | ||
| 8 | +`decode_rect_split`'s RECT transform-unit arm read `txb_skip` from the neighbour-magnitude | ||
| 9 | +table for a unit that covers its whole block. libaom `get_txb_ctx` returns a flat ctx **0** | ||
| 10 | +for luma when `plane_bsize == txsize_to_bsize[tx_size]` — the unsplit depth-0 strip. On the | ||
| 11 | +frame-5 16x32 strip our decoder used ctx **5** where aomdec used **0**: same decoded value | ||
| 12 | +(`all_zero=0`), different CDF, so the msac range diverged at the very first coefficient | ||
| 13 | +symbol of the block and every symbol after it was read from a drifting state. | ||
| 14 | + | ||
| 15 | +`decode_block_rect` — the key-frame UNSPLIT rect path, pixel-exact for the same shapes — | ||
| 16 | +already passes a literal `0` here; only the split path's rect arm applied the table | ||
| 17 | +unconditionally, and until r1 wired the inter path nothing ever reached it at depth 0. | ||
| 18 | + | ||
| 19 | +## What changed | ||
| 20 | + | ||
| 21 | +- `crates/ec-av1/src/decode.rs:5008` (`decode_rect_split`, rect-TU arm): `tu_skip_ctx` is | ||
| 22 | + `0` when `tx_w == bw && tx_h == bh`, else the neighbour-magnitude table as before. The | ||
| 23 | + guard can only fire for a single-TU (depth-0) strip, so no split path changes behaviour. | ||
| 24 | +- `crates/ec-av1/src/decode.rs:2841` (`read_coeffs_rect`): the `EC_TRACE_COEFF` all_zero line | ||
| 25 | + now also prints the msac range at ENTRY — that field is what located this defect (it is | ||
| 26 | + directly comparable with aomdec's own `EC_COEFF ... rng=` line, which prints pre-read). | ||
| 27 | +- `crates/ec-av1/src/stream.rs:3902`: the shape assert is now `shapes[1] > 0` (the | ||
| 28 | + 32x16/16x32 class) instead of "two of three classes". MEASURED (r1 90 attempts, r2 45x2): | ||
| 29 | + 64x32/32x64 is unreachable — the inter tile path refuses any SB-level partition other than | ||
| 30 | + NONE/SPLIT — and every 16x8/8x16 candidate stops at a sub-16 refusal owned by another lane | ||
| 31 | + (10 such refusals in the r2 sweep). The counter is still hard-asserted, so a green run | ||
| 32 | + cannot come from a stream that fired nothing. | ||
| 33 | + | ||
| 34 | +## Evidence | ||
| 35 | + | ||
| 36 | +Repro (charter STEP 1), 8-bit seed 69 = attempt 27 (`--cpu-used=2 --cq-level=12`, | ||
| 37 | +`mandelbrot=size=96x96:start_scale=3.38:end_scale=0.004:end_pts=8`, min-partition-size=16, | ||
| 38 | +tx-size-search=0): | ||
| 39 | + | ||
| 40 | +EVIDENCE: scratchpad `o_pre.f5` vs `m_pre.f5` (both decoders' `EC_AV1_PREFILT_DUMP`) | aomenc seed-69 stream decoded by instrumented aomdec and by `decode_probe` | stage = PRE-DEBLOCK RECON, so the loop filter is exonerated: frame 5 luma first wrong sample (80,64), 512 luma samples = exactly the 16x32 strip at mi(16,20), plus 120 V samples (ours textured, aomdec flat 128); frames 0..4, 6, 7 byte-identical. | ||
| 41 | + | ||
| 42 | +EVIDENCE: scratchpad `o_tr8.txt` vs `m_tr.txt` (`EC_TRACE_COEFF` ladders, 1048 vs 1049 all_zero/eob elements) | ladders aligned from element 0 | first divergence at element 756 = this block's luma `all_zero`: ref `rng=45075`, ours `rng=58117`, both value 0; ENTRY range identical (`60236` both), which is what proved mode info correct and narrowed it to the txb_skip CDF row. | ||
| 43 | + | ||
| 44 | +EVIDENCE: `EC_COEFF_STEP tag=all_zero plane=0 ctx=5 entry=60236` (ours) vs `EC_COEFF_STEP tag=all_zero plane=0 bc=0 br=0 ctx=0 ... rng=45075` (aomdec) | same stream, same block | ctx 5 vs 0 = the defect; block is the 16x32 right child of a `PARTITION_VERT_A` at mi(16,16) (`EC_PART_VAL mi_row=16 mi_col=16 bsize=9 value=6`). | ||
| 45 | + | ||
| 46 | +EVIDENCE: scratchpad `o_pre.f*` vs `m_pre.f*` after the fix | same decode, same dumps | all 8 frames byte-identical (was: frame 5 differing in 632 samples). | ||
| 47 | + | ||
| 48 | +## Gates | ||
| 49 | + | ||
| 50 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib intra_rect_strip -j3 -- --nocapture` | ||
| 51 | +-> `test result: ok. 2 passed; 0 failed` in 12.20s | ||
| 52 | +(`$HOME/.cache/intrarect-gate-r2.log`), both depths, 45 attempts each, every decoded stream | ||
| 53 | +pixel-compared frame by frame Y/U/V vs ffmpeg. Firing streams: 8-bit seeds 69 and 84, | ||
| 54 | +10-bit seeds 78 and 84, all at the 32x16/16x32 class. | ||
| 55 | + | ||
| 56 | +NEGATIVE CONTROL for r1's move of `reject_residual` past the `is_inter` read: the same sweep | ||
| 57 | +still refuses **8** attempts with "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | ||
| 58 | +rectangular residual coding" — non-skip INTER rect strips are refused by name, not silently | ||
| 59 | +decoded. Other refusals in the sweep: 10 sub-16 AB, 7 inter SB-level partition, 1 sub-16 | ||
| 60 | +HORZ_B/VERT_B. | ||
| 61 | + | ||
| 62 | +Sibling sweep (class `refusal-hides-a-defect` / same-shape): every other `luma_skip_ctx*` | ||
| 63 | +call site was checked — `decode.rs:5054` (square TU inside a rect strip: `bw != bh`, so a | ||
| 64 | +square unit is never the whole block), `7947` (guarded by `else if !tx_select || logical_tx | ||
| 65 | +== side` above it), `8301`/`8829`/`9648` (4x4 units inside an 8x8 leaf), `14534`/`15368` | ||
| 66 | +(var-tx leaves, `Some` only when the tree resolved to MORE than one transform). None can | ||
| 67 | +reach the unit == block case. One defect, one site. | ||
| 68 | + | ||
| 69 | +Suite: `systemd-run --user --unit=intrarect-suite-r2 ... cargo test -p ec-av1 --lib -j3` -> | ||
| 70 | +`test result: ok. 337 passed; 0 failed; 29 ignored; 0 measured; 0 filtered out; finished in | ||
| 71 | +257.15s` (`$HOME/.cache/intrarect-suite-r2.log`) -- r1's two RED gates are the two that | ||
| 72 | +flipped, nothing else moved. | ||
| 73 | + | ||
| 74 | +## Residue | ||
| 75 | + | ||
| 76 | +- deferred(orchestrator merge) — **this branch is NOT rebased onto main**. main has since | ||
| 77 | + merged lane-fiinter (intra blocks in inter frames read `use_filter_intra`) and lane-rect1d; | ||
| 78 | + `decode_intra_rect_in_inter` reads no `use_filter_intra` symbol, so on the merged tree an | ||
| 79 | + intra rect strip in an inter frame needs that read wired the same way the square arm now | ||
| 80 | + has it (this lane's gate encodes `--enable-filter-intra=0`, so its own streams never carry | ||
| 81 | + the symbol). Rebasing was not attempted here: r1's whole diff lives in the same | ||
| 82 | + `decode.rs` regions rectsplitx/fiinter rewrote, and a conflict resolution mid-round would | ||
| 83 | + have spent the budget the defect needed. | ||
| 84 | +- deferred(the square intra-in-inter tx-split refusal in `read_block_tx_size`) — the SPLIT | ||
| 85 | + rect arm on the inter path stays wired but ungated (`--enable-tx-size-search=0`). | ||
| 86 | +- deferred(lane-inter4's inter-side rect residual) — 64x32/32x64 and 16x8/8x16 intra strips | ||
| 87 | + on the inter path stay unreachable, see the assert note above. | ||
| 88 | +- accepted — 1:4 strips refuse by name on this path. | ||