forge
Explore
Log in

Don't you dare go Hollow

ec-av1: lane-av1-422p -- chunk the 4x32 chroma stop: BLOCK_INVALID plane_bsize reads max_txsize_rect_lookup[255] = TX_4X8 OOB (0x05 at the decode_token_recon_block copy 0xc0d030, objdump-measured), so an 8x32 luma strip's 4:2:2 chroma is FOUR stacked TX_4X8 units per plane (stepr = tx_size_high_unit = 2, chroma rows 0/8/16/24, plane-major, skip arm included) riding the ChromaRect8x4 class; read_rect_chroma_unit gains chroma_skip_offset (this arm Some(3): num_pels_log2_lookup[255] = 0xff at the 0xc0de70 copy -> offset 10 -> the +3 offset-10 rows; every existing caller None, behavior-identical); whole 16-frame stream decodes (probe OK, rect4_32 vert=1, 8 units at mi=(24,52), skip_ctx 3..5, chroma422_rect=172), pixels NOT exact -> header refusal stays byte-identical; frontier named: decode_rect4_16_strip's chroma422_pair16 chunk passes no offset (offset-7 rows where the same rule demands 10), decode_rect_split's own EC_RECTCHROMA_GAP chroma, 8 out-of-range u16 samples; 420 gate green (1 passed, 6 pixel-exact), cargo check 0 warnings

Browse files at this commit

84698b3dc949f4d27d1f80d81e0ac90d7b1633bbAhmet Kaan GümüşParent: 5c27850
crates/ec-av1/src/decode.rsmodified+224 -9
@@ -13534,6 +13534,8 @@ fn decode_block_rect4(
13534 // `TxbSet::Chroma16`). The caller set is closed -- this reader only13534 // `TxbSet::Chroma16`). The caller set is closed -- this reader only
13535 // ever sees 32x8 / 8x32 luma and the sequence header admits ss 0/013535 // ever sees 32x8 / 8x32 luma and the sequence header admits ss 0/0
13536 // and 1/1 only -- so the table is exhaustive.13536 // and 1/1 only -- so the table is exhaustive.
13537+ let chroma422_rect32 =
13538+ (chroma_w, chroma_h) == (4, 32) && ss_x(fctx) == 1 && ss_y(fctx) == 0;
13537 let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) {13539 let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (chroma_w, chroma_h) {
13538 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),13540 (16, 4) => (TxbSet::Chroma8, &SCAN_16X4[..]),
13539 (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),13541 (4, 16) => (TxbSet::Chroma8, &SCAN_4X16[..]),
@@ -13542,11 +13544,30 @@ fn decode_block_rect4(
13542 // lane-av1-422: a 4:2:2 1:4 strip halves only the width, so the13544 // lane-av1-422: a 4:2:2 1:4 strip halves only the width, so the
13543 // landscape leaves (32x8, 16x4 luma) code their chroma as the RECT13545 // landscape leaves (32x8, 16x4 luma) code their chroma as the RECT
13544 // (16,8)/(8,4) -- the same TxbSet/scan pair the (16,8)/(8,4) rows of13546 // (16,8)/(8,4) -- the same TxbSet/scan pair the (16,8)/(8,4) rows of
13545- // [`decode_rect_split`]'s chroma table use. The portrait leaves are13547+ // [`decode_rect_split`]'s chroma table use.
13546- // unreachable: ss_size_lookup marks them BLOCK_INVALID at (1,0), so13548+ // lane-av1-422p: the PORTRAIT leaf occurs too -- the pinned
13547- // a conformant 4:2:2 stream cannot carry that leaf size.13549+ // fixture's frame 2 carries an 8x32 strip at ss(1,0), whose (4, 32)
13550+ // chroma block `ss_size_lookup[BLOCK_8X32][1][0]` marks
13551+ // BLOCK_INVALID (255, enums.h). BLOCK_INVALID does not mean
13552+ // "uncodable": `av1_get_tx_size` reads `max_txsize_rect_lookup[255]`
13553+ // OUT OF BOUNDS there, the byte at +255 in the pinned Release oracle
13554+ // is 0x05 = TX_4X8 (the `decode_token_recon_block` copy at
13555+ // 0xc0d030, objdump-measured), and `av1_get_adjusted_tx_size` has no
13556+ // TX_4X8 case. libaom HAS the transform, so the shape CHUNKS (the
13557+ // `chroma422_rect32` arm below) into FOUR stacked TX_4X8 units per
13558+ // plane (`tx_size_high_unit[TX_4X8] = 2`: blk_row 0, 2, 4, 6)
13559+ // instead of refusing; no coefficient-table row is added, because
13560+ // BLOCK_4X32 is not a table libaom has. 4:2:0 and 4:4:4 never land
13561+ // here (their 8x32 strips read (4, 16) and (8, 32)), so the row is
13562+ // 4:2:2-only.
13548 (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8[..]),13563 (16, 8) => (TxbSet::ChromaRect16x8, &SCAN_16X8[..]),
13549 (8, 4) => (TxbSet::ChromaRect8x4, &SCAN_8X4[..]),13564 (8, 4) => (TxbSet::ChromaRect8x4, &SCAN_8X4[..]),
13565+ // lane-av1-422p: the units' own set/scan -- the whole-rect read
13566+ // below never sees this row, the `chroma422_rect32` arm chunks
13567+ // first. Anything else is still a named-lane gap.
13568+ (4, 32) if ss_x(fctx) == 1 && ss_y(fctx) == 0 => {
13569+ (TxbSet::ChromaRect8x4, &SCAN_4X8[..])
13570+ }
13550 _ => unreachable!(13571 _ => unreachable!(
13551 "decode_block_rect4 chroma shape set is closed: {chroma_w}x{chroma_h}"13572 "decode_block_rect4 chroma shape set is closed: {chroma_w}x{chroma_h}"
13552 ),13573 ),
@@ -13558,6 +13579,146 @@ fn decode_block_rect4(
13558 vec![0i32; chroma_w * chroma_h],13579 vec![0i32; chroma_w * chroma_h],
13559 vec![0i32; chroma_w * chroma_h],13580 vec![0i32; chroma_w * chroma_h],
13560 )13581 )
13582+ } else if chroma422_rect32 {
13583+ // lane-av1-422p: the (4, 32) plane as FOUR TX_4X8 units per plane,
13584+ // plane-major (every U unit, then every V) -- the walk the pinned
13585+ // oracle's `decode_token_recon_block` makes for the BLOCK_INVALID
13586+ // plane block: TX_4X8, so stepr = `tx_size_high_unit[TX_4X8]` = 2
13587+ // 4-px rows and stepc = 1, unit rows at chroma y 0, 8, 16, 24.
13588+ // Luma is the same single TX_8X32 rect the general arm reads.
13589+ let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
13590+ let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x8, mode);
13591+ let (luma_levels, luma_tx_type) = read_coeffs_rect(
13592+ dec,
13593+ &mut luma_coding,
13594+ luma_scan,
13595+ bw,
13596+ bh,
13597+ 0,
13598+ dc_sign_ctx(around[0].2),
13599+ TxType::DctDct,
13600+ )?;
13601+ hit!(RECT4_COEFF_HITS);
13602+ let luma_residual = dequant_and_inverse_typed_wh(
13603+ &luma_levels,
13604+ bw,
13605+ bh,
13606+ crate::decode::bit_depth(fctx),
13607+ block_q_idx(fctx),
13608+ plane_q_delta(0, fctx).0,
13609+ plane_q_delta(0, fctx).1,
13610+ luma_tx_type,
13611+ block_iqmatrix(fctx, 0, bw, bh, luma_tx_type),
13612+ );
13613+ if let Some(b) = &palette_y_buf {
13614+ set_palette_pred(b.clone(), fctx);
13615+ }
13616+ push_intra_rect(0,
13617+ px,
13618+ py,
13619+ bw,
13620+ bh,
13621+ mode,
13622+ angle_delta_y,
13623+ reach,
13624+ &luma_residual,
13625+ None,
13626+ filter_intra,
13627+ smooth_neighbor, fctx,
13628+ );
13629+ // CfL parameters are computed ONCE per block over the strip's luma
13630+ // (`are_parameters_computed`) and shared by all four units, as in
13631+ // every other chunk arm.
13632+ let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
13633+ let mut unit_grids: Vec<((usize, usize), usize, Grid)> = Vec::new();
13634+ for (plane, buf) in [(1usize, &mut *u), (2usize, &mut *v)] {
13635+ for unit_row in 0..4usize {
13636+ let unit_mi = (mi_r + unit_row * 2, mi_c);
13637+ let unit_reach = tu_reach_rect(
13638+ bw, bh, 0, unit_row * 8, 8, 8, reach,
13639+ px, py, y.width, y.height, fctx,
13640+ );
13641+ if let Some((ub, vb)) = &palette_uv_bufs {
13642+ let pbuf = if plane == 1 { ub } else { vb };
13643+ set_palette_pred(
13644+ palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8),
13645+ fctx,
13646+ );
13647+ }
13648+ // Each unit is read and recorded IMMEDIATELY: unit row 0's
13649+ // `txb_skip_ctx` still sees the real above/left neighbour
13650+ // states, a lower unit sees this block's own upper unit's
13651+ // (libaom's per-unit `set_entropy_context`), and the lower
13652+ // unit predicts off the upper one's reconstructed samples.
13653+ let chroma_around = neighbours.around_mi_422_chroma(unit_mi, 8, 8);
13654+ let unit_grid = read_rect_chroma_unit(
13655+ dec,
13656+ cdfs,
13657+ TxbSet::ChromaRect8x4,
13658+ &SCAN_4X8,
13659+ 4,
13660+ 8,
13661+ plane,
13662+ chroma_around[plane],
13663+ uv_predict_mode,
13664+ angle_delta_uv,
13665+ unit_reach,
13666+ buf,
13667+ cpx,
13668+ cpy + unit_row * 8,
13669+ base_q_idx,
13670+ // `get_txb_ctx_general`'s chroma branch
13671+ // (txb_common.h): plane_bsize is BLOCK_INVALID (255)
13672+ // here, `num_pels_log2_lookup[255]` = 255 (the +255
13673+ // byte of the decodetxb copy at 0xc0de70,
13674+ // objdump-measured) exceeds `BLOCK_4X8`'s 5, so the
13675+ // ctx_offset is 10 -- the port's offset-7-first
13676+ // `txb_skip_chroma_8` stores the offset-10 rows at
13677+ // rows 3..6, hence +3.
13678+ Some(3),
13679+ alpha
13680+ .zip(ac)
13681+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
13682+ smooth_neighbor_uv, fctx,
13683+ )?;
13684+ neighbours.record_mi_chroma(unit_mi, 8, 8, plane, &unit_grid);
13685+ unit_grids.push((unit_mi, plane, unit_grid));
13686+ }
13687+ }
13688+ // The whole-block stamp rewrites the chroma cells ONE state wide,
13689+ // which would erase the unit boundary the next block reads (class
13690+ // `override-slot-on-one-arm`), so it carries zero chroma grids and
13691+ // the per-unit writes replay after it. Its luma cells and side
13692+ // spans are this arm's own bookkeeping.
13693+ let zero_chroma = vec![0i32; chroma_w * chroma_h];
13694+ neighbours.record_mi_rect(
13695+ (mi_r, mi_c),
13696+ bw,
13697+ bh,
13698+ &[&luma_levels[..], &zero_chroma[..], &zero_chroma[..]],
13699+ );
13700+ for (unit_mi, plane, grid) in &unit_grids {
13701+ neighbours.record_mi_chroma(*unit_mi, 8, 8, *plane, grid);
13702+ }
13703+ neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
13704+ neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
13705+ record_strip_palette(
13706+ neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size,
13707+ pal_uv_colors,
13708+ );
13709+ if bw > bh {
13710+ hit!(RECT4_32_HORZ_HITS);
13711+ } else {
13712+ hit!(RECT4_32_VERT_HITS);
13713+ }
13714+ // lane-frame36 r2 (same shape as `decode_block_rect64`'s split arm,
13715+ // swept this round): `set_txfm_ctxs` runs for EVERY block of an inter
13716+ // frame, so this 1:4 strip -- which is also the INTER frame's reader
13717+ // for 32x8/8x32 ([`decode_intra_rect4_in_inter`]) -- publishes its
13718+ // transform size in both TXFM_CONTEXT bands. Without it the next block
13719+ // reads the row's stale value.
13720+ txfm_partition_update_rect(neighbours, (mi_r, mi_c), (bw, bh), (bw, bh));
13721+ return Ok((mode, uv_predict_mode));
13561 } else {13722 } else {
13562 let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);13723 let around = neighbours.around_mi_rect((mi_r, mi_c), bw, bh);
13563 let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x8, mode);13724 let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x8, mode);
@@ -13706,6 +13867,44 @@ fn decode_block_rect4(
13706 smooth_neighbor, fctx,13867 smooth_neighbor, fctx,
13707 );13868 );
13708 let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));13869 let ac = alpha.map(|_| cfl_src_rect(px, py, bw, bh));
13870+ if chroma422_rect32 {
13871+ // lane-av1-422p: `predict_and_reconstruct_intra_block` (decodeframe.c
13872+ // ~1000) predicts EVERY unit regardless of `skip_txfm`, so the skip
13873+ // arm walks the same four TX_4X8 units per plane -- the lower unit
13874+ // predicts off the upper one's predicted samples. No coefficients
13875+ // are coded; the tail's whole-block zero stamp below is the state
13876+ // libaom's `set_entropy_context` leaves.
13877+ for (plane, _buf) in [(1usize, &mut *u), (2usize, &mut *v)] {
13878+ for unit_row in 0..4usize {
13879+ let unit_reach = tu_reach_rect(
13880+ bw, bh, 0, unit_row * 8, 8, 8, reach,
13881+ px, py, y.width, y.height, fctx,
13882+ );
13883+ if let Some((ub, vb)) = &palette_uv_bufs {
13884+ let pbuf = if plane == 1 { ub } else { vb };
13885+ set_palette_pred(
13886+ palette_window(pbuf, chroma_w, 0, unit_row * 8, 4, 8),
13887+ fctx,
13888+ );
13889+ }
13890+ push_intra_rect(plane,
13891+ cpx,
13892+ cpy + unit_row * 8,
13893+ 4,
13894+ 8,
13895+ uv_predict_mode,
13896+ angle_delta_uv,
13897+ unit_reach,
13898+ &ZERO_RESIDUAL[..4 * 8],
13899+ alpha
13900+ .zip(ac)
13901+ .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
13902+ None,
13903+ smooth_neighbor_uv, fctx,
13904+ );
13905+ }
13906+ }
13907+ } else {
13709 if let Some((ub, _)) = &palette_uv_bufs {13908 if let Some((ub, _)) = &palette_uv_bufs {
13710 set_palette_pred(ub.clone(), fctx);13909 set_palette_pred(ub.clone(), fctx);
13711 }13910 }
@@ -13738,6 +13937,7 @@ fn decode_block_rect4(
13738 None,13937 None,
13739 smooth_neighbor_uv, fctx,13938 smooth_neighbor_uv, fctx,
13740 );13939 );
13940+ }
13741 neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);13941 neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[&luma_levels[..], &u_levels[..], &v_levels[..]]);
13742 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);13942 neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip);
13743 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);13943 neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0, fctx);
@@ -14990,6 +15190,11 @@ fn decode_rect4_16_strip(
14990 cpx,15190 cpx,
14991 cpy + unit_row * 8,15191 cpy + unit_row * 8,
14992 base_q_idx,15192 base_q_idx,
15193+ // lane-av1-422p: `None` keeps this arm on the
15194+ // offset-7 rows exactly as before; the
15195+ // offset-10 question for this arm is the
15196+ // owning lane's (see lanes/av1422p.report.md).
15197+ None,
14993 alpha15198 alpha
14994 .zip(ac)15199 .zip(ac)
14995 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),15200 .map(|((au, av), ac)| (if plane == 1 { au } else { av }, ac)),
@@ -16899,6 +17104,16 @@ fn read_rect_chroma_unit(
16899 // Signature parity with [`read_plane`]; the dequant reads its q index17104 // Signature parity with [`read_plane`]; the dequant reads its q index
16900 // off `block_q_idx(fctx)` like every other reader here.17105 // off `block_q_idx(fctx)` like every other reader here.
16901 _base_q_idx: u8,17106 _base_q_idx: u8,
17107+ // lane-av1-422p: `get_txb_ctx_general`'s chroma branch
17108+ // (txb_common.h) reads `txb_skip_ctx = above + left + ctx_offset`,
17109+ // where `ctx_offset` is 10 when the plane block is bigger than the
17110+ // transform and 7 otherwise. The port stores the offset-7 rows at
17111+ // `txb_skip_chroma_8` rows 0..3 and the offset-10 rows at rows 3..6
17112+ // (lane-av1-422b), so a unit SMALLER than its plane block passes
17113+ // `Some(3)` to reach the offset-10 rows. Every unit that IS the whole
17114+ // plane block stays `None` -- 4:2:2 plane blocks never shrink to a
17115+ // rect unit except in the chunk arms.
17116+ chroma_skip_offset: Option<usize>,
16902 cfl: Option<(i32, CflSrc)>,17117 cfl: Option<(i32, CflSrc)>,
16903 smooth_neighbor_uv: bool, fctx: &crate::decode::FrameCtx,17118 smooth_neighbor_uv: bool, fctx: &crate::decode::FrameCtx,
16904 ) -> Result<Grid> {17119 ) -> Result<Grid> {
@@ -16916,7 +17131,7 @@ fn read_rect_chroma_unit(
16916 let mut coding = cdfs.txb(set, uv_predict_mode);17131 let mut coding = cdfs.txb(set, uv_predict_mode);
16917 let (levels, tx_type) = read_coeffs_rect(17132 let (levels, tx_type) = read_coeffs_rect(
16918 dec, &mut coding, scan, w, h,17133 dec, &mut coding, scan, w, h,
16919- usize::from(around.0) + usize::from(around.1),17134+ usize::from(around.0) + usize::from(around.1) + chroma_skip_offset.unwrap_or(0),
16920 dc_sign_ctx(around.2), default_tx,17135 dc_sign_ctx(around.2), default_tx,
16921 )?;17136 )?;
16922 let residual = dequant_and_inverse_typed_wh(17137 let residual = dequant_and_inverse_typed_wh(
@@ -17528,7 +17743,7 @@ fn decode_block(
17528 let u_grid = read_rect_chroma_unit(17743 let u_grid = read_rect_chroma_unit(
17529 dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, 1,17744 dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, 1,
17530 chroma_around[1], uv_predict_mode, angle_delta_uv, reach, u,17745 chroma_around[1], uv_predict_mode, angle_delta_uv, reach, u,
17531- cpx, cpy, base_q_idx,17746+ cpx, cpy, base_q_idx, None,
17532 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),17747 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
17533 smooth_neighbor_uv, fctx,17748 smooth_neighbor_uv, fctx,
17534 )?;17749 )?;
@@ -17538,7 +17753,7 @@ fn decode_block(
17538 let v_grid = read_rect_chroma_unit(17753 let v_grid = read_rect_chroma_unit(
17539 dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, 2,17754 dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, 2,
17540 chroma_around[2], uv_predict_mode, angle_delta_uv, reach, v,17755 chroma_around[2], uv_predict_mode, angle_delta_uv, reach, v,
17541- cpx, cpy, base_q_idx,17756+ cpx, cpy, base_q_idx, None,
17542 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),17757 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
17543 smooth_neighbor_uv, fctx,17758 smooth_neighbor_uv, fctx,
17544 )?;17759 )?;
@@ -17916,7 +18131,7 @@ fn decode_block(
17916 read_rect_chroma_unit(18131 read_rect_chroma_unit(
17917 dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, plane_pass,18132 dec, cdfs, chroma_set, scans.1, chroma_tx, chroma_tx_h, plane_pass,
17918 cu_around[plane_pass], uv_predict_mode, angle_delta_uv, cu_reach, buf,18133 cu_around[plane_pass], uv_predict_mode, angle_delta_uv, cu_reach, buf,
17919- cu_x, cu_y, base_q_idx,18134+ cu_x, cu_y, base_q_idx, None,
17920 alpha.zip(ac).map(|((au, av), ac)| {18135 alpha.zip(ac).map(|((au, av), ac)| {
17921 (if plane_pass == 1 { au } else { av }, ac)18136 (if plane_pass == 1 { au } else { av }, ac)
17922 }),18137 }),
@@ -35301,7 +35516,7 @@ fn decode_inter_block(
35301 read_rect_chroma_unit(35516 read_rect_chroma_unit(
35302 dec, cdfs, rect_set, rect_scan, chroma_w, chroma_h, 1,35517 dec, cdfs, rect_set, rect_scan, chroma_w, chroma_h, 1,
35303 chroma_around[1], uv_predict_mode, angle_delta_uv, reach, u,35518 chroma_around[1], uv_predict_mode, angle_delta_uv, reach, u,
35304- cpx, cpy, base_q_idx,35519+ cpx, cpy, base_q_idx, None,
35305 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),35520 alpha.zip(ac).map(|((au, _), ac)| (au, ac)),
35306 smooth_neighbor_uv, fctx,35521 smooth_neighbor_uv, fctx,
35307 )?35522 )?
@@ -35343,7 +35558,7 @@ fn decode_inter_block(
35343 read_rect_chroma_unit(35558 read_rect_chroma_unit(
35344 dec, cdfs, rect_set, rect_scan, chroma_w, chroma_h, 2,35559 dec, cdfs, rect_set, rect_scan, chroma_w, chroma_h, 2,
35345 chroma_around[2], uv_predict_mode, angle_delta_uv, reach, v,35560 chroma_around[2], uv_predict_mode, angle_delta_uv, reach, v,
35346- cpx, cpy, base_q_idx,35561+ cpx, cpy, base_q_idx, None,
35347 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),35562 alpha.zip(ac).map(|((_, av), ac)| (av, ac)),
35348 smooth_neighbor_uv, fctx,35563 smooth_neighbor_uv, fctx,
35349 )?35564 )?
lanes/av1422p.report.mdadded+119 -0
@@ -0,0 +1,119 @@
1+# lane-av1-422p — the 4x32 chroma stop is NAMED and CHUNKED: libaom HAS the
2+# transform (the BLOCK_INVALID plane block reads max_txsize_rect_lookup[255]
3+# = TX_4X8 out of bounds), so `decode_block_rect4` walks FOUR TX_4X8 units per
4+# plane on the offset-10 skip rows; the whole 16-frame stream now decodes, the
5+# pixels are NOT exact, so the header refusal STAYS byte-identical
6+
7+## Outcome
8+
9+1. Step 1 of the charter (print before adding): with the header refusal
10+ temporarily bypassed (probe-only, restored byte-identical), the stop
11+ printed `EC_422P_STOP decode_block_rect4 chroma shape (4,32) luma=(8,32)
12+ ss=(1,0)` — the portrait 1:4 leaf the av1422o report named as its
13+ frontier, on the pinned fixture (sha256 `d3fa4beeb1309033e4a03f5ae5c4
14+ 31c8fa8386ba1ada088684710423c7938129`).
15+2. Measured, not guessed: `av1_get_tx_size` reads
16+ `max_txsize_rect_lookup[plane_bsize]` with plane_bsize =
17+ `ss_size_lookup[BLOCK_8X32][1][0]` = BLOCK_INVALID (255, `enums.h`). The
18+ byte at +255 of the copy `decode_token_recon_block` actually reads
19+ (objdump: every `movzbl 0xc0d030(%r*)` in that function) is `0x05` =
20+ TX_4X8; `av1_get_adjusted_tx_size` has no TX_4X8 case. The decodetxb copy
21+ of `num_pels_log2_lookup` (the `cmpb` against `0xc0db70(%r15)`, symbol at
22+ 0xc0de70) reads `0xff` at +255, so `get_txb_ctx_general`'s chroma branch
23+ (`txb_common.h`: `num_pels_log2_lookup[255] > num_pels_log2_lookup
24+ [BLOCK_4X8]`) takes the offset-10 arm. Both bytes re-measured on the
25+ pinned Release oracle this session.
26+3. The chunk (libaom `decode_token_recon_block` semantics: stepr =
27+ `tx_size_high_unit[TX_4X8]` = 2 4-px rows, stepc = 1, unit_width/height
28+ ROUND_POWER_OF_TWO down to (1, 4)): FOUR stacked TX_4X8 units per plane
29+ (chroma rows 0, 8, 16, 24), plane-major, riding the existing
30+ `(4, 8) => ChromaRect8x4` entropy class via [`read_rect_chroma_unit`] —
31+ no coefficient-table row added (BLOCK_4X32 is not a table libaom has).
32+ Each unit is read and recorded immediately: unit row 0's txb_skip_ctx
33+ sees the real neighbour states, lower units see the block's own upper
34+ unit's, and each unit predicts off the upper one's samples. The skip arm
35+ walks the same units (`predict_and_reconstruct_intra_block` predicts
36+ every unit regardless of `skip_txfm`). CfL parameters are computed once
37+ per block over the strip's 8x32 luma and shared by all units. Luma is
38+ the same single TX_8X32 rect the general arm reads.
39+4. The chunk units' `txb_skip_ctx` is `above + left + 10`
40+ (`get_txb_ctx_general`): the port's offset-7-first `txb_skip_chroma_8`
41+ stores the offset-10 rows at rows 3..6 (lane-av1-422b), so
42+ [`read_rect_chroma_unit`] gained a `chroma_skip_offset: Option<usize>`
43+ parameter (mirroring [`read_plane`]'s `chroma_ctx_offset`) and this arm
44+ passes `Some(3)`. Every existing caller passes `None` =
45+ behavior-identical (their rect unit IS the whole plane block, offset-7
46+ rows); the whole-rect read never sees the new `(4, 32)` match row.
47+5. 4:2:0 and 4:4:4 are on their existing paths: the chunk is gated on
48+ `(chroma_w, chroma_h) == (4, 32)` at ss(1,0), which only an 8x32 luma
49+ strip at 4:2:2 produces (4:2:0 reads (4, 16), 4:4:4 reads (8, 32)); the
50+ stale "portrait leaves are unreachable / a conformant stream cannot
51+ carry that leaf size" comment is disproven by the fixture and replaced.
52+
53+## Counter (probe, bypass env; temp print removed)
54+
55+- `rect4_32: vert=1 coded=1` — exactly one 8x32 rect4 strip in the stream,
56+ the block that used to stop.
57+- Eight unit reads at mi=(24,52), plane-major (U rows 0..3, V rows 0..3),
58+ the temp trace printing skip_ctx 3/4/5 — i.e. the offset-10 rows
59+ (base 0..2 + 3) — and varying unit-to-unit as the block's own upper
60+ units enter the context.
61+- `chroma422_rect: 172` total rect 422 chroma units across the 16 decoded
62+ frames (CHROMA422_RECT_HITS, ticked inside [`read_rect_chroma_unit`]).
63+- Pre-fix walk: panics at the stop before any report; post-fix probe prints
64+ `OK: 16 frames decoded, 256x144`.
65+
66+## Pixels — delete condition UNMET, refusal STAYS
67+
68+- Frame 0 (keyframe): luma byte-EXACT vs `aomdec --rawvideo`; U/V carry
69+ 4491/4888 sample diffs from offset ~23 — the PRE-EXISTING keyframe chroma
70+ gap in [`decode_rect_split`] (the live `EC_RECTCHROMA_GAP luma=16x8
71+ tx=8x8 chroma=8x8` diagnostics, ×21 plus one 64x32; present at e24dc84b
72+ per the av1422o report, not this lane's function).
73+- Frames 1..15 diverge widely (luma included), consistent with an entropy
74+ divergence somewhere in the inter walk — this is the first time the
75+ stream decodes past the old stop, so there is no earlier full-stream
76+ baseline to diff against.
77+- Frontier (NOT fixed — larger than this one shape; named per charter):
78+ 1. **`decode_rect4_16_strip`'s `chroma422_pair16` chunk passes no chroma
79+ skip offset** — it reads the offset-7 rows (txb_skip rows 0..3) where
80+ the same measured rule (plane_bsize BLOCK_INVALID for the pair's
81+ BLOCK_4X16 too) demands offset 10, i.e. `Some(3)`. That function is
82+ the protected av1422o lane fix, so this lane only plumbed `None`
83+ through the new parameter (behavior-identical) and names the defect
84+ for its owning lane. It runs in frame 2 before the 4x32, making it
85+ the prime suspect for the inter-frame divergence.
86+ 2. [`decode_rect_split`]'s own-chroma gap (the EC_RECTCHROMA_GAP class
87+ above).
88+ 3. Our dump carries out-of-range u16 samples on frames 1 (2 samples) and
89+ 14 (6 samples) — an unclipped-output class, unattributed.
90+- The header refusal stands untouched: `git diff` shows ONLY
91+ `crates/ec-av1/src/decode.rs` (+255/−40); `stream.rs` is byte-identical
92+ and the probe without the bypass prints `REFUSED: unsupported: AV1
93+ decode_stream (a chroma format of 4:2:2 ...)` as before.
94+
95+## Verification
96+
97+- `cargo check -p ec-av1 --all-targets` (target dir
98+ `~/.cache/cargo-target-av1422p`): **0 warnings, 0 errors**.
99+- 420 gate green under `EC_AV1_REQUIRE_AOMENC=1`:
100+ `stream::tests::a_real_aomenc_stream_with_a_skipped_8x8_intra_leaf_
101+ whose_tx_split_decodes_pixel_exact`: 1 passed, 0 failed ("6 pixel-exact
102+ matches, 0 named refusals").
103+- Oracle reference: `$HOME/.cache/aom-oracle/build/aomdec` on the fixture →
104+ 16 frames raw 4:2:2, per-frame per-plane diffed against `dump_yuv`.
105+- Untouched: `decode_rect4_16_strip` (mechanical `None` arg only, no
106+ behavioral edit), `read_inter_rect_chroma` (the four TX_4X8 (4, 32) inter
107+ chunk stays), the 4:2:0 group-tail chroma SKIP arm, `decode_probe.rs`,
108+ the lossless arm (depth != 0 || lossless returns before the chroma
109+ table), the landscape (16,8)/(8,4) arms, and every existing
110+ [`read_rect_chroma_unit`] caller's decode behavior.
111+
112+## State
113+
114+- Commit on lane-av1-422p (no push): the chroma_skip_offset parameter, the
115+ 4x32 chunk arms (skip and non-skip), the corrected portrait-leaf comment,
116+ and this report.
117+- Next stop named for the owning lane: the `chroma422_pair16` offset-10
118+ skip rows in `decode_rect4_16_strip`, then the inter-frame walk's first
119+ divergence against the oracle.