forge
Explore
Log in

Don't you dare go Hollow

The 128 root's half-out-of-frame partition symbol was read and thrown away -- split_or_horz/split_or_vert DECIDE the partition (spec 5.11.4), they are not a forced split

Browse files at this commit

9b30932a664e9a8550e14f0e784da693bbe5a1edAhmet Kaan GümüşParent: 64b4002
  • fix
    • the 128 root's half-out-of-frame partition symbol was read and thrown away -- split_or_horz/split_or_vert DECIDE the partition (spec 5.11.4), they are not a forced split
Show full message
fix(av1): the 128 root's half-out-of-frame partition symbol was read and thrown away -- split_or_horz/split_or_vert DECIDE the partition (spec 5.11.4), they are not a forced split

`read_sb128_root` read the gathered 2-symbol partition at a superblock with
only rows or only cols in frame and unconditionally returned PARTITION_SPLIT,
so a 128 root that actually codes HORZ/VERT at the frame edge was silently
reconstructed as a split instead of reaching the refusal that names it. The
64 root already carries the fixed form (its comment records the 4K 10-bit
mkv head that the same defect desynced); this mirrors it at 128.

Witness: PART128_GATHERED_SYMBOLS / part128_gathered_symbols(), and the
lane-oddh 64x72 gate (mi_rows=18 > 16, so its single 128 root takes exactly
this path) now asserts it fired. That gate's recipe gains
--min-partition-size=16 -- without it aomenc emits PARTITION_HORZ_4 below
16x16, another lane's gap, and the gate measured that instead of the 128 root.

decode_probe prints the sequence's superblock size, bit depth and max frame
size, which is the first fact a film-blocker triage needs.
crates/ec-av1/examples/decode_probe.rsmodified+12 -0
@@ -66,6 +66,18 @@ fn main() {
6666 }
6767 }
6868 println!("TILING: {frames_seen} frame headers parsed");
69+ // lane-sb128 r4: the superblock size decides the whole partition tree, so
70+ // report it next to the tiling -- it is the first thing a film blocker
71+ // triage needs.
72+ if let Some(seq) = parser.sequence_header() {
73+ println!(
74+ "SEQ: use_128x128_superblock={} bit_depth={} max_frame={}x{}",
75+ seq.use_128x128_superblock,
76+ seq.color_config.bit_depth,
77+ seq.max_frame_width,
78+ seq.max_frame_height
79+ );
80+ }
6981 for (cols, rows, uniform, ctx_id) in &seen {
7082 println!(
7183 "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}"
crates/ec-av1/src/decode.rsmodified+29 -4
@@ -88,6 +88,14 @@ pub(crate) fn sb_mi_cur() -> u32 {
8888 thread_local! {
8989 static PART128_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
9090 static PART128_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
91+ static PART128_GATHERED_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
92+}
93+
94+/// Current value of `PART128_GATHERED_SYMBOLS`: 128 roots that read the
95+/// half-out-of-frame gathered split_or_horz/split_or_vert symbol (spec
96+/// 5.11.4), which this decoder used to read and throw away.
97+pub(crate) fn part128_gathered_symbols() -> usize {
98+ PART128_GATHERED_SYMBOLS.with(|c| c.get())
9199 }
92100
93101 /// Current value of [`PART128_SYMBOLS`].
@@ -11778,16 +11786,33 @@ fn read_sb128_root(
1177811786 }
1177911787 p
1178011788 } else {
11789+ // lane-sb128 r4: the gathered half-out-of-frame reads DECIDE the
11790+ // partition, they are not a forced split -- exactly the discarded-bit
11791+ // defect the 64 root carries a comment about at `partition_w64`'s
11792+ // gathered arm. Value 1 is SPLIT; 0 is HORZ (rows out of frame) or
11793+ // VERT (cols out of frame), which the refusal below then names
11794+ // instead of silently reconstructing a split.
11795+ PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() + 1));
1178111796 match (has_cols128, has_rows128) {
1178211797 (true, false) => {
11783- dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128));
11798+ if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &VERT_ALIKE128)) == 1 {
11799+ PARTITION_SPLIT
11800+ } else {
11801+ PARTITION_HORZ
11802+ }
1178411803 }
1178511804 (false, true) => {
11786- dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128));
11805+ if dec.symbol_fixed(&gather_of(&cdfs.partition_w128[ctx128], &HORZ_ALIKE128)) == 1 {
11806+ PARTITION_SPLIT
11807+ } else {
11808+ PARTITION_VERT
11809+ }
11810+ }
11811+ _ => {
11812+ PART128_GATHERED_SYMBOLS.with(|c| c.set(c.get() - 1));
11813+ PARTITION_SPLIT
1178711814 }
11788- _ => {}
1178911815 }
11790- PARTITION_SPLIT
1179111816 };
1179211817 if part128 != PARTITION_SPLIT {
1179311818 return Err(unsupported(
crates/ec-av1/src/stream.rsmodified+16 -2
@@ -1110,7 +1110,8 @@ mod tests {
11101110 let mut child = Command::new(aomenc_path())
11111111 .args([
11121112 "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32",
1113- "--cpu-used=0", "--sb-size=128", "--kf-max-dist=0", "--limit=1",
1113+ "--cpu-used=0", "--sb-size=128", "--min-partition-size=16",
1114+ "--kf-max-dist=0", "--limit=1",
11141115 "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-",
11151116 ])
11161117 .stdin(Stdio::piped())
@@ -1141,12 +1142,25 @@ mod tests {
11411142 assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock");
11421143
11431144 let _guard = lock_gate_counters();
1145+ let before = crate::decode::part128_symbols()
1146+ + crate::decode::part128_gathered_symbols();
11441147 let (frames, hidden) =
11451148 decode_all_frames_vs_oracle(&stream, "sb128-oddh-64x72");
11461149 assert!(frames > 0, "no frames decoded for {width}x{height}");
1150+ // The 128 root actually READ a partition symbol here: at mi_rows=18
1151+ // `has_rows` is true, so BLOCK_128X128 is not a forced split.
1152+ let part128 = crate::decode::part128_symbols()
1153+ + crate::decode::part128_gathered_symbols()
1154+ - before;
1155+ assert!(
1156+ part128 > 0,
1157+ "{width}x{height} decoded without reading a single BLOCK_128X128 \
1158+ partition symbol -- the gate proves nothing about the 128 root"
1159+ );
11471160 eprintln!(
11481161 "a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact: \
1149- {frames} frames pixel-exact ({hidden} hidden) at {width}x{height}"
1162+ {frames} frames pixel-exact ({hidden} hidden) at {width}x{height}, \
1163+ part128_symbols={part128}"
11501164 );
11511165 }
11521166