Lane-av1444edge -- the two 4:4:4 lossy cells the chroma-format sweep left unassigned
Browse files at this commit5aa9f3df2e466e7b2ada33d47f9f334bd2eab59fParent: 84fa44c- test
- lane-av1444edge -- the two 4:4:4 lossy cells the chroma-format sweep left unassigned
3 changed files +142 -0
- crates/ec-av1/fixtures/444_lossy_rect4_odd_130x122.obu +0 -0
- crates/ec-av1/fixtures/444_lossy_rect4_wide_256x128.obu +0 -0
- crates/ec-av1/src/stream.rs +142 -0
crates/ec-av1/fixtures/444_lossy_rect4_odd_130x122.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/444_lossy_rect4_wide_256x128.obuadded+0 -0
Binary file changed
crates/ec-av1/src/stream.rsmodified+142 -0
| @@ -7108,6 +7108,148 @@ pub(crate) mod tests { | |||
| 7108 | eprintln!("{NAME}: 4:2:0 control {h4} HORZ_4 / {v4} VERT_4 strips, 0 own-extent gathers"); | 7108 | eprintln!("{NAME}: 4:2:0 control {h4} HORZ_4 / {v4} VERT_4 strips, 0 own-extent gathers"); |
| 7109 | } | 7109 | } |
| 7110 | 7110 | ||
| 7111 | + /// lane-av1444edge: the two 4:4:4 lossy cells the chroma-format sweep | ||
| 7112 | + /// (§6.2) left as "unassigned, neither reduces to a known class". They | ||
| 7113 | + /// are one class, and it is the sibling gate's: a 1:4 (HORZ_4 / VERT_4) | ||
| 7114 | + /// inter strip's chroma coefficient context gathered at the 4:2:0 PAIR | ||
| 7115 | + /// extent at ss (0,0), where `is_chroma_reference` | ||
| 7116 | + /// (av1_common_int.h:1454) makes every block its own chroma reference so | ||
| 7117 | + /// no pair exists. What these two add is the geometry and the depth the | ||
| 7118 | + /// sibling's 128x96 gate does not reach. | ||
| 7119 | + /// | ||
| 7120 | + /// **Arm A -- partial-frame right edge, 130x122.** Neither dimension is a | ||
| 7121 | + /// multiple of 8 (the sweep's own odd-dimension gate covers 4:2:0 only, so | ||
| 7122 | + /// the 4:4:4 partial-column walk had no exactness evidence), and 66x66 is | ||
| 7123 | + /// EXACT at the same settings, so the walk is right at one odd geometry | ||
| 7124 | + /// and wrong at another. Arm B -- 256x128, 4 frames, with CDEF and loop | ||
| 7125 | + /// restoration both live on the last two frames. | ||
| 7126 | + /// | ||
| 7127 | + /// **The recipes** (the sweep's, byte-reproduced -- the truncated sha256 | ||
| 7128 | + /// prefixes it recorded, `c87ac65b…` and `06621606…`, match): | ||
| 7129 | + /// ```text | ||
| 7130 | + /// ffmpeg -f lavfi -i "testsrc2=size=<W>x<H>:rate=25" -frames:v 4 \ | ||
| 7131 | + /// -pix_fmt yuv444p -strict -1 -f yuv4mpegpipe - | \ | ||
| 7132 | + /// aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 \ | ||
| 7133 | + /// --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 \ | ||
| 7134 | + /// --limit=4 --obu -o - - | ||
| 7135 | + /// ``` | ||
| 7136 | + /// (`rate=25` is load-bearing for the same reason as the sibling gate: | ||
| 7137 | + /// `testsrc2`'s pattern is time-parameterised.) | ||
| 7138 | + /// | ||
| 7139 | + /// Red before the fix, both arms: arm A frame 3, 11521 samples, first at | ||
| 7140 | + /// Y(128,16) (ours 134, oracle 170); arm B frame 2, 25296 samples, first | ||
| 7141 | + /// at Y(192,0) (ours 92, oracle 106), frame 3 51108 more. The | ||
| 7142 | + /// pre-loop-filter reconstruction already carries the identical first | ||
| 7143 | + /// wrong sample on both, so no filter is involved; in arm B the first | ||
| 7144 | + /// wrong superblock in DECODE order is SBcol2/SBrow0 (first wrong pixel | ||
| 7145 | + /// (128,48) = mi(12,32), whose mode/ref/mv are identical on both sides), | ||
| 7146 | + /// and the arithmetic fork lands on the very next block, mi(13,32), where | ||
| 7147 | + /// the oracle reads ref0 = LAST and we read GOLDEN. | ||
| 7148 | + /// | ||
| 7149 | + /// Non-vacuity, three ways per arm: the pinned bytes (length + FNV-1a); | ||
| 7150 | + /// the decoded chroma planes are full resolution, which is the ss (0,0) | ||
| 7151 | + /// shape claim; and `decode::rect4_inter_own_chroma444_hits()` must be | ||
| 7152 | + /// non-zero AND `inter16_rect4_counters()` must report 1:4 inter strips, | ||
| 7153 | + /// so the corrected route is known to have run rather than the gate | ||
| 7154 | + /// passing on a stream that never reached it. | ||
| 7155 | + #[test] | ||
| 7156 | + fn a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries() { | ||
| 7157 | + const NAME: &str = | ||
| 7158 | + "a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries"; | ||
| 7159 | + // (fixture, len, fnv1a64, width, height, strips HORZ_4 + VERT_4) | ||
| 7160 | + const ARMS: [(&str, usize, u64, usize, usize, usize); 2] = [ | ||
| 7161 | + ( | ||
| 7162 | + "fixtures/444_lossy_rect4_odd_130x122.obu", | ||
| 7163 | + 8945, | ||
| 7164 | + 0x5125_0554_751c_bf12, | ||
| 7165 | + 130, | ||
| 7166 | + 122, | ||
| 7167 | + 28, // measured 8 HORZ_4 + 20 VERT_4 | ||
| 7168 | + ), | ||
| 7169 | + ( | ||
| 7170 | + "fixtures/444_lossy_rect4_wide_256x128.obu", | ||
| 7171 | + 15239, | ||
| 7172 | + 0xf94a_0218_bb34_4f9e, | ||
| 7173 | + 256, | ||
| 7174 | + 128, | ||
| 7175 | + 76, // measured 60 HORZ_4 + 16 VERT_4 | ||
| 7176 | + ), | ||
| 7177 | + ]; | ||
| 7178 | + let _guard = lock_gate_counters(); | ||
| 7179 | + for (fixture, len, fnv, w, h, min_strips) in ARMS { | ||
| 7180 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture); | ||
| 7181 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | ||
| 7182 | + panic!( | ||
| 7183 | + "{NAME}: pinned fixture {} is missing ({e}) -- the gate cannot \ | ||
| 7184 | + run, which is a failure, not a skip", | ||
| 7185 | + obu.display() | ||
| 7186 | + ) | ||
| 7187 | + }); | ||
| 7188 | + assert_eq!(stream.len(), len, "{NAME}: {fixture} length moved"); | ||
| 7189 | + assert_eq!(fnv1a64(&stream), fnv, "{NAME}: {fixture} bytes moved"); | ||
| 7190 | + | ||
| 7191 | + // The 1:4-strip counters are process-wide with no reset, so read | ||
| 7192 | + // them as a DELTA: a full-suite run has already put 1:4 strips | ||
| 7193 | + // through the decoder by the time this test starts, and an | ||
| 7194 | + // absolute count would be a non-vacuity assertion that passes on | ||
| 7195 | + // residue from another stream. | ||
| 7196 | + let before_strips = { | ||
| 7197 | + let (h, v, _, _) = crate::decode::inter16_rect4_counters(); | ||
| 7198 | + h + v | ||
| 7199 | + }; | ||
| 7200 | + crate::decode::reset_rect4_inter_own_chroma444_hits(); | ||
| 7201 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 7202 | + panic!("{NAME}: {fixture} no longer decodes cleanly: {e}") | ||
| 7203 | + }); | ||
| 7204 | + let own_chroma = crate::decode::rect4_inter_own_chroma444_hits(); | ||
| 7205 | + let strips = { | ||
| 7206 | + let (h, v, _, _) = crate::decode::inter16_rect4_counters(); | ||
| 7207 | + h + v - before_strips | ||
| 7208 | + }; | ||
| 7209 | + assert!( | ||
| 7210 | + strips >= min_strips, | ||
| 7211 | + "{NAME}: {fixture} coded only {strips} 1:4 inter strips \ | ||
| 7212 | + (HORZ_4 + VERT_4), expected about {min_strips} -- the stream \ | ||
| 7213 | + moved, and the route this gate witnesses may no longer be on it" | ||
| 7214 | + ); | ||
| 7215 | + assert!( | ||
| 7216 | + own_chroma > 0, | ||
| 7217 | + "{NAME}: {fixture} ran no 1:4 inter strip over its own chroma \ | ||
| 7218 | + extent -- the corrected route never ran (class \ | ||
| 7219 | + gate-blind-to-feature)" | ||
| 7220 | + ); | ||
| 7221 | + assert_eq!(frames.len(), 4, "{NAME}: {fixture} frame count"); | ||
| 7222 | + for (i, f) in frames.iter().enumerate() { | ||
| 7223 | + assert_eq!( | ||
| 7224 | + (f.width, f.height), | ||
| 7225 | + (w, h), | ||
| 7226 | + "{NAME}: {fixture} frame {i} dimensions" | ||
| 7227 | + ); | ||
| 7228 | + // At 4:4:4 the chroma planes are full resolution; a decoder | ||
| 7229 | + // that kept the 4:2:0 extent would hand quarter-size chroma | ||
| 7230 | + // planes to the byte compare, which cannot pass. Say it here | ||
| 7231 | + // rather than let the compare stand in for the shape claim. | ||
| 7232 | + assert_eq!( | ||
| 7233 | + f.u.len(), | ||
| 7234 | + w * h, | ||
| 7235 | + "{NAME}: {fixture} frame {i} chroma plane is {} samples; at \ | ||
| 7236 | + 4:4:4 it must be full resolution ({w}x{h})", | ||
| 7237 | + f.u.len() | ||
| 7238 | + ); | ||
| 7239 | + } | ||
| 7240 | + if aomdec_path().is_file() { | ||
| 7241 | + let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME); | ||
| 7242 | + eprintln!( | ||
| 7243 | + "{NAME}: {fixture} {decoded} decode-order frame(s) \ | ||
| 7244 | + ({hidden} hidden) byte-exact vs aomdec, {own_chroma} own-extent \ | ||
| 7245 | + 1:4 chroma gather(s), {strips} 1:4 inter strip(s)" | ||
| 7246 | + ); | ||
| 7247 | + } else { | ||
| 7248 | + eprintln!("{NAME}: {fixture}: no oracle aomdec, pixel arm skipped"); | ||
| 7249 | + } | ||
| 7250 | + } | ||
| 7251 | + } | ||
| 7252 | + | ||
| 7111 | /// lane-av1lrflush: the pipelined loop-restoration band release flushes | 7253 | /// lane-av1lrflush: the pipelined loop-restoration band release flushes |
| 7112 | /// RU row 0 on the inter frame whose top superblock row carries a | 7254 | /// RU row 0 on the inter frame whose top superblock row carries a |
| 7113 | /// 128-root rect -- the exact shape lanes/av1444sb.report.md r2 named as | 7255 | /// 128-root rect -- the exact shape lanes/av1444sb.report.md r2 named as |