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 commit9b30932a664e9a8550e14f0e784da693bbe5a1edParent: 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
3 changed files +57 -6
- crates/ec-av1/examples/decode_probe.rs +12 -0
- crates/ec-av1/src/decode.rs +29 -4
- crates/ec-av1/src/stream.rs +16 -2
crates/ec-av1/examples/decode_probe.rsmodified+12 -0
| @@ -66,6 +66,18 @@ fn main() { | |||
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | println!("TILING: {frames_seen} frame headers parsed"); | 68 | 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 | + } | ||
| 69 | for (cols, rows, uniform, ctx_id) in &seen { | 81 | for (cols, rows, uniform, ctx_id) in &seen { |
| 70 | println!( | 82 | println!( |
| 71 | "TILING: cols={cols} rows={rows} uniform_spacing={uniform} context_update_tile_id={ctx_id}" | 83 | "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 { | |||
| 88 | thread_local! { | 88 | thread_local! { |
| 89 | static PART128_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 89 | static PART128_SYMBOLS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 90 | static PART128_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 90 | 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()) | ||
| 91 | } | 99 | } |
| 92 | 100 | ||
| 93 | /// Current value of [`PART128_SYMBOLS`]. | 101 | /// Current value of [`PART128_SYMBOLS`]. |
| @@ -11778,16 +11786,33 @@ fn read_sb128_root( | |||
| 11778 | } | 11786 | } |
| 11779 | p | 11787 | p |
| 11780 | } else { | 11788 | } 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)); | ||
| 11781 | match (has_cols128, has_rows128) { | 11796 | match (has_cols128, has_rows128) { |
| 11782 | (true, false) => { | 11797 | (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 | + } | ||
| 11784 | } | 11803 | } |
| 11785 | (false, true) => { | 11804 | (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 | ||
| 11787 | } | 11814 | } |
| 11788 | - _ => {} | ||
| 11789 | } | 11815 | } |
| 11790 | - PARTITION_SPLIT | ||
| 11791 | }; | 11816 | }; |
| 11792 | if part128 != PARTITION_SPLIT { | 11817 | if part128 != PARTITION_SPLIT { |
| 11793 | return Err(unsupported( | 11818 | return Err(unsupported( |
crates/ec-av1/src/stream.rsmodified+16 -2
| @@ -1110,7 +1110,8 @@ mod tests { | |||
| 1110 | let mut child = Command::new(aomenc_path()) | 1110 | let mut child = Command::new(aomenc_path()) |
| 1111 | .args([ | 1111 | .args([ |
| 1112 | "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | 1112 | "--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", | ||
| 1114 | "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", | 1115 | "--threads=1", "--row-mt=0", "--obu", "-o", "-", "-", |
| 1115 | ]) | 1116 | ]) |
| 1116 | .stdin(Stdio::piped()) | 1117 | .stdin(Stdio::piped()) |
| @@ -1141,12 +1142,25 @@ mod tests { | |||
| 1141 | assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock"); | 1142 | assert!(sb128, "aomenc ignored --sb-size=128: this stream is 64x64-superblock"); |
| 1142 | 1143 | ||
| 1143 | let _guard = lock_gate_counters(); | 1144 | let _guard = lock_gate_counters(); |
| 1145 | + let before = crate::decode::part128_symbols() | ||
| 1146 | + + crate::decode::part128_gathered_symbols(); | ||
| 1144 | let (frames, hidden) = | 1147 | let (frames, hidden) = |
| 1145 | decode_all_frames_vs_oracle(&stream, "sb128-oddh-64x72"); | 1148 | decode_all_frames_vs_oracle(&stream, "sb128-oddh-64x72"); |
| 1146 | assert!(frames > 0, "no frames decoded for {width}x{height}"); | 1149 | 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 | + ); | ||
| 1147 | eprintln!( | 1160 | eprintln!( |
| 1148 | "a_real_aomenc_128x128_superblock_stream_decodes_pixel_exact: \ | 1161 | "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}" | ||
| 1150 | ); | 1164 | ); |
| 1151 | } | 1165 | } |
| 1152 | 1166 | ||