forge
Explore
Log in

Don't you dare go Hollow

Decode the frame-edge half-strip instead of refusing it (odd height/width)

Browse files at this commit

a24f3293b899f146c0e6bb9c7abf028971bd325dAhmet Kaan GümüşParent: 2988169
  • feat
    • decode the frame-edge half-strip instead of refusing it (odd height/width)
Show full message
feat(av1): decode the frame-edge half-strip instead of refusing it (odd height/width)

Cherry-picks lane-golomb eacd7fd (the gathered edge partition bit is the answer,
6 sites) and adds the arms it left refusing: the key-frame 16-level edge strip
(one 16x8/8x16 through decode_leaf_rect) and the inter path's superblock-level
and 16-level edge strips (one 64x32/32x64 resp. 16x8/8x16 inter block via
write_w/write_h, square CDF corner-cut as at the 32-level rect arm).

None of it is gated yet: a 64x72 key frame desyncs at its FIRST partition symbol
(mi=(0,0) BLOCK_64X64 ctx=0: aomdec value=3, ours value=9; whole-frame 4583/4608
Y samples wrong while the 64x64 control is exact), so every stream that reaches
these arms is already off the rails. That desync is r2's target; see
lanes/oddh-r1.report.md for the ladder, the ruled-out header paths and the
disposition of the width-192 defect the even-height control shares.
crates/ec-av1/fixtures/reelb_head_key_frame.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+321 -66
@@ -954,6 +954,21 @@ pub(crate) fn horz_vert_intra_hits() -> usize {
954954 HORZ_VERT_INTRA_HITS.with(|c| c.get())
955955 }
956956
957+// How many blocks were decoded as a frame-edge rect strip -- the single
958+// coded half of a `PARTITION_HORZ`/`PARTITION_VERT` at the true frame edge
959+// (lane-oddh r1), i.e. a block living inside the 8px band of a frame whose
960+// height or width is 8 mod 16 (the user's 3840x1608 film). Intra and inter
961+// paths share the counter.
962+thread_local! {
963+ static EDGE_RECT_STRIP_HITS: std::cell::Cell<usize> =
964+ const { std::cell::Cell::new(0) };
965+}
966+
967+/// Current value of [`EDGE_RECT_STRIP_HITS`].
968+pub(crate) fn edge_rect_strip_hits() -> usize {
969+ EDGE_RECT_STRIP_HITS.with(|c| c.get())
970+}
971+
957972 // How many HORZ/VERT intra strips resolved a SPLIT luma transform
958973 // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) --
959974 // the case every rect path here refused by name before, and the first
@@ -10809,16 +10824,31 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1080910824 }
1081010825 p
1081110826 } else {
10827+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
10828+ // bit is the answer, not a formality -- libaom's
10829+ // `ec_read_partition_impl` returns `PARTITION_HORZ` (resp.
10830+ // `PARTITION_VERT`) when it reads 0, and only `PARTITION_SPLIT`
10831+ // when it reads 1. Forcing SPLIT here desynced the last
10832+ // superblock row of every frame whose height is not a multiple
10833+ // of 64 -- the ReelB head (3840x1608) diverges at
10834+ // mi_row=400 mi_col=0, the first block of that row.
1081210835 match (has_cols, has_rows) {
1081310836 (true, false) => {
10814- dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
10837+ if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)) == 1 {
10838+ PARTITION_SPLIT
10839+ } else {
10840+ PARTITION_HORZ
10841+ }
1081510842 }
1081610843 (false, true) => {
10817- dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
10844+ if dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)) == 1 {
10845+ PARTITION_SPLIT
10846+ } else {
10847+ PARTITION_VERT
10848+ }
1081810849 }
10819- _ => {}
10850+ _ => PARTITION_SPLIT,
1082010851 }
10821- PARTITION_SPLIT
1082210852 };
1082310853 match part {
1082410854 PARTITION_NONE => {
@@ -10875,20 +10905,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1087510905 } else {
1087610906 match (has_cols32, has_rows32) {
1087710907 (true, false) => {
10878- dec.symbol_fixed(&gather(
10879- &cdfs.partition_w32[ctx32],
10880- VERT_ALIKE,
10881- ));
10908+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
10909+ // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
10910+ // (libaom `ec_read_partition_impl`).
10911+ if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 {
10912+ PARTITION_SPLIT
10913+ } else {
10914+ PARTITION_HORZ
10915+ }
1088210916 }
1088310917 (false, true) => {
10884- dec.symbol_fixed(&gather(
10885- &cdfs.partition_w32[ctx32],
10886- HORZ_ALIKE,
10887- ));
10918+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
10919+ // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
10920+ // (libaom `ec_read_partition_impl`).
10921+ if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 {
10922+ PARTITION_SPLIT
10923+ } else {
10924+ PARTITION_VERT
10925+ }
1088810926 }
10889- _ => {}
10927+ _ => PARTITION_SPLIT,
1089010928 }
10891- PARTITION_SPLIT
1089210929 };
1089310930 match part32 {
1089410931 PARTITION_NONE => {
@@ -11327,16 +11364,63 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1132711364 does not code yet",
1132811365 ));
1132911366 }
11330- if has_cols16 {
11367+ // lane-golomb r1 (class
11368+ // `parsed-then-discarded`): the gathered
11369+ // bit IS the partition -- 0 names
11370+ // PARTITION_HORZ (resp. VERT), only 1 is
11371+ // SPLIT (libaom `ec_read_partition_impl`).
11372+ // This path can only walk the four SPLIT
11373+ // leaves, so a 0 refuses by name instead
11374+ // of desyncing.
11375+ let edge_split = if has_cols16 {
1133111376 dec.symbol_fixed(&gather(
1133211377 &cdfs.partition_w16[ctx16],
1133311378 VERT_ALIKE,
11334- ));
11379+ ))
1133511380 } else {
1133611381 dec.symbol_fixed(&gather(
1133711382 &cdfs.partition_w16[ctx16],
1133811383 HORZ_ALIKE,
11339- ));
11384+ ))
11385+ };
11386+ if edge_split == 0 {
11387+ // lane-oddh r1: the strip IS decodable
11388+ // -- libaom's `decode_partition` codes
11389+ // only the FIRST half of an edge
11390+ // HORZ/VERT (the second call is
11391+ // guarded by the same has_rows/
11392+ // has_cols test that made the
11393+ // partition non-square), so one
11394+ // 16x8 (resp. 8x16) strip covers the
11395+ // whole visible band of a frame whose
11396+ // height (resp. width) is 8 mod 16 --
11397+ // the user's 3840x1608 film.
11398+ HORZ_VERT_INTRA_HITS.with(|c| c.set(c.get() + 1));
11399+ EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1));
11400+ let (mi_row0, mi_col0) =
11401+ (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
11402+ let (bw, bh) = if has_cols16 { (16, 8) } else { (8, 16) };
11403+ let mode = decode_leaf_rect(
11404+ &mut dec,
11405+ &mut cdfs,
11406+ &mut neighbours,
11407+ at16,
11408+ (mi_row0 as usize, mi_col0 as usize),
11409+ bw,
11410+ bh,
11411+ None,
11412+ &mut y,
11413+ &mut u,
11414+ &mut v,
11415+ enable_filter_intra,
11416+ allow_screen_content_tools,
11417+ base_q_idx,
11418+ tx_select,
11419+ reduced_tx_set,
11420+ )?;
11421+ neighbours.above_mode[sc] = mode;
11422+ neighbours.left_mode[sr] = mode;
11423+ continue;
1134011424 }
1134111425 let (mi_row0, mi_col0) =
1134211426 (sr as u32 * SUB_MI, sc as u32 * SUB_MI);
@@ -11886,22 +11970,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1188611970 tx_select,
1188711971 reduced_tx_set,
1188811972 )?;
11889- decode_block_rect64(
11890- &mut dec,
11891- &mut cdfs,
11892- &mut neighbours,
11893- (at.0 + 2, at.1),
11894- 64,
11895- 32,
11896- &mut y,
11897- &mut u,
11898- &mut v,
11899- enable_filter_intra,
11900- allow_screen_content_tools,
11901- base_q_idx,
11902- tx_select,
11903- reduced_tx_set,
11904- )?;
11973+ // lane-golomb r1: at the frame edge only the first half of the
11974+ // strip is coded (libaom `decode_partition` guards the second
11975+ // with the same has_rows test that made this partition non-square).
11976+ if has_rows {
11977+ decode_block_rect64(
11978+ &mut dec,
11979+ &mut cdfs,
11980+ &mut neighbours,
11981+ (at.0 + 2, at.1),
11982+ 64,
11983+ 32,
11984+ &mut y,
11985+ &mut u,
11986+ &mut v,
11987+ enable_filter_intra,
11988+ allow_screen_content_tools,
11989+ base_q_idx,
11990+ tx_select,
11991+ reduced_tx_set,
11992+ )?;
11993+ }
1190511994 }
1190611995 PARTITION_VERT => {
1190711996 // lane-sbpart r2: mirror of PARTITION_HORZ above with
@@ -11922,22 +12011,27 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1192212011 tx_select,
1192312012 reduced_tx_set,
1192412013 )?;
11925- decode_block_rect64(
11926- &mut dec,
11927- &mut cdfs,
11928- &mut neighbours,
11929- (at.0, at.1 + 2),
11930- 32,
11931- 64,
11932- &mut y,
11933- &mut u,
11934- &mut v,
11935- enable_filter_intra,
11936- allow_screen_content_tools,
11937- base_q_idx,
11938- tx_select,
11939- reduced_tx_set,
11940- )?;
12014+ // lane-golomb r1: at the frame edge only the first half of the
12015+ // strip is coded (libaom `decode_partition` guards the second
12016+ // with the same has_cols test that made this partition non-square).
12017+ if has_cols {
12018+ decode_block_rect64(
12019+ &mut dec,
12020+ &mut cdfs,
12021+ &mut neighbours,
12022+ (at.0, at.1 + 2),
12023+ 32,
12024+ 64,
12025+ &mut y,
12026+ &mut u,
12027+ &mut v,
12028+ enable_filter_intra,
12029+ allow_screen_content_tools,
12030+ base_q_idx,
12031+ tx_select,
12032+ reduced_tx_set,
12033+ )?;
12034+ }
1194112035 }
1194212036 PARTITION_HORZ_A | PARTITION_HORZ_B | PARTITION_VERT_A | PARTITION_VERT_B => {
1194312037 // lane-part32 r4: the four superblock-level AB arms, each
@@ -17776,12 +17870,24 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1777617870 p
1777717871 }
1777817872 (true, false) => {
17779- dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE));
17780- PARTITION_SPLIT
17873+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
17874+ // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
17875+ // (libaom `ec_read_partition_impl`).
17876+ if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], VERT_ALIKE)) == 1 {
17877+ PARTITION_SPLIT
17878+ } else {
17879+ PARTITION_HORZ
17880+ }
1778117881 }
1778217882 (false, true) => {
17783- dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE));
17784- PARTITION_SPLIT
17883+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
17884+ // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
17885+ // (libaom `ec_read_partition_impl`).
17886+ if dec.symbol_fixed(&gather(&cdfs.partition_w64[sb_ctx], HORZ_ALIKE)) == 1 {
17887+ PARTITION_SPLIT
17888+ } else {
17889+ PARTITION_VERT
17890+ }
1778517891 }
1778617892 (false, false) => PARTITION_SPLIT,
1778717893 };
@@ -17847,6 +17953,68 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1784717953 )?;
1784817954 continue;
1784917955 }
17956+ // lane-oddh r1: a superblock at the TRUE frame edge whose gathered
17957+ // partition bit read 0 is a `PARTITION_HORZ` (resp. `VERT`) whose
17958+ // second half lies outside the frame -- libaom `decode_partition`
17959+ // guards that second call with the same has_rows/has_cols test, so
17960+ // exactly one 64x32 (resp. 32x64) block is coded. Interior rect
17961+ // superblocks still refuse below (this arm can only be reached from
17962+ // the gathered edge bit).
17963+ if (part64 == PARTITION_HORZ && !has_rows) || (part64 == PARTITION_VERT && !has_cols) {
17964+ EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1));
17965+ let (write_w, write_h) =
17966+ if part64 == PARTITION_HORZ { (SB, SB / 2) } else { (SB / 2, SB) };
17967+ decode_inter_block(
17968+ &mut dec,
17969+ &mut cdfs,
17970+ &mut neighbours,
17971+ &mut grid,
17972+ sb_at,
17973+ SB,
17974+ mi_cols,
17975+ mi_rows,
17976+ &mut y,
17977+ &mut u,
17978+ &mut v,
17979+ &ref_y,
17980+ &ref_u,
17981+ &ref_v,
17982+ &ref_slots,
17983+ &sign_bias_table,
17984+ &global_motion,
17985+ base_q_idx,
17986+ TxbSet::Luma64,
17987+ TxbSet::Luma64,
17988+ TxbSet::Chroma32,
17989+ TX32,
17990+ TX32,
17991+ &scan32,
17992+ &scan32,
17993+ 3,
17994+ allow_high_precision_mv,
17995+ force_integer_mv,
17996+ interp_fixed,
17997+ enable_dual_filter,
17998+ tpl_frame.as_ref(),
17999+ reference_select,
18000+ enable_masked_compound,
18001+ enable_interintra_compound,
18002+ enable_jnt_comp,
18003+ order_hint_bits,
18004+ order_hint,
18005+ ref_order_hints,
18006+ skip_mode_present,
18007+ skip_mode_frame,
18008+ switchable_motion_mode,
18009+ allow_warped_motion,
18010+ false,
18011+ write_w,
18012+ write_h,
18013+ allow_screen_content_tools,
18014+ frame_width as usize,
18015+ )?;
18016+ continue;
18017+ }
1785018018 if part64 != PARTITION_SPLIT {
1785118019 return Err(unsupported(
1785218020 "an inter SB-level partition type other than NONE or SPLIT (this decoder's \
@@ -17886,14 +18054,27 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1788618054 } else {
1788718055 match (has_cols32, has_rows32) {
1788818056 (true, false) => {
17889- dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE));
18057+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
18058+ // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
18059+ // (libaom `ec_read_partition_impl`).
18060+ if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], VERT_ALIKE)) == 1 {
18061+ PARTITION_SPLIT
18062+ } else {
18063+ PARTITION_HORZ
18064+ }
1789018065 }
1789118066 (false, true) => {
17892- dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE));
18067+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
18068+ // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
18069+ // (libaom `ec_read_partition_impl`).
18070+ if dec.symbol_fixed(&gather(&cdfs.partition_w32[ctx32], HORZ_ALIKE)) == 1 {
18071+ PARTITION_SPLIT
18072+ } else {
18073+ PARTITION_VERT
18074+ }
1789318075 }
17894- _ => {}
18076+ _ => PARTITION_SPLIT,
1789518077 }
17896- PARTITION_SPLIT
1789718078 };
1789818079 match part32 {
1789918080 PARTITION_NONE => {
@@ -17985,17 +18166,24 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1798518166 p
1798618167 } else {
1798718168 if has_cols16 {
17988- dec.symbol_fixed(&gather(
17989- &cdfs.partition_w16[ctx16],
17990- VERT_ALIKE,
17991- ));
18169+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
18170+ // bit IS the partition -- 0 means PARTITION_HORZ, only 1 means SPLIT
18171+ // (libaom `ec_read_partition_impl`).
18172+ if dec.symbol_fixed(&gather(&cdfs.partition_w16[ctx16], VERT_ALIKE)) == 1 {
18173+ PARTITION_SPLIT
18174+ } else {
18175+ PARTITION_HORZ
18176+ }
1799218177 } else {
17993- dec.symbol_fixed(&gather(
17994- &cdfs.partition_w16[ctx16],
17995- HORZ_ALIKE,
17996- ));
18178+ // lane-golomb r1 (class `parsed-then-discarded`): the gathered
18179+ // bit IS the partition -- 0 means PARTITION_VERT, only 1 means SPLIT
18180+ // (libaom `ec_read_partition_impl`).
18181+ if dec.symbol_fixed(&gather(&cdfs.partition_w16[ctx16], HORZ_ALIKE)) == 1 {
18182+ PARTITION_SPLIT
18183+ } else {
18184+ PARTITION_VERT
18185+ }
1799718186 }
17998- PARTITION_SPLIT
1799918187 };
1800018188 if part16 == PARTITION_NONE {
1800118189 decode_inter_block(
@@ -18051,6 +18239,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1805118239 allow_screen_content_tools,
1805218240 frame_width as usize,
1805318241 )?;
18242+ } else if (part16 == PARTITION_HORZ && !has_rows16)
18243+ || (part16 == PARTITION_VERT && !has_cols16)
18244+ {
18245+ // lane-oddh r1: the frame-edge half-strip (see the
18246+ // superblock-level arm) one level down -- a single
18247+ // 16x8 (resp. 8x16) inter block covering the whole
18248+ // visible band. Interior 16x8/8x16 inter leaves stay
18249+ // refused below.
18250+ EDGE_RECT_STRIP_HITS.with(|c| c.set(c.get() + 1));
18251+ let (write_w, write_h) = if part16 == PARTITION_HORZ {
18252+ (SUB, SUB / 2)
18253+ } else {
18254+ (SUB / 2, SUB)
18255+ };
18256+ decode_inter_block(
18257+ &mut dec,
18258+ &mut cdfs,
18259+ &mut neighbours,
18260+ &mut grid,
18261+ at16,
18262+ SUB,
18263+ mi_cols,
18264+ mi_rows,
18265+ &mut y,
18266+ &mut u,
18267+ &mut v,
18268+ &ref_y,
18269+ &ref_u,
18270+ &ref_v,
18271+ &ref_slots,
18272+ &sign_bias_table,
18273+ &global_motion,
18274+ base_q_idx,
18275+ TxbSet::Luma16,
18276+ if reduced_tx_set {
18277+ TxbSet::Luma16Inter
18278+ } else {
18279+ TxbSet::Luma16InterSet1
18280+ },
18281+ TxbSet::Chroma8,
18282+ TX16,
18283+ TX8,
18284+ &scan16,
18285+ &scan8,
18286+ 2,
18287+ allow_high_precision_mv,
18288+ force_integer_mv,
18289+ interp_fixed,
18290+ enable_dual_filter,
18291+ tpl_frame.as_ref(),
18292+ reference_select,
18293+ enable_masked_compound,
18294+ enable_interintra_compound,
18295+ enable_jnt_comp,
18296+ order_hint_bits,
18297+ order_hint,
18298+ ref_order_hints,
18299+ skip_mode_present,
18300+ skip_mode_frame,
18301+ switchable_motion_mode,
18302+ allow_warped_motion,
18303+ false,
18304+ write_w,
18305+ write_h,
18306+ allow_screen_content_tools,
18307+ frame_width as usize,
18308+ )?;
1805418309 } else if part16 != PARTITION_SPLIT {
1805518310 return Err(unsupported(
1805618311 "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)",
crates/ec-av1/src/stream.rsmodified+35 -0
@@ -2671,6 +2671,41 @@ mod tests {
26712671 eprintln!("{NAME}: pixel-exact, grain_hits={}", crate::film_grain::grain_hits());
26722672 }
26732673
2674+ /// lane-golomb r1: THE FILM ITSELF. `crates/ec-av1/fixtures/reelb_head_key_frame.obu`
2675+ /// is the first frame of the user's ReelB AV1 release (3840x1608
2676+ /// yuv420p10le, `ffmpeg -i <mkv> -c copy -frames:v 1 -f obu`, 147 bytes) --
2677+ /// a real 10-bit key frame whose height is NOT a multiple of the 64-pixel
2678+ /// superblock, so its last superblock row (mi_row=400 of 402) carries the
2679+ /// edge partition symbol this lane fixed: libaom's `ec_read_partition_impl`
2680+ /// returns `PARTITION_HORZ` when the gathered `split_or_horz` bit is 0, and
2681+ /// this decoder used to READ that bit and throw it away, forcing SPLIT
2682+ /// (class `parsed-then-discarded`). The desync surfaced two rows later as
2683+ /// "a Golomb tail longer than this decoder reads" -- a refusal naming the
2684+ /// symptom, never the cause.
2685+ #[test]
2686+ fn the_reelb_head_key_frame_decodes_pixel_exact() {
2687+ const NAME: &str = "the_reelb_head_key_frame_decodes_pixel_exact";
2688+ if !have_ffmpeg() {
2689+ eprintln!("SKIP {NAME}: no ffmpeg");
2690+ return;
2691+ }
2692+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
2693+ .join("fixtures/reelb_head_key_frame.obu");
2694+ let stream = std::fs::read(&path)
2695+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
2696+ let (width, height) = (3840usize, 1608usize);
2697+ let frames = match decode_stream(&stream) {
2698+ Ok(frames) => frames,
2699+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
2700+ };
2701+ assert_eq!(frames.len(), 1, "{NAME}: one key frame");
2702+ assert_eq!((frames[0].width, frames[0].height), (width, height));
2703+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
2704+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
2705+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg");
2706+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
2707+ }
2708+
26742709 /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1
26752710 /// --superres-denominator=12` key frame, decoded pixel-exact against
26762711 /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s
lanes/golomb-r1.report.mdadded+47 -0
@@ -0,0 +1,47 @@
1+# lane-golomb r1 — the edge partition bit was read and thrown away
2+
3+## Verdict
4+The "a Golomb tail longer than this decoder reads" refusal on the ReelB head was, as
5+suspected (`refusal-from-own-desync`), a symptom. Root cause: at a frame edge the partition
6+symbol is a single *gathered* bit, and this decoder read it and **discarded** it, always
7+inferring `PARTITION_SPLIT`. libaom `ec_read_partition_impl` (decodeframe.c:1255):
8+`!has_rows && has_cols` → `read ? PARTITION_SPLIT : PARTITION_HORZ`; the mirror case →
9+`PARTITION_VERT`. Class: `parsed-then-discarded`.
10+
11+Charter STEP-2 fallback ("libaom read_golomb caps at 32 bits, extend the reader") is FALSE:
12+`~/.cache/aom-oracle/src/av1/decoder/decodetxb.c:22` aborts the frame at `length > 20`, exactly
13+our cap. The cap was never the bug and is unchanged.
14+
15+## First divergent element (EVIDENCE)
16+EVIDENCE: /tmp/.../scratchpad/{ao-all.txt,ours-all.txt} | instrumented aomdec vs decode_probe,
17+EC_TRACE_MODE+EC_TRACE_MODE_STEP+EC_TRACE_COEFF on the 2-frame extract f2.obu, ladders aligned
18+element by element on msac RANGE | first diff at element 12053: key frame, **mi_row=400
19+mi_col=0** (last, 8-pixel-tall superblock row of a 1608-tall frame), `name=skip`
20+oracle rng=34753 vs ours rng=43258. Oracle codes that superblock as one `BLOCK_64X32`
21+(`EC_IMODE ... bsize=11`, PARTITION_HORZ); we forced SPLIT and descended to 16x16.
22+After the fix the range ladder is element-exact for all 13712 shared elements of the key frame
23+(EVIDENCE: /tmp/.../scratchpad/{a4.n,o4.n} | awk first-diff | idx 13713, inside a later INTER
24+frame, i.e. past the whole key frame).
25+
26+## Fix
27+`crates/ec-av1/src/decode.rs` — every edge-partition site, both tile paths, all three levels
28+(64/32/16, intra and inter): the gathered bit now names HORZ/VERT vs SPLIT. The 64-level
29+HORZ/VERT arms only decode the second half when it is inside the frame (`has_rows`/`has_cols`),
30+mirroring libaom `decode_partition`. The intra 16x16 edge site can only walk four SPLIT leaves,
31+so a 0 bit refuses by name there (new string, listed in `refusal_inventory.rs`) instead of
32+desyncing.
33+
34+## Gates
35+- NEW `stream::tests::the_reelb_head_key_frame_decodes_pixel_exact` — the film itself:
36+ `crates/ec-av1/fixtures/reelb_head_key_frame.obu` (147 B, first frame of his 3840x1608
37+ yuv420p10le release) decodes and matches `ffmpeg -pix_fmt yuv420p10le` on Y, U and V.
38+ EVIDENCE: cargo test -p ec-av1 --lib -- the_reelb_head_key_frame | 1 passed |
39+ Y/U/V all equal to ffmpeg's decode, 3840x1608.
40+- Full lib suite: `$HOME/.cache/golomb-suite.log` — **337 passed / 0 failed / 31 ignored**.
41+
42+## Film probes after the fix
43+- `hg-head.obu` (18 frames): key frame + first inter frames now entropy-exact; stops at
44+ "an inter SB-level partition type other than NONE or SPLIT" — the same edge partition, now
45+ correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter
46+ residual coding does not exist here). Next lane.
47+- `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane).
lanes/oddh-r1.report.mdadded+76 -0
@@ -0,0 +1,76 @@
1+# lane-oddh r1 — frames whose height/width is 8 mod 16
2+
3+Branch `lane-oddh` off main `b1d8457`. Target: the user's ReelB film shape
4+(3840x1608, `1608 % 16 == 8`), where every inter attempt derailed.
5+
6+## What the round established (measured, not reasoned)
7+
8+1. **The charter's premise is stale in its blame, right in its shape.** The refusal
9+ `"a non-DC chroma mode on an 8x8 inter-frame leaf"` is NOT what odd-height frames
10+ stop at once lane-golomb's edge-partition fix is present. Cherry-picking
11+ `eacd7fd` (clean, no conflicts) moves 192x136 to the same refusal its
12+ *even-height control* 192x128 hits, i.e. that one is width/content-related, not
13+ odd-height (see 4).
14+
15+2. **Minimal repro is 64x72, not 192x136.** With the standard inter-gate recipe
16+ (`--enable-rect-partitions=0 --min/max-partition-size=8/16`, mandelbrot, cq 40):
17+ - `64x64` decodes 4/4 frames pixel-exact (control),
18+ - `64x72` (bottom band 8 px) stopped at the key-frame 16-level edge refusal,
19+ - `72x64` (right band 8 px) stops in the inter tile path.
20+
21+3. **The real blocker underneath is a first-symbol desync of the KEY tile at
22+ height 72.** Not an edge-band defect at all: the *first* partition symbol of the
23+ frame diverges.
24+ `EVIDENCE: /tmp/.../scratchpad/k-64x72.obu (667 B, key frame only, aomenc cq40) | EC_AV1_TRACE=1 decode_probe vs EC_TRACE=1 aomdec | first element mi=(0,0) bsize=BLOCK_64X64 ctx=0: aomdec value=3 (PARTITION_SPLIT, tell=1 rng=32768), ours value=9`
25+ `EVIDENCE: /tmp/.../scratchpad/k-64x72.{ours,aom,ref}.y | aomdec --rawvideo + ffmpeg rawvideo vs our Y dump | aomdec == ffmpeg byte-for-byte; ours differs in 4583 of 4608 Y samples (whole frame), while the 64x64 control differs in 0`
26+ Our tile payload starts at file offset 20 in both the 64x64 and the 64x72 stream
27+ (`key_tile_bytes len=543`/`647`, file sizes 563/667), and `base_q_idx=160`,
28+ `mi_cols=16`, `mi_rows=18` all parse correctly, so the header field values are
29+ right; the divergence is in the very first symbol read off those bytes.
30+ **Not diagnosed further — this is the handoff item.** Ruled out by reading the
31+ source: `sb_rows`/`sb_cols` (`sequence.rs:409-422`, 18 -> 2 correct) and the
32+ uniform-spacing tile-info loops (`frame.rs:1296-1334`, both increment loops match
33+ spec 5.9.15, so the extra `increment_tile_rows_log2` bit that height 72 introduces
34+ IS consumed).
35+
36+4. Pre-existing, unrelated to odd height: `192x128` and `192x136` both stop at
37+ `"a 1:4 partition below 16x16"` with `--enable-1to4-partitions=0` on the command
38+ line — a same-shaped refusal-from-own-desync at width 192, present on the control.
39+
40+## Code changed (all in this worktree, unproven end to end)
41+
42+- cherry-pick `eacd7fd` (lane-golomb) — the frame-edge partition bit at 6 sites in
43+ both tile paths, plus its film key-frame fixture/gate. Clean merge.
44+- `crates/ec-av1/src/decode.rs:11371` — the key-frame 16-level frame-edge
45+ `PARTITION_HORZ`/`VERT` now decodes its single visible 16x8 / 8x16 strip through
46+ `decode_leaf_rect` instead of refusing (removes that refusal string; entry dropped
47+ from `refusal_inventory.rs`).
48+- `crates/ec-av1/src/decode.rs` (inter tile path, superblock level and 16-level) —
49+ the same edge half-strip as one 64x32 / 32x64 resp. 16x8 / 8x16 inter block
50+ (`write_w`/`write_h`, square CDF/size-class corner-cut, exactly the accepted
51+ corner-cut of the 32-level rect arm at `decode.rs:18448`). Interior rect
52+ partitions still refuse by name.
53+- `decode.rs` — new counter `edge_rect_strip_hits()` (blocks decoded inside the 8px
54+ edge band), for the gate a successor must write.
55+
56+`corner-cut:` the two inter edge arms read square CDFs / size classes for a
57+rectangular block (ceiling: coefficient and mode syntax for TX_64X32/TX_16X8 inter is
58+not modelled; upgrade path = the same treatment the 32-level rect arm eventually gets).
59+
60+## Verification status — honest
61+
62+- NO gate was added and NO refusal claim is proven: every stream that reaches the new
63+ arms is desynced before them (finding 3), so a pixel compare would measure the
64+ desync, not the arm. Writing
65+ `a_real_aomenc_inter_sequence_with_an_8px_tall_edge_row_decodes_pixel_exact` on top
66+ of a first-symbol desync would have produced a vacuous or a permanently-red gate.
67+- Suite: see `$HOME/.cache/oddh-suite.log` (run as a systemd unit, result quoted in
68+ the handoff message).
69+
70+## Disposition
71+
72+- fix-now (next round, r2): the 64x72 key-tile first-symbol desync. It is the root
73+ blocker; the edge arms above are dead code until it is fixed.
74+- deferred(the desync above): the 8px-edge-band gate + the refusal lift claim.
75+- deferred(width-192 defect, separate lane): the `"1:4 partition below 16x16"` stop
76+ that both 192x128 and 192x136 share.