Merge 39f45c31 (422bigblock) — suite green: 422bigblock 624/0
Browse files at this commit5 changed files +410 -59
- 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 +167 -59
- crates/ec-av1/src/stream.rs +56 -0
- lanes/av1422bigblock.report.md +187 -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+167 -59
| @@ -18802,7 +18802,9 @@ fn decode_block_128rect( | |||
| 18802 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); | 18802 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(mi_c)); |
| 18803 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); | 18803 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(mi_r)); |
| 18804 | // Non-lossless: per mu chunk, `(64 >> ss) / chroma_tx` chroma units per | 18804 | // Non-lossless: per mu chunk, `(64 >> ss) / chroma_tx` chroma units per |
| 18805 | - // axis (one 32x32 at 4:2:0, four 32x32 at 4:4:4 — lane-av1-444sb). | 18805 | + // axis -- one 32x32 at 4:2:0, two stacked on the tall axis at 4:2:2 |
| 18806 | + // (lane-av1-422bigblock: the chunk's chroma plane block is 32x64 there), | ||
| 18807 | + // four at 4:4:4 (lane-av1-444sb's own finding on this same walk). | ||
| 18806 | debug_assert!( | 18808 | debug_assert!( |
| 18807 | lossless_frame | 18809 | lossless_frame |
| 18808 | || (chroma_w / chroma_tx, chroma_h / chroma_tx) | 18810 | || (chroma_w / chroma_tx, chroma_h / chroma_tx) |
| @@ -18819,6 +18821,7 @@ fn decode_block_128rect( | |||
| 18819 | // The chroma context arrays are indexed in LUMA mi; every chroma unit of | 18821 | // The chroma context arrays are indexed in LUMA mi; every chroma unit of |
| 18820 | // every chunk shares this luma span (2 chroma pixels per luma unit). | 18822 | // every chunk shares this luma span (2 chroma pixels per luma unit). |
| 18821 | let luma_span = chroma_tx << ss_x(fctx); | 18823 | let luma_span = chroma_tx << ss_x(fctx); |
| 18824 | + let luma_span_h = chroma_tx << ss_y(fctx); | ||
| 18822 | for ch_row in 0..nch_y { | 18825 | for ch_row in 0..nch_y { |
| 18823 | for ch_col in 0..nch_x { | 18826 | for ch_col in 0..nch_x { |
| 18824 | for tu_row in ch_row * tpc..(ch_row + 1) * tpc { | 18827 | for tu_row in ch_row * tpc..(ch_row + 1) * tpc { |
| @@ -18889,12 +18892,14 @@ fn decode_block_128rect( | |||
| 18889 | } | 18892 | } |
| 18890 | } | 18893 | } |
| 18891 | // Transform units per axis inside this mu chunk's chroma span: | 18894 | // Transform units per axis inside this mu chunk's chroma span: |
| 18892 | - // a 64x64 luma chunk covers `64 >> ss` chroma pixels per axis, so | 18895 | + // a 64x64 luma chunk covers `64 >> ss` chroma pixels per axis, |
| 18893 | - // it holds `(64 >> ss) / chroma_tx` units — one 32x32 at 4:2:0, | 18896 | + // so it holds `(64 >> ss) / chroma_tx` units -- one 32x32 at |
| 18894 | - // four at 4:4:4 (lane-av1-444sb: the hardcoded 4:2:0 span read | 18897 | + // 4:2:0, four at 4:4:4 (lane-av1-444sb), TWO STACKED TX_32X32 on |
| 18895 | - // one unit per chunk there, left six of a 128x64 block's eight | 18898 | + // the tall axis at 4:2:2 (lane-av1-422bigblock: the chunk's |
| 18896 | - // 32x32 units unread and desynced the tile from that block on). | 18899 | + // chroma plane block is 32x64 there, so the two axes' counts |
| 18900 | + // part ways -- 1 x 2); 8x8 TX_4X4 units when lossless. | ||
| 18897 | let cn = ((64 >> ss_x(fctx)) / chroma_tx).max(1); | 18901 | let cn = ((64 >> ss_x(fctx)) / chroma_tx).max(1); |
| 18902 | + let cn_h = ((64 >> ss_y(fctx)) / chroma_tx).max(1); | ||
| 18898 | // libaom's per-chunk `unit_width/height` (plane-mi units of the | 18903 | // libaom's per-chunk `unit_width/height` (plane-mi units of the |
| 18899 | // luma mi grid): `min(mu_blocks + col, max_blocks) >> ss`. | 18904 | // luma mi grid): `min(mu_blocks + col, max_blocks) >> ss`. |
| 18900 | let unit_w = ((ch_col + 1) * 16).min(max_w_mi) >> ss_x(fctx); | 18905 | let unit_w = ((ch_col + 1) * 16).min(max_w_mi) >> ss_x(fctx); |
| @@ -18906,8 +18911,10 @@ fn decode_block_128rect( | |||
| 18906 | // symbol order the interleaved pair used to read; a lossless | 18911 | // symbol order the interleaved pair used to read; a lossless |
| 18907 | // frame's 4x4 chroma units are where it becomes observable. | 18912 | // frame's 4x4 chroma units are where it becomes observable. |
| 18908 | for plane_pass in 1..=2usize { | 18913 | for plane_pass in 1..=2usize { |
| 18909 | - for ci_row in 0..cn { | 18914 | + for ci_row in 0..cn_h { |
| 18910 | for ci_col in 0..cn { | 18915 | for ci_col in 0..cn { |
| 18916 | + // The clamp strides are the CHUNK's chroma mi extent | ||
| 18917 | + // per axis: 16 luma mi >> the axis's own ss. | ||
| 18911 | if ch_col * (16 >> ss_x(fctx)) + ci_col * stepc >= unit_w | 18918 | if ch_col * (16 >> ss_x(fctx)) + ci_col * stepc >= unit_w |
| 18912 | || ch_row * (16 >> ss_y(fctx)) + ci_row * stepc >= unit_h | 18919 | || ch_row * (16 >> ss_y(fctx)) + ci_row * stepc >= unit_h |
| 18913 | { | 18920 | { |
| @@ -18919,12 +18926,13 @@ fn decode_block_128rect( | |||
| 18919 | mi_r + ch_row * 16 + ci_row * ((chroma_tx << ss_y(fctx)) / 4), | 18926 | mi_r + ch_row * 16 + ci_row * ((chroma_tx << ss_y(fctx)) / 4), |
| 18920 | mi_c + ch_col * 16 + ci_col * ((chroma_tx << ss_x(fctx)) / 4), | 18927 | mi_c + ch_col * 16 + ci_col * ((chroma_tx << ss_x(fctx)) / 4), |
| 18921 | ); | 18928 | ); |
| 18922 | - let cu_r = tu_reach( | 18929 | + let cu_r = tu_reach_rect( |
| 18923 | bw, | 18930 | bw, |
| 18924 | bh, | 18931 | bh, |
| 18925 | ch_col * 64 + ci_col * luma_span, | 18932 | ch_col * 64 + ci_col * luma_span, |
| 18926 | - ch_row * 64 + ci_row * luma_span, | 18933 | + ch_row * 64 + ci_row * luma_span_h, |
| 18927 | luma_span, | 18934 | luma_span, |
| 18935 | + luma_span_h, | ||
| 18928 | reach, | 18936 | reach, |
| 18929 | px, | 18937 | px, |
| 18930 | py, | 18938 | py, |
| @@ -18938,7 +18946,8 @@ fn decode_block_128rect( | |||
| 18938 | ); | 18946 | ); |
| 18939 | continue; | 18947 | continue; |
| 18940 | } | 18948 | } |
| 18941 | - let cu_around = neighbours.around_mi(cu_mi, luma_span); | 18949 | + let cu_around = |
| 18950 | + neighbours.around_mi_rect(cu_mi, luma_span, luma_span_h); | ||
| 18942 | let buf: &mut PlaneBuf<'static> = | 18951 | let buf: &mut PlaneBuf<'static> = |
| 18943 | if plane_pass == 1 { &mut *u } else { &mut *v }; | 18952 | if plane_pass == 1 { &mut *u } else { &mut *v }; |
| 18944 | let grid = read_plane( | 18953 | let grid = read_plane( |
| @@ -18952,7 +18961,13 @@ fn decode_block_128rect( | |||
| 18952 | // reads this one's coefficient context; replayed after | 18961 | // reads this one's coefficient context; replayed after |
| 18953 | // `record_split_luma_rect` below, which would otherwise | 18962 | // `record_split_luma_rect` below, which would otherwise |
| 18954 | // clobber them whole-block. | 18963 | // clobber them whole-block. |
| 18955 | - neighbours.record_mi_chroma(cu_mi, luma_span, luma_span, plane_pass, &grid); | 18964 | + neighbours.record_mi_chroma( |
| 18965 | + cu_mi, | ||
| 18966 | + luma_span, | ||
| 18967 | + luma_span_h, | ||
| 18968 | + plane_pass, | ||
| 18969 | + &grid, | ||
| 18970 | + ); | ||
| 18956 | units.push((plane_pass, cu_mi, grid)); | 18971 | units.push((plane_pass, cu_mi, grid)); |
| 18957 | } | 18972 | } |
| 18958 | } | 18973 | } |
| @@ -30977,15 +30992,42 @@ impl<'p> RefPix<'p> { | |||
| 30977 | ( | 30992 | ( |
| 30978 | whole_plane(&g.y, g.width, g.height), | 30993 | whole_plane(&g.y, g.width, g.height), |
| 30979 | { | 30994 | { |
| 30980 | - // Reference pictures carry no subsampling field. A | 30995 | + // Reference pictures carry no subsampling field -- the |
| 30981 | - // 4:4:4 chroma plane is luma-sized; 4:2:0 is the quarter. | 30996 | + // plane's own shape is inferred from its length: |
| 30982 | - let full = g.u.len() == g.width * g.height; | 30997 | + // luma-sized is 4:4:4, `halfw x height` is 4:2:2 |
| 30983 | - let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) }; | 30998 | + // (ss_x 1, ss_y 0 -- the chroma plane is HALF-width |
| 30999 | + // and FULL-height), `halfw x halfh` is 4:2:0. The | ||
| 31000 | + // three lengths are pairwise distinct for every | ||
| 31001 | + // w, h >= 1, so the guess is exact. The old | ||
| 31002 | + // two-way guess read every 4:2:2 reference as | ||
| 31003 | + // quarter-height: a 128x128 frame's chroma resolved | ||
| 31004 | + // 64x64, the bottom mu-chunk row's prediction | ||
| 31005 | + // sampled a clamped row-63 edge and the frame's | ||
| 31006 | + // own pixels were right (the crop is ss-aware) -- | ||
| 31007 | + // only INTER prediction off the slot was wrong | ||
| 31008 | + // (lane-av1-422bigblock: the sb128 witness's | ||
| 31009 | + // frame-2 chroma, rows 64..127). | ||
| 31010 | + let halfw = (g.width + 1) / 2; | ||
| 31011 | + let halfh = (g.height + 1) / 2; | ||
| 31012 | + let (cw, ch) = if g.u.len() == g.width * g.height { | ||
| 31013 | + (g.width, g.height) | ||
| 31014 | + } else if g.u.len() == halfw * g.height { | ||
| 31015 | + (halfw, g.height) | ||
| 31016 | + } else { | ||
| 31017 | + (halfw, halfh) | ||
| 31018 | + }; | ||
| 30984 | whole_plane(&g.u, cw, ch) | 31019 | whole_plane(&g.u, cw, ch) |
| 30985 | }, | 31020 | }, |
| 30986 | { | 31021 | { |
| 30987 | - let full = g.v.len() == g.width * g.height; | 31022 | + let halfw = (g.width + 1) / 2; |
| 30988 | - let (cw, ch) = if full { (g.width, g.height) } else { (g.width / 2, g.height / 2) }; | 31023 | + let halfh = (g.height + 1) / 2; |
| 31024 | + let (cw, ch) = if g.v.len() == g.width * g.height { | ||
| 31025 | + (g.width, g.height) | ||
| 31026 | + } else if g.v.len() == halfw * g.height { | ||
| 31027 | + (halfw, g.height) | ||
| 31028 | + } else { | ||
| 31029 | + (halfw, halfh) | ||
| 31030 | + }; | ||
| 30989 | whole_plane(&g.v, cw, ch) | 31031 | whole_plane(&g.v, cw, ch) |
| 30990 | }, | 31032 | }, |
| 30991 | ) | 31033 | ) |
| @@ -33997,18 +34039,35 @@ fn decode_inter_block( | |||
| 33997 | // this arm has always coded. `chroma_side` | 34039 | // this arm has always coded. `chroma_side` |
| 33998 | // already carries the subsampling. | 34040 | // already carries the subsampling. |
| 33999 | let cu_tx = 32usize; | 34041 | let cu_tx = 32usize; |
| 34000 | - let chunk_chroma = chroma_side * 64 / side; | 34042 | + // lane-av1-422bigblock: a 64x64 mu chunk's |
| 34001 | - let units = chunk_chroma / cu_tx; | 34043 | + // chroma plane block is PER-AXIS |
| 34044 | + // (64 >> ss_x) x (64 >> ss_y) -- 32x64 at | ||
| 34045 | + // ss (1,0), i.e. TWO stacked TX_32X32 units | ||
| 34046 | + // per plane (`av1_get_max_uv_txsize` caps the | ||
| 34047 | + // unit at 32 on each axis). The old square-cut | ||
| 34048 | + // model walked `chroma_side`-square chunks: | ||
| 34049 | + // twice the units the oracle codes at 4:2:2, | ||
| 34050 | + // prediction windows indexed at the square | ||
| 34051 | + // `chroma_side` instead of the prediction | ||
| 34052 | + // buffer's own `chroma_stride`, and chunk | ||
| 34053 | + // columns at 64.. of a 64-wide chroma plane. | ||
| 34054 | + let chunk_chroma_w = (64usize) >> ss_x(fctx); | ||
| 34055 | + let chunk_chroma_h = (64usize) >> ss_y(fctx); | ||
| 34056 | + let units_w = chunk_chroma_w / cu_tx; | ||
| 34057 | + let units_h = chunk_chroma_h / cu_tx; | ||
| 34002 | // The unit's own footprint on the LUMA mi | 34058 | // The unit's own footprint on the LUMA mi |
| 34003 | - // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi) | 34059 | + // grid, per axis (32 << ss) px: 64x64 (16x16 |
| 34004 | - // at ss 0/0. `around_mi` reads and | 34060 | + // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4, |
| 34061 | + // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect` | ||
| 34062 | + // reads and | ||
| 34005 | // `record_mi_chroma` stamps span exactly the | 34063 | // `record_mi_chroma` stamps span exactly the |
| 34006 | // unit's own cells -- `get_txb_ctx` reads the | 34064 | // unit's own cells -- `get_txb_ctx` reads the |
| 34007 | // 8 context cells of the TX_32X32 itself, and | 34065 | // 8 context cells of the TX_32X32 itself, and |
| 34008 | // `av1_set_entropy_contexts` memsets the same | 34066 | // `av1_set_entropy_contexts` memsets the same |
| 34009 | // 8, so the unit over never sees this unit's | 34067 | // 8, so the unit over never sees this unit's |
| 34010 | // state and the unit below always does. | 34068 | // state and the unit below always does. |
| 34011 | - let unit_luma = cu_tx * (side / chroma_side); | 34069 | + let unit_luma_w = cu_tx << ss_x(fctx); |
| 34070 | + let unit_luma_h = cu_tx << ss_y(fctx); | ||
| 34012 | let cu_scan = default_scan(cu_tx); | 34071 | let cu_scan = default_scan(cu_tx); |
| 34013 | if lossless(fctx) { | 34072 | if lossless(fctx) { |
| 34014 | // lane-lossless2: TX_4X4 units over this | 34073 | // lane-lossless2: TX_4X4 units over this |
| @@ -34016,8 +34075,8 @@ fn decode_inter_block( | |||
| 34016 | read_inter_chroma_lossless( | 34075 | read_inter_chroma_lossless( |
| 34017 | dec, cdfs, neighbours, u, v, su, sv, | 34076 | dec, cdfs, neighbours, u, v, su, sv, |
| 34018 | at_mi, (cpx, cpy), | 34077 | at_mi, (cpx, cpy), |
| 34019 | - (cc * chunk_chroma, cr * chunk_chroma), | 34078 | + (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 34020 | - (chunk_chroma, chunk_chroma), | 34079 | + (chunk_chroma_w, chunk_chroma_h), |
| 34021 | (write_chroma_w, write_chroma_h), | 34080 | (write_chroma_w, write_chroma_h), |
| 34022 | chroma_side, mode_for_tx, base_q_idx, | 34081 | chroma_side, mode_for_tx, base_q_idx, |
| 34023 | &mut u_units, &mut v_units, fctx, | 34082 | &mut u_units, &mut v_units, fctx, |
| @@ -34034,24 +34093,28 @@ fn decode_inter_block( | |||
| 34034 | // Plane-major per chunk (libaom's plane | 34093 | // Plane-major per chunk (libaom's plane |
| 34035 | // loop is outermost inside the mu walk); | 34094 | // loop is outermost inside the mu walk); |
| 34036 | // within a plane the units walk raster. | 34095 | // within a plane the units walk raster. |
| 34037 | - for ur in 0..units { | 34096 | + for ur in 0..units_h { |
| 34038 | - for uc in 0..units { | 34097 | + for uc in 0..units_w { |
| 34039 | let unit_mi = ( | 34098 | let unit_mi = ( |
| 34040 | at_mi.0 + cr * 16 | 34099 | at_mi.0 + cr * 16 |
| 34041 | - + ur * (unit_luma / MI), | 34100 | + + ur * (unit_luma_h / MI), |
| 34042 | at_mi.1 + cc * 16 | 34101 | at_mi.1 + cc * 16 |
| 34043 | - + uc * (unit_luma / MI), | 34102 | + + uc * (unit_luma_w / MI), |
| 34044 | ); | 34103 | ); |
| 34045 | // Per unit, AFTER the earlier | 34104 | // Per unit, AFTER the earlier |
| 34046 | // units' stamps: this unit's | 34105 | // units' stamps: this unit's |
| 34047 | // coefficient context must see | 34106 | // coefficient context must see |
| 34048 | // them. | 34107 | // them. |
| 34049 | let cu_around = neighbours | 34108 | let cu_around = neighbours |
| 34050 | - .around_mi(unit_mi, unit_luma); | 34109 | + .around_mi_rect( |
| 34110 | + unit_mi, | ||
| 34111 | + unit_luma_w, | ||
| 34112 | + unit_luma_h, | ||
| 34113 | + ); | ||
| 34051 | let (cu_x, cu_y) = ( | 34114 | let (cu_x, cu_y) = ( |
| 34052 | - cpx + cc * chunk_chroma | 34115 | + cpx + cc * chunk_chroma_w |
| 34053 | + uc * cu_tx, | 34116 | + uc * cu_tx, |
| 34054 | - cpy + cr * chunk_chroma | 34117 | + cpy + cr * chunk_chroma_h |
| 34055 | + ur * cu_tx, | 34118 | + ur * cu_tx, |
| 34056 | ); | 34119 | ); |
| 34057 | // `av1_get_tx_type` (blockd.h: | 34120 | // `av1_get_tx_type` (blockd.h: |
| @@ -34082,11 +34145,16 @@ fn decode_inter_block( | |||
| 34082 | }, | 34145 | }, |
| 34083 | ) | 34146 | ) |
| 34084 | .map(|(_, _, _, _, t)| t); | 34147 | .map(|(_, _, _, _, t)| t); |
| 34148 | + // The prediction buffer is | ||
| 34149 | + // `chroma_stride`-strided (the | ||
| 34150 | + // plane block's own width at | ||
| 34151 | + // 4:2:2), not the square | ||
| 34152 | + // `chroma_side`. | ||
| 34085 | let cu_pred = src.offset( | 34153 | let cu_pred = src.offset( |
| 34086 | - (cr * chunk_chroma | 34154 | + (cr * chunk_chroma_h |
| 34087 | + ur * cu_tx) | 34155 | + ur * cu_tx) |
| 34088 | - * chroma_side | 34156 | + * chroma_stride |
| 34089 | - + cc * chunk_chroma | 34157 | + + cc * chunk_chroma_w |
| 34090 | + uc * cu_tx, | 34158 | + uc * cu_tx, |
| 34091 | ); | 34159 | ); |
| 34092 | let cu_grid = read_inter_plane( | 34160 | let cu_grid = read_inter_plane( |
| @@ -34116,8 +34184,8 @@ fn decode_inter_block( | |||
| 34116 | // context. | 34184 | // context. |
| 34117 | neighbours.record_mi_chroma( | 34185 | neighbours.record_mi_chroma( |
| 34118 | unit_mi, | 34186 | unit_mi, |
| 34119 | - unit_luma, | 34187 | + unit_luma_w, |
| 34120 | - unit_luma, | 34188 | + unit_luma_h, |
| 34121 | plane_idx, | 34189 | plane_idx, |
| 34122 | &cu_grid, | 34190 | &cu_grid, |
| 34123 | ); | 34191 | ); |
| @@ -34132,11 +34200,18 @@ fn decode_inter_block( | |||
| 34132 | chroma_side * chroma_side, | 34200 | chroma_side * chroma_side, |
| 34133 | ); | 34201 | ); |
| 34134 | for rr in 0..cu_tx { | 34202 | for rr in 0..cu_tx { |
| 34135 | - let start = (cr * chunk_chroma | 34203 | + // The ASSEMBLED grid stays at |
| 34204 | + // the square `chroma_side` | ||
| 34205 | + // stride the block tail's | ||
| 34206 | + // `mu_chroma_units` re-stamp | ||
| 34207 | + // indexes; the unit's true | ||
| 34208 | + // per-axis position is what | ||
| 34209 | + // changes. | ||
| 34210 | + let start = (cr * chunk_chroma_h | ||
| 34136 | + ur * cu_tx | 34211 | + ur * cu_tx |
| 34137 | + rr) | 34212 | + rr) |
| 34138 | * chroma_side | 34213 | * chroma_side |
| 34139 | - + cc * chunk_chroma | 34214 | + + cc * chunk_chroma_w |
| 34140 | + uc * cu_tx; | 34215 | + uc * cu_tx; |
| 34141 | dst[start..start + cu_tx] | 34216 | dst[start..start + cu_tx] |
| 34142 | .copy_from_slice( | 34217 | .copy_from_slice( |
| @@ -35544,18 +35619,35 @@ fn decode_inter_block( | |||
| 35544 | // this arm has always coded. `chroma_side` | 35619 | // this arm has always coded. `chroma_side` |
| 35545 | // already carries the subsampling. | 35620 | // already carries the subsampling. |
| 35546 | let cu_tx = 32usize; | 35621 | let cu_tx = 32usize; |
| 35547 | - let chunk_chroma = chroma_side * 64 / side; | 35622 | + // lane-av1-422bigblock: a 64x64 mu chunk's |
| 35548 | - let units = chunk_chroma / cu_tx; | 35623 | + // chroma plane block is PER-AXIS |
| 35624 | + // (64 >> ss_x) x (64 >> ss_y) -- 32x64 at | ||
| 35625 | + // ss (1,0), i.e. TWO stacked TX_32X32 units | ||
| 35626 | + // per plane (`av1_get_max_uv_txsize` caps the | ||
| 35627 | + // unit at 32 on each axis). The old square-cut | ||
| 35628 | + // model walked `chroma_side`-square chunks: | ||
| 35629 | + // twice the units the oracle codes at 4:2:2, | ||
| 35630 | + // prediction windows indexed at the square | ||
| 35631 | + // `chroma_side` instead of the prediction | ||
| 35632 | + // buffer's own `chroma_stride`, and chunk | ||
| 35633 | + // columns at 64.. of a 64-wide chroma plane. | ||
| 35634 | + let chunk_chroma_w = (64usize) >> ss_x(fctx); | ||
| 35635 | + let chunk_chroma_h = (64usize) >> ss_y(fctx); | ||
| 35636 | + let units_w = chunk_chroma_w / cu_tx; | ||
| 35637 | + let units_h = chunk_chroma_h / cu_tx; | ||
| 35549 | // The unit's own footprint on the LUMA mi | 35638 | // The unit's own footprint on the LUMA mi |
| 35550 | - // grid: 64 px (16 mi) at 4:2:0, 32 px (8 mi) | 35639 | + // grid, per axis (32 << ss) px: 64x64 (16x16 |
| 35551 | - // at ss 0/0. `around_mi` reads and | 35640 | + // mi) at 4:2:0, 32x32 (8x8 mi) at 4:4:4, |
| 35641 | + // 64x32 (16x8 mi) at 4:2:2. `around_mi_rect` | ||
| 35642 | + // reads and | ||
| 35552 | // `record_mi_chroma` stamps span exactly the | 35643 | // `record_mi_chroma` stamps span exactly the |
| 35553 | // unit's own cells -- `get_txb_ctx` reads the | 35644 | // unit's own cells -- `get_txb_ctx` reads the |
| 35554 | // 8 context cells of the TX_32X32 itself, and | 35645 | // 8 context cells of the TX_32X32 itself, and |
| 35555 | // `av1_set_entropy_contexts` memsets the same | 35646 | // `av1_set_entropy_contexts` memsets the same |
| 35556 | // 8, so the unit over never sees this unit's | 35647 | // 8, so the unit over never sees this unit's |
| 35557 | // state and the unit below always does. | 35648 | // state and the unit below always does. |
| 35558 | - let unit_luma = cu_tx * (side / chroma_side); | 35649 | + let unit_luma_w = cu_tx << ss_x(fctx); |
| 35650 | + let unit_luma_h = cu_tx << ss_y(fctx); | ||
| 35559 | let cu_scan = default_scan(cu_tx); | 35651 | let cu_scan = default_scan(cu_tx); |
| 35560 | if lossless(fctx) { | 35652 | if lossless(fctx) { |
| 35561 | // lane-lossless2: TX_4X4 units over this | 35653 | // lane-lossless2: TX_4X4 units over this |
| @@ -35563,8 +35655,8 @@ fn decode_inter_block( | |||
| 35563 | read_inter_chroma_lossless( | 35655 | read_inter_chroma_lossless( |
| 35564 | dec, cdfs, neighbours, u, v, su, sv, | 35656 | dec, cdfs, neighbours, u, v, su, sv, |
| 35565 | at_mi, (cpx, cpy), | 35657 | at_mi, (cpx, cpy), |
| 35566 | - (cc * chunk_chroma, cr * chunk_chroma), | 35658 | + (cc * chunk_chroma_w, cr * chunk_chroma_h), |
| 35567 | - (chunk_chroma, chunk_chroma), | 35659 | + (chunk_chroma_w, chunk_chroma_h), |
| 35568 | (write_chroma_w, write_chroma_h), | 35660 | (write_chroma_w, write_chroma_h), |
| 35569 | chroma_side, mode_for_tx, base_q_idx, | 35661 | chroma_side, mode_for_tx, base_q_idx, |
| 35570 | &mut u_units, &mut v_units, fctx, | 35662 | &mut u_units, &mut v_units, fctx, |
| @@ -35581,24 +35673,28 @@ fn decode_inter_block( | |||
| 35581 | // Plane-major per chunk (libaom's plane | 35673 | // Plane-major per chunk (libaom's plane |
| 35582 | // loop is outermost inside the mu walk); | 35674 | // loop is outermost inside the mu walk); |
| 35583 | // within a plane the units walk raster. | 35675 | // within a plane the units walk raster. |
| 35584 | - for ur in 0..units { | 35676 | + for ur in 0..units_h { |
| 35585 | - for uc in 0..units { | 35677 | + for uc in 0..units_w { |
| 35586 | let unit_mi = ( | 35678 | let unit_mi = ( |
| 35587 | at_mi.0 + cr * 16 | 35679 | at_mi.0 + cr * 16 |
| 35588 | - + ur * (unit_luma / MI), | 35680 | + + ur * (unit_luma_h / MI), |
| 35589 | at_mi.1 + cc * 16 | 35681 | at_mi.1 + cc * 16 |
| 35590 | - + uc * (unit_luma / MI), | 35682 | + + uc * (unit_luma_w / MI), |
| 35591 | ); | 35683 | ); |
| 35592 | // Per unit, AFTER the earlier | 35684 | // Per unit, AFTER the earlier |
| 35593 | // units' stamps: this unit's | 35685 | // units' stamps: this unit's |
| 35594 | // coefficient context must see | 35686 | // coefficient context must see |
| 35595 | // them. | 35687 | // them. |
| 35596 | let cu_around = neighbours | 35688 | let cu_around = neighbours |
| 35597 | - .around_mi(unit_mi, unit_luma); | 35689 | + .around_mi_rect( |
| 35690 | + unit_mi, | ||
| 35691 | + unit_luma_w, | ||
| 35692 | + unit_luma_h, | ||
| 35693 | + ); | ||
| 35598 | let (cu_x, cu_y) = ( | 35694 | let (cu_x, cu_y) = ( |
| 35599 | - cpx + cc * chunk_chroma | 35695 | + cpx + cc * chunk_chroma_w |
| 35600 | + uc * cu_tx, | 35696 | + uc * cu_tx, |
| 35601 | - cpy + cr * chunk_chroma | 35697 | + cpy + cr * chunk_chroma_h |
| 35602 | + ur * cu_tx, | 35698 | + ur * cu_tx, |
| 35603 | ); | 35699 | ); |
| 35604 | // `av1_get_tx_type` (blockd.h: | 35700 | // `av1_get_tx_type` (blockd.h: |
| @@ -35629,11 +35725,16 @@ fn decode_inter_block( | |||
| 35629 | }, | 35725 | }, |
| 35630 | ) | 35726 | ) |
| 35631 | .map(|(_, _, _, _, t)| t); | 35727 | .map(|(_, _, _, _, t)| t); |
| 35728 | + // The prediction buffer is | ||
| 35729 | + // `chroma_stride`-strided (the | ||
| 35730 | + // plane block's own width at | ||
| 35731 | + // 4:2:2), not the square | ||
| 35732 | + // `chroma_side`. | ||
| 35632 | let cu_pred = src.offset( | 35733 | let cu_pred = src.offset( |
| 35633 | - (cr * chunk_chroma | 35734 | + (cr * chunk_chroma_h |
| 35634 | + ur * cu_tx) | 35735 | + ur * cu_tx) |
| 35635 | - * chroma_side | 35736 | + * chroma_stride |
| 35636 | - + cc * chunk_chroma | 35737 | + + cc * chunk_chroma_w |
| 35637 | + uc * cu_tx, | 35738 | + uc * cu_tx, |
| 35638 | ); | 35739 | ); |
| 35639 | let cu_grid = read_inter_plane( | 35740 | let cu_grid = read_inter_plane( |
| @@ -35663,8 +35764,8 @@ fn decode_inter_block( | |||
| 35663 | // context. | 35764 | // context. |
| 35664 | neighbours.record_mi_chroma( | 35765 | neighbours.record_mi_chroma( |
| 35665 | unit_mi, | 35766 | unit_mi, |
| 35666 | - unit_luma, | 35767 | + unit_luma_w, |
| 35667 | - unit_luma, | 35768 | + unit_luma_h, |
| 35668 | plane_idx, | 35769 | plane_idx, |
| 35669 | &cu_grid, | 35770 | &cu_grid, |
| 35670 | ); | 35771 | ); |
| @@ -35679,11 +35780,18 @@ fn decode_inter_block( | |||
| 35679 | chroma_side * chroma_side, | 35780 | chroma_side * chroma_side, |
| 35680 | ); | 35781 | ); |
| 35681 | for rr in 0..cu_tx { | 35782 | for rr in 0..cu_tx { |
| 35682 | - let start = (cr * chunk_chroma | 35783 | + // The ASSEMBLED grid stays at |
| 35784 | + // the square `chroma_side` | ||
| 35785 | + // stride the block tail's | ||
| 35786 | + // `mu_chroma_units` re-stamp | ||
| 35787 | + // indexes; the unit's true | ||
| 35788 | + // per-axis position is what | ||
| 35789 | + // changes. | ||
| 35790 | + let start = (cr * chunk_chroma_h | ||
| 35683 | + ur * cu_tx | 35791 | + ur * cu_tx |
| 35684 | + rr) | 35792 | + rr) |
| 35685 | * chroma_side | 35793 | * chroma_side |
| 35686 | - + cc * chunk_chroma | 35794 | + + cc * chunk_chroma_w |
| 35687 | + uc * cu_tx; | 35795 | + uc * cu_tx; |
| 35688 | dst[start..start + cu_tx] | 35796 | dst[start..start + cu_tx] |
| 35689 | .copy_from_slice( | 35797 | .copy_from_slice( |
crates/ec-av1/src/stream.rsmodified+56 -0
| @@ -2226,6 +2226,62 @@ pub(crate) mod tests { | |||
| 2226 | let frames = decode_stream(&stream).expect("the 4:2:0 control must decode"); | 2226 | let frames = decode_stream(&stream).expect("the 4:2:0 control must decode"); |
| 2227 | assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame"); | 2227 | assert_eq!(frames.len(), 1, "{NAME}: the 4:2:0 control decoded no frame"); |
| 2228 | } | 2228 | } |
| 2229 | + /// lane-av1-422bigblock: the two witnessed 4:2:2 big-block defects, pinned | ||
| 2230 | + /// as fixtures (`git add -f`; `fixtures/` is gitignored). | ||
| 2231 | + /// | ||
| 2232 | + /// `422_allskip_2f.obu` (62 bytes) is a 128x128 profile-2 key frame plus | ||
| 2233 | + /// its all-skip first inter frame: the pre-port decoder read phantom | ||
| 2234 | + /// coefficient units in the inter frame and then panicked in | ||
| 2235 | + /// `reconstruct_mc_rect` on a full-height 4:2:2 chroma rect. At this | ||
| 2236 | + /// lane's HEAD the block-half port's per-axis plane-block model already | ||
| 2237 | + /// has it entropy-locked (all 20 key-frame coefficient units pair | ||
| 2238 | + /// rng-for-rng with the instrumented oracle, the inter frame reads | ||
| 2239 | + /// zero, matching the oracle) and pixel-exact vs aomdec. | ||
| 2240 | + /// | ||
| 2241 | + /// `422_sb128_3f.obu` (12543 bytes) carries the f2 128x128 | ||
| 2242 | + /// `PARTITION_NONE` non-skip inter block: the mu-chunk chroma walk cut | ||
| 2243 | + /// each chunk's 32x64 chroma into a `chroma_side`-square 64x64 (twice | ||
| 2244 | + /// the units the oracle codes), indexed the prediction buffer at the | ||
| 2245 | + /// square `chroma_side` instead of `chroma_stride` (the empty-slice | ||
| 2246 | + /// panic at `push_mc_rect_tx`'s densify), and the reference plane | ||
| 2247 | + /// resolution guessed every non-4:4:4 picture quarter-height, so the | ||
| 2248 | + /// bottom mu-chunk row predicted from a clamped row-63 edge. All fixed; | ||
| 2249 | + /// both witnesses decode pixel-exact vs aomdec on the lane's local | ||
| 2250 | + /// `EC_AV1_ALLOW_422_PROBE` patch-run-restore build (recipe and measured | ||
| 2251 | + /// numbers in `lanes/av1422bigblock.report.md`). | ||
| 2252 | + /// | ||
| 2253 | + /// `decode_stream` itself still refuses 4:2:2 at the sequence header -- | ||
| 2254 | + /// unconditionally, per the standing family rule -- so the committed | ||
| 2255 | + /// assertion is the byte pin (fnv1a64, the same load-bearing-identity | ||
| 2256 | + /// fingerprint as the cdf-forwarding gate) plus the refusal-by-name | ||
| 2257 | + /// contract over the pinned bytes. | ||
| 2258 | + #[test] | ||
| 2259 | + fn the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name() { | ||
| 2260 | + const NAME: &str = "the_pinned_422_bigblock_witnesses_are_present_and_refuse_by_name"; | ||
| 2261 | + const REFUSAL: &str = "a chroma format of 4:2:2"; | ||
| 2262 | + for (file, bytes, fp) in [ | ||
| 2263 | + ("422_allskip_2f.obu", 62usize, 0x7e4d69d3c728c55f_u64), | ||
| 2264 | + ("422_sb128_3f.obu", 12543, 0x5171e0aab8000da7), | ||
| 2265 | + ] { | ||
| 2266 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 2267 | + .join("fixtures") | ||
| 2268 | + .join(file); | ||
| 2269 | + let data = std::fs::read(&path).unwrap_or_else(|e| { | ||
| 2270 | + panic!( | ||
| 2271 | + "{NAME}: pinned witness {} is missing ({e}) -- the gate cannot run", | ||
| 2272 | + path.display() | ||
| 2273 | + ) | ||
| 2274 | + }); | ||
| 2275 | + assert_eq!(data.len(), bytes, "{NAME}: {file} size drifted"); | ||
| 2276 | + assert_eq!(fnv1a64(&data), fp, "{NAME}: {file} bytes drifted"); | ||
| 2277 | + let err = decode_stream(&data).unwrap_err().to_string(); | ||
| 2278 | + assert!( | ||
| 2279 | + err.contains(REFUSAL), | ||
| 2280 | + "{NAME}: {file} must refuse by name, got: {err}" | ||
| 2281 | + ); | ||
| 2282 | + } | ||
| 2283 | + } | ||
| 2284 | + | ||
| 2229 | 2285 | ||
| 2230 | /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the | 2286 | /// lane-av1-qmatrix: WITNESS for the lifted `using_qmatrix` refusal (the |
| 2231 | /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is | 2287 | /// old gate `a_frame_using_quantisation_matrices_is_refused_by_name` is |
lanes/av1422bigblock.report.mdadded+187 -0
| @@ -0,0 +1,187 @@ | |||
| 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 | + `halfw = (w+1)/2`, `halfh = (h+1)/2` — the three lengths are pairwise | ||
| 100 | + distinct for every w,h ≥ 1). DISCLOSED 4:2:0 edge: at ODD reference | ||
| 101 | + dimensions the half-width uses ceil (`(w+1)/2`, matching the picture | ||
| 102 | + crop's `round_ss`) where the old guess used floor (`w/2`) — ceil is the | ||
| 103 | + correct stored-crop shape and the change is visible only at odd w/h, which | ||
| 104 | + no committed fixture exercises. | ||
| 105 | + | ||
| 106 | +After the fixes: `422_sb128_3f.obu` and the full `b422_wit.obu` decode | ||
| 107 | +pixel-exact vs aomdec; every coefficient unit of every frame pairs | ||
| 108 | +rng-for-rng with the oracle (29/29, 32/32, 32/32). | ||
| 109 | + | ||
| 110 | +Class sweep of the same square-cut model: | ||
| 111 | +- `decode_intrabc_128rect` has the same `cside * 64 / side` square chunk walk — | ||
| 112 | + **deferred** (same class, unwitnessed: no 4:2:2 intrabc 128-rect witness | ||
| 113 | + exists; unblock = one aomenc `--enable-intrabc` profile-2 128-SB hunt). | ||
| 114 | +- The 444 branch of the inter walk degenerates to identical values (ss 0/0 ⇒ | ||
| 115 | + per-axis == square, `chroma_stride == chroma_side`), verified by gate. | ||
| 116 | + | ||
| 117 | +## Defect 3 (Main's IRC) — s2.obu crash: crash fixed, residual named | ||
| 118 | + | ||
| 119 | +`/tmp/sa422/s2.obu` (recipe: `lanes/av1422stripanchor.report.md` "Observed, not | ||
| 120 | +chased"; 420 control `b420_wit.obu`) panicked at `decode.rs:3709` at HEAD — the | ||
| 121 | +same densify site, fed by defect 2's cause 3 (quarter-height reference) and the | ||
| 122 | +intra 128-rect twin of the square-cut walk: | ||
| 123 | + | ||
| 124 | +- `decode_block_128rect`'s chroma walk was chunk-square (`cn = 32/chroma_tx`, | ||
| 125 | + `cu_y = cpy + ch_row*32`, clamp strides 8/8) with a `debug_assert!` that no | ||
| 126 | + 4:2:2 stream can satisfy. Fixed per-axis exactly like the inter walk | ||
| 127 | + (`tu_reach_rect`, `around_mi_rect`, per-axis record spans), in the SAME | ||
| 128 | + expression shape the already-reviewed 444 fix landed on lane-av1-444sb | ||
| 129 | + (`349b3918`): `cn = ((64 >> ss_x)/chroma_tx).max(1)` for the width axis | ||
| 130 | + plus the added `cn_h = ((64 >> ss_y)/chroma_tx).max(1)` for the height | ||
| 131 | + axis, per-axis chunk offsets `(64 >> ss)` and clamp strides `(16 >> ss)` — | ||
| 132 | + at ss(0,0) the code reduces line-for-line to `349b3918`'s form, so the | ||
| 133 | + merge with that chain is a semantic union. DISCLOSED 4:4:4 behavior change: | ||
| 134 | + the parent's walk was provably broken at ss(0,0) (one unit per chunk instead | ||
| 135 | + of four; the stale assert caught it) and this rewrite, like `349b3918`, | ||
| 136 | + codes the four units — NOT byte-identical to parent at 4:4:4, by design, | ||
| 137 | + and pinned by `349b3918`'s own witness on the merged tree (see the identity | ||
| 138 | + section). DISCLOSED 4:2:0 identity: at ss(1,1) every new expression reduces | ||
| 139 | + to the old constant (32, offsets 32, strides 8, one unit). | ||
| 140 | + | ||
| 141 | +Result: s2.obu decodes all 16 frames, no panic (`OK: 16 frames decoded, | ||
| 142 | +256x144`). The crash the charter assigned is closed. **Deferred (named for its | ||
| 143 | +owning lane):** s2's frame 0 diverges from aomdec (~45% of samples, maxabs | ||
| 144 | +~180, Y first diff at sample 126) with an entropy desync: the oracle codes | ||
| 145 | +1089 coefficient units in frame 0, ours 541, first divergence at unit 38 — a | ||
| 146 | +plane-2 **TX_4X8** chroma unit at **mi(12,24)** (oracle `all_zero=0 | ||
| 147 | +rng=48745`, ours `rng=41584`). Class: sub-8/odd-strip 4:2:2 chroma under the | ||
| 148 | +128-rect intra path (the `ss_size_lookup` BLOCK_INVALID family), pre-existing | ||
| 149 | +— the base tree panics at frame 0's assert and never produced pixels. At base | ||
| 150 | +the stream could not be measured at all; the pre-fix re-run log is | ||
| 151 | +`/tmp/sa422/re-run-av1422ctxgather.log`. Fingerprint: `/tmp/sa422/s2f0.obu`, | ||
| 152 | +unit 38, mi(12,24), TX_4X8, plane 2. | ||
| 153 | + | ||
| 154 | +## 4:2:0/4:4:4 identity + t422 | ||
| 155 | + | ||
| 156 | +- `a_real_aomenc_10bit_inter_sequence_decodes_pixel_exact` — green. | ||
| 157 | +- `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream` | ||
| 158 | + (live aomenc, 420, inter, tiles) — green. | ||
| 159 | +- `a_lossless_sb128_rect_intra_block_decodes_sample_exact` — green. LABEL | ||
| 160 | + CORRECTION (review finding 2): this stream is 4:2:0 (seq_profile 0 in the | ||
| 161 | + fixture bytes), NOT 4:4:4 as this report first claimed; it is a 4:2:0 | ||
| 162 | + lossless sb128 gate and proves nothing about 4:4:4. | ||
| 163 | +- 4:4:4 evidence, done properly: `444_sb128rect_lr_witness.obu` (sha256 | ||
| 164 | + `27825e14…`, the lane-av1-444sb witness, 192x160 profile-1, 3 frames) was | ||
| 165 | + decoded on THIS tree (`OK: 3 frames decoded`) and its output is | ||
| 166 | + BYTE-IDENTICAL to the parent commit's output on the same stream — measured | ||
| 167 | + by stash-and-rebuild, all three frames — so the rewrite is proven | ||
| 168 | + output-neutral on it. The stream itself still diverges from aomdec on this | ||
| 169 | + ancestry, identically before and after the fix: this branch predates the | ||
| 170 | + 444 chain's chroma-context fixes (`9e77c16b` ss-aware chroma-above skip, | ||
| 171 | + `76f8c3fe`), the desync starts at frame-0 Y sample 128 (the first | ||
| 172 | + 128-column superblock) and the first 128-rect block never fires downstream | ||
| 173 | + of it, so `decode_block_128rect` codes no samples on this stream on this | ||
| 174 | + ancestry. `349b3918`'s own gate | ||
| 175 | + (`a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`, | ||
| 176 | + frames 0/1 byte-exact vs aomdec AND ffmpeg) is the merged-tree pin: at | ||
| 177 | + ss(0,0) this lane's walk reduces verbatim to that reviewed form. | ||
| 178 | +- `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders` | ||
| 179 | + and `a_128_root_compound_block_decodes_exact_through_both_decoders` (solo, | ||
| 180 | + they pin the process-global superblock size) — green. | ||
| 181 | +- t422 frame 0 (`/tmp/i422/t422_1f.obu`) byte-exact vs the instrumented oracle | ||
| 182 | + at PREFILT, POSTDEBLOCK, POSTCDEF and FINAL on Y, U and V; t422 16-frame | ||
| 183 | + stream decodes with the same frame count as the parent (15 shown of 16 frame | ||
| 184 | + OBUs, unchanged at HEAD — the 16th is an `OBU_TILE_LIST` quirk, not a | ||
| 185 | + regression). | ||
| 186 | + | ||
| 187 | +`cargo check -p ec-av1`: 0 warnings. Committed on the branch, no push. | ||