ec-av1: lane-av1-422bigblock -- the 128-root 4:2:2 chroma chunk de-square-cut on the per-axis plane-block model and the reference plane resolution taught the third subsampling shape
Browse files at this commitc74c912a0461964953391597b535eaa7ca1472deParent: 8dcaf0a5 changed files +406 -76
- crates/ec-av1/fixtures/422_allskip_2f.obu +0 -0
- crates/ec-av1/fixtures/422_sb128_3f.obu +0 -0
- crates/ec-av1/src/decode.rs +194 -76
- crates/ec-av1/src/stream.rs +56 -0
- lanes/av1422bigblock.report.md +156 -0
crates/ec-av1/fixtures/422_allskip_2f.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/422_sb128_3f.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+194 -76
| @@ -18566,8 +18566,19 @@ fn decode_block_128rect( | ||
| 18566 | 18566 | let mi_rows = 2 * y.true_height.div_ceil(8); |
| 18567 | 18567 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); |
| 18568 | 18568 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); |
| 18569 | - // Non-lossless: one 32x32 chroma unit per mu chunk, per plane. | |
| 18570 | - debug_assert!(lossless_frame || (chroma_w / chroma_tx, chroma_h / chroma_tx) == (nch_x, nch_y)); | |
| 18569 | + // Non-lossless: per mu chunk, the chroma units per axis are | |
| 18570 | + // ((64 >> ss_x) / chroma_tx, (64 >> ss_y) / chroma_tx) -- one 32x32 unit | |
| 18571 | + // per chunk at 4:2:0, TWO stacked on the tall axis at 4:2:2 (the chunk's | |
| 18572 | + // chroma plane block is 32x64), four at 4:4:4. The old square-cut assert | |
| 18573 | + // demanded one unit per chunk on BOTH axes, which no 4:2:2 stream can | |
| 18574 | + // satisfy (lane-av1-422bigblock: the s2.obu witness). | |
| 18575 | + let chunk_cw = (64usize) >> ss_x(fctx); | |
| 18576 | + let chunk_ch = (64usize) >> ss_y(fctx); | |
| 18577 | + debug_assert!( | |
| 18578 | + lossless_frame | |
| 18579 | + || (nch_x * (chunk_cw / chroma_tx), nch_y * (chunk_ch / chroma_tx)) | |
| 18580 | + == (chroma_w / chroma_tx, chroma_h / chroma_tx) | |
| 18581 | + ); | |
| 18571 | 18582 | let tpc = 64 / logical_tx; |
| 18572 | 18583 | let zero_tu = vec![0i32; logical_tx * logical_tx]; |
| 18573 | 18584 | let zero_cu = vec![0i32; chroma_tx * chroma_tx]; |
| @@ -18576,6 +18587,7 @@ fn decode_block_128rect( | ||
| 18576 | 18587 | // The chroma context arrays are indexed in LUMA mi; every chroma unit of |
| 18577 | 18588 | // every chunk shares this luma span (2 chroma pixels per luma unit). |
| 18578 | 18589 | let luma_span = chroma_tx << ss_x(fctx); |
| 18590 | + let luma_span_h = chroma_tx << ss_y(fctx); | |
| 18579 | 18591 | for ch_row in 0..nch_y { |
| 18580 | 18592 | for ch_col in 0..nch_x { |
| 18581 | 18593 | for tu_row in ch_row * tpc..(ch_row + 1) * tpc { |
| @@ -18645,9 +18657,12 @@ fn decode_block_128rect( | ||
| 18645 | 18657 | neighbours.record_mi_luma(tu_mi, logical_tx, &tu_grid); |
| 18646 | 18658 | } |
| 18647 | 18659 | } |
| 18648 | - // Transform units per axis inside this mu chunk's 32x32 chroma | |
| 18649 | - // span: one 32x32 unit normally, 8x8 TX_4X4 units when lossless. | |
| 18650 | - let cn = (32 / chroma_tx).max(1); | |
| 18660 | + // Transform units per axis inside this mu chunk's chroma span | |
| 18661 | + // -- (64 >> ss_x) x (64 >> ss_y): one 32x32 unit at 4:2:0, TWO | |
| 18662 | + // stacked TX_32X32 at 4:2:2, four at 4:4:4; 8x8 TX_4X4 units | |
| 18663 | + // when lossless. | |
| 18664 | + let cn_w = (chunk_cw / chroma_tx).max(1); | |
| 18665 | + let cn_h = (chunk_ch / chroma_tx).max(1); | |
| 18651 | 18666 | // libaom's per-chunk `unit_width/height` (plane-mi units of the |
| 18652 | 18667 | // luma mi grid): `min(mu_blocks + col, max_blocks) >> ss`. |
| 18653 | 18668 | let unit_w = ((ch_col + 1) * 16).min(max_w_mi) >> ss_x(fctx); |
| @@ -18659,25 +18674,28 @@ fn decode_block_128rect( | ||
| 18659 | 18674 | // symbol order the interleaved pair used to read; a lossless |
| 18660 | 18675 | // frame's 4x4 chroma units are where it becomes observable. |
| 18661 | 18676 | for plane_pass in 1..=2usize { |
| 18662 | - for ci_row in 0..cn { | |
| 18663 | - for ci_col in 0..cn { | |
| 18664 | - if ch_col * 8 + ci_col * stepc >= unit_w | |
| 18665 | - || ch_row * 8 + ci_row * stepc >= unit_h | |
| 18677 | + for ci_row in 0..cn_h { | |
| 18678 | + for ci_col in 0..cn_w { | |
| 18679 | + // The clamp strides are the CHUNK's chroma mi extent | |
| 18680 | + // per axis: 16 luma mi >> the axis's own ss. | |
| 18681 | + if ch_col * (16 >> ss_x(fctx)) + ci_col * stepc >= unit_w | |
| 18682 | + || ch_row * (16 >> ss_y(fctx)) + ci_row * stepc >= unit_h | |
| 18666 | 18683 | { |
| 18667 | 18684 | continue; |
| 18668 | 18685 | } |
| 18669 | - let cu_x = cpx + ch_col * 32 + ci_col * chroma_tx; | |
| 18670 | - let cu_y = cpy + ch_row * 32 + ci_row * chroma_tx; | |
| 18686 | + let cu_x = cpx + ch_col * chunk_cw + ci_col * chroma_tx; | |
| 18687 | + let cu_y = cpy + ch_row * chunk_ch + ci_row * chroma_tx; | |
| 18671 | 18688 | let cu_mi = ( |
| 18672 | 18689 | mi_r + ch_row * 16 + ci_row * ((chroma_tx << ss_y(fctx)) / 4), |
| 18673 | 18690 | mi_c + ch_col * 16 + ci_col * ((chroma_tx << ss_x(fctx)) / 4), |
| 18674 | 18691 | ); |
| 18675 | - let cu_r = tu_reach( | |
| 18692 | + let cu_r = tu_reach_rect( | |
| 18676 | 18693 | bw, |
| 18677 | 18694 | bh, |
| 18678 | 18695 | ch_col * 64 + ci_col * luma_span, |
| 18679 | - ch_row * 64 + ci_row * luma_span, | |
| 18696 | + ch_row * 64 + ci_row * luma_span_h, | |
| 18680 | 18697 | luma_span, |
| 18698 | + luma_span_h, | |
| 18681 | 18699 | reach, |
| 18682 | 18700 | px, |
| 18683 | 18701 | py, |
| @@ -18691,7 +18709,8 @@ fn decode_block_128rect( | ||
| 18691 | 18709 | ); |
| 18692 | 18710 | continue; |
| 18693 | 18711 | } |
| 18694 | - let cu_around = neighbours.around_mi(cu_mi, luma_span); | |
| 18712 | + let cu_around = | |
| 18713 | + neighbours.around_mi_rect(cu_mi, luma_span, luma_span_h); | |
| 18695 | 18714 | let buf: &mut PlaneBuf<'static> = |
| 18696 | 18715 | if plane_pass == 1 { &mut *u } else { &mut *v }; |
| 18697 | 18716 | let grid = read_plane( |
| @@ -18705,7 +18724,13 @@ fn decode_block_128rect( | ||
| 18705 | 18724 | // reads this one's coefficient context; replayed after |
| 18706 | 18725 | // `record_split_luma_rect` below, which would otherwise |
| 18707 | 18726 | // clobber them whole-block. |
| 18708 | - neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &grid); | |
| 18727 | + neighbours.record_mi_chroma( | |
| 18728 | + cu_mi, | |
| 18729 | + luma_span, | |
| 18730 | + luma_span_h, | |
| 18731 | + plane_pass, | |
| 18732 | + &grid, | |
| 18733 | + ); | |
| 18709 | 18734 | units.push((plane_pass, cu_mi, grid)); |
| 18710 | 18735 | } |
| 18711 | 18736 | } |
| @@ -30233,15 +30258,42 @@ impl<'p> RefPix<'p> { | ||
| 30233 | 30258 | ( |
| 30234 | 30259 | whole_plane(&g.y, g.width, g.height), |
| 30235 | 30260 | { |
| 30236 | - // Reference pictures carry no subsampling field. A | |
| 30237 | - // 4:4:4 chroma plane is luma-sized; 4:2:0 is the quarter. | |
| 30238 | - let full = g.u.len() == g.width * g.height; | |
| 30239 | - let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) }; | |
| 30261 | + // Reference pictures carry no subsampling field -- the | |
| 30262 | + // plane's own shape is inferred from its length: | |
| 30263 | + // luma-sized is 4:4:4, `halfw x height` is 4:2:2 | |
| 30264 | + // (ss_x 1, ss_y 0 -- the chroma plane is HALF-width | |
| 30265 | + // and FULL-height), `halfw x halfh` is 4:2:0. The | |
| 30266 | + // three lengths are pairwise distinct for every | |
| 30267 | + // w, h >= 1, so the guess is exact. The old | |
| 30268 | + // two-way guess read every 4:2:2 reference as | |
| 30269 | + // quarter-height: a 128x128 frame's chroma resolved | |
| 30270 | + // 64x64, the bottom mu-chunk row's prediction | |
| 30271 | + // sampled a clamped row-63 edge and the frame's | |
| 30272 | + // own pixels were right (the crop is ss-aware) -- | |
| 30273 | + // only INTER prediction off the slot was wrong | |
| 30274 | + // (lane-av1-422bigblock: the sb128 witness's | |
| 30275 | + // frame-2 chroma, rows 64..127). | |
| 30276 | + let halfw = (g.width + 1) / 2; | |
| 30277 | + let halfh = (g.height + 1) / 2; | |
| 30278 | + let (cw, ch) = if g.u.len() == g.width * g.height { | |
| 30279 | + (g.width, g.height) | |
| 30280 | + } else if g.u.len() == halfw * g.height { | |
| 30281 | + (halfw, g.height) | |
| 30282 | + } else { | |
| 30283 | + (halfw, halfh) | |
| 30284 | + }; | |
| 30240 | 30285 | whole_plane(&g.u, cw, ch) |
| 30241 | 30286 | }, |
| 30242 | 30287 | { |
| 30243 | - let full = g.v.len() == g.width * g.height; | |
| 30244 | - let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) }; | |
| 30288 | + let halfw = (g.width + 1) / 2; | |
| 30289 | + let halfh = (g.height + 1) / 2; | |
| 30290 | + let (cw, ch) = if g.v.len() == g.width * g.height { | |
| 30291 | + (g.width, g.height) | |
| 30292 | + } else if g.v.len() == halfw * g.height { | |
| 30293 | + (halfw, g.height) | |
| 30294 | + } else { | |
| 30295 | + (halfw, halfh) | |
| 30296 | + }; | |
| 30245 | 30297 | whole_plane(&g.v, cw, ch) |
| 30246 | 30298 | }, |
| 30247 | 30299 | ) |
| @@ -32828,7 +32880,7 @@ fn decode_inter_block( | ||
| 32828 | 32880 | pu0.true_width, |
| 32829 | 32881 | pu0.true_height, |
| 32830 | 32882 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), |
| 32831 | - mv_to_q4(cpy, mv0.0, ss_x(fctx)), | |
| 32883 | + mv_to_q4(cpy, mv0.0, ss_y(fctx)), | |
| 32832 | 32884 | scale0, |
| 32833 | 32885 | chroma_stride, |
| 32834 | 32886 | chroma_buf_h, |
| @@ -32856,7 +32908,7 @@ fn decode_inter_block( | ||
| 32856 | 32908 | pu1.true_width, |
| 32857 | 32909 | pu1.true_height, |
| 32858 | 32910 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), |
| 32859 | - mv_to_q4(cpy, mv1.0, ss_x(fctx)), | |
| 32911 | + mv_to_q4(cpy, mv1.0, ss_y(fctx)), | |
| 32860 | 32912 | scale1, |
| 32861 | 32913 | chroma_stride, |
| 32862 | 32914 | chroma_buf_h, |
| @@ -32906,7 +32958,7 @@ fn decode_inter_block( | ||
| 32906 | 32958 | pv0.true_width, |
| 32907 | 32959 | pv0.true_height, |
| 32908 | 32960 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), |
| 32909 | - mv_to_q4(cpy, mv0.0, ss_x(fctx)), | |
| 32961 | + mv_to_q4(cpy, mv0.0, ss_y(fctx)), | |
| 32910 | 32962 | scale0, |
| 32911 | 32963 | chroma_stride, |
| 32912 | 32964 | chroma_buf_h, |
| @@ -32934,7 +32986,7 @@ fn decode_inter_block( | ||
| 32934 | 32986 | pv1.true_width, |
| 32935 | 32987 | pv1.true_height, |
| 32936 | 32988 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), |
| 32937 | - mv_to_q4(cpy, mv1.0, ss_x(fctx)), | |
| 32989 | + mv_to_q4(cpy, mv1.0, ss_y(fctx)), | |
| 32938 | 32990 | scale1, |
| 32939 | 32991 | chroma_stride, |
| 32940 | 32992 | chroma_buf_h, |
| @@ -33176,18 +33228,35 @@ fn decode_inter_block( | ||
| 33176 | 33228 | // this arm has always coded. `chroma_side` |
| 33177 | 33229 | // already carries the subsampling. |
| 33178 | 33230 | let cu_tx = 32usize; |
| 33179 | - let chunk_chroma = chroma_side * 64 / side; | |
| 33180 | - let units = chunk_chroma / cu_tx; | |
| 33231 | + // lane-av1-422bigblock: a 64x64 mu chunk's | |
| 33232 | + // chroma plane block is PER-AXIS | |
| 33233 | + // (64 >> ss_x) x (64 >> ss_y) -- 32x64 at | |
| 33234 | + // ss (1,0), i.e. TWO stacked TX_32X32 units | |
| 33235 | + // per plane (`av1_get_max_uv_txsize` caps the | |
| 33236 | + // unit at 32 on each axis). The old square-cut | |
| 33237 | + // model walked `chroma_side`-square chunks: | |
| 33238 | + // twice the units the oracle codes at 4:2:2, | |
| 33239 | + // prediction windows indexed at the square | |
| 33240 | + // `chroma_side` instead of the prediction | |
| 33241 | + // buffer's own `chroma_stride`, and chunk | |
| 33242 | + // columns at 64.. of a 64-wide chroma plane. | |
| 33243 | + let chunk_chroma_w = (64usize) >> ss_x(fctx); | |
| 33244 | + let chunk_chroma_h = (64usize) >> ss_y(fctx); | |
| 33245 | + let units_w = chunk_chroma_w / cu_tx; | |
| 33246 | + let units_h = chunk_chroma_h / cu_tx; | |
| 33181 | 33247 | // The unit's own footprint on the LUMA mi |
| 33182 | - // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi) | |
| 33183 | - // at ss 0/0. `around_mi` reads and | |
| 33248 | + // grid, per axis (32 << ss) px: 64x64 (16x16 | |
| 33249 | + // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4, | |
| 33250 | + // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect` | |
| 33251 | + // reads and | |
| 33184 | 33252 | // `record_mi_chroma` stamps span exactly the |
| 33185 | 33253 | // unit's own cells -- `get_txb_ctx` reads the |
| 33186 | 33254 | // 8 context cells of the TX_32X32 itself, and |
| 33187 | 33255 | // `av1_set_entropy_contexts` memsets the same |
| 33188 | 33256 | // 8, so the unit over never sees this unit's |
| 33189 | 33257 | // state and the unit below always does. |
| 33190 | - let unit_luma = cu_tx * (side / chroma_side); | |
| 33258 | + let unit_luma_w = cu_tx << ss_x(fctx); | |
| 33259 | + let unit_luma_h = cu_tx << ss_y(fctx); | |
| 33191 | 33260 | let cu_scan = default_scan(cu_tx); |
| 33192 | 33261 | if lossless(fctx) { |
| 33193 | 33262 | // lane-lossless2: TX_4X4 units over this |
| @@ -33195,8 +33264,8 @@ fn decode_inter_block( | ||
| 33195 | 33264 | read_inter_chroma_lossless( |
| 33196 | 33265 | dec, cdfs, neighbours, u, v, su, sv, |
| 33197 | 33266 | at_mi, (cpx, cpy), |
| 33198 | - (cc * chunk_chroma, cr * chunk_chroma), | |
| 33199 | - (chunk_chroma, chunk_chroma), | |
| 33267 | + (cc * chunk_chroma_w, cr * chunk_chroma_h), | |
| 33268 | + (chunk_chroma_w, chunk_chroma_h), | |
| 33200 | 33269 | (write_chroma_w, write_chroma_h), |
| 33201 | 33270 | chroma_side, mode_for_tx, base_q_idx, |
| 33202 | 33271 | &mut u_units, &mut v_units, fctx, |
| @@ -33213,24 +33282,28 @@ fn decode_inter_block( | ||
| 33213 | 33282 | // Plane-major per chunk (libaom's plane |
| 33214 | 33283 | // loop is outermost inside the mu walk); |
| 33215 | 33284 | // within a plane the units walk raster. |
| 33216 | - for ur in 0..units { | |
| 33217 | - for uc in 0..units { | |
| 33285 | + for ur in 0..units_h { | |
| 33286 | + for uc in 0..units_w { | |
| 33218 | 33287 | let unit_mi = ( |
| 33219 | 33288 | at_mi.0 + cr * 16 |
| 33220 | - + ur * (unit_luma / MI), | |
| 33289 | + + ur * (unit_luma_h / MI), | |
| 33221 | 33290 | at_mi.1 + cc * 16 |
| 33222 | - + uc * (unit_luma / MI), | |
| 33291 | + + uc * (unit_luma_w / MI), | |
| 33223 | 33292 | ); |
| 33224 | 33293 | // Per unit, AFTER the earlier |
| 33225 | 33294 | // units' stamps: this unit's |
| 33226 | 33295 | // coefficient context must see |
| 33227 | 33296 | // them. |
| 33228 | 33297 | let cu_around = neighbours |
| 33229 | - .around_mi(unit_mi, unit_luma); | |
| 33298 | + .around_mi_rect( | |
| 33299 | + unit_mi, | |
| 33300 | + unit_luma_w, | |
| 33301 | + unit_luma_h, | |
| 33302 | + ); | |
| 33230 | 33303 | let (cu_x, cu_y) = ( |
| 33231 | - cpx + cc * chunk_chroma | |
| 33304 | + cpx + cc * chunk_chroma_w | |
| 33232 | 33305 | + uc * cu_tx, |
| 33233 | - cpy + cr * chunk_chroma | |
| 33306 | + cpy + cr * chunk_chroma_h | |
| 33234 | 33307 | + ur * cu_tx, |
| 33235 | 33308 | ); |
| 33236 | 33309 | // `av1_get_tx_type` (blockd.h: |
| @@ -33261,11 +33334,16 @@ fn decode_inter_block( | ||
| 33261 | 33334 | }, |
| 33262 | 33335 | ) |
| 33263 | 33336 | .map(|(_, _, _, _, t)| t); |
| 33337 | + // The prediction buffer is | |
| 33338 | + // `chroma_stride`-strided (the | |
| 33339 | + // plane block's own width at | |
| 33340 | + // 4:2:2), not the square | |
| 33341 | + // `chroma_side`. | |
| 33264 | 33342 | let cu_pred = src.offset( |
| 33265 | - (cr * chunk_chroma | |
| 33343 | + (cr * chunk_chroma_h | |
| 33266 | 33344 | + ur * cu_tx) |
| 33267 | - * chroma_side | |
| 33268 | - + cc * chunk_chroma | |
| 33345 | + * chroma_stride | |
| 33346 | + + cc * chunk_chroma_w | |
| 33269 | 33347 | + uc * cu_tx, |
| 33270 | 33348 | ); |
| 33271 | 33349 | let cu_grid = read_inter_plane( |
| @@ -33295,8 +33373,8 @@ fn decode_inter_block( | ||
| 33295 | 33373 | // context. |
| 33296 | 33374 | neighbours.record_mi_chroma( |
| 33297 | 33375 | unit_mi, |
| 33298 | - unit_luma, | |
| 33299 | - unit_luma, | |
| 33376 | + unit_luma_w, | |
| 33377 | + unit_luma_h, | |
| 33300 | 33378 | plane_idx, |
| 33301 | 33379 | &cu_grid, |
| 33302 | 33380 | ); |
| @@ -33311,11 +33389,18 @@ fn decode_inter_block( | ||
| 33311 | 33389 | chroma_side * chroma_side, |
| 33312 | 33390 | ); |
| 33313 | 33391 | for rr in 0..cu_tx { |
| 33314 | - let start = (cr * chunk_chroma | |
| 33392 | + // The ASSEMBLED grid stays at | |
| 33393 | + // the square `chroma_side` | |
| 33394 | + // stride the block tail's | |
| 33395 | + // `mu_chroma_units` re-stamp | |
| 33396 | + // indexes; the unit's true | |
| 33397 | + // per-axis position is what | |
| 33398 | + // changes. | |
| 33399 | + let start = (cr * chunk_chroma_h | |
| 33315 | 33400 | + ur * cu_tx |
| 33316 | 33401 | + rr) |
| 33317 | 33402 | * chroma_side |
| 33318 | - + cc * chunk_chroma | |
| 33403 | + + cc * chunk_chroma_w | |
| 33319 | 33404 | + uc * cu_tx; |
| 33320 | 33405 | dst[start..start + cu_tx] |
| 33321 | 33406 | .copy_from_slice( |
| @@ -34262,7 +34347,7 @@ fn decode_inter_block( | ||
| 34262 | 34347 | pu_ref.true_width, |
| 34263 | 34348 | pu_ref.true_height, |
| 34264 | 34349 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34265 | - mv_to_q4(cpy, mv.0, ss_x(fctx)), | |
| 34350 | + mv_to_q4(cpy, mv.0, ss_y(fctx)), | |
| 34266 | 34351 | chroma_stride, |
| 34267 | 34352 | chroma_buf_h, |
| 34268 | 34353 | write_chroma_w, |
| @@ -34277,7 +34362,7 @@ fn decode_inter_block( | ||
| 34277 | 34362 | pv_ref.true_width, |
| 34278 | 34363 | pv_ref.true_height, |
| 34279 | 34364 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34280 | - mv_to_q4(cpy, mv.0, ss_x(fctx)), | |
| 34365 | + mv_to_q4(cpy, mv.0, ss_y(fctx)), | |
| 34281 | 34366 | chroma_stride, |
| 34282 | 34367 | chroma_buf_h, |
| 34283 | 34368 | write_chroma_w, |
| @@ -34309,7 +34394,7 @@ fn decode_inter_block( | ||
| 34309 | 34394 | pu_ref.true_width, |
| 34310 | 34395 | pu_ref.true_height, |
| 34311 | 34396 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34312 | - mv_to_q4(cpy, mv.0, ss_x(fctx)), | |
| 34397 | + mv_to_q4(cpy, mv.0, ss_y(fctx)), | |
| 34313 | 34398 | luma_scale, |
| 34314 | 34399 | chroma_stride, |
| 34315 | 34400 | chroma_buf_h, |
| @@ -34325,7 +34410,7 @@ fn decode_inter_block( | ||
| 34325 | 34410 | pv_ref.true_width, |
| 34326 | 34411 | pv_ref.true_height, |
| 34327 | 34412 | mv_to_q4(cpx, mv.1, ss_x(fctx)), |
| 34328 | - mv_to_q4(cpy, mv.0, ss_x(fctx)), | |
| 34413 | + mv_to_q4(cpy, mv.0, ss_y(fctx)), | |
| 34329 | 34414 | luma_scale, |
| 34330 | 34415 | chroma_stride, |
| 34331 | 34416 | chroma_buf_h, |
| @@ -34420,7 +34505,7 @@ fn decode_inter_block( | ||
| 34420 | 34505 | src.true_width, |
| 34421 | 34506 | src.true_height, |
| 34422 | 34507 | mv_to_q4(cpx, prev_mv.1, ss_x(fctx)), |
| 34423 | - mv_to_q4(cpy, prev_mv.0, ss_x(fctx)), | |
| 34508 | + mv_to_q4(cpy, prev_mv.0, ss_y(fctx)), | |
| 34424 | 34509 | prev_scale, |
| 34425 | 34510 | piece_w, |
| 34426 | 34511 | piece_h, |
| @@ -34676,18 +34761,35 @@ fn decode_inter_block( | ||
| 34676 | 34761 | // this arm has always coded. `chroma_side` |
| 34677 | 34762 | // already carries the subsampling. |
| 34678 | 34763 | let cu_tx = 32usize; |
| 34679 | - let chunk_chroma = chroma_side * 64 / side; | |
| 34680 | - let units = chunk_chroma / cu_tx; | |
| 34764 | + // lane-av1-422bigblock: a 64x64 mu chunk's | |
| 34765 | + // chroma plane block is PER-AXIS | |
| 34766 | + // (64 >> ss_x) x (64 >> ss_y) -- 32x64 at | |
| 34767 | + // ss (1,0), i.e. TWO stacked TX_32X32 units | |
| 34768 | + // per plane (`av1_get_max_uv_txsize` caps the | |
| 34769 | + // unit at 32 on each axis). The old square-cut | |
| 34770 | + // model walked `chroma_side`-square chunks: | |
| 34771 | + // twice the units the oracle codes at 4:2:2, | |
| 34772 | + // prediction windows indexed at the square | |
| 34773 | + // `chroma_side` instead of the prediction | |
| 34774 | + // buffer's own `chroma_stride`, and chunk | |
| 34775 | + // columns at 64.. of a 64-wide chroma plane. | |
| 34776 | + let chunk_chroma_w = (64usize) >> ss_x(fctx); | |
| 34777 | + let chunk_chroma_h = (64usize) >> ss_y(fctx); | |
| 34778 | + let units_w = chunk_chroma_w / cu_tx; | |
| 34779 | + let units_h = chunk_chroma_h / cu_tx; | |
| 34681 | 34780 | // The unit's own footprint on the LUMA mi |
| 34682 | - // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi) | |
| 34683 | - // at ss 0/0. `around_mi` reads and | |
| 34781 | + // grid, per axis (32 << ss) px: 64x64 (16x16 | |
| 34782 | + // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4, | |
| 34783 | + // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect` | |
| 34784 | + // reads and | |
| 34684 | 34785 | // `record_mi_chroma` stamps span exactly the |
| 34685 | 34786 | // unit's own cells -- `get_txb_ctx` reads the |
| 34686 | 34787 | // 8 context cells of the TX_32X32 itself, and |
| 34687 | 34788 | // `av1_set_entropy_contexts` memsets the same |
| 34688 | 34789 | // 8, so the unit over never sees this unit's |
| 34689 | 34790 | // state and the unit below always does. |
| 34690 | - let unit_luma = cu_tx * (side / chroma_side); | |
| 34791 | + let unit_luma_w = cu_tx << ss_x(fctx); | |
| 34792 | + let unit_luma_h = cu_tx << ss_y(fctx); | |
| 34691 | 34793 | let cu_scan = default_scan(cu_tx); |
| 34692 | 34794 | if lossless(fctx) { |
| 34693 | 34795 | // lane-lossless2: TX_4X4 units over this |
| @@ -34695,8 +34797,8 @@ fn decode_inter_block( | ||
| 34695 | 34797 | read_inter_chroma_lossless( |
| 34696 | 34798 | dec, cdfs, neighbours, u, v, su, sv, |
| 34697 | 34799 | at_mi, (cpx, cpy), |
| 34698 | - (cc * chunk_chroma, cr * chunk_chroma), | |
| 34699 | - (chunk_chroma, chunk_chroma), | |
| 34800 | + (cc * chunk_chroma_w, cr * chunk_chroma_h), | |
| 34801 | + (chunk_chroma_w, chunk_chroma_h), | |
| 34700 | 34802 | (write_chroma_w, write_chroma_h), |
| 34701 | 34803 | chroma_side, mode_for_tx, base_q_idx, |
| 34702 | 34804 | &mut u_units, &mut v_units, fctx, |
| @@ -34713,24 +34815,28 @@ fn decode_inter_block( | ||
| 34713 | 34815 | // Plane-major per chunk (libaom's plane |
| 34714 | 34816 | // loop is outermost inside the mu walk); |
| 34715 | 34817 | // within a plane the units walk raster. |
| 34716 | - for ur in 0..units { | |
| 34717 | - for uc in 0..units { | |
| 34818 | + for ur in 0..units_h { | |
| 34819 | + for uc in 0..units_w { | |
| 34718 | 34820 | let unit_mi = ( |
| 34719 | 34821 | at_mi.0 + cr * 16 |
| 34720 | - + ur * (unit_luma / MI), | |
| 34822 | + + ur * (unit_luma_h / MI), | |
| 34721 | 34823 | at_mi.1 + cc * 16 |
| 34722 | - + uc * (unit_luma / MI), | |
| 34824 | + + uc * (unit_luma_w / MI), | |
| 34723 | 34825 | ); |
| 34724 | 34826 | // Per unit, AFTER the earlier |
| 34725 | 34827 | // units' stamps: this unit's |
| 34726 | 34828 | // coefficient context must see |
| 34727 | 34829 | // them. |
| 34728 | 34830 | let cu_around = neighbours |
| 34729 | - .around_mi(unit_mi, unit_luma); | |
| 34831 | + .around_mi_rect( | |
| 34832 | + unit_mi, | |
| 34833 | + unit_luma_w, | |
| 34834 | + unit_luma_h, | |
| 34835 | + ); | |
| 34730 | 34836 | let (cu_x, cu_y) = ( |
| 34731 | - cpx + cc * chunk_chroma | |
| 34837 | + cpx + cc * chunk_chroma_w | |
| 34732 | 34838 | + uc * cu_tx, |
| 34733 | - cpy + cr * chunk_chroma | |
| 34839 | + cpy + cr * chunk_chroma_h | |
| 34734 | 34840 | + ur * cu_tx, |
| 34735 | 34841 | ); |
| 34736 | 34842 | // `av1_get_tx_type` (blockd.h: |
| @@ -34761,11 +34867,16 @@ fn decode_inter_block( | ||
| 34761 | 34867 | }, |
| 34762 | 34868 | ) |
| 34763 | 34869 | .map(|(_, _, _, _, t)| t); |
| 34870 | + // The prediction buffer is | |
| 34871 | + // `chroma_stride`-strided (the | |
| 34872 | + // plane block's own width at | |
| 34873 | + // 4:2:2), not the square | |
| 34874 | + // `chroma_side`. | |
| 34764 | 34875 | let cu_pred = src.offset( |
| 34765 | - (cr * chunk_chroma | |
| 34876 | + (cr * chunk_chroma_h | |
| 34766 | 34877 | + ur * cu_tx) |
| 34767 | - * chroma_side | |
| 34768 | - + cc * chunk_chroma | |
| 34878 | + * chroma_stride | |
| 34879 | + + cc * chunk_chroma_w | |
| 34769 | 34880 | + uc * cu_tx, |
| 34770 | 34881 | ); |
| 34771 | 34882 | let cu_grid = read_inter_plane( |
| @@ -34795,8 +34906,8 @@ fn decode_inter_block( | ||
| 34795 | 34906 | // context. |
| 34796 | 34907 | neighbours.record_mi_chroma( |
| 34797 | 34908 | unit_mi, |
| 34798 | - unit_luma, | |
| 34799 | - unit_luma, | |
| 34909 | + unit_luma_w, | |
| 34910 | + unit_luma_h, | |
| 34800 | 34911 | plane_idx, |
| 34801 | 34912 | &cu_grid, |
| 34802 | 34913 | ); |
| @@ -34811,11 +34922,18 @@ fn decode_inter_block( | ||
| 34811 | 34922 | chroma_side * chroma_side, |
| 34812 | 34923 | ); |
| 34813 | 34924 | for rr in 0..cu_tx { |
| 34814 | - let start = (cr * chunk_chroma | |
| 34925 | + // The ASSEMBLED grid stays at | |
| 34926 | + // the square `chroma_side` | |
| 34927 | + // stride the block tail's | |
| 34928 | + // `mu_chroma_units` re-stamp | |
| 34929 | + // indexes; the unit's true | |
| 34930 | + // per-axis position is what | |
| 34931 | + // changes. | |
| 34932 | + let start = (cr * chunk_chroma_h | |
| 34815 | 34933 | + ur * cu_tx |
| 34816 | 34934 | + rr) |
| 34817 | 34935 | * chroma_side |
| 34818 | - + cc * chunk_chroma | |
| 34936 | + + cc * chunk_chroma_w | |
| 34819 | 34937 | + uc * cu_tx; |
| 34820 | 34938 | dst[start..start + cu_tx] |
| 34821 | 34939 | .copy_from_slice( |
| @@ -39382,7 +39500,7 @@ fn decode_inter_block8( | ||
| 39382 | 39500 | pu0.true_width, |
| 39383 | 39501 | pu0.true_height, |
| 39384 | 39502 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), |
| 39385 | - mv_to_q4(cpy, mv0.0, ss_x(fctx)), | |
| 39503 | + mv_to_q4(cpy, mv0.0, ss_y(fctx)), | |
| 39386 | 39504 | scale0, |
| 39387 | 39505 | chroma_w, |
| 39388 | 39506 | chroma_h, |
| @@ -39397,7 +39515,7 @@ fn decode_inter_block8( | ||
| 39397 | 39515 | pu1.true_width, |
| 39398 | 39516 | pu1.true_height, |
| 39399 | 39517 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), |
| 39400 | - mv_to_q4(cpy, mv1.0, ss_x(fctx)), | |
| 39518 | + mv_to_q4(cpy, mv1.0, ss_y(fctx)), | |
| 39401 | 39519 | scale1, |
| 39402 | 39520 | chroma_w, |
| 39403 | 39521 | chroma_h, |
| @@ -39429,7 +39547,7 @@ ss_y(fctx), | ||
| 39429 | 39547 | pv0.true_width, |
| 39430 | 39548 | pv0.true_height, |
| 39431 | 39549 | mv_to_q4(cpx, mv0.1, ss_x(fctx)), |
| 39432 | - mv_to_q4(cpy, mv0.0, ss_x(fctx)), | |
| 39550 | + mv_to_q4(cpy, mv0.0, ss_y(fctx)), | |
| 39433 | 39551 | scale0, |
| 39434 | 39552 | chroma_w, |
| 39435 | 39553 | chroma_h, |
| @@ -39444,7 +39562,7 @@ ss_y(fctx), | ||
| 39444 | 39562 | pv1.true_width, |
| 39445 | 39563 | pv1.true_height, |
| 39446 | 39564 | mv_to_q4(cpx, mv1.1, ss_x(fctx)), |
| 39447 | - mv_to_q4(cpy, mv1.0, ss_x(fctx)), | |
| 39565 | + mv_to_q4(cpy, mv1.0, ss_y(fctx)), | |
| 39448 | 39566 | scale1, |
| 39449 | 39567 | chroma_w, |
| 39450 | 39568 | chroma_h, |
crates/ec-av1/src/stream.rsmodified+56 -0
| @@ -2209,6 +2209,62 @@ pub(crate) mod tests { | ||
| 2209 | 2209 | let frames = decode_stream(&stream).expect("the 4:2:0 control must decode"); |
| 2210 | 2210 | assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame"); |
| 2211 | 2211 | } |
| 2212 | + /// lane-av1-422bigblock: the two witnessed 4:2:2 big-block defects, pinned | |
| 2213 | + /// as fixtures (`git add -f`; `fixtures/` is gitignored). | |
| 2214 | + /// | |
| 2215 | + /// `422_allskip_2f.obu` (62 bytes) is a 128x128 profile-2 key frame plus | |
| 2216 | + /// its all-skip first inter frame: the pre-port decoder read phantom | |
| 2217 | + /// coefficient units in the inter frame and then panicked in | |
| 2218 | + /// `reconstruct_mc_rect` on a full-height 4:2:2 chroma rect. At this | |
| 2219 | + /// lane's HEAD the block-half port's per-axis plane-block model already | |
| 2220 | + /// has it entropy-locked (all 20 key-frame coefficient units pair | |
| 2221 | + /// rng-for-rng with the instrumented oracle, the inter frame reads | |
| 2222 | + /// zero, matching the oracle) and pixel-exact vs aomdec. | |
| 2223 | + /// | |
| 2224 | + /// `422_sb128_3f.obu` (12543 bytes) carries the f2 128x128 | |
| 2225 | + /// `PARTITION_NONE` non-skip inter block: the mu-chunk chroma walk cut | |
| 2226 | + /// each chunk's 32x64 chroma into a `chroma_side`-square 64x64 (twice | |
| 2227 | + /// the units the oracle codes), indexed the prediction buffer at the | |
| 2228 | + /// square `chroma_side` instead of `chroma_stride` (the empty-slice | |
| 2229 | + /// panic at `push_mc_rect_tx`'s densify), and the reference plane | |
| 2230 | + /// resolution guessed every non-4:4:4 picture quarter-height, so the | |
| 2231 | + /// bottom mu-chunk row predicted from a clamped row-63 edge. All fixed; | |
| 2232 | + /// both witnesses decode pixel-exact vs aomdec on the lane's local | |
| 2233 | + /// `EC_AV1_ALLOW_422_PROBE` patch-run-restore build (recipe and measured | |
| 2234 | + /// numbers in `lanes/av1422bigblock.report.md`). | |
| 2235 | + /// | |
| 2236 | + /// `decode_stream` itself still refuses 4:2:2 at the sequence header -- | |
| 2237 | + /// unconditionally, per the standing family rule -- so the committed | |
| 2238 | + /// assertion is the byte pin (fnv1a64, the same load-bearing-identity | |
| 2239 | + /// fingerprint as the cdf-forwarding gate) plus the refusal-by-name | |
| 2240 | + /// contract over the pinned bytes. | |
| 2241 | + #[test] | |
| 2242 | + fn the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name() { | |
| 2243 | + const NAME: &str = "the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name"; | |
| 2244 | + const REFUSAL: &str = "a chroma format of 4:2:2"; | |
| 2245 | + for (file, bytes, fp) in [ | |
| 2246 | + ("422_allskip_2f.obu", 62usize, 0x7e4d69d3c728c55f_u64), | |
| 2247 | + ("422_sb128_3f.obu", 12543, 0x5171e0aab8000da7), | |
| 2248 | + ] { | |
| 2249 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 2250 | + .join("fixtures") | |
| 2251 | + .join(file); | |
| 2252 | + let data = std::fs::read(&path).unwrap_or_else(|e| { | |
| 2253 | + panic!( | |
| 2254 | + "{NAME}: pinned witness {} is missing ({e}) -- the gate cannot run", | |
| 2255 | + path.display() | |
| 2256 | + ) | |
| 2257 | + }); | |
| 2258 | + assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted"); | |
| 2259 | + assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted"); | |
| 2260 | + let err = decode_stream(&data).unwrap_err().to_string(); | |
| 2261 | + assert!( | |
| 2262 | + err.contains(REFUSAL), | |
| 2263 | + "{NAME}: {file} must refuse by name, got: {err}" | |
| 2264 | + ); | |
| 2265 | + } | |
| 2266 | + } | |
| 2267 | + | |
| 2212 | 2268 | |
| 2213 | 2269 | /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the |
| 2214 | 2270 | /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is |
lanes/av1422bigblock.report.mdadded+156 -0
| @@ -0,0 +1,156 @@ | ||
| 1 | +# lane-av1-422bigblock — the two witnessed 4:2:2 big-block defects | |
| 2 | + | |
| 3 | +Branch `lane-av1-422bigblock`, HEAD `213c1eb0` (contains the block-half port). | |
| 4 | +Target dir `$HOME/.cache/cargo-target-av1422bigblock` throughout. No push. | |
| 5 | + | |
| 6 | +## Verdict | |
| 7 | + | |
| 8 | +Both witnessed defects are fixed and both witnesses are pixel-exact vs aomdec. | |
| 9 | +The panic the ticket predicted for defect 1 no longer reproduces at this HEAD — | |
| 10 | +the block-half port had already fixed the all-skip inter frame; re-verified, not | |
| 11 | +assumed. Defect 2 needed three fixes, two of them found below the historical | |
| 12 | +panic line. The 4:2:0/4:4:4 behavior is unchanged (targeted gates green, t422 | |
| 13 | +frame 0 byte-exact at all four stages). Defect 3 (Main's IRC addition, the | |
| 14 | +s2.obu crash) is fixed as a crash; s2's remaining divergence is a pre-existing | |
| 15 | +sub-8 chroma class, fingerprinted for its owning lane. Committed code still | |
| 16 | +refuses 4:2:2 at the sequence header; the `EC_AV1_ALLOW_422_PROBE` bypass was | |
| 17 | +applied and reverted per probe run and is **not** in the commit. | |
| 18 | + | |
| 19 | +## Fixtures (pinned, `git add -f`; `fixtures/` is gitignored) | |
| 20 | + | |
| 21 | +| fixture | bytes | sha256 | fnv1a64 | | |
| 22 | +|---|---|---|---| | |
| 23 | +| `422_allskip_2f.obu` | 62 | `ba4932c14f95971b5f25321b04abce80c9fdd5de4b1fe6fffcdad82aaea87ce1` | `0x7e4d69d3c728c55f` | | |
| 24 | +| `422_sb128_3f.obu` | 12543 | `0b851799d99cb4d141a7d042138a3999aad7e0fb24d69c670bca1d38c286dce9` | `0x5171e0aab8000da7` | | |
| 25 | + | |
| 26 | +Provenance: the witness hunt's artifacts under `~/.cache/av1422sb128wit/` | |
| 27 | +(`422_allskip_2f.obu` = `b422_wit2f.obu`, `422_sb128_3f.obu` = `b422b_3f.obu`; | |
| 28 | +oracle refs `b422_wit.ref.yuv`). NOTE: the ticket said `422_sb128_3f.obu` is | |
| 29 | +10175 bytes; the live file is 12543 bytes and its sha256 matches the ticket — | |
| 30 | +the byte count in the charter is stale, the hash is authoritative. | |
| 31 | + | |
| 32 | +Gate: `the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name` | |
| 33 | +(stream.rs) asserts both byte pins and the refusal-by-name contract. | |
| 34 | +`decode_stream` still refuses 4:2:2 unconditionally in committed code, so a | |
| 35 | +committed gate cannot decode these streams; the decode-completes + counters + | |
| 36 | +pixel-exact assertions were measured through the probe build and are | |
| 37 | +reproducible from the recipe below. The counters over the sb128 witness: | |
| 38 | +`chroma422_square: 32`; over s2: `chroma422_square: 68, chroma422_rect: 222, | |
| 39 | +chroma422_sub8: 24, chroma422_chunk: 40`, `part128 none=3`. | |
| 40 | + | |
| 41 | +## Reproduce (patch-run-restore, local only) | |
| 42 | + | |
| 43 | +``` | |
| 44 | +sed 's/if seq.subsampling_x != seq.subsampling_y {/if seq.subsampling_x != seq.subsampling_y \&\& std::env::var_os("EC_AV1_ALLOW_422_PROBE").is_none() {/' -i crates/ec-av1/src/stream.rs | |
| 45 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-av1422bigblock cargo build -p ec-av1 --example decode_probe --features gate-counters | |
| 46 | +EC_AV1_ALLOW_422_PROBE=1 EC_PROBE_OUT=/tmp/ours.raw \ | |
| 47 | + $HOME/.cache/cargo-target-av1422bigblock/debug/examples/decode_probe crates/ec-av1/fixtures/422_sb128_3f.obu | |
| 48 | +$HOME/.cache/aom-oracle/build/aomdec --rawvideo -o /tmp/oracle.raw crates/ec-av1/fixtures/422_sb128_3f.obu | |
| 49 | +cmp /tmp/ours.raw /tmp/oracle.raw # identical | |
| 50 | +git checkout -- crates/ec-av1/src/stream.rs | |
| 51 | +``` | |
| 52 | + | |
| 53 | +## Defect 1 — all-skip 422 inter desync: NOT REPRODUCING at HEAD (fixed upstream) | |
| 54 | + | |
| 55 | +At `213c1eb0` the witness decodes clean: `OK: 2 frames decoded, 128x128`, no | |
| 56 | +panic, no phantom reads. Evidence: | |
| 57 | + | |
| 58 | +- Entropy: our `EC_TRACE_COEFF` pairs rng-for-rng with the instrumented | |
| 59 | + oracle's — frame 0 codes 20 coefficient units (one nonzero 32x32 luma unit + | |
| 60 | + 4 stacked-chroma per 32x32 quadrant), identical rng sequence on both sides; | |
| 61 | + frame 1 codes **zero** units on both sides (all-skip, as the oracle). | |
| 62 | +- Pixels: the shown frame is byte-identical to `aomdec --rawvideo`. | |
| 63 | + | |
| 64 | +The ticket's "~20 phantom units + reconstruct_mc_rect side=64 w=64 h=128 panic" | |
| 65 | +is the pre-blockhalf state; the per-axis plane-block model fixed both the | |
| 66 | +phantom reads and the geometry. No code change needed here. The full hunt | |
| 67 | +stream `b422_wit.obu` (6 frames) also decodes OK at HEAD. | |
| 68 | + | |
| 69 | +## Defect 2 — 128-root square-cut chroma chunking: three stacked causes | |
| 70 | + | |
| 71 | +The historical `range end 4128 > 4096` (decode.rs:34279) no longer reproduces; | |
| 72 | +at HEAD the same block panicked deeper, in `push_mc_rect_tx`'s stride-densify | |
| 73 | +(`range end index 32 out of range for slice of length 0`). The f2 128x128 | |
| 74 | +PARTITION_NONE non-skip inter block carries all three causes; the oracle codes | |
| 75 | +16 chroma units (8 per plane, 2 stacked TX_32X32 per 64x64 mu chunk). | |
| 76 | + | |
| 77 | +1. **Square-cut chunking** (`decode_inter_block`, both the inter-luma and the | |
| 78 | + intra-in-inter walk): `chunk_chroma = chroma_side * 64 / side` cut each | |
| 79 | + chunk's per-axis `(64>>ss_x) x (64>>ss_y)` chroma into a | |
| 80 | + `chroma_side`-square 64x64 — twice the units the oracle codes at 4:2:2. | |
| 81 | + Fixed per-axis (`chunk_cw/chunk_ch`, `units_w/units_h`), unit luma spans | |
| 82 | + `(32<<ss_x, 32<<ss_y)` via `around_mi_rect`/per-axis | |
| 83 | + `record_mi_chroma`, and the assembled grid placement per-axis. | |
| 84 | +2. **Prediction stride**: `cu_pred = src.offset((cr*chunk + ur*cu_tx) * | |
| 85 | + chroma_side + ...)` indexed the prediction buffer at the square | |
| 86 | + `chroma_side` (128) while the 4:2:2 buffer is `chroma_stride`-strided (the | |
| 87 | + plane block's own width, 64). Chunk (0,0)'s tall unit read buffer row 64 as | |
| 88 | + row 32, and chunk (1,0) offset to `len` exactly — the empty slice. Fixed to | |
| 89 | + `* chroma_stride`; the assembled grid stays at the square `chroma_side` | |
| 90 | + stride the block-tail `mu_chroma_units` re-stamp already indexes per-axis | |
| 91 | + (verified unit-for-unit against the walk). | |
| 92 | +3. **Reference plane resolution** (`RefPix::planes`): a `Picture` carries no | |
| 93 | + subsampling field, and the two-way guess (luma-sized = 4:4:4, otherwise | |
| 94 | + quarter = 4:2:0) resolved every 4:2:2 reference 64x64. The frame's own | |
| 95 | + pixels were right (the crop is ss-aware) — only inter prediction off the | |
| 96 | + slot was wrong, so the bottom mu-chunk row predicted from a clamped row-63 | |
| 97 | + edge (±1–2 diffs over chroma rows 64..127, 3.3–3.6k samples/plane). Fixed | |
| 98 | + with a three-way length inference (`w*h` / `halfw*h` / `halfw*halfh` — | |
| 99 | + pairwise distinct for every w,h ≥ 1). | |
| 100 | + | |
| 101 | +After the fixes: `422_sb128_3f.obu` and the full `b422_wit.obu` decode | |
| 102 | +pixel-exact vs aomdec; every coefficient unit of every frame pairs | |
| 103 | +rng-for-rng with the oracle (29/29, 32/32, 32/32). | |
| 104 | + | |
| 105 | +Class sweep of the same square-cut model: | |
| 106 | +- `decode_intrabc_128rect` has the same `cside * 64 / side` square chunk walk — | |
| 107 | + **deferred** (same class, unwitnessed: no 4:2:2 intrabc 128-rect witness | |
| 108 | + exists; unblock = one aomenc `--enable-intrabc` profile-2 128-SB hunt). | |
| 109 | +- The 444 branch of the inter walk degenerates to identical values (ss 0/0 ⇒ | |
| 110 | + per-axis == square, `chroma_stride == chroma_side`), verified by gate. | |
| 111 | + | |
| 112 | +## Defect 3 (Main's IRC) — s2.obu crash: crash fixed, residual named | |
| 113 | + | |
| 114 | +`/tmp/sa422/s2.obu` (recipe: `lanes/av1422stripanchor.report.md` "Observed, not | |
| 115 | +chased"; 420 control `b420_wit.obu`) panicked at `decode.rs:3709` at HEAD — the | |
| 116 | +same densify site, fed by defect 2's cause 3 (quarter-height reference) and the | |
| 117 | +intra 128-rect twin of the square-cut walk: | |
| 118 | + | |
| 119 | +- `decode_block_128rect`'s chroma walk was chunk-square (`cn = 32/chroma_tx`, | |
| 120 | + `cu_y = cpy + ch_row*32`, clamp strides 8/8) with a `debug_assert!` that no | |
| 121 | + 4:2:2 stream can satisfy. Fixed per-axis exactly like the inter walk | |
| 122 | + (`cn_w/cn_h`, per-axis chunk offsets and clamp strides, `tu_reach_rect`, | |
| 123 | + `around_mi_rect`, per-axis record spans). 420/444 degenerate to the old | |
| 124 | + values; 4:4:4's previously-broken (assert-caught) non-lossless 128-rect | |
| 125 | + chroma becomes correct as a side effect. | |
| 126 | + | |
| 127 | +Result: s2.obu decodes all 16 frames, no panic (`OK: 16 frames decoded, | |
| 128 | +256x144`). The crash the charter assigned is closed. **Deferred (named for its | |
| 129 | +owning lane):** s2's frame 0 diverges from aomdec (~45% of samples, maxabs | |
| 130 | +~180, Y first diff at sample 126) with an entropy desync: the oracle codes | |
| 131 | +1089 coefficient units in frame 0, ours 541, first divergence at unit 38 — a | |
| 132 | +plane-2 **TX_4X8** chroma unit at **mi(12,24)** (oracle `all_zero=0 | |
| 133 | +rng=48745`, ours `rng=41584`). Class: sub-8/odd-strip 4:2:2 chroma under the | |
| 134 | +128-rect intra path (the `ss_size_lookup` BLOCK_INVALID family), pre-existing | |
| 135 | +— the base tree panics at frame 0's assert and never produced pixels. At base | |
| 136 | +the stream could not be measured at all; the pre-fix re-run log is | |
| 137 | +`/tmp/sa422/re-run-av1422ctxgather.log`. Fingerprint: `/tmp/sa422/s2f0.obu`, | |
| 138 | +unit 38, mi(12,24), TX_4X8, plane 2. | |
| 139 | + | |
| 140 | +## 4:2:0/4:4:4 identity + t422 | |
| 141 | + | |
| 142 | +- `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` — green. | |
| 143 | +- `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream` | |
| 144 | + (live aomenc, 420, inter, tiles) — green. | |
| 145 | +- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` (4:4:4 lossless | |
| 146 | + sb128) — green. | |
| 147 | +- `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders` | |
| 148 | + and `a_128_root_compound_block_decodes_exact_through_both_decoders` (solo, | |
| 149 | + they pin the process-global superblock size) — green. | |
| 150 | +- t422 frame 0 (`/tmp/i422/t422_1f.obu`) byte-exact vs the instrumented oracle | |
| 151 | + at PREFILT, POSTDEBLOCK, POSTCDEF and FINAL on Y, U and V; t422 16-frame | |
| 152 | + stream decodes with the same frame count as the parent (15 shown of 16 frame | |
| 153 | + OBUs, unchanged at HEAD — the 16th is an `OBU_TILE_LIST` quirk, not a | |
| 154 | + regression). | |
| 155 | + | |
| 156 | +`cargo check -p ec-av1`: 0 warnings. Committed on the branch, no push. |