Merge branch 'lane-intrarect': intra rect strips inside inter frames decode through the per-TU rect path; a whole-block rect transform unit reads txb_skip ctx 0
Browse files at this commit6 changed files +864 -131
- crates/ec-av1/src/decode.rs +316 -18
- crates/ec-av1/src/refusal_inventory.rs +9 -1
- crates/ec-av1/src/stream.rs +325 -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+316 -18
| @@ -1848,6 +1848,22 @@ pub(crate) fn rect_leaf_coeff_hits() -> usize { | ||
| 1848 | 1848 | RECT_LEAF_COEFF_HITS.with(|c| c.get()) |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | +// lane-intrarect r1: how many intra-coded HORZ/VERT strips decoded on the | |
| 1852 | +// INTER block path ([`decode_intra_rect_in_inter`]), per shape class -- | |
| 1853 | +// [0] the superblock-level 64x32/32x64, [1] 32x16/16x32, [2] 16x8/8x16. | |
| 1854 | +// Every one of them was the named refusal "an intra-coded HORZ/VERT strip | |
| 1855 | +// needs rectangular intra prediction" before this round. | |
| 1856 | +thread_local! { | |
| 1857 | + static INTRA_RECT_IN_INTER_HITS: std::cell::Cell<[usize; 3]> = | |
| 1858 | + const { std::cell::Cell::new([0; 3]) }; | |
| 1859 | +} | |
| 1860 | + | |
| 1861 | +/// Current value of [`INTRA_RECT_IN_INTER_HITS`] for one shape class | |
| 1862 | +/// (0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16). | |
| 1863 | +pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { | |
| 1864 | + INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) | |
| 1865 | +} | |
| 1866 | + | |
| 1851 | 1867 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader |
| 1852 | 1868 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an |
| 1853 | 1869 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 |
| @@ -3278,7 +3294,7 @@ fn read_coeffs_rect( | ||
| 3278 | 3294 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 3279 | 3295 | if rect_trace { |
| 3280 | 3296 | eprintln!( |
| 3281 | - "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} all_zero={} rng={}", | |
| 3297 | + "EC_COEFF_STEP tag=all_zero plane=0 ctx={skip_ctx} entry={entry_rng} all_zero={} rng={}", | |
| 3282 | 3298 | all_zero as i32, |
| 3283 | 3299 | dec.debug_state().0 |
| 3284 | 3300 | ); |
| @@ -5672,7 +5688,19 @@ fn decode_rect_split( | ||
| 5672 | 5688 | // own (always DC_PRED) mode -- [`read_plane`] applies that |
| 5673 | 5689 | // for the square arm, so this one must too. |
| 5674 | 5690 | let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; |
| 5675 | - let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | |
| 5691 | + // libaom `get_txb_ctx`: a LUMA transform that covers its whole | |
| 5692 | + // block (`plane_bsize == txsize_to_bsize[tx_size]`, i.e. the | |
| 5693 | + // unsplit depth-0 strip) reads txb_skip ctx 0 flat -- the | |
| 5694 | + // neighbour-magnitude table is for a unit SMALLER than its | |
| 5695 | + // block. [`decode_block_rect`]'s own unsplit read passes a | |
| 5696 | + // literal 0 for the same reason; this arm applied the table | |
| 5697 | + // unconditionally and desynced every depth-0 rect strip that | |
| 5698 | + // reached it (lane-intrarect r2: ctx 5 where aomdec read 0). | |
| 5699 | + let tu_skip_ctx = if tx_w == bw && tx_h == bh { | |
| 5700 | + 0 | |
| 5701 | + } else { | |
| 5702 | + neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI) | |
| 5703 | + }; | |
| 5676 | 5704 | let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); |
| 5677 | 5705 | let (tu_grid, tu_tx_type) = read_coeffs_rect( |
| 5678 | 5706 | dec, |
| @@ -5850,6 +5878,211 @@ fn decode_rect_split( | ||
| 5850 | 5878 | Ok(()) |
| 5851 | 5879 | } |
| 5852 | 5880 | |
| 5881 | +/// One intra-coded HORZ/VERT strip on the INTER block path (lane-intrarect | |
| 5882 | +/// r1) -- the shape [`decode_inter_block`]'s intra arm refused by name | |
| 5883 | +/// because it predicts squares only. Every pixel here goes through the rect | |
| 5884 | +/// machinery the key-frame paths already prove: [`decode_rect_split`], which | |
| 5885 | +/// at `depth == 0` is the unsplit strip as a single transform unit and | |
| 5886 | +/// beyond it the per-unit walk of [`depth_to_tx_wh`]. | |
| 5887 | +/// | |
| 5888 | +/// What is genuinely different from [`decode_block_rect`] is the mode | |
| 5889 | +/// syntax: on an inter frame an intra block reads `y_mode[size_group]` and | |
| 5890 | +/// `uv_mode` (libaom `read_intra_block_mode_info`, decodemv.c:1065), never | |
| 5891 | +/// the key frame's `kf_y_mode` above/left pair. This mirrors the square | |
| 5892 | +/// intra-in-inter arm's own reads at the rect footprint, including its | |
| 5893 | +/// inherited gaps -- no `use_filter_intra` symbol (every inter gate recipe | |
| 5894 | +/// pins `--enable-filter-intra=0`; lane-fiinter owns that read for both the | |
| 5895 | +/// square and this arm) and a nonzero luma angle delta refused by name. | |
| 5896 | +/// | |
| 5897 | +/// The strip's own neighbour records (luma per transform unit, chroma, skip | |
| 5898 | +/// grid, deblock grid) are [`decode_rect_split`]'s; the caller adds the | |
| 5899 | +/// inter-side bands and the mi map. | |
| 5900 | +#[allow(clippy::too_many_arguments)] | |
| 5901 | +fn decode_intra_rect_in_inter( | |
| 5902 | + dec: &mut SymbolDecoder, | |
| 5903 | + cdfs: &mut Cdfs, | |
| 5904 | + neighbours: &mut Neighbours, | |
| 5905 | + at: (usize, usize), | |
| 5906 | + bw: usize, | |
| 5907 | + bh: usize, | |
| 5908 | + skip: bool, | |
| 5909 | + allow_screen_content_tools: bool, | |
| 5910 | + y: &mut PlaneBuf, | |
| 5911 | + u: &mut PlaneBuf, | |
| 5912 | + v: &mut PlaneBuf, | |
| 5913 | + base_q_idx: u8, | |
| 5914 | +) -> Result<()> { | |
| 5915 | + // `at` is in MI units (the inter path's own unit since lane-inter4); | |
| 5916 | + // `(r, c)` is the enclosing SUB cell the SUB-granular neighbour bands | |
| 5917 | + // below are still keyed by. | |
| 5918 | + let (mi_r, mi_c) = at; | |
| 5919 | + let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | |
| 5920 | + // `size_group_lookup` (libaom common_data.h) and `bsize_to_tx_size_cat` | |
| 5921 | + // (blockd.h) for the three 2:1 strip shapes: BLOCK_16X8 -> group 1 / | |
| 5922 | + // cat 1, BLOCK_32X16 -> 2 / 2, BLOCK_64X32 -> 3 / 3 (the rectsplitx | |
| 5923 | + // finding -- the category is NOT the same for every strip size). | |
| 5924 | + // A 1:4 strip breaks that diagonal (BLOCK_32X8 is group 1 but cat 2), so | |
| 5925 | + // it is refused by name rather than read from the wrong CDF row. | |
| 5926 | + let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) { | |
| 5927 | + (8, 16) => (1usize, 1usize), | |
| 5928 | + (16, 32) => (2, 2), | |
| 5929 | + (32, 64) => (3, 3), | |
| 5930 | + _ => { | |
| 5931 | + return Err(unsupported( | |
| 5932 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | |
| 5933 | + )) | |
| 5934 | + } | |
| 5935 | + }; | |
| 5936 | + // [`read_intra_mode_rect`]'s own refusal: palette/intrabc syntax is | |
| 5937 | + // consumed for square blocks only, so a strip in a screen-content frame | |
| 5938 | + // would skip symbols the encoder wrote. | |
| 5939 | + if allow_screen_content_tools { | |
| 5940 | + return Err(unsupported( | |
| 5941 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax \ | |
| 5942 | + is consumed for square blocks only)", | |
| 5943 | + )); | |
| 5944 | + } | |
| 5945 | + let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | |
| 5946 | + if mode >= 13 { | |
| 5947 | + return Err(unsupported( | |
| 5948 | + "an intra mode this decoder does not code (round 2)", | |
| 5949 | + )); | |
| 5950 | + } | |
| 5951 | + // lane-angleinter (merged on main for the square intra-in-inter arm): | |
| 5952 | + // the delta is read off `angle_delta_cdf[mode - V_PRED]` and feeds the | |
| 5953 | + // directional predictor; this arm refused a nonzero one before the merge. | |
| 5954 | + let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | |
| 5955 | + read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) | |
| 5956 | + } else { | |
| 5957 | + 0 | |
| 5958 | + }; | |
| 5959 | + if angle_delta_y != 0 { | |
| 5960 | + INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | |
| 5961 | + } | |
| 5962 | + // `is_cfl_allowed` (spec 5.11.5) caps CFL at 32x32, so the | |
| 5963 | + // superblock-level strip reads the no-CFL alphabet -- the same split | |
| 5964 | + // [`read_intra_mode_rect`] makes for [`decode_block_rect64`]. | |
| 5965 | + let cfl_allowed = bw.max(bh) <= 32; | |
| 5966 | + let uv_mode = if cfl_allowed { | |
| 5967 | + dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | |
| 5968 | + } else { | |
| 5969 | + dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | |
| 5970 | + }; | |
| 5971 | + if (9..=12).contains(&uv_mode) { | |
| 5972 | + SMOOTH_UV_HITS.with(|h| h.set(h.get() + 1)); | |
| 5973 | + } | |
| 5974 | + let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | |
| 5975 | + Some(read_cfl_alphas(dec, cdfs)) | |
| 5976 | + } else { | |
| 5977 | + None | |
| 5978 | + }; | |
| 5979 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { | |
| 5980 | + DC_PRED | |
| 5981 | + } else { | |
| 5982 | + uv_mode | |
| 5983 | + }; | |
| 5984 | + let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) { | |
| 5985 | + DIRECTIONAL_UV_HITS.with(|h| h.set(h.get() + 1)); | |
| 5986 | + read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED]) | |
| 5987 | + } else { | |
| 5988 | + 0 | |
| 5989 | + }; | |
| 5990 | + if angle_delta_uv != 0 { | |
| 5991 | + UV_ANGLE_DELTA_HITS.with(|h| h.set(h.get() + 1)); | |
| 5992 | + INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|h| h.set(h.get() + 1)); | |
| 5993 | + } | |
| 5994 | + // lane-fiinter (merged on main for the square intra-in-inter arm): | |
| 5995 | + // `read_filter_intra_mode_info` is the tail of | |
| 5996 | + // `read_intra_block_mode_info`, after the palette syntax (refused whole | |
| 5997 | + // above for this shape), and `av1_filter_intra_allowed_bsize` admits the | |
| 5998 | + // 2:1 strips with both sides <= 32 -- their own CDF rows | |
| 5999 | + // ([`filter_intra_size_class_rect`]). | |
| 6000 | + let mut filter_intra = None; | |
| 6001 | + if mode == DC_PRED | |
| 6002 | + && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) | |
| 6003 | + && let Some(class) = filter_intra_size_class_rect(bw, bh) | |
| 6004 | + && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | |
| 6005 | + { | |
| 6006 | + FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | |
| 6007 | + INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1)); | |
| 6008 | + filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | |
| 6009 | + } | |
| 6010 | + // The intra-edge filter type is the NEIGHBOUR's mode (libaom | |
| 6011 | + // `get_filt_type`), luma's off the luma neighbours and chroma's off the | |
| 6012 | + // chroma ones -- [`decode_block_rect`]'s own pair. | |
| 6013 | + let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); | |
| 6014 | + let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | |
| 6015 | + if smooth_neighbor { | |
| 6016 | + SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | |
| 6017 | + } | |
| 6018 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | |
| 6019 | + let depth = if TX_SELECT_INTER.with(std::cell::Cell::get) { | |
| 6020 | + let ctx = tx_size_context_rect(neighbours, (mi_r, mi_c), bw, bh); | |
| 6021 | + match tx_cat { | |
| 6022 | + 1 => dec.symbol(&mut cdfs.tx_size_cat1[ctx]), | |
| 6023 | + 2 => dec.symbol(&mut cdfs.tx_size_cat2[ctx]), | |
| 6024 | + _ => dec.symbol(&mut cdfs.tx_size_cat3[ctx]), | |
| 6025 | + } | |
| 6026 | + } else { | |
| 6027 | + 0 | |
| 6028 | + }; | |
| 6029 | + if depth != 0 { | |
| 6030 | + TX_DEPTH_HITS.with(|h| h.set(h.get() + 1)); | |
| 6031 | + // merge b51719f+lane-intrarect (class merge-cross-product-defect): | |
| 6032 | + // main's 10-bit `split_transform_intra_block` gate reaches this arm | |
| 6033 | + // with a nonzero tx depth, and the split rect-TU walk mis-decodes it | |
| 6034 | + // (2340 luma samples off at seed 51; refusing here restores that gate | |
| 6035 | + // while the depth-0 strip the lane proved keeps decoding). The lane's | |
| 6036 | + // own gate never exercised a split strip. | |
| 6037 | + return Err(unsupported( | |
| 6038 | + "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | |
| 6039 | + )); | |
| 6040 | + } | |
| 6041 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | |
| 6042 | + let modes = RectStripModes { | |
| 6043 | + skip, | |
| 6044 | + mode, | |
| 6045 | + angle_delta_y, | |
| 6046 | + uv_predict_mode, | |
| 6047 | + angle_delta_uv, | |
| 6048 | + alpha, | |
| 6049 | + filter_intra, | |
| 6050 | + smooth_neighbor, | |
| 6051 | + smooth_neighbor_uv, | |
| 6052 | + // screen-content frames are refused whole above, so this strip can | |
| 6053 | + // carry no palette. | |
| 6054 | + palette_y: None, | |
| 6055 | + palette_uv: None, | |
| 6056 | + }; | |
| 6057 | + decode_rect_split( | |
| 6058 | + dec, | |
| 6059 | + cdfs, | |
| 6060 | + neighbours, | |
| 6061 | + (mi_r, mi_c), | |
| 6062 | + bw, | |
| 6063 | + bh, | |
| 6064 | + tx_w, | |
| 6065 | + tx_h, | |
| 6066 | + &modes, | |
| 6067 | + y, | |
| 6068 | + u, | |
| 6069 | + v, | |
| 6070 | + base_q_idx, | |
| 6071 | + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | |
| 6072 | + )?; | |
| 6073 | + let class = match bw.max(bh) { | |
| 6074 | + 64 => 0, | |
| 6075 | + 32 => 1, | |
| 6076 | + _ => 2, | |
| 6077 | + }; | |
| 6078 | + INTRA_RECT_IN_INTER_HITS.with(|h| { | |
| 6079 | + let mut v = h.get(); | |
| 6080 | + v[class] += 1; | |
| 6081 | + h.set(v); | |
| 6082 | + }); | |
| 6083 | + Ok(()) | |
| 6084 | +} | |
| 6085 | + | |
| 5853 | 6086 | /// Decodes one true `bw`x`bh` `PARTITION_HORZ`/`PARTITION_VERT` intra strip |
| 5854 | 6087 | /// (lane-intradisp r1, spec `decode_block` restricted to a 32x32 quadrant's |
| 5855 | 6088 | /// two rect children). Only the `skip` case is supported: `skip`/`y_mode`/ |
| @@ -14879,18 +15112,6 @@ fn decode_inter_block( | ||
| 14879 | 15112 | let whole_sb = side == 64 && write_w == 64 && write_h == 64; |
| 14880 | 15113 | maybe_read_delta_q(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 14881 | 15114 | maybe_read_delta_lf(dec, cdfs, rmi, cmi, whole_sb, skip); |
| 14882 | - // lane-warp r5: see `reject_residual` -- a square-block decode of a | |
| 14883 | - // HORZ_B strip is symbol-exact only for `skip` (no residual, no | |
| 14884 | - // motion_mode/warp symbol), so gate here before any further read. | |
| 14885 | - if reject_residual && !skip && !rect_inter_residual_supported(write_w, write_h) { | |
| 14886 | - if std::env::var_os("EC_AV1_RECT_DUMP").is_some() { | |
| 14887 | - eprintln!("EC_RECT_REFUSE mi_row={rmi} mi_col={cmi} w={write_w} h={write_h} side={side}"); | |
| 14888 | - } | |
| 14889 | - return Err(unsupported( | |
| 14890 | - "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | |
| 14891 | - )); | |
| 14892 | - } | |
| 14893 | - | |
| 14894 | 15115 | let (has_above, has_left) = ( |
| 14895 | 15116 | rmi > neighbours.tile_row0_mi, |
| 14896 | 15117 | cmi > neighbours.tile_col0_mi, |
| @@ -14906,6 +15127,29 @@ fn decode_inter_block( | ||
| 14906 | 15127 | dec.debug_state().0 |
| 14907 | 15128 | ); |
| 14908 | 15129 | } |
| 15130 | + // lane-warp r5: see `reject_residual` -- a square-block decode of a | |
| 15131 | + // HORZ_B strip is symbol-exact only for `skip` (no residual, no | |
| 15132 | + // motion_mode/warp symbol). lane-intrarect r1 MOVED this gate from just | |
| 15133 | + // after the `skip` read to here, past `is_inter` (class | |
| 15134 | + // [[refusal-short-circuits-its-own-code]]: at the old place it refused | |
| 15135 | + // 24/24 attempts of this lane's own gate before the intra arm below | |
| 15136 | + // could run). An INTRA strip with its true `write_w`x`write_h` footprint | |
| 15137 | + // now codes its residual rectangularly ([`decode_intra_rect_in_inter`]); | |
| 15138 | + // an INTER one, and a strip decoded with square dimensions anyway, still | |
| 15139 | + // cannot. | |
| 15140 | + // merge b51719f+lane-intrarect: main's `rect_inter_residual_supported` | |
| 15141 | + // term stays -- lane-inter4's 16x8/8x16 inter leaves DO code a | |
| 15142 | + // rectangular residual, and the lane's condition (written before that | |
| 15143 | + // landed) refused every one of them. | |
| 15144 | + if reject_residual | |
| 15145 | + && !skip | |
| 15146 | + && !rect_inter_residual_supported(write_w, write_h) | |
| 15147 | + && (is_inter || (write_w == side && write_h == side)) | |
| 15148 | + { | |
| 15149 | + return Err(unsupported( | |
| 15150 | + "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | |
| 15151 | + )); | |
| 15152 | + } | |
| 14909 | 15153 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 14910 | 15154 | eprintln!( |
| 14911 | 15155 | "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}", |
| @@ -16917,10 +17161,64 @@ fn decode_inter_block( | ||
| 16917 | 17161 | // already-square-predicted buffer). Named refusal instead of a |
| 16918 | 17162 | // silently wrong square-shaped intra prediction. |
| 16919 | 17163 | if write_w != side || write_h != side { |
| 16920 | - return Err(unsupported( | |
| 16921 | - "an intra-coded HORZ/VERT strip needs rectangular intra prediction \ | |
| 16922 | - this decoder does not code yet", | |
| 16923 | - )); | |
| 17164 | + // lane-intrarect r1: the strip decodes through its own rect | |
| 17165 | + // machinery ([`decode_intra_rect_in_inter`] -> the key-frame | |
| 17166 | + // paths' [`decode_rect_split`]) instead of refusing. That call | |
| 17167 | + // already writes everything the shared tail below would for a | |
| 17168 | + // square block EXCEPT the inter-side bands and the mi map, so | |
| 17169 | + // this arm returns rather than falling through (a second | |
| 17170 | + // `record_rect`/`fill_lf_grid_rect` at block granularity would | |
| 17171 | + // overwrite the per-transform-unit records it just made). | |
| 17172 | + decode_intra_rect_in_inter( | |
| 17173 | + dec, | |
| 17174 | + cdfs, | |
| 17175 | + neighbours, | |
| 17176 | + at, | |
| 17177 | + write_w, | |
| 17178 | + write_h, | |
| 17179 | + skip, | |
| 17180 | + allow_screen_content_tools, | |
| 17181 | + y, | |
| 17182 | + u, | |
| 17183 | + v, | |
| 17184 | + base_q_idx, | |
| 17185 | + )?; | |
| 17186 | + // merge b51719f+lane-intrarect: `at` is in MI units on this path | |
| 17187 | + // (lane-inter4), so the strip's mi origin is `at` itself -- the | |
| 17188 | + // lane's `r * SUB_MI` re-derivation would snap a sub-SUB strip to | |
| 17189 | + // its enclosing 16-px cell. | |
| 17190 | + let (mi_r0, mi_c0) = (rmi, cmi); | |
| 17191 | + for dr in 0..write_h / MI { | |
| 17192 | + for dc in 0..write_w / MI { | |
| 17193 | + grid.set( | |
| 17194 | + mi_r0 + dr, | |
| 17195 | + mi_c0 + dc, | |
| 17196 | + MiInfo { | |
| 17197 | + is_inter: false, | |
| 17198 | + ref_frame: -1, | |
| 17199 | + ref_frame1: None, | |
| 17200 | + mv1: None, | |
| 17201 | + mv: (0, 0), | |
| 17202 | + is_new_mv: false, | |
| 17203 | + size: write_w / MI, | |
| 17204 | + size_h: write_h / MI, | |
| 17205 | + is_global_mv0: false, | |
| 17206 | + is_global_mv1: false, | |
| 17207 | + }, | |
| 17208 | + ); | |
| 17209 | + } | |
| 17210 | + } | |
| 17211 | + neighbours.record_inter_rect_mi( | |
| 17212 | + at, | |
| 17213 | + write_w / MI, | |
| 17214 | + write_h / MI, | |
| 17215 | + skip, | |
| 17216 | + false, | |
| 17217 | + 0, | |
| 17218 | + [3, 3], | |
| 17219 | + skip_mode, | |
| 17220 | + ); | |
| 17221 | + return Ok(()); | |
| 16924 | 17222 | } |
| 16925 | 17223 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 16926 | 17224 | if mode >= 13 { |
crates/ec-av1/src/refusal_inventory.rsmodified+9 -1
| @@ -69,7 +69,15 @@ const REFUSALS: &[&str] = &[ | ||
| 69 | 69 | "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 | 70 | "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 | 71 | "an intra mode this decoder does not code (round 2)", |
| 72 | - "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", | |
| 72 | + // lane-intrarect r1 lifted the whole-shape refusal that stood here (the | |
| 73 | + // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); | |
| 74 | + // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the | |
| 75 | + // size-group/category diagonal the 2:1 shapes share. | |
| 76 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | |
| 77 | + "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | |
| 78 | + // The same arm's screen-content gate: palette/intrabc syntax is consumed | |
| 79 | + // for square blocks only, so a strip in such a frame would skip symbols. | |
| 80 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", | |
| 73 | 81 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 74 | 82 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 75 | 83 | "a motion_mode symbol for a block shape with no CDF row here", |
crates/ec-av1/src/stream.rsmodified+325 -0
| @@ -4245,6 +4245,331 @@ mod tests { | ||
| 4245 | 4245 | tx_select_inter_gate(10); |
| 4246 | 4246 | } |
| 4247 | 4247 | |
| 4248 | + /// lane-intrarect r1's decisive gate: a real aomenc INTER sequence whose | |
| 4249 | + /// hard mid-GOP content cut makes aomenc code INTRA blocks inside inter | |
| 4250 | + /// frames, with rect partitions ON so those intra blocks land on | |
| 4251 | + /// HORZ/VERT strip shapes. Every such block was the named refusal "an | |
| 4252 | + /// intra-coded HORZ/VERT strip needs rectangular intra prediction this | |
| 4253 | + /// decoder does not code yet" until this round; they now decode through | |
| 4254 | + /// the same `decode_rect_split` machinery the key-frame rect paths use. | |
| 4255 | + /// | |
| 4256 | + /// Hard-asserts per-shape counters (`intra_rect_strip_in_inter_hits`: | |
| 4257 | + /// 0 = 64x32/32x64, 1 = 32x16/16x32, 2 = 16x8/8x16) summed over the | |
| 4258 | + /// attempts that were actually pixel-compared -- at least TWO of the | |
| 4259 | + /// three shape classes must fire, so a green run cannot come from one | |
| 4260 | + /// lucky size. A decode that succeeds is ALWAYS pixel-compared (class | |
| 4261 | + /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without | |
| 4262 | + /// two shapes is a FAILURE, never a SKIP. | |
| 4263 | + #[test] | |
| 4264 | + fn a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact() { | |
| 4265 | + intra_rect_in_inter_gate(8); | |
| 4266 | + } | |
| 4267 | + | |
| 4268 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | |
| 4269 | + #[test] | |
| 4270 | + fn a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact_10bit() { | |
| 4271 | + intra_rect_in_inter_gate(10); | |
| 4272 | + } | |
| 4273 | + | |
| 4274 | + fn intra_rect_in_inter_gate(bit_depth: u32) { | |
| 4275 | + const NAME: &str = "a_real_aomenc_inter_sequence_with_an_intra_rect_strip_decodes_pixel_exact"; | |
| 4276 | + if !have_ffmpeg() { | |
| 4277 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 4278 | + return; | |
| 4279 | + } | |
| 4280 | + if !have_aomenc() { | |
| 4281 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 4282 | + return; | |
| 4283 | + } | |
| 4284 | + let (width, height, frame_count) = (96usize, 96usize, 8usize); | |
| 4285 | + let mut refusals: Vec<String> = Vec::new(); | |
| 4286 | + let mut uncounted_exact = 0u32; | |
| 4287 | + let mut compared = 0u32; | |
| 4288 | + let mut shapes = [0usize; 3]; | |
| 4289 | + for attempt in 0..45u32 { | |
| 4290 | + let seed = 42 + attempt; | |
| 4291 | + // mandelbrot's fractal detail plus a HARD cut at frame 4: half | |
| 4292 | + // the picture becomes a flat white box, which no motion vector | |
| 4293 | + // can predict, so aomenc's RD codes those blocks INTRA inside an | |
| 4294 | + // inter frame. The box's vertical edge at x=48 is what makes the | |
| 4295 | + // partition search reach for HORZ/VERT strips there. | |
| 4296 | + // A FAST ZOOM: `end_scale`/`end_pts` make mandelbrot rush | |
| 4297 | + // through its own zoom, so consecutive frames share almost no | |
| 4298 | + // content and aomenc's RD codes blocks INTRA inside INTER frames | |
| 4299 | + // (`--kf-min-dist=1000` forbids a new key frame). That is the | |
| 4300 | + // only way a real encoder reaches this decoder's intra-in-inter | |
| 4301 | + // arm; a slowly-evolving source codes every rect strip inter. | |
| 4302 | + let source = format!( | |
| 4303 | + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", | |
| 4304 | + 5.0 - f64::from(attempt) * 0.06 | |
| 4305 | + ); | |
| 4306 | + let y4m = Command::new("ffmpeg") | |
| 4307 | + .args([ | |
| 4308 | + "-v", | |
| 4309 | + "error", | |
| 4310 | + "-f", | |
| 4311 | + "lavfi", | |
| 4312 | + "-i", | |
| 4313 | + &source, | |
| 4314 | + "-vf", | |
| 4315 | + "hue=s=0", | |
| 4316 | + "-pix_fmt", | |
| 4317 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | |
| 4318 | + "-strict", | |
| 4319 | + "-1", | |
| 4320 | + "-t", | |
| 4321 | + "0.32", | |
| 4322 | + "-f", | |
| 4323 | + "yuv4mpegpipe", | |
| 4324 | + "-strict", | |
| 4325 | + "-1", | |
| 4326 | + "-", | |
| 4327 | + ]) | |
| 4328 | + .stdin(Stdio::null()) | |
| 4329 | + .stdout(Stdio::piped()) | |
| 4330 | + .stderr(Stdio::piped()) | |
| 4331 | + .output() | |
| 4332 | + .expect("ffmpeg failed to run"); | |
| 4333 | + assert!( | |
| 4334 | + y4m.status.success(), | |
| 4335 | + "ffmpeg fixture: {}", | |
| 4336 | + String::from_utf8_lossy(&y4m.stderr) | |
| 4337 | + ); | |
| 4338 | + let depth_args: &[&str] = if bit_depth == 10 { | |
| 4339 | + &["-b", "10", "--input-bit-depth=10"] | |
| 4340 | + } else { | |
| 4341 | + &[] | |
| 4342 | + }; | |
| 4343 | + // MEASURED (r1): the speed preset gates the feature (class | |
| 4344 | + // [[gate-preset-gates-the-feature]]) -- at `--cpu-used=4` this | |
| 4345 | + // content produces no rect partition at all, at `--cpu-used=0` | |
| 4346 | + // aomenc emits AB partitions the tile path refuses (it ignores | |
| 4347 | + // `--enable-ab-partitions=0`, ledger). So the attempt sweep walks | |
| 4348 | + // the preset as well as the seed. | |
| 4349 | + let cpu = format!("--cpu-used={}", attempt % 5); | |
| 4350 | + // The quantiser drives how finely the RD partitions: the sweep | |
| 4351 | + // walks it too, so "no rect strip fired" cannot be an artefact of | |
| 4352 | + // one cq. | |
| 4353 | + let cq = format!("--cq-level={}", [30u32, 20, 12][(attempt / 5) as usize % 3]); | |
| 4354 | + let mut child = Command::new(aomenc_path()) | |
| 4355 | + .args(depth_args) | |
| 4356 | + .arg(&cpu) | |
| 4357 | + .arg(&cq) | |
| 4358 | + .args([ | |
| 4359 | + // class [[aomenc-first-flag-wins]]: every flag is spelled | |
| 4360 | + // exactly ONCE in this recipe, so there is no override to | |
| 4361 | + // order. These four are what this gate is about. | |
| 4362 | + "--enable-rect-partitions=1", | |
| 4363 | + // MEASURED (r1): the charter's `--min-partition-size=8` | |
| 4364 | + // makes 24/24 attempts stop at a sub-16 AB-partition | |
| 4365 | + // refusal ("a HORZ_A/HORZ_B/VERT_A partition below 16x16", | |
| 4366 | + // "a coded (non-skip) HORZ_B/VERT_B rect strip below | |
| 4367 | + // 16x16") before any intra rect strip is reached -- those | |
| 4368 | + // are other lanes' surfaces. 16 keeps the 16x8/8x16 shape | |
| 4369 | + // reachable (a 16x16 block's own HORZ/VERT children). | |
| 4370 | + "--min-partition-size=16", | |
| 4371 | + "--max-partition-size=64", | |
| 4372 | + // MEASURED (r1): with tx-size search ON, 24/24 attempts stop at | |
| 4373 | + // the SQUARE intra-in-inter arm's own refusal ("an intra | |
| 4374 | + // block in an inter frame whose tx_depth splits its luma | |
| 4375 | + // transform (round 1)", read_block_tx_size) long before a | |
| 4376 | + // rect strip is reached -- that arm is another lane's | |
| 4377 | + // surface. OFF, no tx-depth symbol is coded at all and | |
| 4378 | + // every rect strip here is the unsplit single-transform | |
| 4379 | + // case. The SPLIT rect arm (`depth_to_tx_wh` + | |
| 4380 | + // decode_rect_split's per-unit walk) is wired but stays | |
| 4381 | + // UNGATED on this path until that square refusal lifts. | |
| 4382 | + "--enable-tx-size-search=0", | |
| 4383 | + "--codec=av1", | |
| 4384 | + "--passes=1", | |
| 4385 | + "--end-usage=q", | |
| 4386 | + "--lag-in-frames=0", | |
| 4387 | + "--auto-alt-ref=0", | |
| 4388 | + // One key frame at the head: the frames after the cut must | |
| 4389 | + // stay INTER frames carrying intra blocks, not become a | |
| 4390 | + // new key frame. | |
| 4391 | + "--kf-min-dist=1000", | |
| 4392 | + "--kf-max-dist=1000", | |
| 4393 | + "--threads=1", | |
| 4394 | + "--row-mt=0", | |
| 4395 | + "--enable-order-hint=0", | |
| 4396 | + "--enable-warped-motion=0", | |
| 4397 | + "--enable-obmc=0", | |
| 4398 | + "--enable-masked-comp=0", | |
| 4399 | + "--enable-interintra-comp=0", | |
| 4400 | + "--enable-dist-wtd-comp=0", | |
| 4401 | + "--enable-diff-wtd-comp=0", | |
| 4402 | + "--enable-onesided-comp=0", | |
| 4403 | + "--enable-interintra-wedge=0", | |
| 4404 | + "--enable-smooth-interintra=0", | |
| 4405 | + "--enable-ab-partitions=0", | |
| 4406 | + "--enable-1to4-partitions=0", | |
| 4407 | + // The intra-in-inter arm reads no `use_filter_intra` | |
| 4408 | + // symbol (square OR rect) -- lane-fiinter owns that read. | |
| 4409 | + "--enable-filter-intra=0", | |
| 4410 | + "--enable-smooth-intra=0", | |
| 4411 | + "--enable-paeth-intra=0", | |
| 4412 | + "--enable-directional-intra=0", | |
| 4413 | + "--enable-angle-delta=0", | |
| 4414 | + "--enable-cdef=0", | |
| 4415 | + "--enable-restoration=0", | |
| 4416 | + "--enable-palette=0", | |
| 4417 | + "--enable-intrabc=0", | |
| 4418 | + "--enable-cfl-intra=0", | |
| 4419 | + "--enable-ref-frame-mvs=0", | |
| 4420 | + "--obu", | |
| 4421 | + "-o", | |
| 4422 | + "-", | |
| 4423 | + "-", | |
| 4424 | + ]) | |
| 4425 | + .stdin(Stdio::piped()) | |
| 4426 | + .stdout(Stdio::piped()) | |
| 4427 | + .stderr(Stdio::piped()) | |
| 4428 | + .spawn() | |
| 4429 | + .expect("aomenc failed to start"); | |
| 4430 | + child | |
| 4431 | + .stdin | |
| 4432 | + .take() | |
| 4433 | + .expect("aomenc stdin") | |
| 4434 | + .write_all(&y4m.stdout) | |
| 4435 | + .expect("writing y4m to aomenc"); | |
| 4436 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 4437 | + assert!( | |
| 4438 | + out.status.success(), | |
| 4439 | + "aomenc refused the fixture: {}", | |
| 4440 | + String::from_utf8_lossy(&out.stderr) | |
| 4441 | + ); | |
| 4442 | + let stream = out.stdout; | |
| 4443 | + let before = [ | |
| 4444 | + decode::intra_rect_strip_in_inter_hits(0), | |
| 4445 | + decode::intra_rect_strip_in_inter_hits(1), | |
| 4446 | + decode::intra_rect_strip_in_inter_hits(2), | |
| 4447 | + ]; | |
| 4448 | + let kf_rect_before = decode::rect_partition_hits(); | |
| 4449 | + let frames = match decode_stream(&stream) { | |
| 4450 | + Ok(frames) => frames, | |
| 4451 | + Err(e) => { | |
| 4452 | + let msg = e.to_string(); | |
| 4453 | + assert!( | |
| 4454 | + msg.contains("unsupported"), | |
| 4455 | + "intra-rect-in-inter decode failed outright (seed {seed}): {msg}" | |
| 4456 | + ); | |
| 4457 | + refusals.push(format!("seed {seed} {cpu} {cq}: {msg}")); | |
| 4458 | + continue; | |
| 4459 | + } | |
| 4460 | + }; | |
| 4461 | + let delta = [ | |
| 4462 | + decode::intra_rect_strip_in_inter_hits(0) - before[0], | |
| 4463 | + decode::intra_rect_strip_in_inter_hits(1) - before[1], | |
| 4464 | + decode::intra_rect_strip_in_inter_hits(2) - before[2], | |
| 4465 | + ]; | |
| 4466 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 4467 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 4468 | + } else { | |
| 4469 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 4470 | + }; | |
| 4471 | + assert_eq!(frames.len(), frame_count); | |
| 4472 | + eprintln!( | |
| 4473 | + "intrarect gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra rect strips in inter frames \ | |
| 4474 | + 64-level={} 32-level={} 16-level={}, key-frame rect strips this stream={}", | |
| 4475 | + delta[0], delta[1], delta[2], | |
| 4476 | + decode::rect_partition_hits() - kf_rect_before | |
| 4477 | + ); | |
| 4478 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 4479 | + for (plane, (g, w)) in [ | |
| 4480 | + ("Y", (&got.y, &want.y)), | |
| 4481 | + ("U", (&got.u, &want.u)), | |
| 4482 | + ("V", (&got.v, &want.v)), | |
| 4483 | + ] { | |
| 4484 | + let stride = if plane == "Y" { width } else { width / 2 }; | |
| 4485 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | |
| 4486 | + eprintln!( | |
| 4487 | + "intrarect gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \ | |
| 4488 | + diff at ({}, {}) got {} want {} ({} samples differ)", | |
| 4489 | + at % stride, | |
| 4490 | + at / stride, | |
| 4491 | + g[at], | |
| 4492 | + w[at], | |
| 4493 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | |
| 4494 | + ); | |
| 4495 | + // Magnitude separates a deblock/prediction difference | |
| 4496 | + // (all |d| == 1) from an entropy desync (large, | |
| 4497 | + // arbitrary): the first thing r2 needs to know. | |
| 4498 | + let maxd = g | |
| 4499 | + .iter() | |
| 4500 | + .zip(w.iter()) | |
| 4501 | + .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b))) | |
| 4502 | + .max() | |
| 4503 | + .unwrap_or(0); | |
| 4504 | + let rows: std::collections::BTreeSet<usize> = g | |
| 4505 | + .iter() | |
| 4506 | + .zip(w.iter()) | |
| 4507 | + .enumerate() | |
| 4508 | + .filter(|(_, (a, b))| a != b) | |
| 4509 | + .map(|(k, _)| k / stride) | |
| 4510 | + .collect(); | |
| 4511 | + eprintln!( | |
| 4512 | + "intrarect gate {bit_depth}-bit seed={seed}: frame {i} {plane} max \ | |
| 4513 | + |diff|={maxd}, rows {:?}..{:?}", | |
| 4514 | + rows.iter().next(), | |
| 4515 | + rows.iter().next_back() | |
| 4516 | + ); | |
| 4517 | + } | |
| 4518 | + assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})"); | |
| 4519 | + } | |
| 4520 | + } | |
| 4521 | + compared += 1; | |
| 4522 | + if delta.iter().all(|d| *d == 0) { | |
| 4523 | + uncounted_exact += 1; | |
| 4524 | + refusals.push(format!( | |
| 4525 | + "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra rect strip on the \ | |
| 4526 | + inter path" | |
| 4527 | + )); | |
| 4528 | + } | |
| 4529 | + for k in 0..3 { | |
| 4530 | + shapes[k] += delta[k]; | |
| 4531 | + } | |
| 4532 | + if shapes.iter().filter(|n| **n > 0).count() >= 2 { | |
| 4533 | + break; | |
| 4534 | + } | |
| 4535 | + } | |
| 4536 | + gate_buckets( | |
| 4537 | + NAME, | |
| 4538 | + compared - uncounted_exact, | |
| 4539 | + uncounted_exact, | |
| 4540 | + refusals.len() - uncounted_exact as usize, | |
| 4541 | + ); | |
| 4542 | + eprintln!( | |
| 4543 | + "{NAME} ({bit_depth}-bit): compared {compared} streams, intra rect strips in inter \ | |
| 4544 | + frames per shape: 64x32/32x64={} 32x16/16x32={} 16x8/8x16={}; refusals:\n{}", | |
| 4545 | + shapes[0], | |
| 4546 | + shapes[1], | |
| 4547 | + shapes[2], | |
| 4548 | + refusals.join("\n") | |
| 4549 | + ); | |
| 4550 | + assert!( | |
| 4551 | + compared > 0, | |
| 4552 | + "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \ | |
| 4553 | + pixel-compared:\n{}", | |
| 4554 | + refusals.join("\n") | |
| 4555 | + ); | |
| 4556 | + // MEASURED (r1, 90 attempts; r2 re-ran the 45-attempt sweep at both | |
| 4557 | + // depths): only the 32x16/16x32 class is REACHABLE on this branch -- | |
| 4558 | + // the inter tile path refuses any SB-level partition other than | |
| 4559 | + // NONE/SPLIT, so a 64x32/32x64 intra strip cannot be produced at all, | |
| 4560 | + // and every 16x8/8x16 candidate stops at a sub-16 refusal owned by | |
| 4561 | + // another lane. So the bar is that class, hard, not "two of three": | |
| 4562 | + // a green run still cannot come from a stream that fired nothing. | |
| 4563 | + assert!( | |
| 4564 | + shapes[1] > 0, | |
| 4565 | + "{NAME} ({bit_depth}-bit): no 32x16/16x32 intra rect strip fired over \ | |
| 4566 | + {compared} compared streams (64-level={} 32-level={} 16-level={})", | |
| 4567 | + shapes[0], | |
| 4568 | + shapes[1], | |
| 4569 | + shapes[2] | |
| 4570 | + ); | |
| 4571 | + } | |
| 4572 | + | |
| 4248 | 4573 | fn tx_select_inter_gate(bit_depth: u32) { |
| 4249 | 4574 | if !have_ffmpeg() { |
| 4250 | 4575 | eprintln!( |
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`), | |
| 4 | -C-verified for 8 rect shapes across DC/SMOOTH/PAETH + 17 directional angles | |
| 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. | |
| 3 | +Branch `lane-intrarect` off `lane-rectsplitx` cbf8ffd. **Result: code landed, gate RED | |
| 4 | +(one real residual defect, evidence below). The lane does not merge in this state.** | |
| 8 | 5 | |
| 9 | 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) | |
| 41 | -`lanes/intrarect_dump.c`: standalone C, **not linked against the built | |
| 42 | -oracle** (linking libaom's actual `.o`s pulled in RTCD/aom_config | |
| 43 | -dependencies past this lane's budget) -- an independent hand-transcription | |
| 44 | -of `aom_dsp/intrapred.c`'s `dc_predictor_rect`/`smooth_predictor`/ | |
| 45 | -`paeth_predictor` and `av1/common/reconintra.c`'s | |
| 46 | -`av1_dr_prediction_z1/z2/z3_c` + `intra_edge_filter_strength` + | |
| 47 | -`av1_use_intra_edge_upsample` + `av1_filter_intra_edge_c` + | |
| 48 | -`av1_upsample_intra_edge_c`, read fresh from `~/.cache/aom-oracle/src` this | |
| 49 | -round (same independent-transcription pattern `lanes/wedge_dump.c` used, | |
| 50 | -per the charter's shared-oracle-blindness note). | |
| 8 | +- `crates/ec-av1/src/decode.rs` (`decode_intra_rect_in_inter`, new, right before | |
| 9 | + `decode_block_rect`): an intra-coded HORZ/VERT strip on the inter block path reads its | |
| 10 | + mode info with the INTER frame's own intra syntax (`y_mode[size_group]` / | |
| 11 | + `uv_mode_cfl|uv_mode_no_cfl` / cfl alphas / uv angle delta — mirroring the square | |
| 12 | + intra-in-inter arm, including its inherited gaps: no `use_filter_intra` symbol, nonzero | |
| 13 | + luma angle delta refused), its tx depth from the shape's own `bsize_to_tx_size_cat` | |
| 14 | + (16x8 -> cat1, 32x16 -> cat2, 64x32 -> cat3, ctx from `tx_size_context_rect`), then hands | |
| 15 | + every pixel to `decode_rect_split` — the same machinery the key-frame rect paths use, which | |
| 16 | + at `depth == 0` is the unsplit single-transform strip. | |
| 17 | +- `crates/ec-av1/src/decode.rs` (`decode_inter_block`, the `write_w != side` arm): calls it | |
| 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`): | |
| 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) | |
| 37 | +## Recipe deviations from the charter (each measured, not chosen) | |
| 60 | 38 | |
| 61 | -**Transcribed-only, not independently C-verified this round**: | |
| 62 | -- `SMOOTH_V_PRED`/`SMOOTH_H_PRED` -- same weight-split code path as | |
| 63 | - `SMOOTH_PRED` (which is verified), not separately dumped | |
| 64 | -- `filter_intra_edge_corner`'s rect gate (`reach >= 24`) -- exercised by the | |
| 65 | - dump's angle/shape sweep whenever it applies, but not isolated as its own | |
| 66 | - case | |
| 67 | -- The `n_top`/`n_left` < full-reach path (a block against the frame edge with | |
| 68 | - fewer real neighbour samples than `bw`/`bh`) -- the dump feeds full-length | |
| 69 | - synthetic neighbours throughout; this is unchanged pre-existing | |
| 70 | - `Edges::build` repeat-extension logic, not something this lane's widening | |
| 71 | - touches structurally, and it's exercised (for squares) by the full suite | |
| 39 | +- `--min-partition-size=8` -> `16`: at 8, 24/24 attempts stop at sub-16 AB refusals | |
| 40 | + ("a HORZ_A/HORZ_B/VERT_A partition below 16x16", "a coded (non-skip) HORZ_B/VERT_B rect | |
| 41 | + strip below 16x16") — other lanes' surfaces. | |
| 42 | +- `--enable-tx-size-search=1` -> `0`: with it on, 24/24 attempts stop at the SQUARE | |
| 43 | + intra-in-inter arm's own refusal ("an intra block in an inter frame whose tx_depth splits | |
| 44 | + its luma transform (round 1)", `read_block_tx_size`). Consequence: **the SPLIT rect arm on | |
| 45 | + the inter path is wired but UNGATED**; only the unsplit strip is exercised. | |
| 46 | +- Content: the charter's mandelbrot + overlay cut never produced an intra rect strip (every | |
| 47 | + rect strip in those streams was INTER, refused by lane-inter4's wall). The fixture that | |
| 48 | + works is a FAST-ZOOM mandelbrot (`end_scale=0.004:end_pts=8`), where consecutive frames | |
| 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 | |
| 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. | |
| 55 | +## Gate result — RED | |
| 83 | 56 | |
| 84 | -## Commits (this worktree, lane-intrarect branch, not pushed) | |
| 85 | -- `bade5c8` feat(av1): widen intra::predict/Edges to rect (bw != bh) | |
| 86 | -- `6813a8a` test(av1): C-verify rect intra predictors against an independent transcription | |
| 57 | +Command: | |
| 58 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrarect EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` | |
| 87 | 59 | |
| 88 | -## Deviations from the charter | |
| 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. | |
| 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. | |
| 96 | 61 | |
| 97 | -## Next lane | |
| 98 | -Flip the KEY-frame tile dispatch (`decode.rs` ~3624/~3841) to accept the | |
| 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. | |
| 62 | +Suite: `335 passed; 2 failed (this lane's two new gates); 29 ignored` — nothing else regressed, | |
| 63 | +`refusal_inventory` and `gate_coverage` green with the moved refusal and the lifted string. | |
| 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 | |
| 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. | |
| 72 | +## Residue | |
| 112 | 73 | |
| 113 | -CORRECTIONS to this report's earlier claims: | |
| 114 | -1. "Fixed a latent `intra_edge_filter_strength` bug (missing `blk_wh<=12` | |
| 115 | - branch)" is OVERSTATED. The branch does exist in reconintra.c:996-997, but | |
| 116 | - it is behaviourally IDENTICAL to its `<=16` successor (both `d >= 40 -> | |
| 117 | - strength 1`), so adding it changes no output for any input. It is a | |
| 118 | - fidelity-of-transcription improvement with zero behavioural effect, not a | |
| 119 | - bug fix. | |
| 120 | -2. The harness's uncovered modes are V_PRED and H_PRED **in addition to** the | |
| 121 | - SMOOTH_V/SMOOTH_H this report named. All four are transcribed-only; the | |
| 122 | - verifier hand-checked SMOOTH_V/H against intrapred.c:115-172 (correct), and | |
| 123 | - V/H are axis-free single-edge reads carrying no rect risk. | |
| 124 | -Also uncovered: `Edges::build`'s repeat-extension branch is never exercised at | |
| 125 | -rect reach (the harness always supplies a full bw+bh neighbour run). | |
| 74 | +- fix-now (r2): the pixel defect above. Frames 0..4 are exact and the magnitudes are small | |
| 75 | + (<= 3 at 8 bit), so this is NOT an entropy desync — the tile stays in sync. The diff band | |
| 76 | + starts at row 58 and runs to the frame bottom, i.e. the strip's own bottom deblock band | |
| 77 | + (edge at y=64 filters rows 57..70) plus everything predicted below it. Look at the deblock | |
| 78 | + records for a rect intra strip on the inter path first (`decode_rect_split`'s | |
| 79 | + `fill_lf_grid_rect` + the `record_inter_rect` the new call site adds), then at prediction; | |
| 80 | + entropy is cleared by construction. | |
| 81 | +- deferred(the square intra-in-inter tx-split refusal in `read_block_tx_size`) — the split | |
| 82 | + rect arm on the inter path is unproven. | |
| 83 | +- deferred(lane-inter4 merge) — 64x32/32x64 and the 16x8/8x16 shape need the inter-side rect | |
| 84 | + work; lane-inter4's `coded_rectangular_residual` gate is NOT on this branch and was not | |
| 85 | + un-ignored. | |
| 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. |