merge: main 48b35ab into lane-intra14 -- MV-stack twins, 128x128 chroma mu chunks, kf1200 chroma pair edges
Browse files at this commit21 changed files +2477 -159
- crates/ec-av1/examples/decode_probe.rs +2 -0
- crates/ec-av1/fixtures/reelb_ss300_key_frame.obu +0 -0
- crates/ec-av1/fixtures/reelc_kf2700.obu +0 -0
- crates/ec-av1/src/cdf.rs +10 -0
- crates/ec-av1/src/cdf_state.rs +21 -8
- crates/ec-av1/src/decode.rs +435 -116
- crates/ec-av1/src/gate_coverage.rs +8 -9
- crates/ec-av1/src/mvstack.rs +199 -18
- crates/ec-av1/src/refusal_inventory.rs +2 -1
- crates/ec-av1/src/stream.rs +746 -7
- lanes/kf1200-r1.report.md +106 -0
- lanes/kf1200-r2.handoff.md +72 -0
- lanes/kf1200-r2.report.md +183 -0
- lanes/mvtwin-r1.report.md +91 -0
- lanes/reelckf-r1.handoff.md +100 -0
- lanes/reelckf-r1.report.md +99 -0
- lanes/reelckf-r2.handoff.md +22 -0
- lanes/reelckf-r2.report.md +80 -0
- lanes/sb128b-r1.report.md +103 -0
- lanes/sb128b-r2.report.md +97 -0
- lanes/sb128b-r3.report.md +101 -0
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
| @@ -29,6 +29,8 @@ fn main() { | |||
| 29 | } | 29 | } |
| 30 | }; | 30 | }; |
| 31 | let report = || { | 31 | let report = || { |
| 32 | + let (sc, dp) = ec_av1::decode::reelc_chroma_counters(); | ||
| 33 | + println!("reelc_chroma: skip_cfl={sc} dir_1to4_pairs={dp}"); | ||
| 32 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); | 34 | let (h, v, c) = ec_av1::stream::rect4_32_counters(); |
| 33 | println!("rect4_32: horz={h} vert={v} coded={c}"); | 35 | println!("rect4_32: horz={h} vert={v} coded={c}"); |
| 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 36 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
crates/ec-av1/fixtures/reelb_ss300_key_frame.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/reelc_kf2700.obuadded+0 -0
Binary file changed
crates/ec-av1/src/cdf.rsmodified+10 -0
| @@ -3167,6 +3167,16 @@ pub const TXB_SKIP_CHROMA_16_Q3: [[u16; 3]; 3] = | |||
| 3167 | /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255. | 3167 | /// TXB_SKIP_CHROMA_32, q-context 3: the same table as [`TXB_SKIP_CHROMA_32`], for `base_q_idx` 121..=255. |
| 3168 | pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] = | 3168 | pub const TXB_SKIP_CHROMA_32_Q3: [[u16; 3]; 3] = |
| 3169 | [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]]; | 3169 | [[4656, 32768, 0], [16074, 32768, 0], [24704, 32768, 0]]; |
| 3170 | + | ||
| 3171 | +/// `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h): libaom's | ||
| 3172 | +/// chroma `txb_skip_ctx` offset is 10 instead of 7 when the plane block is | ||
| 3173 | +/// LARGER than the transform (`get_txb_ctx`), which in AV1 happens only for a | ||
| 3174 | +/// 128x128 block's four TX_32X32 chroma units -- the offset-7 rows above are | ||
| 3175 | +/// every other case (lane-sb128b r3). | ||
| 3176 | +pub const TXB_SKIP_CHROMA_32_BIG_Q0: [[u16; 3]; 3] = [[146, 32768, 0], [5132, 32768, 0], [31657, 32768, 0]]; | ||
| 3177 | +pub const TXB_SKIP_CHROMA_32_BIG_Q1: [[u16; 3]; 3] = [[641, 32768, 0], [22265, 32768, 0], [31452, 32768, 0]]; | ||
| 3178 | +pub const TXB_SKIP_CHROMA_32_BIG: [[u16; 3]; 3] = [[3082, 32768, 0], [20982, 32768, 0], [29443, 32768, 0]]; | ||
| 3179 | +pub const TXB_SKIP_CHROMA_32_BIG_Q3: [[u16; 3]; 3] = [[1806, 32768, 0], [14645, 32768, 0], [25336, 32768, 0]]; | ||
| 3170 | /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255. | 3180 | /// EOB_EXTRA_LUMA_16, q-context 3: the same table as [`EOB_EXTRA_LUMA_16`], for `base_q_idx` 121..=255. |
| 3171 | pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [ | 3181 | pub const EOB_EXTRA_LUMA_16_Q3: [[u16; 3]; 9] = [ |
| 3172 | [19941, 32768, 0], | 3182 | [19941, 32768, 0], |
crates/ec-av1/src/cdf_state.rsmodified+21 -8
| @@ -399,7 +399,10 @@ pub(crate) struct Cdfs { | |||
| 399 | /// The all-zero flag of a 16x16 chroma transform. | 399 | /// The all-zero flag of a 16x16 chroma transform. |
| 400 | pub txb_skip_chroma_16: [[u16; 3]; 3], | 400 | pub txb_skip_chroma_16: [[u16; 3]; 3], |
| 401 | /// The all-zero flag of a 32x32 chroma transform. | 401 | /// The all-zero flag of a 32x32 chroma transform. |
| 402 | - pub txb_skip_chroma_32: [[u16; 3]; 3], | 402 | + /// SIX contexts, not three: rows 0..3 are libaom's `txb_skip_ctx` 7..9 |
| 403 | + /// (chroma transform == its plane block) and rows 3..6 its 10..12 (plane | ||
| 404 | + /// block larger, i.e. a 128x128 block's four TX_32X32 chroma units). | ||
| 405 | + pub txb_skip_chroma_32: [[u16; 3]; 6], | ||
| 403 | /// The end-of-block group of a luma transform of 1024 positions. | 406 | /// The end-of-block group of a luma transform of 1024 positions. |
| 404 | pub eob_pt_1024_luma: [u16; 12], | 407 | pub eob_pt_1024_luma: [u16; 12], |
| 405 | /// The same, for chroma. | 408 | /// The same, for chroma. |
| @@ -1253,13 +1256,23 @@ impl Cdfs { | |||
| 1253 | cdf::TXB_SKIP_CHROMA_16, | 1256 | cdf::TXB_SKIP_CHROMA_16, |
| 1254 | cdf::TXB_SKIP_CHROMA_16_Q3, | 1257 | cdf::TXB_SKIP_CHROMA_16_Q3, |
| 1255 | ), | 1258 | ), |
| 1256 | - txb_skip_chroma_32: pick( | 1259 | + txb_skip_chroma_32: { |
| 1257 | - q_ctx, | 1260 | + let small = pick( |
| 1258 | - cdf::TXB_SKIP_CHROMA_32_Q0, | 1261 | + q_ctx, |
| 1259 | - cdf::TXB_SKIP_CHROMA_32_Q1, | 1262 | + cdf::TXB_SKIP_CHROMA_32_Q0, |
| 1260 | - cdf::TXB_SKIP_CHROMA_32, | 1263 | + cdf::TXB_SKIP_CHROMA_32_Q1, |
| 1261 | - cdf::TXB_SKIP_CHROMA_32_Q3, | 1264 | + cdf::TXB_SKIP_CHROMA_32, |
| 1262 | - ), | 1265 | + cdf::TXB_SKIP_CHROMA_32_Q3, |
| 1266 | + ); | ||
| 1267 | + let big = pick( | ||
| 1268 | + q_ctx, | ||
| 1269 | + cdf::TXB_SKIP_CHROMA_32_BIG_Q0, | ||
| 1270 | + cdf::TXB_SKIP_CHROMA_32_BIG_Q1, | ||
| 1271 | + cdf::TXB_SKIP_CHROMA_32_BIG, | ||
| 1272 | + cdf::TXB_SKIP_CHROMA_32_BIG_Q3, | ||
| 1273 | + ); | ||
| 1274 | + [small[0], small[1], small[2], big[0], big[1], big[2]] | ||
| 1275 | + }, | ||
| 1263 | eob_pt_1024_luma: pick( | 1276 | eob_pt_1024_luma: pick( |
| 1264 | q_ctx, | 1277 | q_ctx, |
| 1265 | cdf::EOB_PT_1024_LUMA_Q0, | 1278 | cdf::EOB_PT_1024_LUMA_Q0, |
crates/ec-av1/src/decode.rsmodified+435 -116
| @@ -310,10 +310,12 @@ fn maybe_read_delta_q(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi_ | |||
| 310 | if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { | 310 | if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { |
| 311 | return; | 311 | return; |
| 312 | } | 312 | } |
| 313 | - // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which | 313 | + // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, |
| 314 | - // it computes against the 64x64 root; under a 128 superblock no leaf this | 314 | + // computed against the sequence's own superblock size (lane-sb128b r1: |
| 315 | - // decoder codes can be the whole superblock (the root is always SPLIT). | 315 | + // it used to be hardcoded against 64 and disabled under `sb128`, which a |
| 316 | - if is_whole_sb && !sb128() && skip { | 316 | + // `PARTITION_NONE` 128x128 root -- itself the whole superblock -- makes |
| 317 | + // wrong). | ||
| 318 | + if is_whole_sb && skip { | ||
| 317 | return; | 319 | return; |
| 318 | } | 320 | } |
| 319 | let mut abs = dec.symbol(&mut cdfs.delta_q) as i32; | 321 | let mut abs = dec.symbol(&mut cdfs.delta_q) as i32; |
| @@ -369,10 +371,12 @@ fn maybe_read_delta_lf(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, mi_r: usize, mi | |||
| 369 | if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { | 371 | if mi_r % sb_mi != 0 || mi_c % sb_mi != 0 { |
| 370 | return; | 372 | return; |
| 371 | } | 373 | } |
| 372 | - // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, which | 374 | + // `is_whole_sb` is the caller's "this leaf IS the superblock" flag, |
| 373 | - // it computes against the 64x64 root; under a 128 superblock no leaf this | 375 | + // computed against the sequence's own superblock size (lane-sb128b r1: |
| 374 | - // decoder codes can be the whole superblock (the root is always SPLIT). | 376 | + // it used to be hardcoded against 64 and disabled under `sb128`, which a |
| 375 | - if is_whole_sb && !sb128() && skip { | 377 | + // `PARTITION_NONE` 128x128 root -- itself the whole superblock -- makes |
| 378 | + // wrong). | ||
| 379 | + if is_whole_sb && skip { | ||
| 376 | return; | 380 | return; |
| 377 | } | 381 | } |
| 378 | let multi = DELTA_LF_MULTI.with(|c| c.get()); | 382 | let multi = DELTA_LF_MULTI.with(|c| c.get()); |
| @@ -2220,6 +2224,44 @@ thread_local! { | |||
| 2220 | static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2224 | static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2221 | static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2225 | static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2222 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2226 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2227 | + /// lane-kf1200: pairs whose chroma edge-filter type read from the PAIR's | ||
| 2228 | + /// base mi differs from what the strip's own (odd) mi would have said -- | ||
| 2229 | + /// the shape that made 4 chroma samples of the ReelB `-ss 1200` | ||
| 2230 | + /// key frame miss by 1. Zero here means a gate never exercised the fix. | ||
| 2231 | + static RECT4_16_UV_PAIR_FILT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2232 | + /// lane-kf1200 r2: sub-8x8 chroma blocks that are `skip_txfm` AND | ||
| 2233 | + /// `UV_CFL_PRED` -- the arm that used to drop the CfL alpha entirely. | ||
| 2234 | + static SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2235 | +} | ||
| 2236 | + | ||
| 2237 | +/// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape | ||
| 2238 | +/// that reconstructed as flat DC before lane-kf1200 r2). | ||
| 2239 | +pub fn skip_cfl_hits() -> usize { | ||
| 2240 | + SKIP_CFL_HITS.with(|c| c.get()) | ||
| 2241 | +} | ||
| 2242 | + | ||
| 2243 | +/// How many 16x4/4x16 chroma pairs took a different `intra_edge_filter_type` | ||
| 2244 | +/// from the pair's base mi than the strip's own mi would have given. | ||
| 2245 | +pub fn rect4_16_uv_pair_filt_hits() -> usize { | ||
| 2246 | + RECT4_16_UV_PAIR_FILT_HITS.with(|c| c.get()) | ||
| 2247 | +} | ||
| 2248 | + | ||
| 2249 | +// lane-reelckf r1: the two chroma defects ReelC's key frames exposed -- | ||
| 2250 | +// CHROMA_SKIP_CFL counts skipped intra blocks whose chroma is `UV_CFL_PRED` | ||
| 2251 | +// (prediction still runs, libaom `predict_and_reconstruct_intra_block`), and | ||
| 2252 | +// RECT4_16_CHROMA_DIR counts 1:4 chroma pairs predicted directionally (whose | ||
| 2253 | +// intra-edge filter type must come from the chroma-reference position). | ||
| 2254 | +thread_local! { | ||
| 2255 | + static CHROMA_SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2256 | + static RECT4_16_CHROMA_DIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2257 | +} | ||
| 2258 | + | ||
| 2259 | +/// `(skipped UV_CFL_PRED blocks, directional 1:4 chroma pairs)` -- lane-reelckf. | ||
| 2260 | +pub fn reelc_chroma_counters() -> (usize, usize) { | ||
| 2261 | + ( | ||
| 2262 | + CHROMA_SKIP_CFL_HITS.with(|c| c.get()), | ||
| 2263 | + RECT4_16_CHROMA_DIR_HITS.with(|c| c.get()), | ||
| 2264 | + ) | ||
| 2223 | } | 2265 | } |
| 2224 | 2266 | ||
| 2225 | /// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 | 2267 | /// Current values of the 16x16-level 1:4 counters: `(16x4 strips, 4x16 |
| @@ -4886,6 +4928,32 @@ impl Neighbours { | |||
| 4886 | self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid); | 4928 | self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid); |
| 4887 | } | 4929 | } |
| 4888 | 4930 | ||
| 4931 | + /// [`Self::record_mi_luma`] for ONE CHROMA transform unit of a block whose | ||
| 4932 | + /// uv plane block is several units (lane-sb128b r2: a 128x128 block's | ||
| 4933 | + /// 64x64 uv plane block is four TX_32X32 units, `av1_get_max_uv_txsize`). | ||
| 4934 | + /// `w_px`/`h_px` are the unit's extent in LUMA pixels -- the chroma | ||
| 4935 | + /// coefficient-context arrays are indexed by luma mi, the convention | ||
| 4936 | + /// [`Self::record_split_luma_rect_mi`] already writes them in, frame-edge | ||
| 4937 | + /// clamp included. | ||
| 4938 | + fn record_mi_chroma( | ||
| 4939 | + &mut self, | ||
| 4940 | + (mi_r, mi_c): (usize, usize), | ||
| 4941 | + w_px: usize, | ||
| 4942 | + h_px: usize, | ||
| 4943 | + plane: usize, | ||
| 4944 | + grid: &[i32], | ||
| 4945 | + ) { | ||
| 4946 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | ||
| 4947 | + let (bound_h, bound_w) = (round_up_even(self.mi_rows), round_up_even(self.mi_cols)); | ||
| 4948 | + let state = neighbour_state(grid); | ||
| 4949 | + for cell in 0..(h_px / MI).min(bound_h.saturating_sub(mi_r)) { | ||
| 4950 | + self.left[mi_r + cell][plane] = state; | ||
| 4951 | + } | ||
| 4952 | + for cell in 0..(w_px / MI).min(bound_w.saturating_sub(mi_c)) { | ||
| 4953 | + self.above[mi_c + cell][plane] = state; | ||
| 4954 | + } | ||
| 4955 | + } | ||
| 4956 | + | ||
| 4889 | /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx | 4957 | /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx |
| 4890 | /// r1): the above context spans the unit's width, the left context its | 4958 | /// r1): the above context spans the unit's width, the left context its |
| 4891 | /// height, which for a square unit is the same loop it always was. | 4959 | /// height, which for a square unit is the same loop it always was. |
| @@ -7795,11 +7863,38 @@ fn decode_rect4_16( | |||
| 7795 | let (cpx, cpy) = (ppx / 2, ppy / 2); | 7863 | let (cpx, cpy) = (ppx / 2, ppy / 2); |
| 7796 | let (cw, ch) = (pw / 2, ph / 2); | 7864 | let (cw, ch) = (pw / 2, ph / 2); |
| 7797 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 7865 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 7866 | + if (V_PRED..=D67_PRED).contains(&uv_predict_mode) { | ||
| 7867 | + RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7868 | + } | ||
| 7798 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); | 7869 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); |
| 7799 | - let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c); | 7870 | + // lane-kf1200 r1: the chroma edge-filter type reads the neighbours |
| 7871 | + // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s | ||
| 7872 | + // 16x8/8x16 region -- libaom builds `chroma_above_mbmi`/ | ||
| 7873 | + // `chroma_left_mbmi` from `mi[-((mi_row & ss_y) * stride + (mi_col | ||
| 7874 | + // & ss_x))]` (`set_mi_offsets`, av1/common/blockd.h ~1050), i.e. | ||
| 7875 | + // the pair's top-left luma mi, never this leaf's odd row/column. | ||
| 7876 | + // Reading `lmi` here named the leaf directly above (a non-chroma | ||
| 7877 | + // -reference 4-row block, `uv_mode == UV_DC_PRED`) and so lost a | ||
| 7878 | + // SMOOTH neighbour: filt_type 0 instead of 1 turned | ||
| 7879 | + // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a | ||
| 7880 | + // directional chroma strip, moving 4 samples by 1. | ||
| 7881 | + let smooth_neighbor_uv = | ||
| 7882 | + neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | ||
| 7883 | + if smooth_neighbor_uv != neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c) { | ||
| 7884 | + RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7885 | + } | ||
| 7800 | let (u_levels, v_levels) = if skip { | 7886 | let (u_levels, v_levels) = if skip { |
| 7801 | let zeros = vec![0i32; cw * ch]; | 7887 | let zeros = vec![0i32; cw * ch]; |
| 7802 | - for (buf, _plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | 7888 | + // libaom `predict_and_reconstruct_intra_block` (decodeframe.c |
| 7889 | + // ~1000) predicts EVERY plane and only guards the residual on | ||
| 7890 | + // `mbmi->skip_txfm`, so a skipped `UV_CFL_PRED` block is still | ||
| 7891 | + // DC + alpha * luma-AC. Dropping the CfL term here left a | ||
| 7892 | + // chroma-only bounded box on ReelC's key frames. | ||
| 7893 | + let ac = alpha.map(|_| cfl_ac_q3_rect(y, ppx, ppy, pw, ph)); | ||
| 7894 | + if alpha.is_some() { | ||
| 7895 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7896 | + } | ||
| 7897 | + for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | ||
| 7803 | buf.reconstruct_rect( | 7898 | buf.reconstruct_rect( |
| 7804 | cpx, | 7899 | cpx, |
| 7805 | cpy, | 7900 | cpy, |
| @@ -7809,7 +7904,9 @@ fn decode_rect4_16( | |||
| 7809 | angle_delta_uv, | 7904 | angle_delta_uv, |
| 7810 | pair_reach, | 7905 | pair_reach, |
| 7811 | &zeros, | 7906 | &zeros, |
| 7812 | - None, | 7907 | + alpha |
| 7908 | + .zip(ac.as_deref()) | ||
| 7909 | + .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)), | ||
| 7813 | None, | 7910 | None, |
| 7814 | smooth_neighbor_uv, | 7911 | smooth_neighbor_uv, |
| 7815 | ); | 7912 | ); |
| @@ -8515,8 +8612,12 @@ fn read_intra_mode( | |||
| 8515 | // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here. | 8612 | // `segment_id`, `cdef`, `delta_q` -- `cdef` lands right here. |
| 8516 | maybe_read_cdef_idx(dec, mi_r, mi_c, skip); | 8613 | maybe_read_cdef_idx(dec, mi_r, mi_c, skip); |
| 8517 | istep!("cdef", 0); | 8614 | istep!("cdef", 0); |
| 8518 | - maybe_read_delta_q(dec, cdfs, mi_r, mi_c, side == 64, skip); | 8615 | + // lane-sb128b r1: "this leaf IS the superblock" is `side == sb_size`, not |
| 8519 | - maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, side == 64, skip); | 8616 | + // a hardcoded 64 -- a `PARTITION_NONE` 128x128 root is the whole |
| 8617 | + // superblock and skips `delta_q` exactly like a 64 one under a 64 root. | ||
| 8618 | + let whole_sb = side == sb_mi_cur() as usize * 4; | ||
| 8619 | + maybe_read_delta_q(dec, cdfs, mi_r, mi_c, whole_sb, skip); | ||
| 8620 | + maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, whole_sb, skip); | ||
| 8520 | istep!("dq", 0); | 8621 | istep!("dq", 0); |
| 8521 | // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at | 8622 | // `read_intrabc_info` (spec 5.11.13, libaom decodemv.c:693, called at |
| 8522 | // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before | 8623 | // :811 right after `skip_txfm`/`segment_id`/`cdef`/`delta_q` and before |
| @@ -9210,7 +9311,12 @@ fn read_plane( | |||
| 9210 | let skip_ctx = if plane_idx == 0 { | 9311 | let skip_ctx = if plane_idx == 0 { |
| 9211 | luma_skip_ctx.unwrap_or(0) | 9312 | luma_skip_ctx.unwrap_or(0) |
| 9212 | } else { | 9313 | } else { |
| 9213 | - usize::from(around.0) + usize::from(around.1) | 9314 | + // libaom `get_txb_ctx`: a chroma unit's context is |
| 9315 | + // `combine_entropy_contexts(above, left)` plus 7, or plus 10 when the | ||
| 9316 | + // plane block is bigger than the transform. Our chroma tables hold the | ||
| 9317 | + // offset-7 rows first, so the caller adds 3 for the bigger-block case | ||
| 9318 | + // (only a 128x128 block's TX_32X32 chroma units, lane-sb128b r3). | ||
| 9319 | + usize::from(around.0) + usize::from(around.1) + luma_skip_ctx.unwrap_or(0) | ||
| 9214 | }; | 9320 | }; |
| 9215 | // spec 5.11.47/libaom `av1_read_tx_type`: a filter-intra luma block's | 9321 | // spec 5.11.47/libaom `av1_read_tx_type`: a filter-intra luma block's |
| 9216 | // `intra_ext_tx_cdf` row is indexed by `fimode_to_intradir[filter_intra_mode]`, | 9322 | // `intra_ext_tx_cdf` row is indexed by `fimode_to_intradir[filter_intra_mode]`, |
| @@ -9395,7 +9501,11 @@ fn decode_block( | |||
| 9395 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None); | 9501 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None); |
| 9396 | (resolved, if resolved == 64 { 32 } else { resolved }) | 9502 | (resolved, if resolved == 64 { 32 } else { resolved }) |
| 9397 | } else { | 9503 | } else { |
| 9398 | - (side, luma_tx) | 9504 | + // lane-sb128b r1: `max_txsize_rect_lookup[BLOCK_128X128]` is |
| 9505 | + // TX_64X64, so a 128x128 block is always FOUR luma transform units | ||
| 9506 | + // even with `tx_select` off -- the TU loop below, never the | ||
| 9507 | + // single-unit path. | ||
| 9508 | + (side.min(64), luma_tx) | ||
| 9399 | }; | 9509 | }; |
| 9400 | if tx_select && logical_tx < side && uv_mode != DC_PRED { | 9510 | if tx_select && logical_tx < side && uv_mode != DC_PRED { |
| 9401 | SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1)); | 9511 | SQ_CHROMA_TX_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -9500,10 +9610,17 @@ fn decode_block( | |||
| 9500 | // The palette/intrabc override path keeps the single-call shape (its | 9610 | // The palette/intrabc override path keeps the single-call shape (its |
| 9501 | // per-TU windowing is the non-skip loop's own `palette_y_buf` slice, | 9611 | // per-TU windowing is the non-skip loop's own `palette_y_buf` slice, |
| 9502 | // untested for skip and unreachable in these streams). | 9612 | // untested for skip and unreachable in these streams). |
| 9613 | + // lane-sb128b r2: a 128x128 block's transform is TX_64X64 even with | ||
| 9614 | + // `tx_select` off (`max_txsize_rect_lookup[BLOCK_128X128]`), so the | ||
| 9615 | + // per-unit prediction is keyed on the transform being smaller than | ||
| 9616 | + // the block, not on the tx-depth syntax. The counter keeps lane-hgkf's | ||
| 9617 | + // narrower meaning (a READ split tx depth). | ||
| 9503 | let split_tx_skip = | 9618 | let split_tx_skip = |
| 9504 | - tx_select && logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); | 9619 | + logical_tx < side && palette_y_buf.is_none() && intrabc_bufs.is_none(); |
| 9505 | if split_tx_skip { | 9620 | if split_tx_skip { |
| 9506 | - SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 9621 | + if tx_select { |
| 9622 | + SKIP_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 9623 | + } | ||
| 9507 | let n_axis = side / logical_tx; | 9624 | let n_axis = side / logical_tx; |
| 9508 | for tu_row in 0..n_axis { | 9625 | for tu_row in 0..n_axis { |
| 9509 | for tu_col in 0..n_axis { | 9626 | for tu_col in 0..n_axis { |
| @@ -9553,41 +9670,62 @@ fn decode_block( | |||
| 9553 | ); | 9670 | ); |
| 9554 | } | 9671 | } |
| 9555 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 9672 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 9556 | - if let Some((ub, _)) = &palette_uv_bufs { | 9673 | + let cn = (chroma_side / chroma_tx).max(1); |
| 9557 | - set_palette_pred(ub.clone()); | 9674 | + for cu_row in 0..cn { |
| 9558 | - } | 9675 | + for cu_col in 0..cn { |
| 9559 | - u.reconstruct( | 9676 | + let luma_span = chroma_tx * 2; |
| 9560 | - cpx, | 9677 | + let cu_r = if cn == 1 { |
| 9561 | - cpy, | 9678 | + reach |
| 9562 | - chroma_side, | 9679 | + } else { |
| 9563 | - uv_predict_mode, | 9680 | + tu_reach( |
| 9564 | - angle_delta_uv, | 9681 | + side, side, |
| 9565 | - reach, | 9682 | + cu_col * luma_span, cu_row * luma_span, luma_span, |
| 9566 | - &vec![0i32; chroma_side * chroma_side], | 9683 | + reach, px, py, y.width, y.height, |
| 9567 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | 9684 | + ) |
| 9568 | - None, | 9685 | + }; |
| 9569 | - smooth_neighbor_uv, | 9686 | + let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx); |
| 9570 | - ); | 9687 | + if let Some((ub, _)) = &palette_uv_bufs { |
| 9571 | - if let Some((_, vb)) = &palette_uv_bufs { | 9688 | + set_palette_pred(ub.clone()); |
| 9572 | - set_palette_pred(vb.clone()); | 9689 | + } |
| 9690 | + u.reconstruct( | ||
| 9691 | + cu_x, | ||
| 9692 | + cu_y, | ||
| 9693 | + chroma_tx, | ||
| 9694 | + uv_predict_mode, | ||
| 9695 | + angle_delta_uv, | ||
| 9696 | + cu_r, | ||
| 9697 | + &vec![0i32; chroma_tx * chroma_tx], | ||
| 9698 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | ||
| 9699 | + None, | ||
| 9700 | + smooth_neighbor_uv, | ||
| 9701 | + ); | ||
| 9702 | + if let Some((_, vb)) = &palette_uv_bufs { | ||
| 9703 | + set_palette_pred(vb.clone()); | ||
| 9704 | + } | ||
| 9705 | + v.reconstruct( | ||
| 9706 | + cu_x, | ||
| 9707 | + cu_y, | ||
| 9708 | + chroma_tx, | ||
| 9709 | + uv_predict_mode, | ||
| 9710 | + angle_delta_uv, | ||
| 9711 | + cu_r, | ||
| 9712 | + &vec![0i32; chroma_tx * chroma_tx], | ||
| 9713 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | ||
| 9714 | + None, | ||
| 9715 | + smooth_neighbor_uv, | ||
| 9716 | + ); | ||
| 9717 | + } | ||
| 9573 | } | 9718 | } |
| 9574 | - v.reconstruct( | ||
| 9575 | - cpx, | ||
| 9576 | - cpy, | ||
| 9577 | - chroma_side, | ||
| 9578 | - uv_predict_mode, | ||
| 9579 | - angle_delta_uv, | ||
| 9580 | - reach, | ||
| 9581 | - &vec![0i32; chroma_side * chroma_side], | ||
| 9582 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | ||
| 9583 | - None, | ||
| 9584 | - smooth_neighbor_uv, | ||
| 9585 | - ); | ||
| 9586 | let luma_grid = vec![0i32; side * side]; | 9719 | let luma_grid = vec![0i32; side * side]; |
| 9587 | let u_grid = vec![0i32; chroma_side * chroma_side]; | 9720 | let u_grid = vec![0i32; chroma_side * chroma_side]; |
| 9588 | let v_grid = vec![0i32; chroma_side * chroma_side]; | 9721 | let v_grid = vec![0i32; chroma_side * chroma_side]; |
| 9589 | neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); | 9722 | neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); |
| 9590 | - } else if !tx_select || logical_tx == side { | 9723 | + } else if logical_tx == side { |
| 9724 | + // lane-sb128b r1: the test used to be `!tx_select || logical_tx == side`. | ||
| 9725 | + // Without `tx_select` `logical_tx` IS `side` at every size <= 64, so | ||
| 9726 | + // that arm was redundant -- and wrong at 128, where | ||
| 9727 | + // `max_txsize_rect_lookup` caps the block's transform at 64 and the | ||
| 9728 | + // block is four units whether or not `tx_select` is on. | ||
| 9591 | // A single luma transform unit -- the old path, unchanged (including | 9729 | // A single luma transform unit -- the old path, unchanged (including |
| 9592 | // the 64x64 corner case, `logical_tx == side == 64` with | 9730 | // the 64x64 corner case, `logical_tx == side == 64` with |
| 9593 | // `coeff_tx_side == 32`). | 9731 | // `coeff_tx_side == 32`). |
| @@ -9680,8 +9818,27 @@ fn decode_block( | |||
| 9680 | // the earlier tiles in this same block already wrote -- the same | 9818 | // the earlier tiles in this same block already wrote -- the same |
| 9681 | // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf. | 9819 | // per-TU pattern [`decode_leaf8`] already runs for an 8x8 leaf. |
| 9682 | let n_axis = side / logical_tx; | 9820 | let n_axis = side / logical_tx; |
| 9683 | - for tu_row in 0..n_axis { | 9821 | + let cn = (chroma_side / chroma_tx).max(1); |
| 9684 | - for tu_col in 0..n_axis { | 9822 | + // libaom's transform-block loop is over 64x64 luma "mu" chunks |
| 9823 | + // (`decode_token_recon_block`: `mu_blocks_wide/high` = | ||
| 9824 | + // `mi_size_wide[BLOCK_64X64]`), and it codes EVERY PLANE of a chunk | ||
| 9825 | + // before moving to the next one. Below 128 a block is a single chunk, | ||
| 9826 | + // so this is byte-for-byte the all-luma-then-all-chroma order that has | ||
| 9827 | + // always run; at 128 the four quadrants interleave Y,U,V per quadrant | ||
| 9828 | + // and reading all four luma units first desyncs the tile at the second | ||
| 9829 | + // one (lane-sb128b r3, measured against aomdec's `EC_TRACE_COEFF`). | ||
| 9830 | + let nchunk = (side / 64).max(1); | ||
| 9831 | + // `cn > 1` means the uv plane block is larger than the uv transform, | ||
| 9832 | + // which moves libaom's chroma `txb_skip_ctx` offset from 7 to 10. | ||
| 9833 | + let chroma_ctx_offset = if cn > 1 { Some(3) } else { None }; | ||
| 9834 | + let tpc = (n_axis / nchunk).max(1); | ||
| 9835 | + let cpc = (cn / nchunk).max(1); | ||
| 9836 | + let mut last_grids = [Vec::new(), Vec::new()]; | ||
| 9837 | + let mut units: Vec<((usize, usize), usize, Vec<i32>, Vec<i32>)> = Vec::new(); | ||
| 9838 | + for ch_row in 0..nchunk { | ||
| 9839 | + for ch_col in 0..nchunk { | ||
| 9840 | + for tu_row in ch_row * tpc..(ch_row + 1) * tpc { | ||
| 9841 | + for tu_col in ch_col * tpc..(ch_col + 1) * tpc { | ||
| 9685 | let tu_mi = ( | 9842 | let tu_mi = ( |
| 9686 | mi_r + tu_row * (logical_tx / MI), | 9843 | mi_r + tu_row * (logical_tx / MI), |
| 9687 | mi_c + tu_col * (logical_tx / MI), | 9844 | mi_c + tu_col * (logical_tx / MI), |
| @@ -9742,7 +9899,11 @@ fn decode_block( | |||
| 9742 | tu_px, | 9899 | tu_px, |
| 9743 | tu_py, | 9900 | tu_py, |
| 9744 | logical_tx, | 9901 | logical_tx, |
| 9745 | - logical_tx, | 9902 | + // The unit's own COEFFICIENT grid, half its side at |
| 9903 | + // TX_64X64 (a 64-point transform codes nothing past 32); | ||
| 9904 | + // identical to `logical_tx` at every smaller size | ||
| 9905 | + // (lane-sb128b r1). | ||
| 9906 | + coeff_tx_side, | ||
| 9746 | base_q_idx, | 9907 | base_q_idx, |
| 9747 | None, | 9908 | None, |
| 9748 | filter_intra, | 9909 | filter_intra, |
| @@ -9760,59 +9921,81 @@ fn decode_block( | |||
| 9760 | neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); | 9921 | neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); |
| 9761 | } | 9922 | } |
| 9762 | } | 9923 | } |
| 9924 | + // CfL is only allowed up to 32x32, i.e. only at `nchunk == 1`, where | ||
| 9925 | + // this still runs after every luma unit of the block. | ||
| 9763 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 9926 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 9764 | - let chroma_around = neighbours.around(at, side); | 9927 | + // The block's uv plane block is `chroma_side` across but its uv |
| 9765 | - if let Some((ub, _)) = &palette_uv_bufs { | 9928 | + // transform is `chroma_tx` (`av1_get_max_uv_txsize` = |
| 9766 | - set_palette_pred(ub.clone()); | 9929 | + // `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`): |
| 9930 | + // identical at every size up to 64x64, but a 128x128 block's 64x64 uv | ||
| 9931 | + // plane block adjusts TX_64X64 down to TX_32X32, so each plane is | ||
| 9932 | + // FOUR units (lane-sb128b r2) -- one per mu chunk. | ||
| 9933 | + for cu_row in ch_row * cpc..(ch_row + 1) * cpc { | ||
| 9934 | + for cu_col in ch_col * cpc..(ch_col + 1) * cpc { | ||
| 9935 | + // The chroma context arrays are indexed in LUMA mi, so this | ||
| 9936 | + // unit's anchor is its own luma quadrant: `chroma_tx` chroma | ||
| 9937 | + // pixels span `2 * chroma_tx` luma ones. | ||
| 9938 | + let luma_span = chroma_tx * 2; | ||
| 9939 | + let cu_mi = ( | ||
| 9940 | + mi_r + cu_row * (luma_span / MI), | ||
| 9941 | + mi_c + cu_col * (luma_span / MI), | ||
| 9942 | + ); | ||
| 9943 | + let cu_around = neighbours.around_mi(cu_mi, luma_span); | ||
| 9944 | + let cu_reach = if cn == 1 { | ||
| 9945 | + reach | ||
| 9946 | + } else { | ||
| 9947 | + tu_reach( | ||
| 9948 | + side, side, | ||
| 9949 | + cu_col * luma_span, cu_row * luma_span, luma_span, | ||
| 9950 | + reach, px, py, y.width, y.height, | ||
| 9951 | + ) | ||
| 9952 | + }; | ||
| 9953 | + let (cu_x, cu_y) = (cpx + cu_col * chroma_tx, cpy + cu_row * chroma_tx); | ||
| 9954 | + if let Some((ub, _)) = &palette_uv_bufs { | ||
| 9955 | + set_palette_pred(ub.clone()); | ||
| 9956 | + } | ||
| 9957 | + let u_grid = read_plane( | ||
| 9958 | + dec, cdfs, chroma_set, scans.1, 1, cu_around[1], mode, | ||
| 9959 | + uv_predict_mode, angle_delta_uv, cu_reach, u, cu_x, cu_y, | ||
| 9960 | + chroma_tx, chroma_tx, base_q_idx, | ||
| 9961 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | ||
| 9962 | + None, chroma_ctx_offset, smooth_neighbor_uv, | ||
| 9963 | + )?; | ||
| 9964 | + if let Some((_, vb)) = &palette_uv_bufs { | ||
| 9965 | + set_palette_pred(vb.clone()); | ||
| 9966 | + } | ||
| 9967 | + let v_grid = read_plane( | ||
| 9968 | + dec, cdfs, chroma_set, scans.1, 2, cu_around[2], mode, | ||
| 9969 | + uv_predict_mode, angle_delta_uv, cu_reach, v, cu_x, cu_y, | ||
| 9970 | + chroma_tx, chroma_tx, base_q_idx, | ||
| 9971 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | ||
| 9972 | + None, chroma_ctx_offset, smooth_neighbor_uv, | ||
| 9973 | + )?; | ||
| 9974 | + if cn > 1 { | ||
| 9975 | + CHROMA_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 9976 | + // Immediately, so the NEXT unit of this same block reads | ||
| 9977 | + // this one's coefficient context (libaom's chroma | ||
| 9978 | + // `txb_skip_ctx` for the second quadrant is 11, i.e. base | ||
| 9979 | + // 1 from this left neighbour -- measured against aomdec). | ||
| 9980 | + // The same writes are replayed after `record_split_luma` | ||
| 9981 | + // below, which would otherwise clobber them whole-block. | ||
| 9982 | + neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 1, &u_grid); | ||
| 9983 | + neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, 2, &v_grid); | ||
| 9984 | + units.push((cu_mi, luma_span, u_grid.clone(), v_grid.clone())); | ||
| 9985 | + } | ||
| 9986 | + last_grids = [u_grid, v_grid]; | ||
| 9987 | + } | ||
| 9767 | } | 9988 | } |
| 9768 | - let u_grid = read_plane( | ||
| 9769 | - dec, | ||
| 9770 | - cdfs, | ||
| 9771 | - chroma_set, | ||
| 9772 | - scans.1, | ||
| 9773 | - 1, | ||
| 9774 | - chroma_around[1], | ||
| 9775 | - mode, | ||
| 9776 | - uv_predict_mode, | ||
| 9777 | - angle_delta_uv, | ||
| 9778 | - reach, | ||
| 9779 | - u, | ||
| 9780 | - cpx, | ||
| 9781 | - cpy, | ||
| 9782 | - chroma_side, | ||
| 9783 | - chroma_tx, | ||
| 9784 | - base_q_idx, | ||
| 9785 | - alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), | ||
| 9786 | - None, | ||
| 9787 | - None, | ||
| 9788 | - smooth_neighbor_uv, | ||
| 9789 | - )?; | ||
| 9790 | - if let Some((_, vb)) = &palette_uv_bufs { | ||
| 9791 | - set_palette_pred(vb.clone()); | ||
| 9792 | } | 9989 | } |
| 9793 | - let v_grid = read_plane( | 9990 | + } |
| 9794 | - dec, | 9991 | + // Mode/side bookkeeping plus, at `cn == 1`, the whole-plane chroma |
| 9795 | - cdfs, | 9992 | + // context write; at `cn > 1` the per-unit writes above are what the |
| 9796 | - chroma_set, | 9993 | + // next block reads, so they run after this (last writer wins). |
| 9797 | - scans.1, | 9994 | + neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&last_grids[0], &last_grids[1]]); |
| 9798 | - 2, | 9995 | + for (cu_mi, luma_span, u_grid, v_grid) in &units { |
| 9799 | - chroma_around[2], | 9996 | + neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 1, u_grid); |
| 9800 | - mode, | 9997 | + neighbours.record_mi_chroma(*cu_mi, *luma_span, *luma_span, 2, v_grid); |
| 9801 | - uv_predict_mode, | 9998 | + } |
| 9802 | - angle_delta_uv, | ||
| 9803 | - reach, | ||
| 9804 | - v, | ||
| 9805 | - cpx, | ||
| 9806 | - cpy, | ||
| 9807 | - chroma_side, | ||
| 9808 | - chroma_tx, | ||
| 9809 | - base_q_idx, | ||
| 9810 | - alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), | ||
| 9811 | - None, | ||
| 9812 | - None, | ||
| 9813 | - smooth_neighbor_uv, | ||
| 9814 | - )?; | ||
| 9815 | - neighbours.record_split_luma(at, side, mode, uv_predict_mode, [&u_grid, &v_grid]); | ||
| 9816 | } | 9999 | } |
| 9817 | // Unconditional, `size == 0` for a non-palette block: clears any stale | 10000 | // Unconditional, `size == 0` for a non-palette block: clears any stale |
| 9818 | // neighbour palette state the same way [`Neighbours::record`] always | 10001 | // neighbour palette state the same way [`Neighbours::record`] always |
| @@ -10512,8 +10695,21 @@ fn decode_leaf_split4( | |||
| 10512 | neighbours.left_uv_mode[r] = uv_predict_mode; | 10695 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10513 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | 10696 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10514 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { | 10697 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { |
| 10515 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 10698 | + // A skipped chroma block still gets its CfL contribution: libaom's |
| 10516 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 10699 | + // `predict_and_reconstruct_intra_block` calls `cfl_predict_block` |
| 10700 | + // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719) | ||
| 10701 | + // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is | ||
| 10702 | + // added -- `skip_txfm` only drops the residual, never the alpha. | ||
| 10703 | + // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the | ||
| 10704 | + // merge keeps one fix and feeds both lanes' counters so neither of | ||
| 10705 | + // their gates goes vacuous. | ||
| 10706 | + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | ||
| 10707 | + if alpha.is_some() { | ||
| 10708 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | ||
| 10709 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10710 | + } | ||
| 10711 | + u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | ||
| 10712 | + v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | ||
| 10517 | (vec![0i32; 16], vec![0i32; 16]) | 10713 | (vec![0i32; 16], vec![0i32; 16]) |
| 10518 | } else { | 10714 | } else { |
| 10519 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | 10715 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| @@ -10865,8 +11061,21 @@ fn decode_leaf_rect8( | |||
| 10865 | neighbours.left_uv_mode[r] = uv_predict_mode; | 11061 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10866 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | 11062 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10867 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { | 11063 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { |
| 10868 | - u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 11064 | + // A skipped chroma block still gets its CfL contribution: libaom's |
| 10869 | - v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], None, None, smooth_neighbor_uv); | 11065 | + // `predict_and_reconstruct_intra_block` calls `cfl_predict_block` |
| 11066 | + // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719) | ||
| 11067 | + // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is | ||
| 11068 | + // added -- `skip_txfm` only drops the residual, never the alpha. | ||
| 11069 | + // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the | ||
| 11070 | + // merge keeps one fix and feeds both lanes' counters so neither of | ||
| 11071 | + // their gates goes vacuous. | ||
| 11072 | + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | ||
| 11073 | + if alpha.is_some() { | ||
| 11074 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | ||
| 11075 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | ||
| 11076 | + } | ||
| 11077 | + u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | ||
| 11078 | + v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | ||
| 10870 | (vec![0i32; 16], vec![0i32; 16]) | 11079 | (vec![0i32; 16], vec![0i32; 16]) |
| 10871 | } else { | 11080 | } else { |
| 10872 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | 11081 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| @@ -11219,8 +11428,14 @@ fn read_tx_size( | |||
| 11219 | // key-frame path's own deblock-grid approximation. | 11428 | // key-frame path's own deblock-grid approximation. |
| 11220 | ctx_override: Option<usize>, | 11429 | ctx_override: Option<usize>, |
| 11221 | ) -> usize { | 11430 | ) -> usize { |
| 11222 | - let ctx = ctx_override.unwrap_or_else(|| tx_size_context(n, at_mi, side)); | 11431 | + // `max_txsize_rect_lookup[bsize]` (libaom `read_selected_tx_size` / |
| 11223 | - let depth = match side { | 11432 | + // `get_tx_size_context`): a block wider than 64 still tops out at |
| 11433 | + // TX_64X64, so BLOCK_128X128 reads BLOCK_64X64's own category (its depth | ||
| 11434 | + // chain 64->32->16->8->4 is the same four steps) and resolves against 64, | ||
| 11435 | + // never against its own 128 side (lane-sb128b r1). | ||
| 11436 | + let max_tx = side.min(64); | ||
| 11437 | + let ctx = ctx_override.unwrap_or_else(|| tx_size_context(n, at_mi, max_tx)); | ||
| 11438 | + let depth = match max_tx { | ||
| 11224 | 8 => { | 11439 | 8 => { |
| 11225 | dec.symbol(&mut cdfs.tx_size_cat0[ctx]) | 11440 | dec.symbol(&mut cdfs.tx_size_cat0[ctx]) |
| 11226 | } | 11441 | } |
| @@ -11233,7 +11448,7 @@ fn read_tx_size( | |||
| 11233 | 64 => { | 11448 | 64 => { |
| 11234 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) | 11449 | dec.symbol(&mut cdfs.tx_size_cat3[ctx]) |
| 11235 | } | 11450 | } |
| 11236 | - _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64"), | 11451 | + _ => unreachable!("decode_block/decode_leaf8 only call this at 8/16/32/64/128"), |
| 11237 | }; | 11452 | }; |
| 11238 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | 11453 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { |
| 11239 | let (rng, _) = dec.debug_state(); | 11454 | let (rng, _) = dec.debug_state(); |
| @@ -11245,7 +11460,7 @@ fn read_tx_size( | |||
| 11245 | if depth != 0 { | 11460 | if depth != 0 { |
| 11246 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 11461 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 11247 | } | 11462 | } |
| 11248 | - side >> depth | 11463 | + max_tx >> depth |
| 11249 | } | 11464 | } |
| 11250 | 11465 | ||
| 11251 | /// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's | 11466 | /// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's |
| @@ -12852,6 +13067,29 @@ fn sb_visit_order(r0: u32, r1: u32, c0: u32, c1: u32, sb128: bool) -> Vec<(u32, | |||
| 12852 | /// decides the root -- only SPLIT recurses into the four 64x64 quadrants this | 13067 | /// decides the root -- only SPLIT recurses into the four 64x64 quadrants this |
| 12853 | /// decoder codes, the other seven arms refuse by name. | 13068 | /// decoder codes, the other seven arms refuse by name. |
| 12854 | #[allow(clippy::too_many_arguments)] | 13069 | #[allow(clippy::too_many_arguments)] |
| 13070 | +thread_local! { | ||
| 13071 | + /// How many 128x128 superblock roots resolved to `PARTITION_NONE` -- one | ||
| 13072 | + /// whole 128x128 block (lane-sb128b r1's gate counter). | ||
| 13073 | + pub(crate) static PART128_NONE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 13074 | +} | ||
| 13075 | + | ||
| 13076 | +/// [`PART128_NONE_HITS`], for a gate's own before/after delta. | ||
| 13077 | +pub(crate) fn part128_none_hits() -> usize { | ||
| 13078 | + PART128_NONE_HITS.with(std::cell::Cell::get) | ||
| 13079 | +} | ||
| 13080 | + | ||
| 13081 | +thread_local! { | ||
| 13082 | + /// How many CHROMA transform units were coded inside a block whose uv | ||
| 13083 | + /// plane block is more than one unit (lane-sb128b r2 -- only a 128x128 | ||
| 13084 | + /// block, four per plane). | ||
| 13085 | + pub(crate) static CHROMA_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 13086 | +} | ||
| 13087 | + | ||
| 13088 | +/// [`CHROMA_SPLIT_TX_HITS`], for a gate's own before/after delta. | ||
| 13089 | +pub(crate) fn chroma_split_tx_hits() -> usize { | ||
| 13090 | + CHROMA_SPLIT_TX_HITS.with(std::cell::Cell::get) | ||
| 13091 | +} | ||
| 13092 | + | ||
| 12855 | fn read_sb128_root( | 13093 | fn read_sb128_root( |
| 12856 | dec: &mut SymbolDecoder, | 13094 | dec: &mut SymbolDecoder, |
| 12857 | cdfs: &mut Cdfs, | 13095 | cdfs: &mut Cdfs, |
| @@ -12866,7 +13104,7 @@ fn read_sb128_root( | |||
| 12866 | sb_c: u32, | 13104 | sb_c: u32, |
| 12867 | mi_cols: u32, | 13105 | mi_cols: u32, |
| 12868 | mi_rows: u32, | 13106 | mi_rows: u32, |
| 12869 | -) -> Result<()> { | 13107 | +) -> Result<usize> { |
| 12870 | let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI); | 13108 | let (mi_r128, mi_c128) = ((sb_r & !1) * SB_MI, (sb_c & !1) * SB_MI); |
| 12871 | crate::restoration::read_lr( | 13109 | crate::restoration::read_lr( |
| 12872 | dec, | 13110 | dec, |
| @@ -12917,13 +13155,20 @@ fn read_sb128_root( | |||
| 12917 | } | 13155 | } |
| 12918 | } | 13156 | } |
| 12919 | }; | 13157 | }; |
| 12920 | - if part128 != PARTITION_SPLIT { | 13158 | + // lane-sb128b r1: `PARTITION_NONE` -- one 128x128 block -- is decoded by |
| 13159 | + // the key-frame caller below. The six remaining arms (HORZ/VERT and the | ||
| 13160 | + // four AB shapes) still need the rect/AB machinery at this size. | ||
| 13161 | + if part128 != PARTITION_SPLIT && part128 != PARTITION_NONE { | ||
| 12921 | return Err(unsupported( | 13162 | return Err(unsupported( |
| 12922 | - "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", | 13163 | + "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", |
| 12923 | )); | 13164 | )); |
| 12924 | } | 13165 | } |
| 12925 | - PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | 13166 | + if part128 == PARTITION_SPLIT { |
| 12926 | - Ok(()) | 13167 | + PART128_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 13168 | + } else { | ||
| 13169 | + PART128_NONE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 13170 | + } | ||
| 13171 | + Ok(part128) | ||
| 12927 | } | 13172 | } |
| 12928 | 13173 | ||
| 12929 | pub(crate) fn decode_key_frame_tile_with_cdfs( | 13174 | pub(crate) fn decode_key_frame_tile_with_cdfs( |
| @@ -13101,10 +13346,20 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13101 | ); | 13346 | ); |
| 13102 | TILE_HITS.with(|c| c.set(c.get() + 1)); | 13347 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 13103 | 13348 | ||
| 13349 | + // lane-sb128b r1: set when the 128 root resolved to `PARTITION_NONE` -- | ||
| 13350 | + // its one block covers all four 64x64 quadrants, so the remaining three | ||
| 13351 | + // visits of this superblock code nothing at all. | ||
| 13352 | + let mut sb128_none = false; | ||
| 13104 | for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { | 13353 | for (sb_r, sb_c, row_start, sb_start) in sb_visit_order(sb_r0, sb_r1, sb_c0, sb_c1, sb128) { |
| 13105 | if row_start { | 13354 | if row_start { |
| 13106 | neighbours.start_row(); | 13355 | neighbours.start_row(); |
| 13107 | } | 13356 | } |
| 13357 | + if sb_start { | ||
| 13358 | + sb128_none = false; | ||
| 13359 | + } | ||
| 13360 | + if sb128_none { | ||
| 13361 | + continue; | ||
| 13362 | + } | ||
| 13108 | { | 13363 | { |
| 13109 | // lane-sb128 r1: the 128 root. Its loop-restoration units are read | 13364 | // lane-sb128 r1: the 128 root. Its loop-restoration units are read |
| 13110 | // once for the whole 128x128 (spec 5.11.57 is called with the | 13365 | // once for the whole 128x128 (spec 5.11.57 is called with the |
| @@ -13112,7 +13367,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13112 | // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT | 13367 | // `BLOCK_128X128` CDF (8 symbols) decides the root -- only SPLIT |
| 13113 | // recurses into the four 64x64 quadrants this decoder codes. | 13368 | // recurses into the four 64x64 quadrants this decoder codes. |
| 13114 | if sb128 && sb_start { | 13369 | if sb128 && sb_start { |
| 13115 | - read_sb128_root( | 13370 | + let part128 = read_sb128_root( |
| 13116 | &mut dec, | 13371 | &mut dec, |
| 13117 | &mut cdfs, | 13372 | &mut cdfs, |
| 13118 | &neighbours, | 13373 | &neighbours, |
| @@ -13124,6 +13379,62 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 13124 | mi_cols, | 13379 | mi_cols, |
| 13125 | mi_rows, | 13380 | mi_rows, |
| 13126 | )?; | 13381 | )?; |
| 13382 | + if part128 == PARTITION_NONE { | ||
| 13383 | + // One 128x128 intra block: four TX_64X64 luma units and a | ||
| 13384 | + // single 64x64 chroma unit per plane (`av1_get_max_uv_txsize` | ||
| 13385 | + // of a 128x128 block is TX_64X64 over its 64x64 uv plane | ||
| 13386 | + // block). No CfL, no filter intra, no palette at this size -- | ||
| 13387 | + // [`read_intra_mode`]'s own size gates already say so. | ||
| 13388 | + sb128_none = true; | ||
| 13389 | + CDEF_TRANSMITTED.with(|c| c.set(false)); | ||
| 13390 | + let at128 = ((sb_r & !1) as usize * 4, (sb_c & !1) as usize * 4); | ||
| 13391 | + decode_block( | ||
| 13392 | + &mut dec, | ||
| 13393 | + &mut cdfs, | ||
| 13394 | + &mut neighbours, | ||
| 13395 | + at128, | ||
| 13396 | + SB * 2, | ||
| 13397 | + TxbSet::Luma64, | ||
| 13398 | + TxbSet::Chroma32, | ||
| 13399 | + TX32, | ||
| 13400 | + TX32, | ||
| 13401 | + (&scan32, &scan32), | ||
| 13402 | + false, | ||
| 13403 | + &mut y, | ||
| 13404 | + &mut u, | ||
| 13405 | + &mut v, | ||
| 13406 | + base_q_idx, | ||
| 13407 | + enable_filter_intra, | ||
| 13408 | + allow_screen_content_tools, | ||
| 13409 | + allow_intrabc, | ||
| 13410 | + &scan32, | ||
| 13411 | + &scan16, | ||
| 13412 | + &scan8, | ||
| 13413 | + &scan4, | ||
| 13414 | + tx_select, | ||
| 13415 | + reduced_tx_set, | ||
| 13416 | + )?; | ||
| 13417 | + // libaom writes one `cdef_strength` into the block's own | ||
| 13418 | + // `MB_MODE_INFO`, which every mi cell of the block -- | ||
| 13419 | + // hence all four 64x64 CDEF units -- points at; our grid | ||
| 13420 | + // is per-unit, so the read (which only ever lands in the | ||
| 13421 | + // top-left unit, `read_cdef`'s index 0) is copied across. | ||
| 13422 | + let (q_r, q_c) = ((sb_r & !1) as usize, (sb_c & !1) as usize); | ||
| 13423 | + CDEF_IDX_GRID.with(|g| { | ||
| 13424 | + let mut g = g.borrow_mut(); | ||
| 13425 | + let cols = CDEF_SB_COLS.with(|c| c.get()); | ||
| 13426 | + if cols > 0 && q_r * cols + q_c < g.len() { | ||
| 13427 | + let idx = g[q_r * cols + q_c]; | ||
| 13428 | + for (dr, dc) in [(0, 1), (1, 0), (1, 1)] { | ||
| 13429 | + let i = (q_r + dr) * cols + q_c + dc; | ||
| 13430 | + if q_c + dc < cols && i < g.len() { | ||
| 13431 | + g[i] = idx; | ||
| 13432 | + } | ||
| 13433 | + } | ||
| 13434 | + } | ||
| 13435 | + }); | ||
| 13436 | + continue; | ||
| 13437 | + } | ||
| 13127 | } | 13438 | } |
| 13128 | if !sb128 { | 13439 | if !sb128 { |
| 13129 | crate::restoration::read_lr( | 13440 | crate::restoration::read_lr( |
| @@ -20720,7 +21031,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 20720 | } | 21031 | } |
| 20721 | { | 21032 | { |
| 20722 | if sb128 && sb_start { | 21033 | if sb128 && sb_start { |
| 20723 | - read_sb128_root( | 21034 | + if read_sb128_root( |
| 20724 | &mut dec, | 21035 | &mut dec, |
| 20725 | &mut cdfs, | 21036 | &mut cdfs, |
| 20726 | &neighbours, | 21037 | &neighbours, |
| @@ -20731,7 +21042,15 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 20731 | sb_c, | 21042 | sb_c, |
| 20732 | mi_cols, | 21043 | mi_cols, |
| 20733 | mi_rows, | 21044 | mi_rows, |
| 20734 | - )?; | 21045 | + )? != PARTITION_SPLIT |
| 21046 | + { | ||
| 21047 | + // lane-sb128b r1 decodes a `PARTITION_NONE` 128 root on | ||
| 21048 | + // KEY frames only; an inter 128x128 leaf needs whole-block | ||
| 21049 | + // MC, OBMC and compound at a size this path has never run. | ||
| 21050 | + return Err(unsupported( | ||
| 21051 | + "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", | ||
| 21052 | + )); | ||
| 21053 | + } | ||
| 20735 | } | 21054 | } |
| 20736 | if !sb128 { | 21055 | if !sb128 { |
| 20737 | crate::restoration::read_lr( | 21056 | crate::restoration::read_lr( |
crates/ec-av1/src/gate_coverage.rsmodified+8 -9
| @@ -148,10 +148,9 @@ const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")]; | |||
| 148 | /// depth retires the entry, and this test fails until it is deleted. | 148 | /// depth retires the entry, and this test fails until it is deleted. |
| 149 | #[cfg(test)] | 149 | #[cfg(test)] |
| 150 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ | 150 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ |
| 151 | - ( | 151 | + // `enable-cfl-intra` LEFT both lists on 2026-09-02 (lane-reelckf r1): the |
| 152 | - "enable-cfl-intra", | 152 | + // sb128 skipped-CfL / 1:4-chroma gate passes `--enable-cfl-intra=1` at 8 |
| 153 | - "off in 41 gates, on in none: chroma-from-luma prediction is unimplemented", | 153 | + // AND 10 bits and pixel-compares both arms. |
| 154 | - ), | ||
| 155 | ( | 154 | ( |
| 156 | "enable-dist-wtd-comp", | 155 | "enable-dist-wtd-comp", |
| 157 | "off in 11 gates, on in none: distance-weighted compound is unimplemented", | 156 | "off in 11 gates, on in none: distance-weighted compound is unimplemented", |
| @@ -206,10 +205,6 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp | |||
| 206 | // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02: | 205 | // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02: |
| 207 | // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both | 206 | // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both |
| 208 | // orientations and coded strips inside pixel-exact attempts. | 207 | // orientations and coded strips inside pixel-exact attempts. |
| 209 | - ( | ||
| 210 | - "enable-cfl-intra", | ||
| 211 | - "hole at both depths, see the 8-bit list", | ||
| 212 | - ), | ||
| 213 | ( | 208 | ( |
| 214 | "enable-dual-filter", | 209 | "enable-dual-filter", |
| 215 | "hole at both depths, see the 8-bit list", | 210 | "hole at both depths, see the 8-bit list", |
| @@ -416,8 +411,12 @@ mod tests { | |||
| 416 | /// an 8-bit and a 10-bit stream from one recipe, so its flags cover both | 411 | /// an 8-bit and a 10-bit stream from one recipe, so its flags cover both |
| 417 | /// depths -- classifying it by the 10-bit strings inside its conditional | 412 | /// depths -- classifying it by the 10-bit strings inside its conditional |
| 418 | /// alone hid `--enable-tx-size-search=1` from the 8-bit list. | 413 | /// alone hid `--enable-tx-size-search=1` from the 8-bit list. |
| 414 | + /// lane-reelckf r1: the same blind spot with the other spelling -- a gate | ||
| 415 | + /// that loops `for depth in [8usize, 10]` builds BOTH streams from one | ||
| 416 | + /// recipe, but its `yuv420p10le` arm made `is_ten_bit` classify it as | ||
| 417 | + /// 10-bit only, hiding `--enable-cfl-intra=1` from the 8-bit list. | ||
| 419 | fn covers_both_depths(body: &str) -> bool { | 418 | fn covers_both_depths(body: &str) -> bool { |
| 420 | - body.contains("if bit_depth == 10") | 419 | + body.contains("if bit_depth == 10") || body.contains("for depth in [8usize, 10]") |
| 421 | } | 420 | } |
| 422 | 421 | ||
| 423 | /// Whether a gate body drives a stream at this depth. | 422 | /// Whether a gate body drives a stream at this depth. |
crates/ec-av1/src/mvstack.rsmodified+199 -18
| @@ -92,6 +92,36 @@ pub(crate) fn tmv_hits() -> usize { | |||
| 92 | TMV_HITS.load(std::sync::atomic::Ordering::Relaxed) | 92 | TMV_HITS.load(std::sync::atomic::Ordering::Relaxed) |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | +/// lane-mvtwin r1 firing counters, one per divergence this round closed. | ||
| 96 | +/// `COMP_GM_FILL_HITS`: compound extension candidates whose `comp_list` slot | ||
| 97 | +/// came from `gm_mv_candidates[side]` rather than a scanned neighbour, and | ||
| 98 | +/// where that global mv was NOT `(0, 0)` (the only case the old zero fill | ||
| 99 | +/// could not fake). `STACK_FULL_DROPS`: distinct candidates libaom drops at | ||
| 100 | +/// `MAX_REF_MV_STACK_SIZE` on insertion. `TILE_REACH_CLIPS`: row/col reaches | ||
| 101 | +/// shortened by a tile origin past mi 0, which the old frame-edge clamp | ||
| 102 | +/// missed entirely. | ||
| 103 | +static COMP_GM_FILL_HITS: std::sync::atomic::AtomicUsize = | ||
| 104 | + std::sync::atomic::AtomicUsize::new(0); | ||
| 105 | +static STACK_FULL_DROPS: std::sync::atomic::AtomicUsize = | ||
| 106 | + std::sync::atomic::AtomicUsize::new(0); | ||
| 107 | +static TILE_REACH_CLIPS: std::sync::atomic::AtomicUsize = | ||
| 108 | + std::sync::atomic::AtomicUsize::new(0); | ||
| 109 | + | ||
| 110 | +/// [`COMP_GM_FILL_HITS`]. | ||
| 111 | +pub(crate) fn comp_gm_fill_hits() -> usize { | ||
| 112 | + COMP_GM_FILL_HITS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +/// [`STACK_FULL_DROPS`]. | ||
| 116 | +pub(crate) fn stack_full_drops() -> usize { | ||
| 117 | + STACK_FULL_DROPS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +/// [`TILE_REACH_CLIPS`]. | ||
| 121 | +pub(crate) fn tile_reach_clips() -> usize { | ||
| 122 | + TILE_REACH_CLIPS.load(std::sync::atomic::Ordering::Relaxed) | ||
| 123 | +} | ||
| 124 | + | ||
| 95 | /// Everything [`find_mv_stack_with_sign_bias`] needs to fold temporal MV | 125 | /// Everything [`find_mv_stack_with_sign_bias`] needs to fold temporal MV |
| 96 | /// candidates into a block's stack (spec 7.10.2.8, only reached when the | 126 | /// candidates into a block's stack (spec 7.10.2.8, only reached when the |
| 97 | /// frame header's own `use_ref_frame_mvs` is set): the current frame's own | 127 | /// frame header's own `use_ref_frame_mvs` is set): the current frame's own |
| @@ -213,6 +243,14 @@ impl MiGrid { | |||
| 213 | self.tile_col1 = col1; | 243 | self.tile_col1 = col1; |
| 214 | } | 244 | } |
| 215 | 245 | ||
| 246 | + /// The current tile's top-left mi-unit origin ([`Self::set_tile_bounds`]). | ||
| 247 | + /// libaom's `tile->mi_row_start`/`mi_col_start`, which every availability | ||
| 248 | + /// and reach clamp in `setup_ref_mv_list` is written against | ||
| 249 | + /// (`xd->up_available`, `find_valid_row_offset`, mvref_common.c:512-528). | ||
| 250 | + pub fn tile_origin(&self) -> (usize, usize) { | ||
| 251 | + (self.tile_row0, self.tile_col0) | ||
| 252 | + } | ||
| 253 | + | ||
| 216 | /// Records the unit at `(row, col)`. Out-of-range coordinates are a | 254 | /// Records the unit at `(row, col)`. Out-of-range coordinates are a |
| 217 | /// no-op — the caller only ever addresses units inside the grid it built. | 255 | /// no-op — the caller only ever addresses units inside the grid it built. |
| 218 | pub fn set(&mut self, row: usize, col: usize, info: MiInfo) { | 256 | pub fn set(&mut self, row: usize, col: usize, info: MiInfo) { |
| @@ -313,7 +351,15 @@ const MVREF_ROW_COLS: usize = 3; | |||
| 313 | fn add_candidate(candidates: &mut Vec<StackEntry>, mv: (i32, i32), weight: u32) { | 351 | fn add_candidate(candidates: &mut Vec<StackEntry>, mv: (i32, i32), weight: u32) { |
| 314 | if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) { | 352 | if let Some(entry) = candidates.iter_mut().find(|e| e.mv == mv) { |
| 315 | entry.weight += weight; | 353 | entry.weight += weight; |
| 354 | + } else if candidates.len() >= MAX_STACK_SIZE { | ||
| 355 | + STACK_FULL_DROPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 316 | } else { | 356 | } else { |
| 357 | + // libaom `add_ref_mv_candidate` (mvref_common.c:100) and | ||
| 358 | + // `add_tpl_ref_mv` (:388) only push when | ||
| 359 | + // `*refmv_count < MAX_REF_MV_STACK_SIZE` -- the 9th distinct MV is | ||
| 360 | + // DROPPED AT INSERTION, never "kept if it outweighs an earlier one". | ||
| 361 | + // Sorting first and truncating afterwards (what this did) keeps a | ||
| 362 | + // different set whenever more than 8 distinct candidates are seen. | ||
| 317 | candidates.push(StackEntry { mv, weight }); | 363 | candidates.push(StackEntry { mv, weight }); |
| 318 | } | 364 | } |
| 319 | } | 365 | } |
| @@ -773,22 +819,35 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 773 | // nothing here relies on that. | 819 | // nothing here relies on that. |
| 774 | let row_adj = bh4 < 2 && mi_row % 2 == 1; | 820 | let row_adj = bh4 < 2 && mi_row % 2 == 1; |
| 775 | let col_adj = bw4 < 2 && mi_col % 2 == 1; | 821 | let col_adj = bw4 < 2 && mi_col % 2 == 1; |
| 776 | - let max_row_offset: isize = if mi_row > 0 { | 822 | + // r1 (lane-mvtwin): availability and reach are TILE-relative, never |
| 823 | + // frame-relative -- libaom's `xd->up_available`/`left_available` are | ||
| 824 | + // `mi_row > tile->mi_row_start` / `mi_col > tile->mi_col_start`, and | ||
| 825 | + // `find_valid_row_offset`/`find_valid_col_offset` (mvref_common.c:512-528) | ||
| 826 | + // clamp the reach to `tile->mi_row_start - mi_row`. Clamping to the FRAME | ||
| 827 | + // edge left `max_row_offset`/`max_col_offset` too long inside every tile | ||
| 828 | + // that does not start at 0, which changes the row/col scan's `inc` weight | ||
| 829 | + // (and so the stack ORDER) even though `MiGrid::get` already returns | ||
| 830 | + // `None` for the cells outside the tile. | ||
| 831 | + let (tile_row0, tile_col0) = grid.tile_origin(); | ||
| 832 | + if tile_row0 > 0 || tile_col0 > 0 { | ||
| 833 | + TILE_REACH_CLIPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 834 | + } | ||
| 835 | + let max_row_offset: isize = if mi_row > tile_row0 { | ||
| 777 | let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); | 836 | let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); |
| 778 | - reach.max(-(mi_row as isize)) | 837 | + reach.max(tile_row0 as isize - mi_row as isize) |
| 779 | } else { | 838 | } else { |
| 780 | 0 | 839 | 0 |
| 781 | }; | 840 | }; |
| 782 | - let max_col_offset: isize = if mi_col > 0 { | 841 | + let max_col_offset: isize = if mi_col > tile_col0 { |
| 783 | let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj); | 842 | let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj); |
| 784 | - reach.max(-(mi_col as isize)) | 843 | + reach.max(tile_col0 as isize - mi_col as isize) |
| 785 | } else { | 844 | } else { |
| 786 | 0 | 845 | 0 |
| 787 | }; | 846 | }; |
| 788 | 847 | ||
| 789 | let mut processed_rows = 0usize; | 848 | let mut processed_rows = 0usize; |
| 790 | let mut processed_cols = 0usize; | 849 | let mut processed_cols = 0usize; |
| 791 | - let found_above = mi_row > 0 | 850 | + let found_above = max_row_offset.unsigned_abs() >= 1 |
| 792 | && scan_row( | 851 | && scan_row( |
| 793 | grid, | 852 | grid, |
| 794 | mi_row, | 853 | mi_row, |
| @@ -802,7 +861,7 @@ pub fn find_mv_stack_with_sign_bias( | |||
| 802 | &mut newmv_count, | 861 | &mut newmv_count, |
| 803 | &mut processed_rows, | 862 | &mut processed_rows, |
| 804 | ); | 863 | ); |
| 805 | - let found_left = mi_col > 0 | 864 | + let found_left = max_col_offset.unsigned_abs() >= 1 |
| 806 | && scan_col( | 865 | && scan_col( |
| 807 | grid, | 866 | grid, |
| 808 | mi_row, | 867 | mi_row, |
| @@ -1227,7 +1286,12 @@ fn add_compound_candidate( | |||
| 1227 | ) { | 1286 | ) { |
| 1228 | if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) { | 1287 | if let Some(entry) = candidates.iter_mut().find(|e| e.mv0 == mv0 && e.mv1 == mv1) { |
| 1229 | entry.weight += weight; | 1288 | entry.weight += weight; |
| 1289 | + } else if candidates.len() >= MAX_STACK_SIZE { | ||
| 1290 | + STACK_FULL_DROPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 1230 | } else { | 1291 | } else { |
| 1292 | + // Same insertion cap as [`add_candidate`]: libaom's compound branch | ||
| 1293 | + // of `add_ref_mv_candidate` (mvref_common.c:128) and `add_tpl_ref_mv` | ||
| 1294 | + // (:425) both gate the push on `*refmv_count < MAX_REF_MV_STACK_SIZE`. | ||
| 1231 | candidates.push(CompoundStackEntry { mv0, mv1, weight }); | 1295 | candidates.push(CompoundStackEntry { mv0, mv1, weight }); |
| 1232 | } | 1296 | } |
| 1233 | } | 1297 | } |
| @@ -1477,9 +1541,18 @@ fn process_compound_ref_mv_candidate( | |||
| 1477 | /// libaom's combine step (`setup_ref_mv_list`, `mvref_common.c` ~696-720): | 1541 | /// libaom's combine step (`setup_ref_mv_list`, `mvref_common.c` ~696-720): |
| 1478 | /// zips each side's `ref_id` (exact matches) then `ref_diff` (borrowed, | 1542 | /// zips each side's `ref_id` (exact matches) then `ref_diff` (borrowed, |
| 1479 | /// sign-flipped) entries, position-wise and independently per side, into up | 1543 | /// sign-flipped) entries, position-wise and independently per side, into up |
| 1480 | -/// to two full `(mv0, mv1)` pair candidates — missing slots default to | 1544 | +/// to two full `(mv0, mv1)` pair candidates. r1 (lane-mvtwin): slots past |
| 1481 | -/// `(0, 0)`, matching libaom's zero-initialized `combined_mvs`. | 1545 | +/// both lists are filled with THAT SIDE's own global motion vector |
| 1482 | -fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32, i32)); 2] { | 1546 | +/// (`gm_mv_candidates[idx]`, mvref_common.c:718-719), never `(0, 0)` — the |
| 1547 | +/// exact gap the single-reference twin closed in r6 for its own | ||
| 1548 | +/// `mv_ref_list` tail, still open on this side. Invisible while every live | ||
| 1549 | +/// reference's global motion is IDENTITY (an unclamped gm mv of exactly | ||
| 1550 | +/// `(0,0)`), wrong the moment a compound pair names a ROTZOOM/AFFINE | ||
| 1551 | +/// reference and the scans leave the stack short. | ||
| 1552 | +fn combine_compound_candidates( | ||
| 1553 | + lists: &CompoundRefLists, | ||
| 1554 | + gm_mv_candidates: [(i32, i32); 2], | ||
| 1555 | +) -> [((i32, i32), (i32, i32)); 2] { | ||
| 1483 | let side_slots = |side: usize| -> [(i32, i32); 2] { | 1556 | let side_slots = |side: usize| -> [(i32, i32); 2] { |
| 1484 | let merged: Vec<(i32, i32)> = lists.ref_id[side] | 1557 | let merged: Vec<(i32, i32)> = lists.ref_id[side] |
| 1485 | .iter() | 1558 | .iter() |
| @@ -1487,7 +1560,14 @@ fn combine_compound_candidates(lists: &CompoundRefLists) -> [((i32, i32), (i32, | |||
| 1487 | .take(2) | 1560 | .take(2) |
| 1488 | .copied() | 1561 | .copied() |
| 1489 | .collect(); | 1562 | .collect(); |
| 1490 | - std::array::from_fn(|i| merged.get(i).copied().unwrap_or((0, 0))) | 1563 | + std::array::from_fn(|i| { |
| 1564 | + merged.get(i).copied().unwrap_or_else(|| { | ||
| 1565 | + if gm_mv_candidates[side] != (0, 0) { | ||
| 1566 | + COMP_GM_FILL_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 1567 | + } | ||
| 1568 | + gm_mv_candidates[side] | ||
| 1569 | + }) | ||
| 1570 | + }) | ||
| 1491 | }; | 1571 | }; |
| 1492 | let side0 = side_slots(0); | 1572 | let side0 = side_slots(0); |
| 1493 | let side1 = side_slots(1); | 1573 | let side1 = side_slots(1); |
| @@ -1532,22 +1612,35 @@ pub fn find_mv_stack_compound( | |||
| 1532 | 1612 | ||
| 1533 | let row_adj = bh4 < 2 && mi_row % 2 == 1; | 1613 | let row_adj = bh4 < 2 && mi_row % 2 == 1; |
| 1534 | let col_adj = bw4 < 2 && mi_col % 2 == 1; | 1614 | let col_adj = bw4 < 2 && mi_col % 2 == 1; |
| 1535 | - let max_row_offset: isize = if mi_row > 0 { | 1615 | + // r1 (lane-mvtwin): availability and reach are TILE-relative, never |
| 1616 | + // frame-relative -- libaom's `xd->up_available`/`left_available` are | ||
| 1617 | + // `mi_row > tile->mi_row_start` / `mi_col > tile->mi_col_start`, and | ||
| 1618 | + // `find_valid_row_offset`/`find_valid_col_offset` (mvref_common.c:512-528) | ||
| 1619 | + // clamp the reach to `tile->mi_row_start - mi_row`. Clamping to the FRAME | ||
| 1620 | + // edge left `max_row_offset`/`max_col_offset` too long inside every tile | ||
| 1621 | + // that does not start at 0, which changes the row/col scan's `inc` weight | ||
| 1622 | + // (and so the stack ORDER) even though `MiGrid::get` already returns | ||
| 1623 | + // `None` for the cells outside the tile. | ||
| 1624 | + let (tile_row0, tile_col0) = grid.tile_origin(); | ||
| 1625 | + if tile_row0 > 0 || tile_col0 > 0 { | ||
| 1626 | + TILE_REACH_CLIPS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 1627 | + } | ||
| 1628 | + let max_row_offset: isize = if mi_row > tile_row0 { | ||
| 1536 | let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); | 1629 | let reach = if bh4 < 2 { -4 } else { -6 } + isize::from(row_adj); |
| 1537 | - reach.max(-(mi_row as isize)) | 1630 | + reach.max(tile_row0 as isize - mi_row as isize) |
| 1538 | } else { | 1631 | } else { |
| 1539 | 0 | 1632 | 0 |
| 1540 | }; | 1633 | }; |
| 1541 | - let max_col_offset: isize = if mi_col > 0 { | 1634 | + let max_col_offset: isize = if mi_col > tile_col0 { |
| 1542 | let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj); | 1635 | let reach = if bw4 < 2 { -4 } else { -6 } + isize::from(col_adj); |
| 1543 | - reach.max(-(mi_col as isize)) | 1636 | + reach.max(tile_col0 as isize - mi_col as isize) |
| 1544 | } else { | 1637 | } else { |
| 1545 | 0 | 1638 | 0 |
| 1546 | }; | 1639 | }; |
| 1547 | 1640 | ||
| 1548 | let mut processed_rows = 0usize; | 1641 | let mut processed_rows = 0usize; |
| 1549 | let mut processed_cols = 0usize; | 1642 | let mut processed_cols = 0usize; |
| 1550 | - let found_above = mi_row > 0 | 1643 | + let found_above = max_row_offset.unsigned_abs() >= 1 |
| 1551 | && scan_row_compound( | 1644 | && scan_row_compound( |
| 1552 | grid, | 1645 | grid, |
| 1553 | mi_row, | 1646 | mi_row, |
| @@ -1561,7 +1654,7 @@ pub fn find_mv_stack_compound( | |||
| 1561 | &mut newmv_count, | 1654 | &mut newmv_count, |
| 1562 | &mut processed_rows, | 1655 | &mut processed_rows, |
| 1563 | ); | 1656 | ); |
| 1564 | - let found_left = mi_col > 0 | 1657 | + let found_left = max_col_offset.unsigned_abs() >= 1 |
| 1565 | && scan_col_compound( | 1658 | && scan_col_compound( |
| 1566 | grid, | 1659 | grid, |
| 1567 | mi_row, | 1660 | mi_row, |
| @@ -1802,7 +1895,8 @@ pub fn find_mv_stack_compound( | |||
| 1802 | // bump) — otherwise append `comp_list[0]` as a brand-new entry. When | 1895 | // bump) — otherwise append `comp_list[0]` as a brand-new entry. When |
| 1803 | // the stack is empty, both `comp_list[0]` and `comp_list[1]` are | 1896 | // the stack is empty, both `comp_list[0]` and `comp_list[1]` are |
| 1804 | // appended unconditionally, with no dedup check at all. | 1897 | // appended unconditionally, with no dedup check at all. |
| 1805 | - let comp_list = combine_compound_candidates(&lists); | 1898 | + let comp_list = |
| 1899 | + combine_compound_candidates(&lists, [gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]); | ||
| 1806 | if candidates.len() == 1 { | 1900 | if candidates.len() == 1 { |
| 1807 | let (mv0, mv1) = if comp_list[0] == (candidates[0].mv0, candidates[0].mv1) { | 1901 | let (mv0, mv1) = if comp_list[0] == (candidates[0].mv0, candidates[0].mv1) { |
| 1808 | comp_list[1] | 1902 | comp_list[1] |
| @@ -2824,7 +2918,7 @@ mod tests { | |||
| 2824 | // side 1 has only one entry -> comp_idx 1 falls back to ref_diff. | 2918 | // side 1 has only one entry -> comp_idx 1 falls back to ref_diff. |
| 2825 | lists.ref_diff[1].push((4, 4)); | 2919 | lists.ref_diff[1].push((4, 4)); |
| 2826 | 2920 | ||
| 2827 | - let combined = combine_compound_candidates(&lists); | 2921 | + let combined = combine_compound_candidates(&lists, [(0, 0), (0, 0)]); |
| 2828 | assert_eq!(combined[0], ((1, 1), (3, 3))); | 2922 | assert_eq!(combined[0], ((1, 1), (3, 3))); |
| 2829 | assert_eq!(combined[1], ((2, 2), (4, 4))); | 2923 | assert_eq!(combined[1], ((2, 2), (4, 4))); |
| 2830 | } | 2924 | } |
| @@ -2911,4 +3005,91 @@ mod tests { | |||
| 2911 | assert_eq!(stack.entries[1].mv0, (-3, -3)); | 3005 | assert_eq!(stack.entries[1].mv0, (-3, -3)); |
| 2912 | assert_eq!(stack.entries[1].mv1, (7, 7)); | 3006 | assert_eq!(stack.entries[1].mv1, (7, 7)); |
| 2913 | } | 3007 | } |
| 3008 | + | ||
| 3009 | + /// lane-mvtwin r1, defect 1 (twin drift, compound only): libaom fills a | ||
| 3010 | + /// `comp_list` slot past both `ref_id`/`ref_diff` lists with THAT SIDE's | ||
| 3011 | + /// own `gm_mv_candidates[idx]` (mvref_common.c:718-719). This module | ||
| 3012 | + /// filled it with `(0, 0)`, which is only accidentally right while every | ||
| 3013 | + /// live reference's global motion is IDENTITY -- the single-ref twin had | ||
| 3014 | + /// already closed the same gap on its own `mv_ref_list` tail in r6. | ||
| 3015 | + #[test] | ||
| 3016 | + fn a_missing_compound_combine_slot_takes_that_sides_global_mv_not_zero() { | ||
| 3017 | + let lists = CompoundRefLists::default(); | ||
| 3018 | + let combined = combine_compound_candidates(&lists, [(9, -5), (-11, 3)]); | ||
| 3019 | + assert_eq!(combined[0], ((9, -5), (-11, 3))); | ||
| 3020 | + assert_eq!(combined[1], ((9, -5), (-11, 3))); | ||
| 3021 | + // One side supplied, the other short: only the short side falls back. | ||
| 3022 | + let mut half = CompoundRefLists::default(); | ||
| 3023 | + half.ref_id[0].push((1, 2)); | ||
| 3024 | + let combined = combine_compound_candidates(&half, [(9, -5), (-11, 3)]); | ||
| 3025 | + assert_eq!(combined[0], ((1, 2), (-11, 3))); | ||
| 3026 | + assert_eq!(combined[1], ((9, -5), (-11, 3))); | ||
| 3027 | + } | ||
| 3028 | + | ||
| 3029 | + /// lane-mvtwin r1, defect 2 (both twins): libaom drops the 9th distinct | ||
| 3030 | + /// candidate AT INSERTION (`*refmv_count < MAX_REF_MV_STACK_SIZE`, | ||
| 3031 | + /// mvref_common.c:100/128/388/425). Pushing everything and truncating | ||
| 3032 | + /// after the weight sort keeps a different set: here the heavy 9th | ||
| 3033 | + /// candidate would survive and evict a scanned one. | ||
| 3034 | + #[test] | ||
| 3035 | + fn the_ninth_distinct_candidate_is_dropped_at_insertion_not_after_sorting() { | ||
| 3036 | + let mut candidates = Vec::new(); | ||
| 3037 | + for i in 0..MAX_STACK_SIZE as i32 { | ||
| 3038 | + add_candidate(&mut candidates, (i, i), 2); | ||
| 3039 | + } | ||
| 3040 | + let before = stack_full_drops(); | ||
| 3041 | + add_candidate(&mut candidates, (99, 99), 10_000); | ||
| 3042 | + assert_eq!(candidates.len(), MAX_STACK_SIZE); | ||
| 3043 | + assert!(!candidates.iter().any(|e| e.mv == (99, 99))); | ||
| 3044 | + assert_eq!(stack_full_drops(), before + 1); | ||
| 3045 | + // A full stack still takes the dedup weight bump libaom applies | ||
| 3046 | + // before the cap check. | ||
| 3047 | + add_candidate(&mut candidates, (0, 0), 6); | ||
| 3048 | + assert_eq!(candidates[0].weight, 8); | ||
| 3049 | + | ||
| 3050 | + let mut comp = Vec::new(); | ||
| 3051 | + for i in 0..MAX_STACK_SIZE as i32 { | ||
| 3052 | + add_compound_candidate(&mut comp, (i, i), (i, -i), 2); | ||
| 3053 | + } | ||
| 3054 | + add_compound_candidate(&mut comp, (99, 99), (99, 99), 10_000); | ||
| 3055 | + assert_eq!(comp.len(), MAX_STACK_SIZE); | ||
| 3056 | + } | ||
| 3057 | + | ||
| 3058 | + /// lane-mvtwin r1, defect 3 (both twins): the row/col reach is clamped to | ||
| 3059 | + /// the TILE origin (`find_valid_row_offset`, mvref_common.c:512-528), not | ||
| 3060 | + /// the frame edge. `MiGrid::get` already hides the out-of-tile cells, so | ||
| 3061 | + /// the only visible symptom is the scan WEIGHT (`inc`) -- and through it | ||
| 3062 | + /// the stack order. Query at mi_row 9 with the tile starting at row 8: | ||
| 3063 | + /// the real reach is -1, so `inc = 1` and the weight stays at the floor | ||
| 3064 | + /// 2; the frame-edge clamp gave -6, `inc = min(6, size_h) = 4`, doubling | ||
| 3065 | + /// the vote. | ||
| 3066 | + #[test] | ||
| 3067 | + fn the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge() { | ||
| 3068 | + let weight_with_tile_origin = |row0: usize| { | ||
| 3069 | + // A neighbour at least as wide as the query block (`bw4 <= n4`) | ||
| 3070 | + // is what makes libaom compute `inc` at all. | ||
| 3071 | + let wide = MiInfo { | ||
| 3072 | + size: 4, | ||
| 3073 | + size_h: 4, | ||
| 3074 | + ..inter((5, 5)) | ||
| 3075 | + }; | ||
| 3076 | + let mut grid = MiGrid::new(16, 16); | ||
| 3077 | + grid.set(8, 4, wide); | ||
| 3078 | + grid.set(8, 6, wide); | ||
| 3079 | + grid.set_tile_bounds(row0, 0, 16, 16); | ||
| 3080 | + let stack = find_mv_stack(&grid, 9, 4, 2, 2, LAST_FRAME, 16, 16); | ||
| 3081 | + assert_eq!(stack.entries.len(), 1); | ||
| 3082 | + stack.entries[0].weight | ||
| 3083 | + }; | ||
| 3084 | + let tiled = weight_with_tile_origin(8); | ||
| 3085 | + let whole_frame = weight_with_tile_origin(0); | ||
| 3086 | + // One scanned row cell (`end_mi == bw4 == 2`, `len == 2`) plus the | ||
| 3087 | + // top-right probe's own flat `CORNER_WEIGHT`, which the reach never | ||
| 3088 | + // touches -- so the whole delta below is the row scan's `inc`. | ||
| 3089 | + // reach -1 -> inc 1 -> weight stays at the floor 2. | ||
| 3090 | + assert_eq!(tiled, REF_CAT_LEVEL + 2 * 2 + CORNER_WEIGHT); | ||
| 3091 | + // frame-edge clamp: reach -6 -> inc min(6, size_h) = 4. | ||
| 3092 | + assert_eq!(whole_frame, REF_CAT_LEVEL + 2 * 4 + CORNER_WEIGHT); | ||
| 3093 | + assert_ne!(tiled, whole_frame); | ||
| 3094 | + } | ||
| 2914 | } | 3095 | } |
crates/ec-av1/src/refusal_inventory.rsmodified+2 -1
| @@ -42,7 +42,8 @@ const REFUSALS: &[&str] = &[ | |||
| 42 | "a tx_type symbol outside its CDF's own set: {t}", | 42 | "a tx_type symbol outside its CDF's own set: {t}", |
| 43 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 43 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| 44 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", | 44 | "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", |
| 45 | - "a 128x128 superblock partition other than SPLIT (NONE/HORZ/VERT and the four AB arms at the 128 root are not decoded)", | 45 | + "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", |
| 46 | + "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", | ||
| 46 | "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", | 47 | "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)", |
| 47 | "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", | 48 | "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", |
| 48 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", | 49 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", |
crates/ec-av1/src/stream.rsmodified+746 -7
| @@ -2984,6 +2984,105 @@ mod tests { | |||
| 2984 | assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | 2984 | assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); |
| 2985 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | 2985 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); |
| 2986 | } | 2986 | } |
| 2987 | + /// lane-reelckf r2: `crates/ec-av1/fixtures/reelc_kf2700.obu` is a 1920x792 | ||
| 2988 | + /// 10-bit AV1 key frame taken out of one of the user's own films | ||
| 2989 | + /// (`ffmpeg -ss 2700 -c:v copy -f obu`, then truncated to its first temporal | ||
| 2990 | + /// unit, 36 kB) -- the ONLY stream in this repo that contains a SKIPPED | ||
| 2991 | + /// `UV_CFL_PRED` block. 30 aomenc recipes (r1's 20 plus r2's chroma-correlated | ||
| 2992 | + /// `geq` sweep, cq 40..63, cpu-used 0..2, min/max-partition 4..64, 8 and | ||
| 2993 | + /// 10 bit) never made the encoder pick one, so the counter can only be | ||
| 2994 | + /// hard-asserted against a real film frame. The instrumented oracle agrees: | ||
| 2995 | + /// `EC_TRACE_MODE=1 aomdec` prints 5 `EC_IMODE_VAL ... uv_mode=13 skip=1` | ||
| 2996 | + /// lines for this frame. | ||
| 2997 | + /// | ||
| 2998 | + /// The defect it pins (fixed at 29cd53f, `decode.rs:7719`/`:10528`/`:10891`): | ||
| 2999 | + /// a skipped intra block must still PREDICT with CfL -- libaom's | ||
| 3000 | + /// `predict_and_reconstruct_intra_block` predicts every plane and guards only | ||
| 3001 | + /// the residual on `skip_txfm`. Before the fix this frame had 499 wrong | ||
| 3002 | + /// chroma samples (U rows 48..79 cols 464..492); after it, zero. | ||
| 3003 | + /// | ||
| 3004 | + /// The ffmpeg reference is `ffmpeg -f obu -i <fixture> -f rawvideo | ||
| 3005 | + /// -pix_fmt yuv420p10le -` (what `ffmpeg_decode_sequence_10bit` runs). | ||
| 3006 | + #[test] | ||
| 3007 | + fn a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact() { | ||
| 3008 | + const NAME: &str = "a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact"; | ||
| 3009 | + let path = | ||
| 3010 | + std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures/reelc_kf2700.obu"); | ||
| 3011 | + let stream = std::fs::read(&path) | ||
| 3012 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 3013 | + let (width, height) = (1920usize, 792usize); | ||
| 3014 | + let before = crate::decode::reelc_chroma_counters(); | ||
| 3015 | + let frames = match decode_stream(&stream) { | ||
| 3016 | + Ok(frames) => frames, | ||
| 3017 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 3018 | + }; | ||
| 3019 | + let after = crate::decode::reelc_chroma_counters(); | ||
| 3020 | + let skip_cfl = after.0 - before.0; | ||
| 3021 | + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); | ||
| 3022 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 3023 | + // Asserted before the ffmpeg compare so an absent ffmpeg cannot make the | ||
| 3024 | + // gate vacuous: the skipped-CfL path is exercised on every run. | ||
| 3025 | + assert!( | ||
| 3026 | + skip_cfl > 0, | ||
| 3027 | + "{NAME}: zero skipped-CfL blocks -- the fixture no longer exercises defect 1" | ||
| 3028 | + ); | ||
| 3029 | + if !have_ffmpeg() { | ||
| 3030 | + eprintln!("SKIP {NAME} pixel compare: no ffmpeg (skipped_cfl={skip_cfl})"); | ||
| 3031 | + return; | ||
| 3032 | + } | ||
| 3033 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | ||
| 3034 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | ||
| 3035 | + assert_eq!( | ||
| 3036 | + frames[0].u, ffmpeg_frames[0].u, | ||
| 3037 | + "{NAME}: U vs ffmpeg ({skip_cfl} skipped-CfL blocks)" | ||
| 3038 | + ); | ||
| 3039 | + assert_eq!( | ||
| 3040 | + frames[0].v, ffmpeg_frames[0].v, | ||
| 3041 | + "{NAME}: V vs ffmpeg ({skip_cfl} skipped-CfL blocks)" | ||
| 3042 | + ); | ||
| 3043 | + eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}"); | ||
| 3044 | + } | ||
| 3045 | + | ||
| 3046 | + /// lane-kf1200 r2: the same film's `-ss 300` key frame, pinned because no | ||
| 3047 | + /// aomenc recipe reaches its shape -- a SKIPPED sub-8x8 chroma block whose | ||
| 3048 | + /// `uv_mode` is `UV_CFL_PRED`. (lane-reelckf r1 burned 20 recipes across cq | ||
| 3049 | + /// 40..63 and nine lavfi sources hunting exactly this block and never got | ||
| 3050 | + /// one; ledger dead-end "never produced a SKIPPED 1:4 or sub-8x8 CfL | ||
| 3051 | + /// block".) Before the fix the two sub-8x8 skip arms passed `None` for the | ||
| 3052 | + /// CfL argument, so the block reconstructed as flat DC and 463 bytes of | ||
| 3053 | + /// this frame's chroma were wrong. HARD-asserts `skip_cfl_hits` moved, so | ||
| 3054 | + /// the fixture cannot silently stop exercising the arm. | ||
| 3055 | + #[test] | ||
| 3056 | + fn the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact() { | ||
| 3057 | + const NAME: &str = "the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact"; | ||
| 3058 | + if !have_ffmpeg() { | ||
| 3059 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 3060 | + return; | ||
| 3061 | + } | ||
| 3062 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 3063 | + .join("fixtures/reelb_ss300_key_frame.obu"); | ||
| 3064 | + let stream = std::fs::read(&path) | ||
| 3065 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 3066 | + let (width, height) = (3840usize, 1608usize); | ||
| 3067 | + let before = crate::decode::skip_cfl_hits(); | ||
| 3068 | + let frames = match decode_stream(&stream) { | ||
| 3069 | + Ok(frames) => frames, | ||
| 3070 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 3071 | + }; | ||
| 3072 | + let skipped_cfl = crate::decode::skip_cfl_hits() - before; | ||
| 3073 | + assert!( | ||
| 3074 | + skipped_cfl > 0, | ||
| 3075 | + "{NAME}: zero skipped sub-8x8 CfL blocks -- the fixture no longer \ | ||
| 3076 | + exercises the arm this test exists for" | ||
| 3077 | + ); | ||
| 3078 | + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); | ||
| 3079 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 3080 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | ||
| 3081 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | ||
| 3082 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | ||
| 3083 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | ||
| 3084 | + eprintln!("{NAME}: {skipped_cfl} skipped sub-8x8 CfL chroma blocks, frame pixel-exact"); | ||
| 3085 | + } | ||
| 2987 | 3086 | ||
| 2988 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 | 3087 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 |
| 2989 | /// --superres-denominator=12` key frame, decoded pixel-exact against | 3088 | /// --superres-denominator=12` key frame, decoded pixel-exact against |
| @@ -11767,6 +11866,169 @@ mod tests { | |||
| 11767 | ); | 11866 | ); |
| 11768 | } | 11867 | } |
| 11769 | 11868 | ||
| 11869 | + /// lane-reelckf r1: ReelC's key frames decoded with no refusal and WRONG | ||
| 11870 | + /// CHROMA (luma bit-exact at every one of ten seek points), from two | ||
| 11871 | + /// defects this gate pins: | ||
| 11872 | + /// | ||
| 11873 | + /// 1. a SKIPPED intra block whose `uv_mode` is `UV_CFL_PRED` still | ||
| 11874 | + /// predicts with the CfL term -- libaom | ||
| 11875 | + /// `predict_and_reconstruct_intra_block` (decodeframe.c) calls | ||
| 11876 | + /// `av1_predict_intra_block_facade` unconditionally and only guards | ||
| 11877 | + /// the residual on `mbmi->skip_txfm`. Three skip arms (the 16x16-level | ||
| 11878 | + /// 1:4 chroma pair and the two sub-8x8 4x4 groups) dropped it. | ||
| 11879 | + /// 2. the chroma intra-edge FILTER TYPE of a 1:4 pair comes from the | ||
| 11880 | + /// CHROMA REFERENCE position (libaom `get_intra_edge_filter_type` -> | ||
| 11881 | + /// `chroma_above_mbmi`/`chroma_left_mbmi`), not from the closing | ||
| 11882 | + /// strip: at the closing strip the above cell is the pair's own first | ||
| 11883 | + /// strip, the mi-exact UV map misses and the coarse fallback answers, | ||
| 11884 | + /// which flipped `av1_use_intra_edge_upsample` (blk_wh 12 <= 16 for | ||
| 11885 | + /// type 0, no upsample for type 1) and moved directional chroma by | ||
| 11886 | + /// +-1..3. | ||
| 11887 | + /// | ||
| 11888 | + /// Recipe is a real `aomenc --sb-size=128 --cpu-used=0` (the shape ReelC | ||
| 11889 | + /// uses) with 1:4 partitions and CfL on, both bit depths, and both | ||
| 11890 | + /// counters hard-asserted per compared attempt. | ||
| 11891 | + #[test] | ||
| 11892 | + fn a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact() { | ||
| 11893 | + const NAME: &str = | ||
| 11894 | + "a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact"; | ||
| 11895 | + let _gate_lock = lock_gate_counters(); | ||
| 11896 | + if !have_ffmpeg() { | ||
| 11897 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 11898 | + return; | ||
| 11899 | + } | ||
| 11900 | + if !have_aomenc() { | ||
| 11901 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 11902 | + return; | ||
| 11903 | + } | ||
| 11904 | + let mut compared = 0usize; | ||
| 11905 | + let (width, height) = (256usize, 256usize); | ||
| 11906 | + for depth in [8usize, 10] { | ||
| 11907 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 11908 | + let y4m = Command::new("ffmpeg") | ||
| 11909 | + .args([ | ||
| 11910 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 11911 | + &format!( | ||
| 11912 | + "mandelbrot=size={width}x{height},\ | ||
| 11913 | + noise=alls=20:allf=t+u:all_seed=7" | ||
| 11914 | + ), | ||
| 11915 | + "-pix_fmt", pix, "-strict", "-1", "-t", "1", "-vframes", "1", | ||
| 11916 | + "-f", "yuv4mpegpipe", "-", | ||
| 11917 | + ]) | ||
| 11918 | + .stdin(Stdio::null()) | ||
| 11919 | + .stdout(Stdio::piped()) | ||
| 11920 | + .stderr(Stdio::piped()) | ||
| 11921 | + .output() | ||
| 11922 | + .expect("ffmpeg failed to run"); | ||
| 11923 | + assert!( | ||
| 11924 | + y4m.status.success(), | ||
| 11925 | + "{NAME}: ffmpeg fixture (depth={depth}): {}", | ||
| 11926 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 11927 | + ); | ||
| 11928 | + let encode = || { | ||
| 11929 | + let mut child = Command::new(aomenc_path()) | ||
| 11930 | + .args([ | ||
| 11931 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=52", | ||
| 11932 | + "--cpu-used=0", "--threads=1", "--row-mt=0", "--sb-size=128", | ||
| 11933 | + "--kf-max-dist=0", "--enable-rect-partitions=1", | ||
| 11934 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=1", | ||
| 11935 | + "--enable-cfl-intra=1", "--enable-tx-size-search=0", | ||
| 11936 | + "--enable-filter-intra=0", "--enable-intra-edge-filter=1", | ||
| 11937 | + "--reduced-tx-type-set=1", "--min-partition-size=4", | ||
| 11938 | + "--max-partition-size=32", | ||
| 11939 | + &format!("--input-bit-depth={depth}"), | ||
| 11940 | + &format!("--bit-depth={depth}"), | ||
| 11941 | + "--obu", "-o", "-", "-", | ||
| 11942 | + ]) | ||
| 11943 | + .stdin(Stdio::piped()) | ||
| 11944 | + .stdout(Stdio::piped()) | ||
| 11945 | + .stderr(Stdio::piped()) | ||
| 11946 | + .spawn() | ||
| 11947 | + .expect("aomenc failed to start"); | ||
| 11948 | + child | ||
| 11949 | + .stdin | ||
| 11950 | + .take() | ||
| 11951 | + .expect("aomenc stdin") | ||
| 11952 | + .write_all(&y4m.stdout) | ||
| 11953 | + .expect("writing y4m to aomenc"); | ||
| 11954 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 11955 | + assert!( | ||
| 11956 | + out.status.success(), | ||
| 11957 | + "aomenc refused the fixture (depth={depth}): {}", | ||
| 11958 | + String::from_utf8_lossy(&out.stderr) | ||
| 11959 | + ); | ||
| 11960 | + out.stdout | ||
| 11961 | + }; | ||
| 11962 | + let stream = encode(); | ||
| 11963 | + assert_eq!( | ||
| 11964 | + stream, | ||
| 11965 | + encode(), | ||
| 11966 | + "{NAME}: aomenc output is not reproducible (depth={depth})" | ||
| 11967 | + ); | ||
| 11968 | + let before = crate::decode::reelc_chroma_counters(); | ||
| 11969 | + let frames = match decode_stream(&stream) { | ||
| 11970 | + Ok(frames) => frames, | ||
| 11971 | + Err(e) => { | ||
| 11972 | + let msg = e.to_string(); | ||
| 11973 | + assert!( | ||
| 11974 | + msg.contains("unsupported"), | ||
| 11975 | + "{NAME}: decode failed (depth={depth}): {msg}" | ||
| 11976 | + ); | ||
| 11977 | + eprintln!("{NAME}: depth={depth} arm refused (not compared): {msg}"); | ||
| 11978 | + continue; | ||
| 11979 | + } | ||
| 11980 | + }; | ||
| 11981 | + compared += 1; | ||
| 11982 | + // Counters read only on an attempt that decoded AND is compared. | ||
| 11983 | + let after = crate::decode::reelc_chroma_counters(); | ||
| 11984 | + let (skip_cfl, dir_pairs) = (after.0 - before.0, after.1 - before.1); | ||
| 11985 | + let ffmpeg_frames = if depth == 10 { | ||
| 11986 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | ||
| 11987 | + } else { | ||
| 11988 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | ||
| 11989 | + }; | ||
| 11990 | + assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: ffmpeg frame count"); | ||
| 11991 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 11992 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma (depth={depth})"); | ||
| 11993 | + assert_eq!( | ||
| 11994 | + got.u, want.u, | ||
| 11995 | + "{NAME} frame {i} U (depth={depth}, {skip_cfl} skipped-CfL blocks, \ | ||
| 11996 | + {dir_pairs} directional 1:4 chroma pairs)" | ||
| 11997 | + ); | ||
| 11998 | + assert_eq!( | ||
| 11999 | + got.v, want.v, | ||
| 12000 | + "{NAME} frame {i} V (depth={depth}, {skip_cfl} skipped-CfL blocks, \ | ||
| 12001 | + {dir_pairs} directional 1:4 chroma pairs)" | ||
| 12002 | + ); | ||
| 12003 | + } | ||
| 12004 | + // Defect 1 (skipped `UV_CFL_PRED`) is NOT asserted here: 20 aomenc | ||
| 12005 | + // recipes (cq 40..63, 9 lavfi sources, min/max-partition 4..64, | ||
| 12006 | + // both `--sb-size=128` and 64) never made the encoder pick a | ||
| 12007 | + // skipped 1:4 / sub-8x8 CfL block, so an assert would only ever | ||
| 12008 | + // fire on his real film. Its evidence is ReelC's own key frames | ||
| 12009 | + // (lanes/reelckf-r1.report.md): ss=2700 went 499 wrong chroma | ||
| 12010 | + // samples -> 0 on this fix alone. The count is printed so a future | ||
| 12011 | + // recipe that does reach it is visible immediately. r2 pinned that | ||
| 12012 | + // film frame as a fixture instead: | ||
| 12013 | + // `a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact` | ||
| 12014 | + // hard-asserts the counter. | ||
| 12015 | + assert!( | ||
| 12016 | + dir_pairs > 0, | ||
| 12017 | + "{NAME}: no directional 1:4 chroma pair decoded (depth={depth}) -- defect 2 \ | ||
| 12018 | + is not exercised" | ||
| 12019 | + ); | ||
| 12020 | + eprintln!( | ||
| 12021 | + "{NAME}: pixel-exact at {depth}-bit over {} frames, skipped_cfl={skip_cfl} \ | ||
| 12022 | + directional_1to4_chroma_pairs={dir_pairs}", | ||
| 12023 | + frames.len() | ||
| 12024 | + ); | ||
| 12025 | + } | ||
| 12026 | + assert!( | ||
| 12027 | + compared > 0, | ||
| 12028 | + "{NAME}: every arm refused -- the gate compared no pixels at all" | ||
| 12029 | + ); | ||
| 12030 | + } | ||
| 12031 | + | ||
| 11770 | /// lane-ab16 r1: real `aomenc --enable-ab-partitions=1` streams whose | 12032 | /// lane-ab16 r1: real `aomenc --enable-ab-partitions=1` streams whose |
| 11771 | /// 16x16 blocks are split T-shaped (`PARTITION_HORZ_A`/`_HORZ_B`/ | 12033 | /// 16x16 blocks are split T-shaped (`PARTITION_HORZ_A`/`_HORZ_B`/ |
| 11772 | /// `_VERT_A`/`_VERT_B`: two 8x8 squares plus one 16x8/8x16 strip), the | 12034 | /// `_VERT_A`/`_VERT_B`: two 8x8 squares plus one 16x8/8x16 strip), the |
| @@ -14721,6 +14983,299 @@ mod tests { | |||
| 14721 | a_real_aomenc_temporal_mv_gate(42, 40); | 14983 | a_real_aomenc_temporal_mv_gate(42, 40); |
| 14722 | } | 14984 | } |
| 14723 | 14985 | ||
| 14986 | + /// lane-mvtwin r1: the COMPOUND MV-stack gate. Every other compound gate | ||
| 14987 | + /// here pins `--enable-ref-frame-mvs=0`, so `find_mv_stack_compound`'s | ||
| 14988 | + /// temporal half (the three `tpl_sample_pos` extension samples lane-sb128 | ||
| 14989 | + /// r3 found missing) and its extension pass have never been exercised by | ||
| 14990 | + /// a real encoder. This arm turns ref-frame-mvs ON, gives the encoder a | ||
| 14991 | + /// 25-frame lookahead plus alt-refs so `reference_select` really drives | ||
| 14992 | + /// blocks to COMPOUND_REFERENCE, and sweeps global motion off/on so the | ||
| 14993 | + /// combine step's `gm_mv_candidates` fill (r1 defect 1) is reachable. | ||
| 14994 | + /// | ||
| 14995 | + /// Firing proof, hard-asserted: `decode::comp_mode_hits` (a real | ||
| 14996 | + /// compound block) AND `mvstack::tmv_hits` (a temporal candidate landed | ||
| 14997 | + /// in some stack) must BOTH have advanced on an attempt that also | ||
| 14998 | + /// decoded pixel-exact -- class [[gate-skips-on-its-own-failure]]: a | ||
| 14999 | + /// decode that succeeds is ALWAYS compared, on every decode-order frame, | ||
| 15000 | + /// and only the counters decide whether the attempt counts. | ||
| 15001 | + fn a_real_aomenc_compound_mv_stack_gate( | ||
| 15002 | + gate_name: &str, | ||
| 15003 | + seed_base: u32, | ||
| 15004 | + attempts: u32, | ||
| 15005 | + bit_depth: u32, | ||
| 15006 | + sb_size: u32, | ||
| 15007 | + global_motion: u32, | ||
| 15008 | + width: usize, | ||
| 15009 | + tile_columns: u32, | ||
| 15010 | + ) { | ||
| 15011 | + let _gate_lock = lock_gate_counters(); | ||
| 15012 | + if !have_ffmpeg() { | ||
| 15013 | + eprintln!("SKIP {gate_name}: no ffmpeg"); | ||
| 15014 | + return; | ||
| 15015 | + } | ||
| 15016 | + if !have_aomenc() { | ||
| 15017 | + eprintln!("SKIP {gate_name}: no aomenc at {}", aomenc_path().display()); | ||
| 15018 | + return; | ||
| 15019 | + } | ||
| 15020 | + let (height, frame_count) = (64usize, 16usize); | ||
| 15021 | + let mut never_fired = 0u32; | ||
| 15022 | + let mut refusals = Vec::new(); | ||
| 15023 | + for attempt in 0..attempts { | ||
| 15024 | + let seed = seed_base + attempt; | ||
| 15025 | + let duration = frame_count as f64 / 25.0; | ||
| 15026 | + let source = | ||
| 15027 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")); | ||
| 15028 | + let y4m = Command::new("ffmpeg") | ||
| 15029 | + .args([ | ||
| 15030 | + "-v", | ||
| 15031 | + "error", | ||
| 15032 | + "-f", | ||
| 15033 | + "lavfi", | ||
| 15034 | + "-i", | ||
| 15035 | + &source, | ||
| 15036 | + "-pix_fmt", | ||
| 15037 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 15038 | + "-strict", | ||
| 15039 | + "-1", | ||
| 15040 | + "-t", | ||
| 15041 | + "0.64", | ||
| 15042 | + "-f", | ||
| 15043 | + "yuv4mpegpipe", | ||
| 15044 | + "-strict", | ||
| 15045 | + "-1", | ||
| 15046 | + "-", | ||
| 15047 | + ]) | ||
| 15048 | + .stdin(Stdio::null()) | ||
| 15049 | + .stdout(Stdio::piped()) | ||
| 15050 | + .stderr(Stdio::piped()) | ||
| 15051 | + .output() | ||
| 15052 | + .expect("ffmpeg failed to run"); | ||
| 15053 | + assert!( | ||
| 15054 | + y4m.status.success(), | ||
| 15055 | + "ffmpeg fixture: {}", | ||
| 15056 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 15057 | + ); | ||
| 15058 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 15059 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 15060 | + } else { | ||
| 15061 | + &[] | ||
| 15062 | + }; | ||
| 15063 | + // The cq sweep: how finely RD partitions decides how often a | ||
| 15064 | + // block's stack comes up short enough to reach the extension | ||
| 15065 | + // pass at all. | ||
| 15066 | + let cq = format!("--cq-level={}", [45u32, 55, 35][(attempt % 3) as usize]); | ||
| 15067 | + let sb = format!("--sb-size={sb_size}"); | ||
| 15068 | + let gm = format!("--enable-global-motion={global_motion}"); | ||
| 15069 | + // `--tile-columns` is log2: 1 means two tile columns, which is | ||
| 15070 | + // what makes every block in the right-hand tile carry a nonzero | ||
| 15071 | + // `tile_col0` and so exercise r1 defect 3's reach clamp. | ||
| 15072 | + let tiles = format!("--tile-columns={tile_columns}"); | ||
| 15073 | + // class [[aomenc-last-flag-wins]]: every flag appears exactly | ||
| 15074 | + // once below, so there is no override to order. | ||
| 15075 | + let out = { | ||
| 15076 | + let mut child = Command::new(aomenc_path()) | ||
| 15077 | + .args(depth_args) | ||
| 15078 | + .arg(&cq) | ||
| 15079 | + .arg(&sb) | ||
| 15080 | + .arg(&gm) | ||
| 15081 | + .arg(&tiles) | ||
| 15082 | + .args([ | ||
| 15083 | + "--codec=av1", | ||
| 15084 | + "--passes=1", | ||
| 15085 | + "--end-usage=q", | ||
| 15086 | + "--cpu-used=0", | ||
| 15087 | + "--kf-max-dist=1000", | ||
| 15088 | + "--threads=1", | ||
| 15089 | + "--row-mt=0", | ||
| 15090 | + // What this gate is about: real compound references | ||
| 15091 | + // with a real temporal MV field behind them. | ||
| 15092 | + "--enable-ref-frame-mvs=1", | ||
| 15093 | + "--enable-order-hint=1", | ||
| 15094 | + "--auto-alt-ref=1", | ||
| 15095 | + "--lag-in-frames=25", | ||
| 15096 | + "--enable-fwd-kf=0", | ||
| 15097 | + "--enable-warped-motion=0", | ||
| 15098 | + "--enable-obmc=0", | ||
| 15099 | + "--enable-masked-comp=0", | ||
| 15100 | + "--enable-interintra-comp=0", | ||
| 15101 | + "--enable-dist-wtd-comp=0", | ||
| 15102 | + "--enable-diff-wtd-comp=0", | ||
| 15103 | + "--enable-onesided-comp=0", | ||
| 15104 | + "--enable-interintra-wedge=0", | ||
| 15105 | + "--enable-smooth-interintra=0", | ||
| 15106 | + "--enable-rect-partitions=0", | ||
| 15107 | + "--enable-ab-partitions=0", | ||
| 15108 | + "--enable-1to4-partitions=0", | ||
| 15109 | + "--enable-filter-intra=0", | ||
| 15110 | + "--enable-smooth-intra=0", | ||
| 15111 | + "--enable-paeth-intra=0", | ||
| 15112 | + "--enable-directional-intra=0", | ||
| 15113 | + "--enable-angle-delta=0", | ||
| 15114 | + "--enable-tx-size-search=0", | ||
| 15115 | + "--enable-cdef=0", | ||
| 15116 | + "--enable-restoration=0", | ||
| 15117 | + "--max-partition-size=32", | ||
| 15118 | + "--min-partition-size=32", | ||
| 15119 | + "--enable-palette=0", | ||
| 15120 | + "--enable-intrabc=0", | ||
| 15121 | + "--enable-cfl-intra=0", | ||
| 15122 | + "--obu", | ||
| 15123 | + "-o", | ||
| 15124 | + "-", | ||
| 15125 | + "-", | ||
| 15126 | + ]) | ||
| 15127 | + .stdin(Stdio::piped()) | ||
| 15128 | + .stdout(Stdio::piped()) | ||
| 15129 | + .stderr(Stdio::piped()) | ||
| 15130 | + .spawn() | ||
| 15131 | + .expect("aomenc failed to start"); | ||
| 15132 | + child | ||
| 15133 | + .stdin | ||
| 15134 | + .take() | ||
| 15135 | + .expect("aomenc stdin") | ||
| 15136 | + .write_all(&y4m.stdout) | ||
| 15137 | + .expect("writing y4m to aomenc"); | ||
| 15138 | + child.wait_with_output().expect("aomenc failed to run") | ||
| 15139 | + }; | ||
| 15140 | + assert!( | ||
| 15141 | + out.status.success(), | ||
| 15142 | + "aomenc refused the fixture: {}", | ||
| 15143 | + String::from_utf8_lossy(&out.stderr) | ||
| 15144 | + ); | ||
| 15145 | + let stream = out.stdout; | ||
| 15146 | + let (before_comp, before_tmv) = (decode::comp_mode_hits(), decode::tmv_hits()); | ||
| 15147 | + let frames = match decode_stream(&stream) { | ||
| 15148 | + Err(e) => { | ||
| 15149 | + let msg = e.to_string(); | ||
| 15150 | + assert!( | ||
| 15151 | + msg.contains("unsupported"), | ||
| 15152 | + "{gate_name} failed outright (seed {seed}): {msg}" | ||
| 15153 | + ); | ||
| 15154 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 15155 | + continue; | ||
| 15156 | + } | ||
| 15157 | + Ok(frames) => frames, | ||
| 15158 | + }; | ||
| 15159 | + let counted = | ||
| 15160 | + decode::comp_mode_hits() != before_comp && decode::tmv_hits() != before_tmv; | ||
| 15161 | + if !counted { | ||
| 15162 | + never_fired += 1; | ||
| 15163 | + } | ||
| 15164 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 15165 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 15166 | + } else { | ||
| 15167 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 15168 | + }; | ||
| 15169 | + assert_eq!(frames.len(), frame_count); | ||
| 15170 | + // EVERY decode-order frame compared, never just the shown ones | ||
| 15171 | + // (class [[gate-blind-to-hidden-frames]]). | ||
| 15172 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 15173 | + assert_eq!( | ||
| 15174 | + got.y, want.y, | ||
| 15175 | + "{gate_name} frame {i} luma vs ffmpeg (seed {seed})" | ||
| 15176 | + ); | ||
| 15177 | + assert_eq!( | ||
| 15178 | + got.u, want.u, | ||
| 15179 | + "{gate_name} frame {i} U vs ffmpeg (seed {seed})" | ||
| 15180 | + ); | ||
| 15181 | + assert_eq!( | ||
| 15182 | + got.v, want.v, | ||
| 15183 | + "{gate_name} frame {i} V vs ffmpeg (seed {seed})" | ||
| 15184 | + ); | ||
| 15185 | + } | ||
| 15186 | + if counted { | ||
| 15187 | + eprintln!( | ||
| 15188 | + "{gate_name} FIRING seed {seed}: comp_mode_hits +{}, tmv_hits +{}, \ | ||
| 15189 | + comp_gm_fill_hits={}, stack_full_drops={}, tile_reach_clips={}", | ||
| 15190 | + decode::comp_mode_hits() - before_comp, | ||
| 15191 | + decode::tmv_hits() - before_tmv, | ||
| 15192 | + crate::mvstack::comp_gm_fill_hits(), | ||
| 15193 | + crate::mvstack::stack_full_drops(), | ||
| 15194 | + crate::mvstack::tile_reach_clips(), | ||
| 15195 | + ); | ||
| 15196 | + gate_buckets(gate_name, 1, never_fired, refusals.len()); | ||
| 15197 | + return; | ||
| 15198 | + } | ||
| 15199 | + } | ||
| 15200 | + gate_buckets(gate_name, 0, never_fired, refusals.len()); | ||
| 15201 | + eprintln!( | ||
| 15202 | + "SKIP {gate_name}: {never_fired} attempts decoded but never drove a compound block \ | ||
| 15203 | + with a temporal MV candidate, and every other attempt hit a named refusal:\n{}", | ||
| 15204 | + refusals.join("\n") | ||
| 15205 | + ); | ||
| 15206 | + } | ||
| 15207 | + | ||
| 15208 | + #[test] | ||
| 15209 | + fn a_real_aomenc_compound_mv_stack_with_temporal_mvs_decodes_pixel_exact() { | ||
| 15210 | + a_real_aomenc_compound_mv_stack_gate( | ||
| 15211 | + "a_real_aomenc_compound_mv_stack_with_temporal_mvs_decodes_pixel_exact", | ||
| 15212 | + 42, | ||
| 15213 | + 30, | ||
| 15214 | + 8, | ||
| 15215 | + 64, | ||
| 15216 | + 0, | ||
| 15217 | + 64, | ||
| 15218 | + 0, | ||
| 15219 | + ); | ||
| 15220 | + } | ||
| 15221 | + | ||
| 15222 | + #[test] | ||
| 15223 | + fn a_real_aomenc_compound_mv_stack_with_global_motion_decodes_pixel_exact() { | ||
| 15224 | + a_real_aomenc_compound_mv_stack_gate( | ||
| 15225 | + "a_real_aomenc_compound_mv_stack_with_global_motion_decodes_pixel_exact", | ||
| 15226 | + 80, | ||
| 15227 | + 30, | ||
| 15228 | + 8, | ||
| 15229 | + 64, | ||
| 15230 | + 1, | ||
| 15231 | + 64, | ||
| 15232 | + 0, | ||
| 15233 | + ); | ||
| 15234 | + } | ||
| 15235 | + | ||
| 15236 | + #[test] | ||
| 15237 | + fn a_real_aomenc_10bit_compound_mv_stack_at_128_superblocks_decodes_pixel_exact() { | ||
| 15238 | + a_real_aomenc_compound_mv_stack_gate( | ||
| 15239 | + "a_real_aomenc_10bit_compound_mv_stack_at_128_superblocks_decodes_pixel_exact", | ||
| 15240 | + 120, | ||
| 15241 | + 30, | ||
| 15242 | + 10, | ||
| 15243 | + 128, | ||
| 15244 | + 1, | ||
| 15245 | + 64, | ||
| 15246 | + 0, | ||
| 15247 | + ); | ||
| 15248 | + } | ||
| 15249 | + | ||
| 15250 | + /// KNOWN OPEN DEFECT, found by lane-mvtwin r1 and NOT caused by it: a | ||
| 15251 | + /// real aomenc stream 128 px wide with `--tile-columns=1` (two 64-px tile | ||
| 15252 | + /// columns) mis-decodes frame 1's luma against ffmpeg, at seed 200 with | ||
| 15253 | + /// this exact recipe. ABLATION-PROVEN pre-existing: the same arm fails | ||
| 15254 | + /// identically with r1's tile-origin reach clamp | ||
| 15255 | + /// (`MiGrid::tile_origin`) forced back to `(0, 0)`, so the cause is | ||
| 15256 | + /// somewhere else in the multi-tile path, not in `mvstack`. Kept as the | ||
| 15257 | + /// exact reproducer for the lane that owns tiles -- it is `#[ignore]`d | ||
| 15258 | + /// rather than deleted so the repro command survives: | ||
| 15259 | + /// `cargo test -p ec-av1 --lib across_two_tile_columns -- --ignored --nocapture`. | ||
| 15260 | + /// | ||
| 15261 | + /// It is also the ONLY arm that reaches r1 defect 3 (the col reach is | ||
| 15262 | + /// clamped to `tile_col0`, not the frame edge): the counter | ||
| 15263 | + /// `mvstack::tile_reach_clips` advanced to 60 on this stream. Defect 3 | ||
| 15264 | + /// itself is proven deterministically by | ||
| 15265 | + /// `mvstack::tests::the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge`. | ||
| 15266 | + #[test] | ||
| 15267 | + #[ignore = "known pre-existing multi-tile-column decode defect, see doc comment"] | ||
| 15268 | + fn a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact() { | ||
| 15269 | + let name = "a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact"; | ||
| 15270 | + let before = crate::mvstack::tile_reach_clips(); | ||
| 15271 | + a_real_aomenc_compound_mv_stack_gate(name, 200, 30, 8, 64, 0, 128, 1); | ||
| 15272 | + assert!( | ||
| 15273 | + crate::mvstack::tile_reach_clips() > before, | ||
| 15274 | + "{name}: no block was ever built inside a tile past mi 0 -- \ | ||
| 15275 | + --tile-columns=1 did not produce a second tile column" | ||
| 15276 | + ); | ||
| 15277 | + } | ||
| 15278 | + | ||
| 14724 | /// bisect scratch: decode a pinned stream exactly once -- generic | 15279 | /// bisect scratch: decode a pinned stream exactly once -- generic |
| 14725 | /// pin-repro tool, kept for manual use. | 15280 | /// pin-repro tool, kept for manual use. |
| 14726 | #[test] | 15281 | #[test] |
| @@ -18327,6 +18882,162 @@ mod tests { | |||
| 18327 | ); | 18882 | ); |
| 18328 | } | 18883 | } |
| 18329 | 18884 | ||
| 18885 | + /// lane-sb128b r1 gate: a real `aomenc --sb-size=128` KEY frame whose 128 | ||
| 18886 | + /// roots resolve to `PARTITION_NONE` -- one whole 128x128 intra block, | ||
| 18887 | + /// four TX_64X64 luma transform units and FOUR TX_32X32 chroma units per | ||
| 18888 | + /// plane (`av1_get_max_uv_txsize(BLOCK_128X128)` is | ||
| 18889 | + /// `av1_get_adjusted_tx_size` of its 64x64 uv plane block's TX_64X64, so | ||
| 18890 | + /// TX_32X32) -- lane-sb128b r2's `chroma_split_tx_hits` asserts them. The r1 gate above pins `--max-partition-size=64`, which | ||
| 18891 | + /// makes every 128 root a forced SPLIT and leaves this arm unexercised. | ||
| 18892 | + /// Smooth gradients at a high `--cq-level` are what make the RD search | ||
| 18893 | + /// keep a whole 128x128 block; `part128_none_hits` HARD-asserts it did. | ||
| 18894 | + #[test] | ||
| 18895 | + fn a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact() { | ||
| 18896 | + const NAME: &str = | ||
| 18897 | + "a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact"; | ||
| 18898 | + let _gate_lock = lock_gate_counters(); | ||
| 18899 | + if !have_ffmpeg() { | ||
| 18900 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 18901 | + return; | ||
| 18902 | + } | ||
| 18903 | + if !have_aomenc() { | ||
| 18904 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 18905 | + return; | ||
| 18906 | + } | ||
| 18907 | + let render = |seed: u32, width: usize, height: usize, ten_bit: bool| -> Vec<u8> { | ||
| 18908 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 18909 | + let out = Command::new("ffmpeg") | ||
| 18910 | + .args([ | ||
| 18911 | + "-v", "error", "-f", "lavfi", "-i", | ||
| 18912 | + &gradients_source(seed, width, height, "duration=0.04:rate=25"), | ||
| 18913 | + "-pix_fmt", pix, "-strict", "-1", "-t", "0.04", | ||
| 18914 | + "-f", "yuv4mpegpipe", "-", | ||
| 18915 | + ]) | ||
| 18916 | + .stdin(Stdio::null()) | ||
| 18917 | + .stdout(Stdio::piped()) | ||
| 18918 | + .stderr(Stdio::piped()) | ||
| 18919 | + .output() | ||
| 18920 | + .expect("ffmpeg failed to run"); | ||
| 18921 | + assert!( | ||
| 18922 | + out.status.success(), | ||
| 18923 | + "ffmpeg fixture: {}", | ||
| 18924 | + String::from_utf8_lossy(&out.stderr) | ||
| 18925 | + ); | ||
| 18926 | + out.stdout | ||
| 18927 | + }; | ||
| 18928 | + let mut matched = 0u32; | ||
| 18929 | + let mut named_refusals = 0u32; | ||
| 18930 | + let mut none_arms = 0u32; | ||
| 18931 | + // (seed, cq, width, height, 10-bit). 384x384 is a 3x3 grid of whole | ||
| 18932 | + // 128 superblocks; 256x256 a 2x2. | ||
| 18933 | + let arms: Vec<(u32, &str, usize, usize, bool)> = vec![ | ||
| 18934 | + (42, "--cq-level=63", 384, 384, false), | ||
| 18935 | + (43, "--cq-level=55", 384, 384, false), | ||
| 18936 | + (44, "--cq-level=63", 256, 256, false), | ||
| 18937 | + (45, "--cq-level=63", 384, 384, true), | ||
| 18938 | + ]; | ||
| 18939 | + for (seed, cq, width, height, ten_bit) in arms { | ||
| 18940 | + let y4m = render(seed, width, height, ten_bit); | ||
| 18941 | + let mut args: Vec<&str> = vec![ | ||
| 18942 | + "--codec=av1", "--passes=1", "--end-usage=q", cq, | ||
| 18943 | + "--cpu-used=0", "--threads=1", "--row-mt=0", | ||
| 18944 | + "--sb-size=128", | ||
| 18945 | + "--enable-rect-partitions=0", | ||
| 18946 | + "--enable-ab-partitions=0", | ||
| 18947 | + "--enable-1to4-partitions=0", | ||
| 18948 | + "--min-partition-size=16", | ||
| 18949 | + "--enable-restoration=1", | ||
| 18950 | + "--enable-palette=0", | ||
| 18951 | + "--deltaq-mode=0", | ||
| 18952 | + "--enable-intrabc=0", | ||
| 18953 | + "--enable-tx-size-search=0", | ||
| 18954 | + "--limit=1", | ||
| 18955 | + ]; | ||
| 18956 | + if ten_bit { | ||
| 18957 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 18958 | + } | ||
| 18959 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | ||
| 18960 | + let mut child = Command::new(aomenc_path()) | ||
| 18961 | + .args(&args) | ||
| 18962 | + .stdin(Stdio::piped()) | ||
| 18963 | + .stdout(Stdio::piped()) | ||
| 18964 | + .stderr(Stdio::piped()) | ||
| 18965 | + .spawn() | ||
| 18966 | + .expect("aomenc failed to start"); | ||
| 18967 | + child | ||
| 18968 | + .stdin | ||
| 18969 | + .take() | ||
| 18970 | + .expect("aomenc stdin") | ||
| 18971 | + .write_all(&y4m) | ||
| 18972 | + .expect("writing y4m to aomenc"); | ||
| 18973 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 18974 | + assert!( | ||
| 18975 | + out.status.success(), | ||
| 18976 | + "aomenc refused the fixture: {}", | ||
| 18977 | + String::from_utf8_lossy(&out.stderr) | ||
| 18978 | + ); | ||
| 18979 | + let stream = out.stdout; | ||
| 18980 | + let before = crate::decode::part128_none_hits(); | ||
| 18981 | + let frames = match decode_stream(&stream) { | ||
| 18982 | + Err(e) => { | ||
| 18983 | + let msg = e.to_string(); | ||
| 18984 | + assert!( | ||
| 18985 | + msg.contains("unsupported"), | ||
| 18986 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 18987 | + ); | ||
| 18988 | + named_refusals += 1; | ||
| 18989 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 18990 | + continue; | ||
| 18991 | + } | ||
| 18992 | + Ok(frames) => frames, | ||
| 18993 | + }; | ||
| 18994 | + let want = if ten_bit { | ||
| 18995 | + ffmpeg_decode_sequence_10bit(&stream, width, height, 1) | ||
| 18996 | + } else { | ||
| 18997 | + ffmpeg_decode_sequence(&stream, width, height, 1) | ||
| 18998 | + }; | ||
| 18999 | + assert_eq!(frames.len(), 1); | ||
| 19000 | + for (i, (got, want)) in frames.iter().zip(&want).enumerate() { | ||
| 19001 | + for (name, a, b, w) in [ | ||
| 19002 | + ("Y", &got.y, &want.y, width), | ||
| 19003 | + ("U", &got.u, &want.u, width / 2), | ||
| 19004 | + ("V", &got.v, &want.v, width / 2), | ||
| 19005 | + ] { | ||
| 19006 | + let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count(); | ||
| 19007 | + let first = a.iter().zip(b.iter()).position(|(x, y)| x != y); | ||
| 19008 | + assert_eq!( | ||
| 19009 | + n, 0, | ||
| 19010 | + "{NAME} frame {i} {name} vs ffmpeg (seed {seed}): {n} differ, first row {} col {} ours {:?} ffmpeg {:?}", | ||
| 19011 | + first.unwrap_or(0) / w, | ||
| 19012 | + first.unwrap_or(0) % w, | ||
| 19013 | + first.map(|k| a[k]), | ||
| 19014 | + first.map(|k| b[k]), | ||
| 19015 | + ); | ||
| 19016 | + } | ||
| 19017 | + } | ||
| 19018 | + let hits = crate::decode::part128_none_hits() - before; | ||
| 19019 | + eprintln!("seed {seed} cq {cq} {width}x{height}: part128_none_hits +{hits}"); | ||
| 19020 | + if hits > 0 { | ||
| 19021 | + none_arms += 1; | ||
| 19022 | + } | ||
| 19023 | + matched += 1; | ||
| 19024 | + } | ||
| 19025 | + assert!( | ||
| 19026 | + matched > 0, | ||
| 19027 | + "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 19028 | + ); | ||
| 19029 | + assert!( | ||
| 19030 | + none_arms > 0, | ||
| 19031 | + "{NAME}: {matched} stream(s) decoded pixel-exact but NOT ONE 128 root was \ | ||
| 19032 | + PARTITION_NONE -- the arm this gate exists for never fired" | ||
| 19033 | + ); | ||
| 19034 | + eprintln!( | ||
| 19035 | + "{NAME}: {matched} pixel-exact ({none_arms} with a 128 NONE root), \ | ||
| 19036 | + {named_refusals} named refusals, part128_none_hits={}", | ||
| 19037 | + crate::decode::part128_none_hits() | ||
| 19038 | + ); | ||
| 19039 | + } | ||
| 19040 | + | ||
| 18330 | #[test] | 19041 | #[test] |
| 18331 | #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] | 19042 | #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] |
| 18332 | fn sb128_r2_control_sb64() { | 19043 | fn sb128_r2_control_sb64() { |
| @@ -20829,6 +21540,11 @@ mod tests { | |||
| 20829 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | 21540 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| 20830 | let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); | 21541 | let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); |
| 20831 | let mut split_proved = 0usize; | 21542 | let mut split_proved = 0usize; |
| 21543 | + // lane-kf1200: chroma pairs whose intra-edge filter type comes out | ||
| 21544 | + // different when read from the PAIR's base mi (libaom's | ||
| 21545 | + // `chroma_above_mbmi`) rather than the odd strip mi -- the shape | ||
| 21546 | + // that was silently wrong by 1 on the ReelB key frames. | ||
| 21547 | + let mut pair_filt_proved = 0usize; | ||
| 20832 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | 21548 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); |
| 20833 | // The second half of the window turns `--enable-tx-size-search` on: | 21549 | // The second half of the window turns `--enable-tx-size-search` on: |
| 20834 | // that is what makes a 16x4 strip SPLIT its transform (depth 1 = | 21550 | // that is what makes a 16x4 strip SPLIT its transform (depth 1 = |
| @@ -20841,11 +21557,26 @@ mod tests { | |||
| 20841 | let axis = if attempt % 2 == 0 { "Y" } else { "X" }; | 21557 | let axis = if attempt % 2 == 0 { "Y" } else { "X" }; |
| 20842 | let step = 67 + (attempt / 2) * 12; | 21558 | let step = 67 + (attempt / 2) * 12; |
| 20843 | let noise = 6 + (attempt % 4) * 3; | 21559 | let noise = 6 + (attempt % 4) * 3; |
| 20844 | - let source = format!( | 21560 | + // lane-kf1200: the odd attempts carry CHROMA content. The |
| 20845 | - "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | 21561 | + // original gray source leaves both chroma planes constant, so |
| 20846 | - geq=lum='mod(floor({axis}/4)*{step},256)',\ | 21562 | + // every `uv_mode` is DC and a pair's edge-filter type can never |
| 20847 | - noise=alls={noise}:all_seed={seed},format=yuv420p" | 21563 | + // differ from its strip's -- the shape that shipped wrong for |
| 20848 | - ); | 21564 | + // months. A smooth chroma gradient makes aomenc pick SMOOTH / |
| 21565 | + // directional `uv_mode`s next to each other. | ||
| 21566 | + let source = if attempt % 2 == 0 { | ||
| 21567 | + format!( | ||
| 21568 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 21569 | + geq=lum='mod(floor({axis}/4)*{step},256)',\ | ||
| 21570 | + noise=alls={noise}:all_seed={seed},format=yuv420p" | ||
| 21571 | + ) | ||
| 21572 | + } else { | ||
| 21573 | + format!( | ||
| 21574 | + "color=c=black:s={width}x{height}:d={duration}:r=25,format=yuv420p,\ | ||
| 21575 | + geq=lum='mod(floor({axis}/4)*{step},256)'\ | ||
| 21576 | + :cb='128+100*sin((X+Y)/23)':cr='128+100*cos(X/19)',\ | ||
| 21577 | + noise=alls={noise}:all_seed={seed}" | ||
| 21578 | + ) | ||
| 21579 | + }; | ||
| 20849 | let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8); | 21580 | let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8); |
| 20850 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 21581 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; |
| 20851 | let y4m = Command::new("ffmpeg") | 21582 | let y4m = Command::new("ffmpeg") |
| @@ -20924,6 +21655,7 @@ mod tests { | |||
| 20924 | ); | 21655 | ); |
| 20925 | let stream = out.stdout; | 21656 | let stream = out.stdout; |
| 20926 | let before = crate::decode::rect4_16_counters(); | 21657 | let before = crate::decode::rect4_16_counters(); |
| 21658 | + let pair_filt_before = crate::decode::rect4_16_uv_pair_filt_hits(); | ||
| 20927 | let frames = match decode_stream(&stream) { | 21659 | let frames = match decode_stream(&stream) { |
| 20928 | Err(e) => { | 21660 | Err(e) => { |
| 20929 | let msg = e.to_string(); | 21661 | let msg = e.to_string(); |
| @@ -20992,6 +21724,7 @@ mod tests { | |||
| 20992 | vert_proved += vert; | 21724 | vert_proved += vert; |
| 20993 | chroma_proved += chroma; | 21725 | chroma_proved += chroma; |
| 20994 | coeff_proved += coeff; | 21726 | coeff_proved += coeff; |
| 21727 | + pair_filt_proved += crate::decode::rect4_16_uv_pair_filt_hits() - pair_filt_before; | ||
| 20995 | split_proved += split; | 21728 | split_proved += split; |
| 20996 | matched += 1; | 21729 | matched += 1; |
| 20997 | } | 21730 | } |
| @@ -21024,11 +21757,17 @@ mod tests { | |||
| 21024 | "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \ | 21757 | "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \ |
| 21025 | the `--enable-tx-size-search=1` half of the window proved nothing" | 21758 | the `--enable-tx-size-search=1` half of the window proved nothing" |
| 21026 | ); | 21759 | ); |
| 21760 | + assert!( | ||
| 21761 | + pair_filt_proved > 0, | ||
| 21762 | + "{NAME}: {bit_depth}-bit compared attempts never decoded a chroma pair whose \ | ||
| 21763 | + edge-filter type differs between the pair's base mi and the strip's own mi -- \ | ||
| 21764 | + the lane-kf1200 fix is unexercised, so this gate would pass with it reverted" | ||
| 21765 | + ); | ||
| 21027 | eprintln!( | 21766 | eprintln!( |
| 21028 | "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \ | 21767 | "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \ |
| 21029 | {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \ | 21768 | {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \ |
| 21030 | - units, {split_proved} split-transform strips, {named_refusals} refusals, \ | 21769 | + units, {split_proved} split-transform strips, {pair_filt_proved} pair-base \ |
| 21031 | - {out_of_scope} out of scope" | 21770 | + filt-type flips, {named_refusals} refusals, {out_of_scope} out of scope" |
| 21032 | ); | 21771 | ); |
| 21033 | } | 21772 | } |
| 21034 | } | 21773 | } |
lanes/kf1200-r1.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | |||
| 1 | +# lane-kf1200 r1 — the 16x4/4x16 chroma pair read its edge-filter type from the wrong mi | ||
| 2 | + | ||
| 3 | +## Defect (census4 premise, re-measured on this branch) | ||
| 4 | + | ||
| 5 | +ReelB `-ss 1200` key frame (1 frame, `3840x1608 yuv420p10le`), our | ||
| 6 | +`EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`: **12 U samples at ±1, Y and V exact**. | ||
| 7 | +Stage bisect (`EC_AV1_PREFILT_DUMP16` ours vs aomdec's): **13 U samples already wrong | ||
| 8 | +before the loop filter** — a reconstruction defect, not deblock/CDEF/LR/film grain, and | ||
| 9 | +not an entropy desync (lane-kf900's shape). | ||
| 10 | + | ||
| 11 | +## Root cause | ||
| 12 | + | ||
| 13 | +Block: chroma `(x=352, y=356)`, `8x4`, `uv_mode = H_PRED`, `angle_delta_uv = -2` | ||
| 14 | +(`p_angle = 174`), the chroma half of a `16x8` **`PARTITION_HORZ_4` pair** at | ||
| 15 | +luma mi `(178,176)`, strip mi `(179,176)`. | ||
| 16 | +Its prediction differed from aomdec's by 4 samples of the last row | ||
| 17 | +(`OUR_PRED sum=16208` vs `EC_PREDOUT sum=16212`); row 0 and column 0 identical. | ||
| 18 | + | ||
| 19 | +`decode.rs:7683` asked for the chroma edge-filter type at the **strip's own mi** | ||
| 20 | +(`lmi = (179,176)`). libaom builds `chroma_above_mbmi`/`chroma_left_mbmi` from | ||
| 21 | +`mi[-((mi_row & ss_y) * mi_stride + (mi_col & ss_x))]` (`set_mi_offsets`, | ||
| 22 | +`av1/common/blockd.h`), i.e. from the **pair's base mi** `(178,176)`, and | ||
| 23 | +`get_intra_edge_filter_type` (`av1/common/reconintra.c:974`) reads that block's | ||
| 24 | +`uv_mode`. The mi directly above the strip, `(178,176)`, is a non-chroma-reference | ||
| 25 | +4-row block whose `uv_mode` is `UV_DC_PRED`; the mi above the PAIR, `(177,176)`, | ||
| 26 | +coded `uv_mode = SMOOTH` (aomdec `EC_IMODE_VAL mi_row=177 mi_col=176 uv_mode=9`). | ||
| 27 | + | ||
| 28 | +So we computed `filt_type = 0` where libaom has `1` (aomdec `EC_PRED ... ft=1`). | ||
| 29 | +With `filt_type = 0`, `av1_use_intra_edge_upsample(4, 8, -6, 0)` is TRUE | ||
| 30 | +(`blk_wh = 12 <= 16`) instead of false — the left edge was upsampled before the | ||
| 31 | +z2 walk, moving 4 samples by 1. The strength/upsample/z2 code itself is correct: | ||
| 32 | +recomputing z2 by hand from the (identical) neighbour pixels reproduces aomdec's | ||
| 33 | +row exactly (`scratchpad/kf1200`, brute force over dy/offsets). | ||
| 34 | + | ||
| 35 | +## Change | ||
| 36 | + | ||
| 37 | +- `crates/ec-av1/src/decode.rs:7683` — `smooth_uv_neighbour(pair_mi.0, pair_mi.1, ...)` | ||
| 38 | + instead of `(lmi.0, lmi.1, ...)`, with the libaom citation. | ||
| 39 | +- `crates/ec-av1/src/decode.rs:2196` — new `RECT4_16_UV_PAIR_FILT_HITS` counter + | ||
| 40 | + `rect4_16_uv_pair_filt_hits()`: pairs where the pair-base answer DIFFERS from the | ||
| 41 | + strip-mi answer, i.e. the blocks the fix changes. | ||
| 42 | +- `crates/ec-av1/src/stream.rs` gate | ||
| 43 | + `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` — the odd | ||
| 44 | + attempts now use a **chroma-carrying** source (smooth `cb`/`cr` gradients); the gray | ||
| 45 | + source left both chroma planes constant, so every `uv_mode` was DC and the shape was | ||
| 46 | + unreachable. New hard assert: `pair_filt_proved > 0` per bit-depth arm. | ||
| 47 | + | ||
| 48 | +No refusal lifted, so `refusal_inventory.rs`/`gate_coverage.rs` are unchanged. | ||
| 49 | + | ||
| 50 | +## EVIDENCE | ||
| 51 | + | ||
| 52 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{ours16,ref.yuv} | ffmpeg -ss 1200 -t 0.4 -c:v copy -f obu, trunc.py to 1 frame (sha256 b4b92873d0329964 twice), decode_probe EC_PROBE_OUT16 vs ffmpeg yuv420p10le | U samples differing 12 -> 0, Y/V 0 (Y 0, U 0, V 0 after fix) | ||
| 53 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{pre.f0,apre.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the same 1-frame stream | 13 U samples differ pre-loop-filter => reconstruction, not filters/grain | ||
| 54 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{opred.txt,apred.txt} | EC_PRED=1 on both decoders | block (352,356) 8x4 mode=2 ad=-2: ours sum=16208 vs EC_PREDOUT sum=16212, oracle EC_PRED ft=1 | ||
| 55 | +EVIDENCE: gate run `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact -- --nocapture` | real aomenc, 8-bit and 10-bit arms | 8-bit: 16 compared attempts, 232 16x4 / 244 4x16, 238 chroma pairs, 13 pair-base filt-type flips, PASS; 10-bit: 15 attempts, 198 pairs, 8 flips, PASS | ||
| 56 | +EVIDENCE: same gate with the fix reverted (pair_mi -> lmi) | one-line revert, rebuild, rerun | FAILED "frame 0 U vs ffmpeg (8-bit, seed 43)" -- the gate is decisive, not vacuous | ||
| 57 | +EVIDENCE: $HOME/.cache/kf1200-census.log | 24 HG key frames, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg, each stream sha256'd twice (identical) | see table | ||
| 58 | + | ||
| 59 | +## 24 key-frame census (bytes differing, 1 frame each) | ||
| 60 | + | ||
| 61 | +| -ss | before (census4) | after | | ||
| 62 | +|----:|-----------------:|------:| | ||
| 63 | +| 0 | 0 | 0 | | ||
| 64 | +| 300 | 463 | 463 | | ||
| 65 | +| 600 | 48771 | 48771 | | ||
| 66 | +| 900 | 14057195 | 14057191 | | ||
| 67 | +| **1200** | **14** | **0** | | ||
| 68 | +| 1500 | 16649701 | 16649650 | | ||
| 69 | +| **1800** | **248** | **0** | | ||
| 70 | +| 2100 | 15147518 | 15147782 | | ||
| 71 | +| 2400 | 42343 | 42343 | | ||
| 72 | +| 2700 | 7726287 | 7726287 | | ||
| 73 | +| 3000 | 0 | 0 | | ||
| 74 | +| 3300 | 44500 | **39971** | | ||
| 75 | +| **3600** | **1** | **0** | | ||
| 76 | +| 3900 | 7554020 | 7554023 | | ||
| 77 | +| 4200 | 0 | 0 | | ||
| 78 | +| 4500 | 0 | 0 | | ||
| 79 | +| 4800 | 2348 | 2348 | | ||
| 80 | +| 5100 | 0 | 0 | | ||
| 81 | +| 5400 | 0 | 0 | | ||
| 82 | +| 5700 | 16375 | 16375 | | ||
| 83 | +| 6000 | 15450360 | 15449720 | | ||
| 84 | +| 6300 | 15410936 | 15410864 | | ||
| 85 | +| 6600 | 15181681 | 15181688 | | ||
| 86 | +| 6900 | 0 | 0 | | ||
| 87 | + | ||
| 88 | +(The census4 numbers were taken with the same recipe; note census4 measured frame 0 of a | ||
| 89 | +segment that then refused later frames, and this run truncates to 1 frame identically. | ||
| 90 | +The multi-million counts are lane-kf900's entropy-desync territory, unchanged here.) | ||
| 91 | + | ||
| 92 | +## Residue | ||
| 93 | + | ||
| 94 | +- deferred: `-ss 300` (463 bytes) — a DIFFERENT shape, also chroma-only and also | ||
| 95 | + pre-loop-filter, but block-constant offsets of +1/+2 over a ~16x16 chroma region at | ||
| 96 | + chroma (412,384) (`EC_AV1_PREFILT_DUMP16` diff, this branch) — reads like CfL alpha or | ||
| 97 | + a chroma DC/dequant defect, not an edge-filter type. Unblocked by: localising that | ||
| 98 | + block's `uv_mode`/CfL alpha the same way (EC_IMODE_VAL + EC_PRED at mi (206,192)). | ||
| 99 | +- deferred: `-ss 600 / 2400 / 4800 / 5700 / 3300` (48771 / 42343 / 2348 / 16375 / 39971) — | ||
| 100 | + larger residuals, not triaged in this round. | ||
| 101 | +- accepted: the multi-million-byte segments are entropy desyncs owned by lane-kf900. | ||
| 102 | + | ||
| 103 | +## Suite | ||
| 104 | + | ||
| 105 | +`cargo test -p ec-av1 --lib` (systemd unit, `EC_AV1_REQUIRE_AOMENC=1`, log `$HOME/.cache/kf1200-suite-r1.log`): | ||
| 106 | +**370 passed / 0 failed / 32 ignored**, 1546 s. | ||
lanes/kf1200-r2.handoff.mdadded+72 -0
| @@ -0,0 +1,72 @@ | |||
| 1 | +# lane-kf1200 r2 HANDOFF | ||
| 2 | + | ||
| 3 | +## Merge state | ||
| 4 | +Branch `lane-kf1200`, tip `385b745`. `git merge main` (85887c7 = lane-mvtwin + | ||
| 5 | +lane-sb128b) landed clean at `d85d7d2`; cdf.rs byte-identical to main's; r1's | ||
| 6 | +pair-mi chroma edge-filter fix survives at decode.rs:7747. main contains | ||
| 7 | +NEITHER lane-reelckf NOR lane-kf900 (`git log --oneline main | grep` empty for | ||
| 8 | +both), so no duplicate-implementation resolution was needed and the | ||
| 9 | +multi-million-byte census rows are still kf900's. | ||
| 10 | +Do NOT commit `lanes/COMMON-20260901.md` — another agent edits it in this | ||
| 11 | +worktree; it is intentionally left unstaged. (It is currently modified.) | ||
| 12 | + | ||
| 13 | +## Per-segment findings (ReelB, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg 10-bit) | ||
| 14 | +- **-ss 300 — FIXED (463 -> 0 bytes).** Plane: U+V only, Y exact. First bad | ||
| 15 | + sample chroma (412,384). Stage: PRE-loop-filter (EC_AV1_PREFILT_DUMP16), | ||
| 16 | + 16x16 chroma region at (384,412). Block: the 4x4 chroma block of the | ||
| 17 | + BLOCK_4X4 2x2 group at luma mi (206,192); chroma-ref mi (207,193), | ||
| 18 | + `uv_mode=13` (UV_CFL_PRED), `skip=1`. Root cause: both sub-8x8 leaf decoders | ||
| 19 | + passed literal `None` for the CfL argument in their `skip_txfm` arm | ||
| 20 | + (decode.rs:10554/10555 4-leaf, :10916/10917 2-leaf), so the block | ||
| 21 | + reconstructed as flat DC. libaom `av1_predict_intra_block_facade` | ||
| 22 | + (av1/common/reconintra.c:1719) calls `cfl_predict_block` whenever | ||
| 23 | + `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` drops only the residual. | ||
| 24 | + Fix: compute `cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)` in both | ||
| 25 | + arms + `SKIP_CFL_HITS` counter (decode.rs:2207, `skip_cfl_hits()`). | ||
| 26 | + Effect: -ss 300 pixel-exact; -ss 4800 2348 -> 34 bytes as a side effect. | ||
| 27 | +- **-ss 600 / 2400 / 3300 / 5700 — ONE class, open.** 48771 / 42343 / 39971 / | ||
| 28 | + 16375 bytes. All planes. Final-picture damage rows Y 1595..1607, chroma | ||
| 29 | + 796..803. Stage: PRE-loop-filter damage is EXACTLY luma rows 1600..1607, | ||
| 30 | + cols 192..3839 (rows 1595..1599 are deblock spill across the y=1600 edge). | ||
| 31 | + Frame is 1608 rows = 25 full 64-px SB rows + an 8-row remainder, so this is | ||
| 32 | + the bottom PARTIAL superblock row; its first three superblocks (cols 0..191) | ||
| 33 | + are pixel-exact. Block: our prediction trace matches aomdec block-for-block | ||
| 34 | + through mi (400,47) (mi 44 four TX_4X4 in an 8x8, mi 46 an 8x8). First | ||
| 35 | + divergence is the FIRST block of superblock #3: | ||
| 36 | + aomdec `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` | ||
| 37 | + ours `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) | ||
| 38 | + i.e. a PARTITION-SYMBOL divergence at the root of a partial-height | ||
| 39 | + superblock (`has_rows == false`, 2 of 16 mi rows present). Not prediction, | ||
| 40 | + not caused by the preceding block. Root cause NOT yet identified. | ||
| 41 | +- **-ss 4800 — open, small.** 34 bytes (was 2348). Chroma only, luma exact, | ||
| 42 | + PRE-loop-filter: U 25 + V 3 samples in an 8x4 chroma patch rows 540..543 | ||
| 43 | + cols 1200..1207, |d| <= 6. Luma mi ~ (270,600). Same geometry as r1's | ||
| 44 | + 16x8 PARTITION_HORZ_4 pair defect -> likely a sibling of the pair-mi bug. | ||
| 45 | +- Accepted (kf900's): 900, 1500, 2100, 2700, 3900, 6000, 6300, 6600. | ||
| 46 | + | ||
| 47 | +## Gate state | ||
| 48 | +- New: `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` | ||
| 49 | + (crates/ec-av1/src/stream.rs), pins | ||
| 50 | + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139201 B, sha256 | ||
| 51 | + 7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12, one | ||
| 52 | + 3840x1608 yuv420p10le key frame, `git add -f`, confirmed in `git ls-files`). | ||
| 53 | + HARD-asserts `skip_cfl_hits > 0` (it fires exactly ONCE in the whole frame) | ||
| 54 | + then Y/U/V vs ffmpeg. Fixture used because lane-reelckf r1's ledger dead-end | ||
| 55 | + records 20 aomenc recipes that never produced a skipped sub-8x8 CfL block. | ||
| 56 | +- r1's `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` | ||
| 57 | + (chroma-carrying source + `pair_filt_proved > 0`) unchanged and green. | ||
| 58 | +- No refusal lifted; refusal_inventory.rs / gate_coverage.rs untouched. | ||
| 59 | +- Suite: 378 passed / 0 failed / 33 ignored (794.95 s), | ||
| 60 | + `$HOME/.cache/kf1200-suite-r2.log`. | ||
| 61 | + | ||
| 62 | +## Exact next step | ||
| 63 | +Range-ladder the partition symbols of superblock (mi_row=400, mi_col=48) on | ||
| 64 | +`scratchpad/kf1200/s600_f1.obu` (1 frame, sha256 36de46676ed7de70… stable | ||
| 65 | +twice): both decoders are still in sync at mi (400,47), so start the ladder | ||
| 66 | +there and compare aomdec's `r->ec.rng` at each `EC_IMODE`/partition read | ||
| 67 | +against ours element by element (compare RANGE, never tell()). The suspect is | ||
| 68 | +the `has_rows == false` forced-partition path at a 64x64 root with only 2 mi | ||
| 69 | +rows left — we take a 32x16 where libaom takes 16x8. Artifacts already on disk | ||
| 70 | +in scratchpad/kf1200: s600_f1.obu, a600p.trace (aomdec EC_PRED), o600.trace | ||
| 71 | +(our OUR_PRED), pre600.f0 / apre600.f0 (prefilter dumps), d1.py (plane differ), | ||
| 72 | +census.sh (24-frame census, debug probe path). | ||
lanes/kf1200-r2.report.mdadded+183 -0
| @@ -0,0 +1,183 @@ | |||
| 1 | +# lane-kf1200 r2 — a skipped sub-8x8 chroma block dropped its CfL alpha | ||
| 2 | + | ||
| 3 | +## 1. Merge | ||
| 4 | + | ||
| 5 | +`git merge --no-commit main` (main `85887c7`, lane-mvtwin + lane-sb128b) — clean | ||
| 6 | +auto-merge, no conflicts. `crates/ec-av1/src/cdf.rs` byte-identical to main's | ||
| 7 | +(`cmp <(git show main:.../cdf.rs) .../cdf.rs` → identical). r1's pair-mi chroma | ||
| 8 | +edge-filter fix and its counter survive at `decode.rs:7747`. Commit `d85d7d2`. | ||
| 9 | +main contains neither lane-reelckf nor lane-kf900 (`git log --oneline main | grep` | ||
| 10 | +→ empty for both), so no duplicate-implementation resolution was needed and the | ||
| 11 | +multi-million-byte census rows are still lane-kf900's territory. | ||
| 12 | + | ||
| 13 | +## 2. Defect found and fixed: `-ss 300`, 463 bytes → 0 | ||
| 14 | + | ||
| 15 | +Re-measured premise on this branch (1-frame truncation, hash stable twice): | ||
| 16 | +U 219 / V 220 samples wrong, Y exact. `EC_AV1_PREFILT_DUMP16` ours vs aomdec's: | ||
| 17 | +227 U + 227 V wrong **before the loop filter**, in a 16x16 chroma region at | ||
| 18 | +chroma `(384,412)` — reconstruction, not filters. | ||
| 19 | + | ||
| 20 | +First bad sample chroma `(412,384)` = the 4x4 chroma block of the `BLOCK_4X4` | ||
| 21 | +2x2 group at luma mi `(206,192)`. aomdec `EC_TRACE_MODE`: | ||
| 22 | +`EC_IMODE_VAL mi_row=207 mi_col=193 mode=4 uv_mode=13 skip=1` — `uv_mode = 13` | ||
| 23 | +is `UV_CFL_PRED`, `skip_txfm = 1`. Our `OUR_PRED x=384 y=412 side=4 mode=0 | ||
| 24 | +sum=8240 row0=[515,515,515,515]` is flat: DC with **no CfL term at all** | ||
| 25 | +(aomdec's own prediction sums to 8241 with a bottom-left ramp). | ||
| 26 | + | ||
| 27 | +Root cause: both sub-8x8 leaf decoders passed a literal `None` for the CfL | ||
| 28 | +argument in their `skip_txfm` arm — | ||
| 29 | + | ||
| 30 | +- `crates/ec-av1/src/decode.rs:10554/10555` (the 4-leaf `BLOCK_4X4` group) | ||
| 31 | +- `crates/ec-av1/src/decode.rs:10916/10917` (the 2-leaf group) | ||
| 32 | + | ||
| 33 | +libaom's `av1_predict_intra_block_facade` (`av1/common/reconintra.c:1719`) calls | ||
| 34 | +`cfl_predict_block` whenever `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` only | ||
| 35 | +suppresses the residual, never the alpha. Both arms now compute | ||
| 36 | +`cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)`, exactly like the | ||
| 37 | +non-skip arm two lines below and like the rect skip arms already did. | ||
| 38 | + | ||
| 39 | +### Class sweep | ||
| 40 | + | ||
| 41 | +Every chroma `reconstruct` / `reconstruct_rect` call site in `decode.rs` was | ||
| 42 | +parsed and its cfl argument printed (script in the r2 scratchpad). The rect | ||
| 43 | +skip arms (`6015`, `6519`, `8078`) already pass `alpha.zip(ac)`; the only other | ||
| 44 | +literal `None` is `20284/20296`, which sits directly behind the refusal | ||
| 45 | +"a non-DC chroma mode on an 8x8 inter-frame leaf" (`decode.rs:20212`), so | ||
| 46 | +`uv_mode == DC_PRED` is guaranteed there. No other instance of the class. | ||
| 47 | + | ||
| 48 | +### Counter + gate | ||
| 49 | + | ||
| 50 | +- `decode.rs:2207` `SKIP_CFL_HITS` / `pub fn skip_cfl_hits()` — skipped sub-8x8 | ||
| 51 | + chroma blocks that carried a CfL alpha. | ||
| 52 | +- `crates/ec-av1/src/stream.rs` | ||
| 53 | + `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` — pins | ||
| 54 | + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139 201 B, sha256 | ||
| 55 | + `7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12`, one | ||
| 56 | + 3840x1608 yuv420p10le key frame), decodes it, HARD-asserts | ||
| 57 | + `skip_cfl_hits > 0`, then compares Y/U/V against ffmpeg's own 10-bit decode. | ||
| 58 | + `git add -f` was used (bare `fixtures` in .gitignore); `git ls-files` confirms | ||
| 59 | + it is tracked. | ||
| 60 | + | ||
| 61 | +Why a fixture and not an aomenc recipe: lane-reelckf r1's ledger dead-end — | ||
| 62 | +20 recipes (cq 40..63 × nine lavfi sources, min/max-partition sweeps, sb-size | ||
| 63 | +64 and 128) never produced a **skipped** sub-8x8 CfL block (`skip_cfl` counter | ||
| 64 | +0 in all). The shape fires exactly **once** in a whole 4K key frame, which is | ||
| 65 | +why no synthetic source reaches it. | ||
| 66 | + | ||
| 67 | +No refusal lifted → `refusal_inventory.rs` / `gate_coverage.rs` unchanged. | ||
| 68 | + | ||
| 69 | +## 3. Remaining residuals — triaged, one class | ||
| 70 | + | ||
| 71 | +`-ss 600 / 2400 / 3300 / 5700` (48771 / 42343 / 39971 / 16375 bytes) are ONE | ||
| 72 | +defect class, not four: in every one of them the damage is confined to the | ||
| 73 | +**last 8 luma rows** of the frame. | ||
| 74 | + | ||
| 75 | +| -ss | Y rows wrong | U/V rows | first bad Y sample | | ||
| 76 | +|----:|---|---|---| | ||
| 77 | +| 600 | 1595..1607 | 796..803 | (1595, 2916) | | ||
| 78 | +| 2400 | 1595..1607 | 796..803 | (1595, 2445) | | ||
| 79 | +| 3300 | 1595..1607 | 796..803 | (1595, 1235) | | ||
| 80 | +| 5700 | 1596..1607 | 796..803 | (1596, 3039) | | ||
| 81 | + | ||
| 82 | +`EC_AV1_PREFILT_DUMP16` on `-ss 600` narrows it further: pre-loop-filter the | ||
| 83 | +damage is exactly rows **1600..1607**, columns **192..3839** (rows 1595..1599 | ||
| 84 | +in the final picture are deblock spill across the y=1600 edge). The frame is | ||
| 85 | +1608 rows = 25 full 64-px superblock rows + one 8-row remainder, so this is the | ||
| 86 | +bottom **partial** superblock row, and the first three superblocks of it | ||
| 87 | +(columns 0..191) are pixel-exact. | ||
| 88 | + | ||
| 89 | +Divergence localised to a single block. Through luma mi `(400,47)` our | ||
| 90 | +prediction trace matches aomdec's block for block (mi 44: four TX_4X4 in an | ||
| 91 | +8x8; mi 46: 8x8 — `EC_PRED mi_row=400 mi_col=46 txw=8 txh=8`). At the very | ||
| 92 | +first block of superblock #3: | ||
| 93 | + | ||
| 94 | +- aomdec: `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` | ||
| 95 | +- ours: `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) | ||
| 96 | + | ||
| 97 | +i.e. we read a 32x16 `PARTITION_HORZ` where libaom reads a 16x8, and the mode | ||
| 98 | +differs too — a **partition-symbol divergence at the root of a partial-height | ||
| 99 | +superblock** (`has_rows == false`, only 2 of 16 mi rows present), not a | ||
| 100 | +prediction bug and not caused by the preceding block. Everything after it in | ||
| 101 | +that row is garbage because the row never re-syncs (it is the last row, so | ||
| 102 | +nothing propagates downward). | ||
| 103 | + | ||
| 104 | +`-ss 4800` (2348 bytes in r1, **34 bytes** after this round's CfL fix) is a | ||
| 105 | +different, much smaller shape: chroma only, | ||
| 106 | +U 29 + V 5 samples in the final picture. `EC_AV1_PREFILT_DUMP16` puts it | ||
| 107 | +**pre-loop-filter** too — U 25 + V 3 samples in an **8x4 chroma patch** at | ||
| 108 | +rows 540..543, cols 1200..1207 (`|d| <= 6`), luma exact. That is the same | ||
| 109 | +geometry as r1's defect (an 8x4 chroma block = the chroma half of a 16x8 | ||
| 110 | +`PARTITION_HORZ_4` pair) at luma mi ~`(270,600)`, so it is a strong candidate | ||
| 111 | +for a sibling of the pair-mi bug rather than a new class. | ||
| 112 | + | ||
| 113 | +## 4. Disposition | ||
| 114 | + | ||
| 115 | +- fix-now (done): `-ss 300` skipped-CfL, fixed + gated + swept. | ||
| 116 | +- deferred: the bottom partial-superblock partition divergence (`-ss 600`, | ||
| 117 | + 2400, 3300, 5700). Unblocked by: a range ladder over the partition symbols | ||
| 118 | + of superblock `(mi_row=400, mi_col=48)` in `s600_f1.obu` comparing aomdec's | ||
| 119 | + `r->ec.rng` at `EC_IMODE` against ours — the first three superblocks of the | ||
| 120 | + same row are exact, so the ladder starts already in sync at mi 400/47. | ||
| 121 | +- deferred: `-ss 4800` (34 B, down from 2348) — stage-attributed (pre-loop-filter, chroma-only, | ||
| 122 | + 8x4 patch at chroma (540,1200), luma mi ~(270,600)); the per-block | ||
| 123 | + `EC_IMODE_VAL`/`EC_PRED` comparison at that mi is the next step. | ||
| 124 | +- accepted: `-ss 900 / 1500 / 2100 / 2700 / 3900 / 6000 / 6300 / 6600` | ||
| 125 | + (multi-million bytes) are lane-kf900's entropy desyncs, not merged into main. | ||
| 126 | + | ||
| 127 | +## 5. 24 key-frame census (bytes differing vs ffmpeg, 1 truncated frame each) | ||
| 128 | + | ||
| 129 | +Recipe: `$HOME/.cache/kf1200-census-r2.log` (script `census.sh` in the r2 | ||
| 130 | +scratchpad) — `ffmpeg -ss S -t 0.4 -c:v copy -f obu`, `trunc.py … 1`, each | ||
| 131 | +stream sha256'd twice (identical in all 24 rows), `EC_PROBE_OUT16` vs | ||
| 132 | +`ffmpeg -pix_fmt yuv420p10le`. | ||
| 133 | + | ||
| 134 | +| -ss | r1 (after pair-mi fix) | r2 (after skipped-CfL fix) | | ||
| 135 | +|----:|-----------------------:|---------------------------:| | ||
| 136 | +| 0 | 0 | 0 | | ||
| 137 | +| **300** | **463** | **0** | | ||
| 138 | +| 600 | 48771 | 48771 | | ||
| 139 | +| 900 | 14057191 | 14057191 | | ||
| 140 | +| 1200 | 0 | 0 | | ||
| 141 | +| 1500 | 16649650 | 16649650 | | ||
| 142 | +| 1800 | 0 | 0 | | ||
| 143 | +| 2100 | 15147782 | 15148697 | | ||
| 144 | +| 2400 | 42343 | 42343 | | ||
| 145 | +| 2700 | 7726287 | 7726168 | | ||
| 146 | +| 3000 | 0 | 0 | | ||
| 147 | +| 3300 | 39971 | 39971 | | ||
| 148 | +| 3600 | 0 | 0 | | ||
| 149 | +| 3900 | 7554023 | 7554023 | | ||
| 150 | +| 4200 | 0 | 0 | | ||
| 151 | +| 4500 | 0 | 0 | | ||
| 152 | +| **4800** | **2348** | **34** | | ||
| 153 | +| 5100 | 0 | 0 | | ||
| 154 | +| 5400 | 0 | 0 | | ||
| 155 | +| 5700 | 16375 | 16375 | | ||
| 156 | +| 6000 | 15449720 | 15449720 | | ||
| 157 | +| 6300 | 15410864 | 15410664 | | ||
| 158 | +| 6600 | 15181688 | 15180826 | | ||
| 159 | +| 6900 | 0 | 0 | | ||
| 160 | + | ||
| 161 | +**11 of 24 key frames now decode pixel-exact** (was 10). `-ss 300` is exact; | ||
| 162 | +`-ss 4800` fell 2348 → 34 bytes (its remaining 8x4 chroma patch is the residue | ||
| 163 | +described in §3). Rows differing by a few hundred bytes inside the | ||
| 164 | +multi-million-byte segments are the usual desync churn of lane-kf900's | ||
| 165 | +territory, not a regression: none of them changed sign or magnitude class. | ||
| 166 | + | ||
| 167 | +## 6. Suite | ||
| 168 | + | ||
| 169 | +`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=kf1200-suite-r2b | ||
| 170 | +-p MemoryMax=10G`, `EC_AV1_REQUIRE_AOMENC=1 EC_NOMEMGUARD=1 -j3`, log | ||
| 171 | +`$HOME/.cache/kf1200-suite-r2.log`: | ||
| 172 | +**378 passed / 0 failed / 33 ignored**, 794.95 s. | ||
| 173 | + | ||
| 174 | +## EVIDENCE | ||
| 175 | + | ||
| 176 | +EVIDENCE: $HOME/.cache/kf1200-suite-r2.log | systemd unit kf1200-suite-r2b, EC_AV1_REQUIRE_AOMENC=1, cargo test -p ec-av1 --lib -j3 | test result: ok. 378 passed; 0 failed; 33 ignored; 794.95s | ||
| 177 | +EVIDENCE: scratchpad/kf1200/{o300,r300} | 1-frame -ss 300 truncation (sha256 7e3ddf0d602f9496 twice), EC_PROBE_OUT16 vs ffmpeg -pix_fmt yuv420p10le | before fix Y 0 / U 219 / V 220 samples differ; after fix Y 0 / U 0 / V 0 | ||
| 178 | +EVIDENCE: scratchpad/kf1200/{pre300.f0,apre300.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec, same stream | 227 U + 227 V wrong PRE-loop-filter in a 16x16 chroma region at (384,412) => reconstruction | ||
| 179 | +EVIDENCE: scratchpad/kf1200/{o300.trace,a300.trace} | EC_PRED=1 ours, EC_TRACE_MODE=1 EC_PRED=1 aomdec | aomdec EC_IMODE_VAL mi_row=207 mi_col=193 uv_mode=13 (UV_CFL_PRED) skip=1; ours OUR_PRED x=384 y=412 side=4 mode=0 sum=8240 flat (no CfL term) | ||
| 180 | +EVIDENCE: gate run `cargo test -p ec-av1 --lib the_reelb_ss300 -- --nocapture` | pinned 1-frame fixture + ffmpeg 10-bit reference | "1 skipped sub-8x8 CfL chroma blocks, frame pixel-exact", 1 passed / 0 failed | ||
| 181 | +EVIDENCE: scratchpad/kf1200/{pre600.f0,apre600.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the -ss 600 1-frame stream | damage exactly luma rows 1600..1607, cols 192..3839 = the bottom partial (8-row) superblock row from superblock #3 on | ||
| 182 | +EVIDENCE: scratchpad/kf1200/{o600.trace,a600p.trace} | EC_PRED both decoders | mi (400,44) and (400,46) match block for block; at mi (400,48) aomdec txw=16 txh=8 mode=2 bsize=5 vs ours bw=32 bh=16 mode=0 => partition divergence at the partial-SB root | ||
| 183 | +EVIDENCE: $HOME/.cache/kf1200-census-r2.log | census.sh, 24 key frames, each stream hashed twice | 11/24 pixel-exact (was 10); -ss 300 463->0, -ss 4800 2348->34 | ||
lanes/mvtwin-r1.report.mdadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +# lane-mvtwin r1 — phase-by-phase diff of the two MV-stack twins vs libaom | ||
| 2 | + | ||
| 3 | +Base: lane-sb128 5ea5ec8, merged main 7a47fc1 (clean; the 128x128-superblock | ||
| 4 | +refusal main re-added at b51719f stayed deleted — grep confirms). | ||
| 5 | +Oracle: `~/.cache/aom-oracle/src/av1/common/mvref_common.c` (`setup_ref_mv_list`, | ||
| 6 | +`av1_find_mv_refs`). Ours: `crates/ec-av1/src/mvstack.rs` | ||
| 7 | +(`find_mv_stack_with_sign_bias` = single-ref twin, `find_mv_stack_compound` = compound twin). | ||
| 8 | + | ||
| 9 | +## The table (libaom line = mvref_common.c) | ||
| 10 | + | ||
| 11 | +| # | phase (libaom) | single-ref ours | compound ours | defect? | | ||
| 12 | +|---|---|---|---|---| | ||
| 13 | +| 1 | `row_adj`/`col_adj`, `find_valid_row/col_offset` reach (:502-533) | mvstack.rs:809 | mvstack.rs:1610 | **DEFECT 3** — both clamped the reach to the FRAME edge, libaom clamps to `tile->mi_row_start`/`mi_col_start` | | ||
| 14 | +| 2 | `scan_row_mbmi` immediate, `len`/`weight`/`inc`/`processed_rows` (:141-190, :534-538) | `scan_row` :471 | `scan_row_compound` :1290 | exact (availability gate was `mi_row > 0`, folded into defect 3) | | ||
| 15 | +| 3 | `scan_col_mbmi` (:192-236, :540-543) | `scan_col` :553 | `scan_col_compound` :1347 | exact | | ||
| 16 | +| 4 | `has_top_right` + top-right `scan_blk_mbmi` (:264-312, :496, :544-548) | `scan_top_right` :645 | `scan_top_right_compound` :1403 | no change — see "has_tr" below | | ||
| 17 | +| 5 | `nearest_match`, `REF_CAT_LEVEL` boost over `nearest_refmv_count` (:550-555) | :836 | :1600 | exact | | ||
| 18 | +| 6 | `add_tpl_ref_mv` main loop, `step_h`/`step_w`/`blk_*_end` (:557-589) | :868 | :1625 | exact (compound reads the field once per side; `motion_field.rs:500` makes the lookup offset-independent, so both sides are Some/None together — libaom's single lookup) | | ||
| 19 | +| 7 | `tpl_sample_pos` 3 extension samples + `check_sb_border` (:591-600, :316) | :898 | :1670 (added lane-sb128 r3) | exact — the twin drift r3 found, now symmetric | | ||
| 20 | +| 8 | `GLOBALMV_OFFSET` / `zero_mv_ctx` far-or-missing test (:375-380, :406-412, :592) | :955 | :1750 | exact | | ||
| 21 | +| 9 | corner `scan_blk_mbmi(-1,-1)` with `dummy_newmv_count`, weight `2*len`=4 (:604-607) | :967 | :1758 | exact | | ||
| 22 | +| 10 | extended row/col scan `idx = 2..=MVREF_ROW_COLS` (:609-622) | :990 | :1770 | exact | | ||
| 23 | +| 11 | `ref_match_count` + `mode_context` switch / `REFMV_OFFSET` (:624-651) | :1140 | :1858 | exact | | ||
| 24 | +| 12 | the TWO bubble passes (nearest region, then the rest) (:653-682) | single stable `sort_by_key` :1050 | same :1802 | not a defect — every nearest entry carries `+REF_CAT_LEVEL` (640) and no post-boost entry can reach it (max post-boost weight seen is `len*weight` <= 80), so the two-phase ranking and one stable global sort agree | | ||
| 25 | +| 13 | insertion cap `*refmv_count < MAX_REF_MV_STACK_SIZE` (:100, :128, :388, :425) | `add_candidate` :341 | `add_compound_candidate` :1268 | **DEFECT 2** — both pushed unbounded then sorted+truncated, keeping a different set than libaom's drop-at-insertion | | ||
| 26 | +| 14 | `mi_size` = min(64x64 span, block span, frame edge) (:684-689) | :1060 | :1815 | exact | | ||
| 27 | +| 15 | `process_compound_ref_mv_candidate`, sign-bias inversion, `can_rf > INTRA_FRAME` (:434-470, :693-706) | n/a | :1478 | exact | | ||
| 28 | +| 16 | `comp_list` combine, slots past both lists = `gm_mv_candidates[idx]` (:708-720) | n/a | `combine_compound_candidates` :1520 | **DEFECT 1 (twin drift)** — filled `(0, 0)`; the single-ref twin closed the same gm-fallback gap in r6 | | ||
| 29 | +| 17 | compound stack merge, `refmv_count==1` dedupe vs empty (:722-742) | n/a | :1845 | exact | | ||
| 30 | +| 18 | `clamp_mv_ref` + `MV_BORDER`, every entry (:745-751, :768-772) | :1105 | :1878 | exact | | ||
| 31 | +| 19 | single-ref extension gated per step on `MAX_MV_REF_CANDIDATES` (:754-766) | :1065 | n/a | exact | | ||
| 32 | +| 20 | `mv_ref_list` tail filled with `gm_mv_candidates[0]`, unclamped (:775-782) | :1128 | n/a (libaom has no compound `mv_ref_list`) | exact | | ||
| 33 | + | ||
| 34 | +### has_tr (phase 4), why no change | ||
| 35 | +Ours probes "is the grid cell at `(mi_row-1, mi_col+bw4)` populated", which for a | ||
| 36 | +decoder is exactly "was it decoded". Walking libaom's mask logic: for SQUARE blocks | ||
| 37 | +the mask result and "already decoded" coincide at both sb64 and sb128; for the | ||
| 38 | +rect case that differs (`bs > 16` at a 64x128 block) libaom's own | ||
| 39 | +`is_last_vertical_rect` refinement forces `has_tr = 1` again, agreeing with our | ||
| 40 | +probe. Porting the mask WITHOUT the three shape refinements (which need the | ||
| 41 | +partition type, not passed to this module) would REGRESS the VERT-rect case. | ||
| 42 | +Recorded as the same corner-cut already documented at `mvstack.rs:588`; | ||
| 43 | +upgrade path = thread the partition type in with the rect inter leaf. | ||
| 44 | + | ||
| 45 | +## Fixes (all in crates/ec-av1/src/mvstack.rs) | ||
| 46 | +- D1 `combine_compound_candidates` (:1520 + call site :1859): unfilled slots take | ||
| 47 | + `gm_mv(gm, ref_frame.side)`, not `(0, 0)` (mvref_common.c:718-719). | ||
| 48 | +- D2 `add_candidate` (:341) / `add_compound_candidate` (:1268): drop the 9th | ||
| 49 | + distinct candidate AT INSERTION (mvref_common.c:100/128/388/425); the dedup | ||
| 50 | + weight bump still applies on a full stack. | ||
| 51 | +- D3 both twins (:809, :1610) + new `MiGrid::tile_origin` (:216): reach and | ||
| 52 | + availability are tile-relative (mvref_common.c:512-533). | ||
| 53 | + | ||
| 54 | +## Checks | ||
| 55 | +`cargo test -p ec-av1 --lib mvstack::` -> 32 passed, 0 failed. Three new | ||
| 56 | +deterministic tests, one per defect: | ||
| 57 | +- `a_missing_compound_combine_slot_takes_that_sides_global_mv_not_zero` | ||
| 58 | +- `the_ninth_distinct_candidate_is_dropped_at_insertion_not_after_sorting` | ||
| 59 | +- `the_row_reach_is_clamped_to_the_tile_origin_not_the_frame_edge` (644 -> 648 vs 652) | ||
| 60 | + | ||
| 61 | +New real-aomenc gate `a_real_aomenc_compound_mv_stack_gate` (stream.rs), the first | ||
| 62 | +compound gate here that does NOT pin `--enable-ref-frame-mvs=0`: | ||
| 63 | +`--enable-ref-frame-mvs=1 --enable-order-hint=1 --auto-alt-ref=1 --lag-in-frames=25`, | ||
| 64 | +cq sweep 45/55/35, 30 seeds/arm, hard-asserting BOTH `comp_mode_hits` and | ||
| 65 | +`tmv_hits` advanced, every decode-order frame compared (Y/U/V) against ffmpeg, | ||
| 66 | +decode errors only tolerated when the message contains "unsupported". | ||
| 67 | +Arms: 8-bit sb64 gm=0 · 8-bit sb64 gm=1 · 10-bit sb128 gm=1. | ||
| 68 | + | ||
| 69 | +EVIDENCE: $HOME/.cache/mvtwin-suite-r1.log | cargo test -p ec-av1 --lib compound_mv_stack -- --test-threads=1 --nocapture | 3 arms FIRING pixel-exact: seed 44 comp_mode_hits +7 tmv_hits +56; seed 80 comp_mode_hits +1 tmv_hits +56; seed 122 (10-bit, sb128) comp_mode_hits +8 tmv_hits +55 | ||
| 70 | +EVIDENCE: crates/ec-av1/src/mvstack.rs tests | cargo test -p ec-av1 --lib mvstack:: | 32 passed 0 failed, each of the 3 defects asserted on its own values | ||
| 71 | + | ||
| 72 | +Full suite (systemd unit, MemoryMax=10G): `cargo test -p ec-av1 --lib -j3` -> | ||
| 73 | +**375 passed, 0 failed, 33 ignored**, 692 s. Log `$HOME/.cache/mvtwin-suite-r1.log`. | ||
| 74 | + | ||
| 75 | +EVIDENCE: $HOME/.cache/mvtwin-suite-r1.log | systemd-run --user --unit=mvtwin-suite-... cargo test -p ec-av1 --lib -j3 | test result: ok. 375 passed; 0 failed; 33 ignored | ||
| 76 | + | ||
| 77 | +## Open residue | ||
| 78 | +- fix-now-elsewhere (NOT this lane's surface): a real aomenc stream 128 px wide | ||
| 79 | + with `--tile-columns=1` MIS-DECODES frame 1 luma vs ffmpeg (seed 200, recipe in | ||
| 80 | + `a_real_aomenc_compound_mv_stack_across_two_tile_columns_decodes_pixel_exact`, | ||
| 81 | + `#[ignore]`d with the repro command in its doc). ABLATION-PROVEN pre-existing: | ||
| 82 | + identical failure with r1's tile-origin clamp forced back to `(0, 0)`. That arm | ||
| 83 | + is also the only one that reaches defect 3 on a real stream — | ||
| 84 | + `mvstack::tile_reach_clips` advanced to 60 there. | ||
| 85 | +- deferred(a stream whose compound pair names a non-IDENTITY ROTZOOM/AFFINE | ||
| 86 | + reference) — `comp_gm_fill_hits` reads 0 on all three green arms, so D1 is | ||
| 87 | + proven by its unit test, not yet by a real stream. aomenc at gradients content | ||
| 88 | + keeps global motion IDENTITY even with `--enable-global-motion=1`. | ||
| 89 | +- deferred(same) — `stack_full_drops` reads 0 on all three arms: no real block | ||
| 90 | + here produced 9 distinct candidates. D2 is unit-test-proven only. | ||
| 91 | +- accepted — `has_tr` corner-cut (phase 4 above), ceiling and upgrade path named. | ||
lanes/reelckf-r1.handoff.mdadded+100 -0
| @@ -0,0 +1,100 @@ | |||
| 1 | +# lane-reelckf r1 handoff | ||
| 2 | + | ||
| 3 | +Tip: see `git log -2`. Base `lane-sb128b` e8e64a6. Both root causes FIXED and the | ||
| 4 | +lane is GREEN on its own gate; the only thing still owed is the final full-suite | ||
| 5 | +number (the unit was still running at the turn cap, 318/~404 tests logged, zero | ||
| 6 | +`FAILED` lines so far). Log: `$HOME/.cache/reelckf-suite-r1.log`. | ||
| 7 | + | ||
| 8 | +## Method (reusable) | ||
| 9 | +`$HOME/.cache/reelckf-work/one.sh <ss>` — extracts 2 s with `ffmpeg -ss <ss> -c:v copy | ||
| 10 | +-f obu`, truncates to ONE frame with `trunc.py`, decodes under | ||
| 11 | +`systemd-run --scope -p MemoryMax=6G` with `EC_PROBE_OUT16`, sha256s the output, | ||
| 12 | +decodes the same truncated file with `ffmpeg -pix_fmt yuv420p10le`, and prints | ||
| 13 | +per-plane diff count + first differing sample + bounding box. | ||
| 14 | +`$HOME/.cache/reelckf-work/stage.sh <ss>` — the same file through | ||
| 15 | +`EC_AV1_PREFILT_DUMP16` / `EC_AV1_POSTDEBLOCK_DUMP16` on BOTH decoders. | ||
| 16 | +`$HOME/.cache/reelckf-work/sweep.sh <lavfi-src> <cq> <depth>` (env `MP=` for | ||
| 17 | +max-partition) — aomenc recipe probe printing `reelc_chroma:` counters. | ||
| 18 | + | ||
| 19 | +## Per-key-frame findings (1920x792 10-bit AV1, 12 seek points) | ||
| 20 | + | ||
| 21 | +All measurements are of decode-order frame 0 of a 1-frame truncation. | ||
| 22 | + | ||
| 23 | +| ss | first differing sample (before) | extent | stage | verdict | | ||
| 24 | +|----|--------------------------------|--------|-------|---------| | ||
| 25 | +| 0 | none | — | — | exact before and after | | ||
| 26 | +| 900 | U (r103,c304) | U rows 103..395 cols 304..479, V rows 99..383; luma exact | prefilter | fixed, now 0 | | ||
| 27 | +| 1800 | U (r19,c538) | U rows 19..313 cols 311..732; luma exact | prefilter | fixed, now 0 | | ||
| 28 | +| 2700 | U (r48,c468) | ONE 8x16-luma chroma pair, chroma rows 48..79 cols 464..492 | prefilter (467 diffs) vs postdeblock (499) — reconstruction, not a filter | fixed, now 0 | | ||
| 29 | +| 3600 | U (r151,c469) | U rows 151..395 cols 468..959; luma exact | prefilter | fixed, now 0 | | ||
| 30 | +| 4500 | none | — | — | exact before and after | | ||
| 31 | +| 5400 | U (r164,c154) | U rows 164..168 cols 153..159 (one 8x4 chroma block) + V (r152,c278) | prefilter | fixed, now 0 | | ||
| 32 | +| 6300 | U (r148,c545) | U rows 148..395; V rows 148..395 cols 84..903 | prefilter | fixed, now 0 | | ||
| 33 | +| 7200 | U (r24,c561) | U rows 24..348 cols 210..959 | prefilter | fixed, now 0 | | ||
| 34 | +| 9900 | U (r8,c500) | U rows 8..395 cols 497..959 | prefilter | fixed, now 0 | | ||
| 35 | +| 8100 | frame 0 REFUSES (128-root non-SPLIT) | — | — | lane-sb128c owns it | | ||
| 36 | +| 9000 | frame 0 REFUSES (128-root non-SPLIT) | — | — | lane-sb128c owns it | | ||
| 37 | + | ||
| 38 | +LUMA WAS BIT-EXACT IN EVERY ROW, before and after. That single fact exonerated | ||
| 39 | +the entropy stream at the first measurement and is why no range ladder was ever | ||
| 40 | +needed. | ||
| 41 | + | ||
| 42 | +## Blocks found, and the symbol/prediction comparison | ||
| 43 | + | ||
| 44 | +* ss=2700, chroma (48,468) = luma (96,936) = mi(24,234). aomdec `EC_TRACE_MODE`: | ||
| 45 | + `EC_IMODE mi_row=24 mi_col=232..235 bsize=16` — four `BLOCK_4X16` | ||
| 46 | + (`PARTITION_VERT_4`); `mi_col=235` is the chroma reference and prints | ||
| 47 | + `uv_mode=13 skip=1`. Our chroma there was plain DC. | ||
| 48 | +* ss=5400, chroma (164,152) = luma (328,608) = mi(82,76). aomdec: `mi_row=80..83 | ||
| 49 | + mi_col=76 bsize=17` (`BLOCK_16X4`, `PARTITION_HORZ_4`), chroma reference | ||
| 50 | + `mi_row=83`, `uv_mode=5` (D113). aomdec `EC_PRED mi_row=83 mi_col=76 plane=1 | ||
| 51 | + txw=8 txh=4 mode=5 p_angle=107 have_top=1 have_left=1 n_top=8 n_left=4 ft=0`, | ||
| 52 | + `EC_PREDOUT row0=415,431,453,471,467,442,408,397`. | ||
| 53 | + Ours (`EC_PRED=1`, `OUR_PRED x=152 y=164 bw=8 bh=4 mode=5 ad=-2`): | ||
| 54 | + `row0=[415,431,452,470,466,441,409,398]` — prediction, not residual. | ||
| 55 | + | ||
| 56 | +## Fixes applied and their effect | ||
| 57 | +1. `decode.rs:7719` + `:10528` + `:10891` — a skipped intra block still predicts | ||
| 58 | + with CfL (libaom `predict_and_reconstruct_intra_block` predicts every plane | ||
| 59 | + and guards only the residual on `skip_txfm`). ss=2700 499 -> 0. | ||
| 60 | +2. `decode.rs:7714` — the 1:4 pair reads `smooth_uv_neighbour` at `pair_mi` (the | ||
| 61 | + chroma reference), not at the closing strip: libaom | ||
| 62 | + `get_intra_edge_filter_type` uses `chroma_above_mbmi`/`chroma_left_mbmi`. The | ||
| 63 | + wrong filter type flipped `av1_use_intra_edge_upsample` (`blk_wh = 8+4 = 12 | ||
| 64 | + <= 16` upsamples for type 0, never for type 1). ss=5400 46 -> 0; every | ||
| 65 | + remaining seek point -> 0. | ||
| 66 | +3. `gate_coverage.rs` — `enable-cfl-intra` retired from BOTH never-exercised | ||
| 67 | + lists, and `covers_both_depths` learned the `for depth in [8usize, 10]` | ||
| 68 | + spelling (a gate with a `yuv420p10le` arm was being classified 10-bit only). | ||
| 69 | + | ||
| 70 | +## Hypotheses RULED OUT (do not re-spend rounds on these) | ||
| 71 | +* Entropy desync / wrong CDF row: luma bit-exact on all ten frames. | ||
| 72 | +* CDEF / loop restoration / deblock at a 128 superblock (the charter's leading | ||
| 73 | + suspects): the prefilter dump already carries the whole defect (ss=2700 | ||
| 74 | + prefilter 467 diffs, postdeblock 499) and luma is exact through every filter. | ||
| 75 | +* `delta_q` / `delta_lf` read at the 128 root: a wrong plane qindex would move | ||
| 76 | + the residual, not the prediction, and would not leave luma exact. | ||
| 77 | +* Intra edge availability at 128 (`has_tr_128x128`/`has_bl_128x128`): `Reach` is | ||
| 78 | + two booleans computed from luma geometry, which libaom reuses for chroma; the | ||
| 79 | + ss=5400 `EC_PRED` line agrees (`n_tr=-1 n_bl=-1`). | ||
| 80 | +* `Reach::of_rect(pw, ph, ...)` being luma-scaled while the chroma block is half | ||
| 81 | + the size: checked, correct — libaom computes availability once, in luma mi. | ||
| 82 | + | ||
| 83 | +## Gate | ||
| 84 | +`cargo test -p ec-av1 --lib a_real_aomenc_sb128_stream_whose_skipped_cfl -- --nocapture` | ||
| 85 | +-> pixel-exact at 8-bit AND 10-bit, `directional_1to4_chroma_pairs=11` per arm, | ||
| 86 | +`skipped_cfl=0`. | ||
| 87 | + | ||
| 88 | +## Exact next step for a successor | ||
| 89 | +1. `grep -E "^test result|FAILED" $HOME/.cache/reelckf-suite-r1.log` — the suite | ||
| 90 | + was mid-run at the cap. If anything is red, it is a sibling of the two | ||
| 91 | + touched paths (grep `smooth_uv_neighbour` and `cfl_ac_q3`). | ||
| 92 | +2. Defect 1 (skipped CfL) has NO synthetic gate. 20 aomenc recipes were swept | ||
| 93 | + (cq 40/44/46/50/52/55/58/62/63 x mandelbrot, blurred mandelbrot, noised | ||
| 94 | + mandelbrot, testsrc2, gradients, smptebars, cellauto, life, grey+noise; | ||
| 95 | + min-partition 4, max-partition 16/32/64, sb-size 128/64) and `skip_cfl` | ||
| 96 | + stayed 0 in every one. Either find a recipe that fires it (the counter is | ||
| 97 | + printed by the gate AND by `decode_probe`, so a hit is immediately visible) | ||
| 98 | + or commit a pinned single-frame stream fixture. | ||
| 99 | +3. The two remaining ReelC seek points (8100, 9000) need lane-sb128c's 128-root | ||
| 100 | + non-SPLIT partition; re-run the 12-point table after that lands. | ||
lanes/reelckf-r1.report.mdadded+99 -0
| @@ -0,0 +1,99 @@ | |||
| 1 | +# lane-reelckf r1 — ReelC key frames: two chroma-only reconstruction defects | ||
| 2 | + | ||
| 3 | +Base: `lane-sb128b` e8e64a6 (= main 18bf7dc + the 128 NONE block fix). | ||
| 4 | + | ||
| 5 | +## Premise re-measured (not taken from the charter) | ||
| 6 | +census4's `reelc4.tsv` was recorded on main 18bf7dc, where every ReelC segment | ||
| 7 | +REFUSED. On this base all ten non-`sb128c` key frames decode with **no refusal** | ||
| 8 | +and **luma bit-exact**, chroma wrong — which is what made the entropy stream an | ||
| 9 | +exonerated suspect from the first measurement. | ||
| 10 | + | ||
| 11 | +## Root causes (both chroma, both cited to libaom) | ||
| 12 | + | ||
| 13 | +1. **A skipped intra block still predicts, and CfL is prediction.** | ||
| 14 | + libaom `predict_and_reconstruct_intra_block` (decodeframe.c) calls | ||
| 15 | + `av1_predict_intra_block_facade` unconditionally and guards only the | ||
| 16 | + residual on `mbmi->skip_txfm`. Three of our skip arms dropped the CfL term | ||
| 17 | + and predicted plain DC: | ||
| 18 | + - `crates/ec-av1/src/decode.rs:7719` — the 16x16-level 1:4 chroma pair | ||
| 19 | + (`decode_rect4_16`). | ||
| 20 | + - `crates/ec-av1/src/decode.rs:10528`, `:10891` — the two sub-8x8 4x4-group | ||
| 21 | + chroma arms. | ||
| 22 | + ReelC ss=2700: chroma-only bounded box at chroma (48..79, 464..492), the | ||
| 23 | + `VERT_4` pair at mi(24,234)/(24,235) — aomdec `EC_TRACE_MODE` prints | ||
| 24 | + `uv_mode=13 skip=1` there. 499 wrong samples -> **0**. | ||
| 25 | + | ||
| 26 | +2. **The 1:4 pair's chroma intra-edge FILTER TYPE is read at the chroma | ||
| 27 | + reference, not at the closing strip.** | ||
| 28 | + libaom `get_intra_edge_filter_type` (reconintra.c) reads | ||
| 29 | + `chroma_above_mbmi`/`chroma_left_mbmi`, i.e. the neighbours of the | ||
| 30 | + chroma-reference mi. We passed the closing strip's own mi, whose above cell | ||
| 31 | + is the pair's FIRST strip: the mi-exact UV map missed, the coarse 16px | ||
| 32 | + fallback answered, and the filter type flipped | ||
| 33 | + `av1_use_intra_edge_upsample` (`blk_wh = 8 + 4 = 12 <= 16` upsamples for | ||
| 34 | + type 0, never for type 1). `crates/ec-av1/src/decode.rs:7714`. | ||
| 35 | + ReelC ss=5400, the `HORZ_4` pair at mi(82,83)/76: aomdec | ||
| 36 | + `EC_PRED ... mode=5 p_angle=107 ft=0`, `EC_PREDOUT row0=415,431,453,471,...` | ||
| 37 | + vs our `OUR_PRED ... row0=[415,431,452,470,...]`. 46 wrong samples -> **0**. | ||
| 38 | + | ||
| 39 | +## Files changed | ||
| 40 | +- `crates/ec-av1/src/decode.rs` — the three skip arms now pass the CfL term; | ||
| 41 | + the 1:4 pair's `smooth_uv_neighbour` is read at `pair_mi`; two new | ||
| 42 | + counters + `pub fn reelc_chroma_counters()`. | ||
| 43 | +- `crates/ec-av1/src/stream.rs` — new gate | ||
| 44 | + `a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact`. | ||
| 45 | +- `crates/ec-av1/examples/decode_probe.rs` — prints `reelc_chroma:` counters. | ||
| 46 | + | ||
| 47 | +## Sweep for the same shape | ||
| 48 | +`grep -n "u\.reconstruct\|v\.reconstruct\|buf\.reconstruct"` over decode.rs, then | ||
| 49 | +every `if skip {` arm (21 sites) inspected: the square path (`:9416`), the rect | ||
| 50 | +strip paths (`:6490`, `:6930`, `:7248`, `:8034`) and the inter paths already | ||
| 51 | +computed `ac` inside their skip arm. The three fixed above were the only | ||
| 52 | +chroma-CfL-dropping arms. All 11 `smooth_uv_neighbour` call sites checked: the | ||
| 53 | +other ten pass a block/group ORIGIN mi (`leaf_mi`, `r*(SUB/MI)`), which already | ||
| 54 | +is the chroma reference; only `decode_rect4_16` passed a non-origin mi. | ||
| 55 | + | ||
| 56 | +## Gate | ||
| 57 | +`cargo test -p ec-av1 --lib a_real_aomenc_sb128_stream_whose_skipped_cfl -- --nocapture` | ||
| 58 | +(real aomenc `--sb-size=128 --cpu-used=0 --enable-1to4-partitions=1 | ||
| 59 | +--enable-cfl-intra=1 --min-partition-size=4 --max-partition-size=32 | ||
| 60 | +--cq-level=52`, 256x256 `mandelbrot+noise(all_seed=7)`, 8- and 10-bit arms, | ||
| 61 | +aomenc output hashed twice for reproducibility, decode error tolerated only if | ||
| 62 | +the message contains "unsupported", `compared > 0` asserted). | ||
| 63 | + | ||
| 64 | +EVIDENCE: $HOME/.cache/reelckf-suite-r1.log (gate stdout quoted below) | cargo test ... --nocapture | pixel-exact at 8-bit and 10-bit, directional_1to4_chroma_pairs=11 per arm, skipped_cfl=0 | ||
| 65 | + | ||
| 66 | +## ReelC key-frame table (1 frame per seek point, `EC_PROBE_OUT16` vs ffmpeg yuv420p10le) | ||
| 67 | + | ||
| 68 | +| ss | before (this base) | after | | ||
| 69 | +|----|--------------------|-------| | ||
| 70 | +| 0 | 0 | 0 | | ||
| 71 | +| 900 | 4173 (U 3107 / V 1066, max 7) | **0** | | ||
| 72 | +| 1800 | 14402 (max 10) | **0** | | ||
| 73 | +| 2700 | 499 (max 3) | **0** | | ||
| 74 | +| 3600 | 119652 (max 37) | **0** | | ||
| 75 | +| 4500 | 0 | 0 | | ||
| 76 | +| 5400 | 46 (max 4) | **0** | | ||
| 77 | +| 6300 | 33742 (max 7) | **0** | | ||
| 78 | +| 7200 | 52891 (max 11) | **0** | | ||
| 79 | +| 9900 | 4131 (max 7) | **0** | | ||
| 80 | +| 8100 | frame 0 refuses (128-root non-SPLIT) — lane-sb128c | unchanged | | ||
| 81 | +| 9000 | frame 0 refuses (128-root non-SPLIT) — lane-sb128c | unchanged | | ||
| 82 | + | ||
| 83 | +Luma was bit-exact in every row, before and after. | ||
| 84 | + | ||
| 85 | +EVIDENCE: $HOME/.cache/reelckf-work/xo_*.raw vs xr_*.raw | ffmpeg -ss <t> -t 2 -c:v copy -f obu, trunc.py to 1 frame, decode_probe EC_PROBE_OUT16, ffmpeg -pix_fmt yuv420p10le | samples_diff 0/2280960 on all ten decodable key frames | ||
| 86 | + | ||
| 87 | +## Residue | ||
| 88 | +- deferred(a lavfi/aomenc recipe or a committed stream fixture that fires a | ||
| 89 | + SKIPPED 1:4 or sub-8x8 CfL block) — defect 1 has no synthetic gate. 20 aomenc | ||
| 90 | + recipes were swept (cq 40/44/46/50/52/55/58/62/63 x mandelbrot, blurred | ||
| 91 | + mandelbrot, noised mandelbrot, testsrc2, gradients, smptebars, cellauto, life, | ||
| 92 | + grey+noise; min-partition 4, max-partition 16/32/64, sb-size 128) and | ||
| 93 | + `skip_cfl` stayed 0 in all of them. Its evidence is ReelC ss=2700 (499 -> 0) | ||
| 94 | + and the counter is printed by the gate and by `decode_probe`, so the first | ||
| 95 | + recipe that reaches it is visible. | ||
| 96 | +- accepted — ss=8100 / ss=9000 still refuse inside frame 0 on the 128-root | ||
| 97 | + non-SPLIT partition; that refusal belongs to lane-sb128c. | ||
| 98 | +- No refusal was lifted this round, so `refusal_inventory.rs` / | ||
| 99 | + `gate_coverage.rs` are unchanged. | ||
lanes/reelckf-r2.handoff.mdadded+22 -0
| @@ -0,0 +1,22 @@ | |||
| 1 | +# lane-reelckf r2 handoff | ||
| 2 | + | ||
| 3 | +SUPERSEDED: the suite finished after this file was written -- | ||
| 4 | +`test result: ok. 379 passed; 0 failed; 33 ignored` (1055 s). Nothing is owed. | ||
| 5 | +Tip `f7e0d3d` at the time of writing; see `lanes/reelckf-r2.report.md`. | ||
| 6 | + | ||
| 7 | +* Log: `$HOME/.cache/reelckf-suite-r2.log`. Check with a single | ||
| 8 | + `grep -E "^test result|FAILED" $HOME/.cache/reelckf-suite-r2.log`. | ||
| 9 | + At the cap: ~200 of ~412 tests logged, **zero `FAILED` lines**. | ||
| 10 | + r1's run of the same suite on the pre-merge tree reached 361 tests with zero | ||
| 11 | + FAILED before I stopped it (superseded by this run); both film-grain gates | ||
| 12 | + (`a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` and its 10-bit | ||
| 13 | + sibling) were `ok` there, so the cross-lane concurrency red did not appear. | ||
| 14 | +* If anything is red, it is a sibling of the two touched paths: grep | ||
| 15 | + `smooth_uv_neighbour` and `cfl_ac_q3` in `crates/ec-av1/src/decode.rs`. | ||
| 16 | +* Nothing else is owed. Merge of main 85887c7 is at 4667015 (clean auto-merge, | ||
| 17 | + cdf.rs untouched, no deletions). | ||
| 18 | +* Reusable instruments: `$HOME/.cache/reelckf-work/one.sh <ss>` (per-seek-point | ||
| 19 | + film compare), `.../cflsweep.sh <tag> <lavfi> <cq> <depth> [cpu] [maxpart] | ||
| 20 | + [minpart]` (aomenc + `EC_TRACE_MODE=1 aomdec`, prints `cfl=` and `skipcfl=` | ||
| 21 | + with no cargo build at all — this is how 28 more recipes were swept while a | ||
| 22 | + suite held the target dir). | ||
lanes/reelckf-r2.report.mdadded+80 -0
| @@ -0,0 +1,80 @@ | |||
| 1 | +# lane-reelckf r2 report | ||
| 2 | + | ||
| 3 | +Base `lane-reelckf` bb6ebe5 (r1). Merged main 85887c7 (lane-mvtwin) at 4667015. | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | +* `crates/ec-av1/fixtures/reelc_kf2700.obu` (NEW, tracked, 36 kB) — a 1920x792 | ||
| 7 | + 10-bit AV1 key frame from one of the user's own films, truncated to its first | ||
| 8 | + temporal unit. The only stream in this repo containing a **skipped | ||
| 9 | + `UV_CFL_PRED` block**; the instrumented oracle counts 5 of them. | ||
| 10 | +* `crates/ec-av1/src/stream.rs:2975` — | ||
| 11 | + `a_real_film_key_frame_with_a_skipped_cfl_block_decodes_pixel_exact`: decodes | ||
| 12 | + the fixture, HARD-asserts `reelc_chroma_counters().0 > 0` (skipped CfL) BEFORE | ||
| 13 | + any ffmpeg dependency, then compares all three planes against | ||
| 14 | + `ffmpeg -f obu -i - -f rawvideo -pix_fmt yuv420p10le -`. | ||
| 15 | + | ||
| 16 | +This closes r1's open item: defect 1 (a skipped intra block must still predict | ||
| 17 | +with CfL) now has a gate that fails if the fix is reverted. | ||
| 18 | + | ||
| 19 | +## Gate hunt for a synthetic recipe: 18 more recipes, still zero | ||
| 20 | +r1 swept 20 aomenc recipes without producing a skipped CfL block. r2 swept 28 | ||
| 21 | +more, detecting the block **oracle-side** (`EC_TRACE_MODE=1 aomdec` → | ||
| 22 | +`EC_IMODE_VAL ... uv_mode=13 skip=1`), which needs no decode of ours: | ||
| 23 | + | ||
| 24 | +| family | recipes | CfL blocks | skipped CfL | | ||
| 25 | +|--------|---------|-----------|-------------| | ||
| 26 | +| `geq` sin/X chroma-correlated stripes, cq 40..63, 8+10 bit | 6 | 0..3 | 0 | | ||
| 27 | +| mandelbrot/testsrc2 with `cb=128+0.35*(lum(2X,2Y)-128)`, cq 40..63 | 6 | 1..117 | 0 | | ||
| 28 | +| smooth ramp / low-frequency `sin(X/60)cos(Y/70)`, cq 45..63 | 6 | 0 | 0 | | ||
| 29 | +| blurred mandelbrot/testsrc2/gradients/cellauto/life, 0.6 chroma gain, cq 55..63, 8+10 bit | 10 | 0..10 | 0 | | ||
| 30 | + | ||
| 31 | +Result (measured, not inferred): aomenc DOES pick CfL freely on | ||
| 32 | +chroma-correlated content (117 blocks at cq 40), but never with `skip=1` — the | ||
| 33 | +two conditions pull against each other (skip needs a zero LUMA residual, CfL | ||
| 34 | +needs luma AC worth scaling). His film reaches it because directional intra on | ||
| 35 | +real texture predicts exactly at a 1:4 leaf. Script: | ||
| 36 | +`$HOME/.cache/reelckf-work/cflsweep.sh <tag> <lavfi> <cq> <depth> [cpu] [maxpart] [minpart]`. | ||
| 37 | + | ||
| 38 | +## Deviation from the charter | ||
| 39 | +The charter asked for stored per-plane **sha256 constants**. The crate has no | ||
| 40 | +sha256 (and adding a hash dependency for one fixture is not warranted), and the | ||
| 41 | +sibling film fixture test `the_reelb_head_key_frame_decodes_pixel_exact` | ||
| 42 | +already pins against a live `ffmpeg` decode. I used that same helper. Vacuity is | ||
| 43 | +covered the other way round: the decode and the `skip_cfl > 0` assert run | ||
| 44 | +unconditionally, only the pixel compare is behind `have_ffmpeg()`. | ||
| 45 | + | ||
| 46 | +## Ten real key frames, re-measured on the MERGED tree (main 85887c7 in) | ||
| 47 | +`$HOME/.cache/reelckf-work/one.sh <ss>` per point: 2 s `-c:v copy -f obu` extract, | ||
| 48 | +truncated to one temporal unit, decoded with `EC_PROBE_OUT16` under a 6G scope, | ||
| 49 | +compared sample-by-sample against `ffmpeg -pix_fmt yuv420p10le`. | ||
| 50 | + | ||
| 51 | +| ss | bytes | decode | samples differing (of 2 280 960) | | ||
| 52 | +|----|-------|--------|----------------------------------| | ||
| 53 | +| 0 | 74 | OK 1920x792 | 0 | | ||
| 54 | +| 900 | 50350 | OK | 0 | | ||
| 55 | +| 1800 | 98871 | OK | 0 | | ||
| 56 | +| 2700 | 36785 | OK | 0 | | ||
| 57 | +| 3600 | 39883 | OK | 0 | | ||
| 58 | +| 4500 | 44734 | OK | 0 | | ||
| 59 | +| 5400 | 287497 | OK | 0 | | ||
| 60 | +| 6300 | 124067 | OK | 0 | | ||
| 61 | +| 7200 | 82748 | OK | 0 | | ||
| 62 | +| 9900 | 161573 | OK | 0 | | ||
| 63 | + | ||
| 64 | +10/10 Y=U=V=0, `max|d|=0`. The merge of lane-mvtwin changed nothing here. | ||
| 65 | +ss=8100 and ss=9000 still refuse at a 128-root non-SPLIT partition (lane-sb128c's | ||
| 66 | +cluster) and are not in the table. | ||
| 67 | + | ||
| 68 | +## Residue | ||
| 69 | +* ss=8100 / ss=9000 — deferred(lane-sb128c's 128-root non-SPLIT partition). | ||
| 70 | + Re-measured on the merged tree, both still stop at exactly | ||
| 71 | + `unsupported: AV1 tile (a 128x128 superblock HORZ/VERT or AB partition (only | ||
| 72 | + SPLIT and NONE are decoded at the 128 root))`. | ||
| 73 | +* A synthetic aomenc recipe for a skipped CfL block — accepted as unreachable at | ||
| 74 | + 48 recipes; the pinned film frame is the gate instead. | ||
| 75 | + | ||
| 76 | +## Full suite (merged tree, tip 735c80e) | ||
| 77 | +`systemd-run --user --unit=reelckf-suite-1788326584 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` | ||
| 78 | +-> `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; | ||
| 79 | +finished in 1055.41s`. Log: `$HOME/.cache/reelckf-suite-r2.log`. | ||
| 80 | +**GREEN 379/0.** | ||
lanes/sb128b-r1.report.mdadded+103 -0
| @@ -0,0 +1,103 @@ | |||
| 1 | +# lane-sb128b r1 — the 128 root's `PARTITION_NONE` arm (key frames) | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128b` off `lane-sb128` 807c110, worktree `edith_codecs-sb128b`, commit `ceec9fa`. | ||
| 4 | + | ||
| 5 | +## ReelC first — the charter's premise is FALSE on ReelC's key frame | ||
| 6 | + | ||
| 7 | +EVIDENCE: `$HOME/.cache/sb128b-work/reelc2s.obu` (fresh cut, `ffmpeg -t 2 -c:v copy -f obu` | ||
| 8 | +off the real film, 1428 bytes) | release `decode_probe` under a 6G scope with `EC_AV1_TRACE=1` | ||
| 9 | +| **90 `partition_w128` symbols, value=3 (`PARTITION_SPLIT`) on every one** (ctx 3 x70, ctx 2 | ||
| 10 | +x14, ctx 1 x5, ctx 0 x1); the run then stops at `an inter frame under a 128x128 superblock`. | ||
| 11 | +Same numbers on the pre-existing `reelc-head.obu`. | ||
| 12 | + | ||
| 13 | +So ReelC's KEY frame is 100% SPLIT at the 128 root — the key-frame 128 arms are **not** its | ||
| 14 | +blocker, and TASK 4's "the inter arms" is where ReelC's non-SPLIT roots live (r2 saw them only | ||
| 15 | +with the inter refusal locally lifted). Charter premise "ReelC's key frame is the first thing to | ||
| 16 | +decode / stops at a TASK-B arm" corrected here, measured, not argued. | ||
| 17 | + | ||
| 18 | +## What landed (all against libaom, each cited) | ||
| 19 | + | ||
| 20 | +`crates/ec-av1/src/decode.rs` | ||
| 21 | +- `read_sb128_root` (11286) returns the root partition; the key-frame loop (11536) decodes | ||
| 22 | + `PARTITION_NONE` as one 128x128 block and skips the superblock's other three visits | ||
| 23 | + (`sb128_none`). The inter loop refuses any non-SPLIT root by name. | ||
| 24 | +- `read_tx_size` (10003): `max_txsize_rect_lookup[BLOCK_128X128]` is TX_64X64 → a 128 block | ||
| 25 | + reads BLOCK_64X64's own `tx_size_cat3` and resolves `max_tx >> depth`, and | ||
| 26 | + `get_tx_size_context` is asked about 64, not 128. | ||
| 27 | +- `decode_block`: the single-TU arm was `!tx_select || logical_tx == side`. Without `tx_select` | ||
| 28 | + `logical_tx` IS `side` at every size <= 64, so the first half was redundant — and wrong at | ||
| 29 | + 128. Now `logical_tx == side`, and the non-select resolve is `(side.min(64), luma_tx)`, so a | ||
| 30 | + 128 block is always four TX_64X64 units. The TU loop passes the unit's **coefficient** side | ||
| 31 | + (32 at TX_64X64), not its transform side. | ||
| 32 | +- `delta_q`/`delta_lf` "this leaf IS the superblock" is now `side == sb_size` (was a hardcoded | ||
| 33 | + 64 plus a `!sb128()` disable) — a NONE 128 root is the whole superblock. | ||
| 34 | +- the 128 block's one `cdef_idx` read is copied to all four 64x64 CDEF units (libaom's four | ||
| 35 | + units share one `MB_MODE_INFO`). | ||
| 36 | + | ||
| 37 | +`crates/ec-av1/src/stream.rs`: new gate (below). `refusal_inventory.rs`: the single | ||
| 38 | +"partition other than SPLIT" string splits into three named arms. | ||
| 39 | + | ||
| 40 | +## Gate | ||
| 41 | + | ||
| 42 | +`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` — real aomenc | ||
| 43 | +`--sb-size=128` with **no** `--max-partition-size` (the r1 gate's flag is exactly what made | ||
| 44 | +every 128 root a forced SPLIT), smooth gradients at `--cq-level=63/55`, 384x384 + 256x256, | ||
| 45 | +8- and 10-bit, `--enable-tx-size-search=0`. `#[ignore]`d: it is a reproducer, not a pass. | ||
| 46 | + | ||
| 47 | +EVIDENCE: `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_key_frame_with_a_128x128_none` | ||
| 48 | +| aomenc 384x384 cq63 seed 42, decoded then compared to ffmpeg | the NONE arm **fires** and the | ||
| 49 | +tile decodes end to end (no desync panic, no refusal), but frame 0 luma differs from ffmpeg at | ||
| 50 | +138523 of 147456 samples, first at row 0 col 60, magnitudes 1..3 (ours 114/113 where ffmpeg has | ||
| 51 | +115) — a reconstruction difference, not an entropy blow-up. | ||
| 52 | + | ||
| 53 | +Two earlier failures on the way, both fixed and both real defects of the generalisation: | ||
| 54 | +`transform.rs:843 index out of bounds (len 64, index 64)` = the redundant `!tx_select` arm | ||
| 55 | +above sending a 128-wide inverse transform; then the pixel deltas. | ||
| 56 | + | ||
| 57 | +## Root cause of the residual (found, not guessed) | ||
| 58 | + | ||
| 59 | +`av1_get_max_uv_txsize` = `av1_get_adjusted_tx_size(max_txsize_rect_lookup[uv_plane_bsize])`. | ||
| 60 | +The uv plane block of a 128x128 is 64x64 → TX_64X64 → **adjusted to TX_32X32**. A 128 block's | ||
| 61 | +chroma is therefore FOUR TX_32X32 units per plane, and `decode_block` codes exactly one | ||
| 62 | +whole-plane chroma unit. That is the desync, and it also means the charter's | ||
| 63 | +"one chroma TU of 64x64 per plane / new chroma TX_64X64 path" is wrong: **no `TxbSet::Chroma64` | ||
| 64 | +is needed at all.** I had transcribed the 16 libaom `[TX_64X64][PLANE_TYPE_UV]` CDF tables and | ||
| 65 | +wired the variant before finding this; that work is reverted (`cdf.rs`/`cdf_state.rs` are | ||
| 66 | +untouched in this commit) rather than shipped as dead code. | ||
| 67 | + | ||
| 68 | +## Refusals | ||
| 69 | + | ||
| 70 | +- `a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 | ||
| 71 | + root)` — NOT lifted, TASKs 2/3, not started. | ||
| 72 | +- `a 128x128 superblock PARTITION_NONE root on an inter frame (...)` — NOT lifted, TASK 4. | ||
| 73 | +- `a 128x128 PARTITION_NONE block's chroma (its 64x64 uv plane block is four TX_32X32 units, | ||
| 74 | + and this decoder codes one whole-plane chroma unit per block)` — NEW, guards the arm this | ||
| 75 | + round built. fix-now(r2): give `decode_block` a chroma TU loop (2x2 TX_32X32, `TxbSet::Chroma32`, | ||
| 76 | + per-unit `chroma_skip_ctx`, grids assembled for `record_split_luma`) — unblocked by that loop; | ||
| 77 | + the gate above is the reproducer and flips green the moment it is right. | ||
| 78 | +- `intrabc under a 128x128 superblock` — accepted, unchanged. | ||
| 79 | + | ||
| 80 | +## Suite | ||
| 81 | + | ||
| 82 | +`cargo test -p ec-av1 --lib` under user unit `sb128b-suite-1788322151.service`, | ||
| 83 | +log `$HOME/.cache/sb128b-suite.log` — result appended below by the handoff line in the report | ||
| 84 | +message. The 7 rect/AB reds inherited from 807c110 (r2's `deferred: attribute the 7`) are the | ||
| 85 | +sibling lane's; this round touched no rect/AB path. | ||
| 86 | + | ||
| 87 | +## Deferred | ||
| 88 | + | ||
| 89 | +- deferred: TASK 2/3 (HORZ/VERT + AB at 128) — not started — unblocked by the chroma TU loop | ||
| 90 | + plus rect handling at 128. | ||
| 91 | +- deferred: TASK 4 (inter 128 NONE) — refused by name — unblocked by the same loop and the | ||
| 92 | + sibling lane's inter residue. | ||
| 93 | +- deferred: `tx_select` at 128 (`read_tx_size` now handles it, cat3 against 64) is UNTESTED — | ||
| 94 | + every gate arm here runs `--enable-tx-size-search=0` — unblocked by an r2 arm with it on. | ||
| 95 | + | ||
| 96 | +## Suite state at hand-off (honest, incomplete) | ||
| 97 | + | ||
| 98 | +`sb128b-suite-1788322151.service` was STILL RUNNING when this round hit its tool-call ceiling. | ||
| 99 | +At that point the log showed **2 failures, both inherited from 807c110's rect/AB cluster**: | ||
| 100 | +`a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact`, | ||
| 101 | +`a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact`. | ||
| 102 | +No total ("test result:" line) yet — read `$HOME/.cache/sb128b-suite.log` for the final count | ||
| 103 | +before merging. NOT a clean-suite claim. | ||
lanes/sb128b-r2.report.mdadded+97 -0
| @@ -0,0 +1,97 @@ | |||
| 1 | +# lane-sb128b r2 — ReelC's key frame is BIT-EXACT; the 128 chroma TU loop; the 128 root's residual | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `4e13f60`, `1524838`, `c415a31` | ||
| 4 | +(off r1's `d3bc8da` + `git merge main` b51719f, clean). | ||
| 5 | + | ||
| 6 | +## FIRST: the ReelC KEY-frame pixel check (the charter's first task — first ReelC pixel measurement ever) | ||
| 7 | + | ||
| 8 | +EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,ours.f0.yuv,ref.yuv}` | | ||
| 9 | +`ffmpeg -ss 0 -t 2 -c:v copy -frames:v 1 -f obu` off the real film (74 B, 1920x792 yuv420p10le) | ||
| 10 | +→ `dump_yuv` (release, 6G scope) vs `ffmpeg -pix_fmt yuv420p10le -f rawvideo` | | ||
| 11 | +**`cmp` says BYTES EQUAL — ReelC's key frame decodes BIT-EXACT (4 561 920 bytes, 0 differing samples).** | ||
| 12 | + | ||
| 13 | +It was NOT exact before the merge. Pre-merge measurement (same artifacts, r1's tree): | ||
| 14 | +Y 36448 samples off (max |d| 2), U/V 9483 each (max |d| 4), all inside the bottom partial | ||
| 15 | +superblock row — luma rows 765..791 (768 = 6*128, frame is 792 tall) plus 3 deblock rows above, | ||
| 16 | +`+1` per 16-row band, ref uniformly flat (this key frame is black). `git merge main` (lane-oddh's | ||
| 17 | +odd-frame-size work) removes it entirely. Class: [[stale-premise lanes]] — the lane's base | ||
| 18 | +predates the fix. | ||
| 19 | + | ||
| 20 | +ReelC now stops at `an inter frame under a 128x128 superblock` (probe on the 2 s cut, 72 frame | ||
| 21 | +headers parsed) — the sibling lane-sb128 r3's residue, exactly as r1 predicted. | ||
| 22 | + | ||
| 23 | +## Merge seam (had to be fixed before anything could run) | ||
| 24 | + | ||
| 25 | +main b51719f re-introduced lane-oddh's blanket refusal `a sequence using 128x128 superblocks on a | ||
| 26 | +frame larger than 64x64` (stream.rs) — textually a clean merge, semantically a lane-killer (the | ||
| 27 | +ledger's recorded `merge seam` constraint). Deleted, with its inventory line, and its gate | ||
| 28 | +`a_real_aomenc_128x128_superblock_stream_is_refused_by_name` turned into | ||
| 29 | +`..._decodes_pixel_exact`. | ||
| 30 | + | ||
| 31 | +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_128x128_superblock_stream gate_coverage` | | ||
| 32 | +real aomenc 64x72 mandelbrot `--cpu-used=0 --sb-size=128` (`use_128x128_superblock` asserted in | ||
| 33 | +the stream), decoded vs ffmpeg | **ok — 10 passed, 0 failed**; the frame's Y/U/V match ffmpeg | ||
| 34 | +sample for sample. One recipe change was needed and is unrelated to the 128 root: at 64x72 | ||
| 35 | +aomenc also picks `PARTITION_HORZ_4` below 16x16, so the gate now passes | ||
| 36 | +`--enable-1to4-partitions=0 --min-partition-size=16` (gate_coverage green with it). | ||
| 37 | + | ||
| 38 | +## TASK A — the chroma half of a 128x128 `PARTITION_NONE` block (landed, not yet exact) | ||
| 39 | + | ||
| 40 | +`crates/ec-av1/src/decode.rs` | ||
| 41 | +- `decode_block`'s multi-TU arm now codes `cn = chroma_side / chroma_tx` **squared** chroma units | ||
| 42 | + per plane instead of one whole-plane unit. `av1_get_max_uv_txsize(BLOCK_128X128)` = | ||
| 43 | + `av1_get_adjusted_tx_size(max_txsize_rect_lookup[BLOCK_64X64])` = TX_32X32, so a 128 block is | ||
| 44 | + 2x2 TX_32X32 per plane; `cn == 1` (every block at 64 and below) is byte-for-byte the read this | ||
| 45 | + always did. Per unit: `around_mi` gathered over the unit's own 64-luma-pixel span (which is | ||
| 46 | + also its `txb_skip_ctx`, `read_plane`'s chroma branch), `tu_reach` on the matching luma | ||
| 47 | + quadrant, own `set_palette_pred`. | ||
| 48 | +- `Neighbours::record_mi_chroma` (new, next to `record_mi_luma`): per-unit chroma coefficient | ||
| 49 | + context, luma-mi indexed with `record_split_luma_rect_mi`'s own frame-edge clamp. Applied | ||
| 50 | + AFTER `record_split_luma` so the per-unit state is what the next block reads. | ||
| 51 | +- The `skip` arm predicts per transform unit now (libaom predicts inside the transform-block | ||
| 52 | + loop); `n_axis == 1` / `cn == 1` is the unchanged whole-block call. | ||
| 53 | +- counter `chroma_split_tx_hits()`. | ||
| 54 | + | ||
| 55 | +**Result: not pixel-exact, so the refusal is BACK, reworded to what was measured.** | ||
| 56 | +EVIDENCE: `$HOME/.cache/sb128b-work/g42.obu` (the gate's own arm reproduced by hand: gradients | ||
| 57 | +seed 42, 384x384, cq63, `--sb-size=128 --cpu-used=0 --enable-tx-size-search=0`) | `dump_yuv` vs | ||
| 58 | +`ffmpeg -pix_fmt yuv420p` | 139162/147456 luma samples differ, first at row 0 col 60 (ours 114, | ||
| 59 | +ffmpeg 115). **ffmpeg's row 0 is a CONSTANT 115 across the whole first unit where ours ramps | ||
| 60 | +115 → 112**, and the stream is 76 bytes: the mode and the DC agree, our first TX_64X64 luma unit | ||
| 61 | +reads AC coefficients libaom never wrote. So the divergence is inside that unit's coefficient | ||
| 62 | +read, not in chroma and not in prediction. | ||
| 63 | + | ||
| 64 | +Refusal now reads: `a 128x128 PARTITION_NONE block (four TX_64X64 luma and four TX_32X32 chroma | ||
| 65 | +units all decode, but the first unit's coefficients already carry AC where libaom has DC only -- | ||
| 66 | +lane-sb128b r2's open entropy residual)`. Gate | ||
| 67 | +`a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` stays `#[ignore]`d as | ||
| 68 | +the reproducer, with its plane asserts rewritten to LOCATE the divergence (count + first | ||
| 69 | +row/col/values) instead of printing 147 456 samples. | ||
| 70 | + | ||
| 71 | +Also corrected in that gate's doc: r1 wrote "ONE TX_64X64 chroma unit per plane / `TxbSet::Chroma64`"; | ||
| 72 | +the truth is four TX_32X32 and no `Chroma64` set exists or is needed. | ||
| 73 | + | ||
| 74 | +## Not done | ||
| 75 | + | ||
| 76 | +- deferred: TASK A's `tx_select` at 128 arm (`--enable-tx-size-search=1`) — not added — unblocked | ||
| 77 | + by the NONE arm being exact at all (an inexact arm cannot gate a tx-depth counter). | ||
| 78 | +- deferred: TASK B (HORZ/VERT + AB at 128) — not started, refused by name | ||
| 79 | + (`a 128x128 superblock HORZ/VERT or AB partition`) — unblocked by the same residual. | ||
| 80 | +- deferred: TASK C (inter 128) — not started, refused by name on both this tree and the sibling's | ||
| 81 | + (`an inter frame under a 128x128 superblock`) — unblocked by lane-sb128 r3 lifting its inter | ||
| 82 | + root refusal; nothing of TASK C was written, so nothing is "ready behind" it. | ||
| 83 | +- `git merge lane-sb128` NOT done: the sibling's tip is `dbf15a4` (gate-recipe fix only, no | ||
| 84 | + inter-128 lift yet), so there was nothing to take. | ||
| 85 | + | ||
| 86 | +## Suite | ||
| 87 | + | ||
| 88 | +r2's first run (`$HOME/.cache/sb128b-suite-r2.log`, unit `sb128b-suite-r2-1788322817.service`) was | ||
| 89 | +armed at the intermediate commit `1524838` and is superseded. Its FAILED list: the 2 rect/AB reds | ||
| 90 | +inherited from 807c110 (`a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact`, | ||
| 91 | +`a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact`) — **still red after | ||
| 92 | +`git merge main` b51719f, so main did NOT fix them** — plus the two 128 gates that this round's | ||
| 93 | +final commit resolves (`..._128x128_superblock_stream...` now green, | ||
| 94 | +`..._128x128_none_partition...` now `#[ignore]`d). | ||
| 95 | +The authoritative run for `c415a31` is unit `sb128b-suite-r2b-1788323051.service` → | ||
| 96 | +`$HOME/.cache/sb128b-suite-r2b.log`; it was still running at this round's tool-call ceiling. | ||
| 97 | +NOT a clean-suite claim: read that log for the totals before merging. | ||
lanes/sb128b-r3.report.mdadded+101 -0
| @@ -0,0 +1,101 @@ | |||
| 1 | +# lane-sb128b r3 — the 128x128 PARTITION_NONE block decodes PIXEL-EXACT (3 root causes), the 10-bit reds were a recipe defect | ||
| 2 | + | ||
| 3 | +Branch `lane-sb128b`, worktree `edith_codecs-sb128b`, commits `dd6f934` (merge main 7a47fc1 + TASK B), | ||
| 4 | +`f2b6f1c` (TASK A), `7ceb309` (merge main 18bf7dc / lane-sb128 5ea5ec8). | ||
| 5 | + | ||
| 6 | +## TASK A — the 128 NONE residual: THREE root causes, none of them where r2 pointed | ||
| 7 | + | ||
| 8 | +r2 read "our first TX_64X64 luma unit reads AC coefficients libaom never wrote". Measured with a | ||
| 9 | +range ladder (instrumented `aomdec` `EC_TRACE_COEFF` vs our `EC_TRACE_COEFF`) that premise is | ||
| 10 | +WRONG: the first luma unit is identical symbol for symbol and range for range | ||
| 11 | +(`all_zero ctx=1 rng=59208 / eob=3 rng=41268 / base_eob level=5 rng=44688 / ... / rng=36616`). | ||
| 12 | +The divergence is at the SECOND element of the block, and it is three separate defects: | ||
| 13 | + | ||
| 14 | +1. **Plane order.** libaom's `decode_token_recon_block` loops 64x64 luma "mu" chunks | ||
| 15 | + (`mu_blocks_wide/high = mi_size_wide[BLOCK_64X64]`) and codes EVERY PLANE of a chunk before the | ||
| 16 | + next chunk. The oracle ladder is Y(0,0) U(0,0) V(0,0) Y(0,16) U(0,8) V(0,8) ... — Y,U,V per | ||
| 17 | + quadrant. We read all four luma units and then all chroma units. Below 128 a block is one chunk, | ||
| 18 | + so the fix (`nchunk = side/64`, luma TUs then chroma units per chunk) is byte-for-byte the old | ||
| 19 | + order at every size the decoder already handled. | ||
| 20 | +2. **The chroma `txb_skip_ctx` offset.** `get_txb_ctx`: chroma ctx is | ||
| 21 | + `combine_entropy_contexts(above,left)` **+7** normally, **+10** when the plane block is LARGER | ||
| 22 | + than the transform. A 128 block's 64x64 uv plane block with TX_32X32 units is AV1's only such | ||
| 23 | + case, and our chroma table only ever carried the offset-7 rows (`txb_skip_chroma_*: [[u16;3];3]`). | ||
| 24 | + Oracle read ctx=10, we read ctx=0. Added `TXB_SKIP_CHROMA_32_BIG{,_Q0,_Q1,_Q3}` from | ||
| 25 | + `av1_default_txb_skip_cdfs[q][TX_32X32][10..13]` (token_cdfs.h, all four q contexts, verified by | ||
| 26 | + re-deriving the existing offset-7 rows from the same array), `txb_skip_chroma_32` is six rows, | ||
| 27 | + caller adds 3 when `cn > 1`. | ||
| 28 | +3. **Deferred chroma context writes.** r2 recorded each chroma unit's coefficient context only | ||
| 29 | + after the whole block, so the second quadrant read ctx 10 where the oracle reads 11 (base 1 from | ||
| 30 | + its left neighbour inside the same block). Now recorded per unit inside the loop; the | ||
| 31 | + post-`record_split_luma` replay stays, because that call would otherwise clobber them whole-block. | ||
| 32 | + | ||
| 33 | +Files: `crates/ec-av1/src/decode.rs` (mu-chunk loop + `chroma_ctx_offset` + per-unit record + | ||
| 34 | +`read_plane`'s chroma `skip_ctx`), `crates/ec-av1/src/cdf.rs` (4 tables), | ||
| 35 | +`crates/ec-av1/src/cdf_state.rs` (`txb_skip_chroma_32` 3 -> 6 rows). | ||
| 36 | + | ||
| 37 | +EVIDENCE: `$HOME/.cache/sb128b-work/{s44.obu,ref44.yuv,ours44.yuv.f0.yuv,ref.ladder}` | | ||
| 38 | +aomenc gate-arm-3 recipe (seed 44 gradients 256x256 cq63 `--sb-size=128 --cpu-used=0 | ||
| 39 | +--enable-tx-size-search=0 ...`), `EC_TRACE_COEFF` ladders of aomdec and `dump_yuv`, then | ||
| 40 | +`dump_yuv` vs `ffmpeg -pix_fmt yuv420p` | **48 `txb_skip` symbols, ranges identical one for one; | ||
| 41 | +0 of 98304 samples differ (pixel-exact)**. Before the fix: 60857 luma samples differed. | ||
| 42 | + | ||
| 43 | +REFUSAL LIFTED (with its gate): `a 128x128 PARTITION_NONE block (...)` deleted from `decode.rs` and | ||
| 44 | +`refusal_inventory.rs`; `a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact` | ||
| 45 | +un-`#[ignore]`d. | ||
| 46 | +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_key_frame_with_a_128x128_none_partition_decodes_pixel_exact --nocapture` | | ||
| 47 | +4 real-aomenc arms (384x384 seed 42 cq63, 384x384 seed 43 cq55, 256x256 seed 44 cq63, 384x384 seed 45 | ||
| 48 | +10-bit) decoded vs ffmpeg | **ok — 4/4 pixel-exact, 0 named refusals, `part128_none_hits=31`** | ||
| 49 | +(9+9+4+9 128-NONE roots). Sibling gates `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact`, | ||
| 50 | +`refusal_inventory`, `gate_coverage` re-run green in the same invocation (14 passed / 0 failed). | ||
| 51 | + | ||
| 52 | +## TASK B — the 2 inherited 10-bit reds were an ENCODER RECIPE defect | ||
| 53 | + | ||
| 54 | +`git show main:crates/ec-av1/src/stream.rs` vs the lane's: r2 rewrote `--min-partition-size=16` to | ||
| 55 | +`32` at **13** call sites that main has at 16, including both failing gates. 32 removes the 16-level | ||
| 56 | +the rect/AB gates assert. Reverted all 13 (the lane's own two 128 gates keep their deliberate 32). | ||
| 57 | +EVIDENCE: `cargo test -p ec-av1 --lib -- a_real_aomenc_10bit_rect_and_ab_partitions_decode_pixel_exact a_real_aomenc_10bit_stream_with_a_32_level_ab_partition_decodes_pixel_exact refusal_inventory gate_coverage` | | ||
| 58 | +recipe reverted, rebuilt, re-run | **ok — 14 passed, 0 failed**. Class: | ||
| 59 | +[[gate-recipe-confound]] / the ledger's "a gate that decodes pixel-exact with counter 0 is an | ||
| 60 | +encoder-recipe defect". Swept: those 13 are every 16->32 rewrite in the lane. | ||
| 61 | + | ||
| 62 | +## TASK C — merges | ||
| 63 | + | ||
| 64 | +`git merge main` twice: 7a47fc1 (one conflict, `decode.rs`'s skipped-block arm: took main's | ||
| 65 | +lane-hgkf per-TU prediction + `true_width` guard + `SKIP_SPLIT_TX_HITS`, broadened its condition | ||
| 66 | +from `tx_select && logical_tx < side` to `logical_tx < side` because a 128 block's transform is | ||
| 67 | +TX_64X64 with no tx-depth syntax; the counter keeps its narrow `tx_select` meaning), then 18bf7dc | ||
| 68 | +(= lane-sb128 5ea5ec8; three conflicts in `stream.rs`, ALL resolved to main's side per the batch | ||
| 69 | +coordinator, so main's single seam gate `a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact` | ||
| 70 | +survives and lane-oddh's seam refusal stays deleted). `cdf.rs` merged clean; its NZ_MAP and | ||
| 71 | +FILTER_INTRA regions are byte-identical to main's (`git diff main -- crates/ec-av1/src/cdf.rs` shows | ||
| 72 | +only the four new `TXB_SKIP_CHROMA_32_BIG*` tables). | ||
| 73 | + | ||
| 74 | +## Suite | ||
| 75 | + | ||
| 76 | +EVIDENCE: `$HOME/.cache/sb128b-suite-r3.log` (unit `sb128b-suite-r3-1788323779.service`, tip | ||
| 77 | +`7ceb309`) | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` | | ||
| 78 | +**test result: ok. 371 passed; 0 failed; 32 ignored; 473.61s** — GREEN. | ||
| 79 | + | ||
| 80 | +## ReelC key frame | ||
| 81 | + | ||
| 82 | +EVIDENCE: `$HOME/.cache/sb128b-work/{reelckf0.obu,reelcours.yuv.f0.yuv,ref.yuv}` | r2's recipe | ||
| 83 | +(`ffmpeg -t 2 -c:v copy -f obu` off the film, 1920x792 yuv420p10le), `dump_yuv` under a 6G scope vs | ||
| 84 | +ffmpeg's rawvideo | **`cmp` says BYTES EQUAL — 4 561 920 bytes, 0 differing samples.** | ||
| 85 | + | ||
| 86 | +Film probe on the 2 s cut (`decode_probe reelc2s.obu`) still stops at | ||
| 87 | +`an inter frame under a 128x128 superblock (this decoder's inter tile path recurses a 64x64 | ||
| 88 | +superblock root only)` — main 18bf7dc (lane-sb128 5ea5ec8) did NOT lift this one on this tree. | ||
| 89 | + | ||
| 90 | +## Open residue | ||
| 91 | + | ||
| 92 | +- deferred: `a 128x128 superblock HORZ/VERT or AB partition` — not started; every 128 root in the | ||
| 93 | + four gate arms resolves NONE or SPLIT, so nothing here is measured. Unblocked by an aomenc recipe | ||
| 94 | + that actually emits a 128-level HORZ/VERT (r2's seed-42 "HORZ/VERT at 128" sighting was our own | ||
| 95 | + desync talking — class [[refusal-from-own-desync]]: with the entropy fixed, that same stream | ||
| 96 | + reads nine NONE roots). | ||
| 97 | +- deferred: `a 128x128 superblock PARTITION_NONE root on an inter frame` and | ||
| 98 | + `an inter frame under a 128x128 superblock` (the ReelC blocker) — inter path untouched this round; | ||
| 99 | + unblocked by the inter tile path recursing a 128 root. | ||
| 100 | +- deferred: the `--enable-tx-size-search=1` arm at 128 (a read tx_depth under a 128 NONE root) — | ||
| 101 | + the four arms all pin `=0`; unblocked now that the NONE arm is exact, so it is a one-arm follow-up. | ||