Lane-av1superhbd -- 4:4:4 superres at 10 and 12 bits, measured exact
Browse files at this commita6c679e7f70987c101b0830bf07aa753659f5fddParent: a460dca- test
- lane-av1superhbd -- 4:4:4 superres at 10 and 12 bits, measured exact
6 changed files +409 -0
- crates/ec-av1/fixtures/444_lossy_superres_256x128_d12_10bit.obu +0 -0
- crates/ec-av1/fixtures/444_lossy_superres_256x128_d12_12bit.obu +0 -0
- crates/ec-av1/fixtures/444_lossy_superres_256x128_d9_12bit.obu +0 -0
- crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128_10bit.obu +0 -0
- crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128_12bit.obu +0 -0
- crates/ec-av1/src/stream.rs +409 -0
crates/ec-av1/fixtures/444_lossy_superres_256x128_d12_10bit.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/444_lossy_superres_256x128_d12_12bit.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/444_lossy_superres_256x128_d9_12bit.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128_10bit.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/444_lossy_superres_mode2_256x128_12bit.obuadded+0 -0
Binary file changed
crates/ec-av1/src/stream.rsmodified+409 -0
| @@ -13169,6 +13169,415 @@ pub(crate) mod tests { | |||
| 13169 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | 13169 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); |
| 13170 | } | 13170 | } |
| 13171 | 13171 | ||
| 13172 | + /// Shared body for the lane-av1superhbd HIGH-BIT-DEPTH 4:4:4 superres | ||
| 13173 | + /// arms: 10-bit and 12-bit, `--superres-mode=1` at a fixed denominator | ||
| 13174 | + /// and `--superres-mode=2` (a per-frame denominator libaom picks itself). | ||
| 13175 | + /// | ||
| 13176 | + /// Everything the 8-bit 4:4:4 superres cell is non-vacuous by, repeated | ||
| 13177 | + /// here, plus the one thing that only matters above 8 bits: the gate | ||
| 13178 | + /// asserts the PARSED `bit_depth` equals the depth it names, because a | ||
| 13179 | + /// 10-bit recipe whose flags were mistyped still decodes -- it just | ||
| 13180 | + /// decodes a DIFFERENT cell than the gate claims, which is the same | ||
| 13181 | + /// "phantom cell" trap lane-av1444edge r3 recorded for | ||
| 13182 | + /// `use_superres=false`. | ||
| 13183 | + /// | ||
| 13184 | + /// The per-frame table is `(denominator, coded_width)` in DECODE order. | ||
| 13185 | + /// The coded width is re-derived as `(UpscaledWidth*8 + denom/2)/denom` | ||
| 13186 | + /// from that frame's OWN parsed denominator rather than only compared to | ||
| 13187 | + /// a literal, so a re-pinned fixture cannot satisfy the literals while | ||
| 13188 | + /// the scaled-size arithmetic moves under them. `superres_hits` and | ||
| 13189 | + /// `predict_scaled_hits` are asserted as DELTAS (both are process-wide | ||
| 13190 | + /// counters with no reset). | ||
| 13191 | + #[allow(clippy::too_many_arguments)] | ||
| 13192 | + fn a_444_hbd_superres_arm( | ||
| 13193 | + name: &str, | ||
| 13194 | + fixture: &str, | ||
| 13195 | + fixture_len: usize, | ||
| 13196 | + fixture_fnv: u64, | ||
| 13197 | + fixture_sha: &str, | ||
| 13198 | + bit_depth: u8, | ||
| 13199 | + upscaled: (usize, usize), | ||
| 13200 | + per_frame: &[(u8, usize)], | ||
| 13201 | + ) -> Vec<FrameHeader> { | ||
| 13202 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture); | ||
| 13203 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | ||
| 13204 | + panic!( | ||
| 13205 | + "{name}: pinned fixture {fixture} is missing ({e}) -- the gate cannot run, \ | ||
| 13206 | + which is a failure, not a skip" | ||
| 13207 | + ) | ||
| 13208 | + }); | ||
| 13209 | + assert_eq!(stream.len(), fixture_len, "{name}: fixture length moved"); | ||
| 13210 | + assert_eq!(fnv1a64(&stream), fixture_fnv, "{name}: fixture bytes moved"); | ||
| 13211 | + | ||
| 13212 | + // --- the header facts the CELL depends on, parsed not assumed ------ | ||
| 13213 | + let mut parser = Av1Parser::new(); | ||
| 13214 | + let mut pos = 0usize; | ||
| 13215 | + let mut seq = None; | ||
| 13216 | + let mut heads: Vec<FrameHeader> = Vec::new(); | ||
| 13217 | + while pos < stream.len() { | ||
| 13218 | + let parsed = parser | ||
| 13219 | + .parse_obu(&stream[pos..]) | ||
| 13220 | + .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}")); | ||
| 13221 | + if parsed.total_size == 0 { | ||
| 13222 | + break; | ||
| 13223 | + } | ||
| 13224 | + pos += parsed.total_size; | ||
| 13225 | + match parsed.kind { | ||
| 13226 | + ObuKind::SequenceHeader(s) => seq = Some(s), | ||
| 13227 | + ObuKind::FrameHeader(h) => heads.push(*h), | ||
| 13228 | + ObuKind::Frame(h, _) => heads.push(*h), | ||
| 13229 | + _ => {} | ||
| 13230 | + } | ||
| 13231 | + } | ||
| 13232 | + let seq = seq.unwrap_or_else(|| panic!("{name}: the stream carries no sequence header")); | ||
| 13233 | + assert_eq!( | ||
| 13234 | + ( | ||
| 13235 | + seq.color_config.subsampling_x, | ||
| 13236 | + seq.color_config.subsampling_y | ||
| 13237 | + ), | ||
| 13238 | + (0, 0), | ||
| 13239 | + "{name}: the stream is not 4:4:4 (ss = ({}, {}))", | ||
| 13240 | + seq.color_config.subsampling_x, | ||
| 13241 | + seq.color_config.subsampling_y | ||
| 13242 | + ); | ||
| 13243 | + // The high-bit-depth claim itself. A `--bit-depth` flag that silently | ||
| 13244 | + // did not take effect still produces a decodable 4:4:4 superres | ||
| 13245 | + // stream -- at 8 bits -- and every other assertion below would pass. | ||
| 13246 | + assert_eq!( | ||
| 13247 | + seq.color_config.bit_depth, bit_depth, | ||
| 13248 | + "{name}: the sequence header parses bit_depth {}, not the {bit_depth} this gate \ | ||
| 13249 | + names -- the encoder flags did not take effect and this is a different cell", | ||
| 13250 | + seq.color_config.bit_depth | ||
| 13251 | + ); | ||
| 13252 | + assert!( | ||
| 13253 | + seq.enable_superres, | ||
| 13254 | + "{name}: the sequence header does not enable superres at all" | ||
| 13255 | + ); | ||
| 13256 | + assert_eq!( | ||
| 13257 | + heads.len(), | ||
| 13258 | + per_frame.len(), | ||
| 13259 | + "{name}: {} frame headers, expected {}", | ||
| 13260 | + heads.len(), | ||
| 13261 | + per_frame.len() | ||
| 13262 | + ); | ||
| 13263 | + for (i, (h, (denom, coded))) in heads.iter().zip(per_frame).enumerate() { | ||
| 13264 | + assert!( | ||
| 13265 | + h.use_superres, | ||
| 13266 | + "{name}: frame {i} has use_superres = false -- this is an UNSCALED stream and \ | ||
| 13267 | + the gate would measure something other than the cell it names (class \ | ||
| 13268 | + gate-blind-to-feature)" | ||
| 13269 | + ); | ||
| 13270 | + assert_eq!( | ||
| 13271 | + h.superres_denom, *denom, | ||
| 13272 | + "{name}: frame {i} PARSED denominator moved from {denom} -- read the header, \ | ||
| 13273 | + never the encoder flag (mode 2 chooses its own)" | ||
| 13274 | + ); | ||
| 13275 | + assert_eq!( | ||
| 13276 | + (h.upscaled_width as usize, h.frame_height as usize), | ||
| 13277 | + upscaled, | ||
| 13278 | + "{name}: frame {i} upscaled size moved" | ||
| 13279 | + ); | ||
| 13280 | + assert_eq!( | ||
| 13281 | + (h.frame_width as usize, h.frame_height as usize), | ||
| 13282 | + (*coded, upscaled.1), | ||
| 13283 | + "{name}: frame {i} CODED size moved -- this is the scaled half of the cell and \ | ||
| 13284 | + the part an unsized stream gets wrong" | ||
| 13285 | + ); | ||
| 13286 | + let d = u32::from(*denom); | ||
| 13287 | + assert_eq!( | ||
| 13288 | + (h.upscaled_width * 8 + d / 2) / d, | ||
| 13289 | + h.frame_width, | ||
| 13290 | + "{name}: frame {i}: FrameWidth is not (UpscaledWidth*8 + denom/2)/denom -- the \ | ||
| 13291 | + scaled size the cell rests on is not the spec's" | ||
| 13292 | + ); | ||
| 13293 | + } | ||
| 13294 | + | ||
| 13295 | + // --- the pixels ----------------------------------------------------- | ||
| 13296 | + let _guard = lock_gate_counters(); | ||
| 13297 | + let before_sr = crate::superres::superres_hits(); | ||
| 13298 | + let before_scaled = crate::mc::predict_scaled_hits(); | ||
| 13299 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 13300 | + panic!("{name}: the pinned {bit_depth}-bit 4:4:4 superres stream was refused: {e}") | ||
| 13301 | + }); | ||
| 13302 | + let scaled_up = crate::superres::superres_hits() - before_sr; | ||
| 13303 | + let scaled_mc = crate::mc::predict_scaled_hits() - before_scaled; | ||
| 13304 | + assert!( | ||
| 13305 | + scaled_up > 0, | ||
| 13306 | + "{name}: zero superres_hits -- the upscaler never ran (class gate-blind-to-feature)" | ||
| 13307 | + ); | ||
| 13308 | + assert!( | ||
| 13309 | + scaled_mc > 0, | ||
| 13310 | + "{name}: zero predict_scaled_hits -- no inter block read a scaled reference, so the \ | ||
| 13311 | + scaled-PREDICTION half of the cell is unexercised (class gate-blind-to-feature)" | ||
| 13312 | + ); | ||
| 13313 | + assert_eq!(frames.len(), per_frame.len(), "{name}: decoded frame count"); | ||
| 13314 | + let max = (1u32 << bit_depth) - 1; | ||
| 13315 | + for (i, f) in frames.iter().enumerate() { | ||
| 13316 | + assert_eq!( | ||
| 13317 | + (f.width, f.height), | ||
| 13318 | + upscaled, | ||
| 13319 | + "{name}: frame {i} came back {}x{}, not the UPSCALED {}x{}", | ||
| 13320 | + f.width, | ||
| 13321 | + f.height, | ||
| 13322 | + upscaled.0, | ||
| 13323 | + upscaled.1 | ||
| 13324 | + ); | ||
| 13325 | + for (plane, samples) in [("Y", &f.y), ("U", &f.u), ("V", &f.v)] { | ||
| 13326 | + assert_eq!( | ||
| 13327 | + samples.len(), | ||
| 13328 | + upscaled.0 * upscaled.1, | ||
| 13329 | + "{name}: frame {i} {plane} plane is {} samples; at 4:4:4 upscaled it must be \ | ||
| 13330 | + full resolution ({}x{})", | ||
| 13331 | + samples.len(), | ||
| 13332 | + upscaled.0, | ||
| 13333 | + upscaled.1 | ||
| 13334 | + ); | ||
| 13335 | + // The depth claim, on the pixels: a decoder that lost the | ||
| 13336 | + // high bits (or produced 8-bit values padded into a u16 | ||
| 13337 | + // plane) would satisfy every length and geometry assert above | ||
| 13338 | + // and only be caught here. | ||
| 13339 | + assert!( | ||
| 13340 | + samples.iter().all(|&s| u32::from(s) <= max), | ||
| 13341 | + "{name}: frame {i} {plane} carries a sample above the {bit_depth}-bit \ | ||
| 13342 | + maximum {max} -- the bit depth of the OUTPUT does not match the header" | ||
| 13343 | + ); | ||
| 13344 | + } | ||
| 13345 | + } | ||
| 13346 | + if aomdec_path().is_file() { | ||
| 13347 | + let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, name); | ||
| 13348 | + eprintln!( | ||
| 13349 | + "{name}: {decoded} decode-order frame(s) ({hidden} hidden) byte-exact vs aomdec \ | ||
| 13350 | + at {bit_depth}-bit {upscaled:?} upscaled from {per_frame:?} (denominator, coded \ | ||
| 13351 | + width) per frame, {scaled_up} upscale(s), {scaled_mc} scaled MC block(s); \ | ||
| 13352 | + fixture sha256 {fixture_sha}" | ||
| 13353 | + ); | ||
| 13354 | + } else { | ||
| 13355 | + eprintln!("{name}: no oracle aomdec, pixel arm skipped"); | ||
| 13356 | + } | ||
| 13357 | + heads | ||
| 13358 | + } | ||
| 13359 | + | ||
| 13360 | + /// lane-av1superhbd (1): 4:4:4 superres at **10 bits**, `--superres-mode=1 | ||
| 13361 | + /// --superres-denominator=12` on all four frames -- coded 171x128 upscaled | ||
| 13362 | + /// to 256x128 at `denom = 12`. | ||
| 13363 | + /// | ||
| 13364 | + /// **What it closes.** Every superres fixture the crate carried parsed | ||
| 13365 | + /// `bit_depth = 8` (4:2:0 `superres_kf_cdef_lr_64x64.obu`) or was 4:2:0 | ||
| 13366 | + /// (`superres_alltools_sb128_320x180.obu`), and the 4:4:4 superres cells | ||
| 13367 | + /// were 8-bit. The chroma-format sweep's not-measured list kept "4:4:4 | ||
| 13368 | + /// superres at 10/12 bits" open on that basis. This arm is the 10-bit | ||
| 13369 | + /// measurement: a 4:4:4 chroma plane upscaled at FULL resolution, where | ||
| 13370 | + /// the upscaler and the scaled inter predictor both run with a | ||
| 13371 | + /// 10-bit sample width and the 4:4:4 chroma gather has no subsampling | ||
| 13372 | + /// halving to hide behind. | ||
| 13373 | + /// | ||
| 13374 | + /// **The recipe** (sha256 | ||
| 13375 | + /// `95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223`, | ||
| 13376 | + /// 15803 bytes, 4 frames, `testsrc2 256x128 rate=25` yuv444p10le): | ||
| 13377 | + /// ```text | ||
| 13378 | + /// ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \ | ||
| 13379 | + /// -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \ | ||
| 13380 | + /// aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \ | ||
| 13381 | + /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | ||
| 13382 | + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | ||
| 13383 | + /// --superres-mode=1 --superres-denominator=12 \ | ||
| 13384 | + /// --superres-kf-denominator=12 --obu -o - - | ||
| 13385 | + /// ``` | ||
| 13386 | + /// `-strict -1` is load-bearing: without it ffmpeg refuses to write | ||
| 13387 | + /// `yuv444p10le` into a y4m pipe at all (zero bytes out). | ||
| 13388 | + #[test] | ||
| 13389 | + fn a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact() { | ||
| 13390 | + a_444_hbd_superres_arm( | ||
| 13391 | + "a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact", | ||
| 13392 | + "fixtures/444_lossy_superres_256x128_d12_10bit.obu", | ||
| 13393 | + 15803, | ||
| 13394 | + 0x9fad_3227_6e91_792c, | ||
| 13395 | + "95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223", | ||
| 13396 | + 10, | ||
| 13397 | + (256, 128), | ||
| 13398 | + &[(12, 171); 4], | ||
| 13399 | + ); | ||
| 13400 | + } | ||
| 13401 | + | ||
| 13402 | + /// lane-av1superhbd (2): 4:4:4 superres at **12 bits**, | ||
| 13403 | + /// `--superres-mode=1 --superres-denominator=12`, coded 171x128 upscaled | ||
| 13404 | + /// to 256x128. | ||
| 13405 | + /// | ||
| 13406 | + /// **Why the source is `mandelbrot` and not `testsrc2`.** The 12-bit | ||
| 13407 | + /// frame gate refuses a frame carrying `allow_screen_content_tools = 1` | ||
| 13408 | + /// by name (palette and intrabc have no 12-bit witness). libaom sets | ||
| 13409 | + /// that bit from its own content detection | ||
| 13410 | + /// (`av1_set_screen_content_options` -> `encoder_utils.c:1153`, keyed on | ||
| 13411 | + /// the palette-pixel ratio of the FIRST pass), and `testsrc2` -- flat | ||
| 13412 | + /// colour bars and hard edges -- trips it at 12 bits while the very same | ||
| 13413 | + /// recipe at 10 bits does not. `--enable-palette=0 --enable-intrabc=0` | ||
| 13414 | + /// and `--tune-content=film` do NOT suppress it (measured: all four | ||
| 13415 | + /// still parse `allow_screen_content_tools = true`), because the | ||
| 13416 | + /// detection is a property of the CONTENT, not of those flags. A | ||
| 13417 | + /// photographic source (`mandelbrot`, same geometry and frame count) | ||
| 13418 | + /// parses `allow_screen_content_tools = false` and decodes. This is a | ||
| 13419 | + /// source choice, stated so the next lane does not re-derive it. | ||
| 13420 | + /// | ||
| 13421 | + /// **The recipe** (sha256 | ||
| 13422 | + /// `973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04`, | ||
| 13423 | + /// 11023 bytes, 4 frames, `mandelbrot 256x128 rate=25` yuv444p12le): | ||
| 13424 | + /// ```text | ||
| 13425 | + /// ffmpeg -f lavfi -i "mandelbrot=size=256x128:rate=25" -frames:v 4 \ | ||
| 13426 | + /// -pix_fmt yuv444p12le -strict -1 -f yuv4mpegpipe - | \ | ||
| 13427 | + /// aomenc --codec=av1 --profile=1 --bit-depth=12 --input-bit-depth=12 \ | ||
| 13428 | + /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | ||
| 13429 | + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | ||
| 13430 | + /// --superres-mode=1 --superres-denominator=12 \ | ||
| 13431 | + /// --superres-kf-denominator=12 --obu -o - - | ||
| 13432 | + /// ``` | ||
| 13433 | + /// Byte-reproducible: two independent encodes produced the same 11023 | ||
| 13434 | + /// bytes. | ||
| 13435 | + #[test] | ||
| 13436 | + fn a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact() { | ||
| 13437 | + a_444_hbd_superres_arm( | ||
| 13438 | + "a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact", | ||
| 13439 | + "fixtures/444_lossy_superres_256x128_d12_12bit.obu", | ||
| 13440 | + 11023, | ||
| 13441 | + 0xd6cf_bb83_2b42_8e2d, | ||
| 13442 | + "973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04", | ||
| 13443 | + 12, | ||
| 13444 | + (256, 128), | ||
| 13445 | + &[(12, 171); 4], | ||
| 13446 | + ); | ||
| 13447 | + } | ||
| 13448 | + | ||
| 13449 | + /// lane-av1superhbd (3): 4:4:4 superres at **12 bits** at the WIDEST | ||
| 13450 | + /// denominator this geometry allows, `--superres-denominator=9` -- coded | ||
| 13451 | + /// 228x128 upscaled to 256x128, so 28 of the 256 columns are the frame's | ||
| 13452 | + /// right-edge upscale margin, against 12's 85. | ||
| 13453 | + /// | ||
| 13454 | + /// It is a separate gate from the den=12 arm because the margin is | ||
| 13455 | + /// where a round-trip is most likely to read past the coded picture: a | ||
| 13456 | + /// decoder that sized the upscale source from `UpscaledWidth` instead of | ||
| 13457 | + /// `FrameWidth` is exact at den=12 on this content and wrong here. Its | ||
| 13458 | + /// recipe is the 12-bit one above with `--superres-denominator=9 | ||
| 13459 | + /// --superres-kf-denominator=9` (sha256 | ||
| 13460 | + /// `898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99`, | ||
| 13461 | + /// 13015 bytes). | ||
| 13462 | + #[test] | ||
| 13463 | + fn a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact() { | ||
| 13464 | + a_444_hbd_superres_arm( | ||
| 13465 | + "a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact", | ||
| 13466 | + "fixtures/444_lossy_superres_256x128_d9_12bit.obu", | ||
| 13467 | + 13015, | ||
| 13468 | + 0x4110_ce7b_cd85_901b, | ||
| 13469 | + "898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99", | ||
| 13470 | + 12, | ||
| 13471 | + (256, 128), | ||
| 13472 | + &[(9, 228); 4], | ||
| 13473 | + ); | ||
| 13474 | + } | ||
| 13475 | + | ||
| 13476 | + /// lane-av1superhbd (4): 4:4:4 superres at **10 bits** under | ||
| 13477 | + /// `--superres-mode=2` -- the random-denominator arm, where libaom picks | ||
| 13478 | + /// a DIFFERENT denominator for every frame and IGNORES | ||
| 13479 | + /// `--superres-denominator` entirely. | ||
| 13480 | + /// | ||
| 13481 | + /// This is what keeps the high-bit-depth superres cell from silently | ||
| 13482 | + /// degenerating into a single-denominator cell: the per-frame parsed | ||
| 13483 | + /// denominators are 11, 14, 15, 9 -- three of them values no flag on the | ||
| 13484 | + /// command line ever named -- so a gate that read the flag instead of | ||
| 13485 | + /// the header would be wrong on three of four frames. The assertion | ||
| 13486 | + /// below makes that structural rather than incidental, and it is the | ||
| 13487 | + /// assertion that fails if a future libaom starts honouring the flag | ||
| 13488 | + /// under mode 2. | ||
| 13489 | + /// | ||
| 13490 | + /// **The recipe** (sha256 | ||
| 13491 | + /// `699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668`, | ||
| 13492 | + /// 17776 bytes, 4 frames, `testsrc2 256x128 rate=25` yuv444p10le): | ||
| 13493 | + /// ```text | ||
| 13494 | + /// ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \ | ||
| 13495 | + /// -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \ | ||
| 13496 | + /// aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \ | ||
| 13497 | + /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | ||
| 13498 | + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | ||
| 13499 | + /// --superres-mode=2 --obu -o - - | ||
| 13500 | + /// ``` | ||
| 13501 | + #[test] | ||
| 13502 | + fn a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact() { | ||
| 13503 | + const NAME: &str = | ||
| 13504 | + "a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact"; | ||
| 13505 | + let heads = a_444_hbd_superres_arm( | ||
| 13506 | + NAME, | ||
| 13507 | + "fixtures/444_lossy_superres_mode2_256x128_10bit.obu", | ||
| 13508 | + 17776, | ||
| 13509 | + 0x164f_4099_7576_7ae4, | ||
| 13510 | + "699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668", | ||
| 13511 | + 10, | ||
| 13512 | + (256, 128), | ||
| 13513 | + &[(11, 186), (14, 146), (15, 137), (9, 228)], | ||
| 13514 | + ); | ||
| 13515 | + // Distinct-denominator assert: the cell must stay a MULTI-denominator | ||
| 13516 | + // one. A libaom that collapsed mode 2 onto a single denominator (or | ||
| 13517 | + // stopped scaling) would still decode, and the gate above would still | ||
| 13518 | + // hold only because the literals would have been re-pinned with it -- | ||
| 13519 | + // so the property is asserted from the parsed headers directly. | ||
| 13520 | + let denoms: Vec<u8> = heads.iter().map(|h| h.superres_denom).collect(); | ||
| 13521 | + let mut distinct = denoms.clone(); | ||
| 13522 | + distinct.sort_unstable(); | ||
| 13523 | + distinct.dedup(); | ||
| 13524 | + assert!( | ||
| 13525 | + distinct.len() >= 3, | ||
| 13526 | + "{NAME}: the stream carries denominators {denoms:?} -- fewer than three distinct \ | ||
| 13527 | + values, so this is no longer the per-frame-denominator cell and the pin has to be \ | ||
| 13528 | + re-derived from the stream" | ||
| 13529 | + ); | ||
| 13530 | + let flagged = [9u8, 12, 16]; | ||
| 13531 | + assert!( | ||
| 13532 | + denoms.iter().any(|d| !flagged.contains(d)), | ||
| 13533 | + "{NAME}: every parsed denominator is one of the flag values {flagged:?} -- mode 2 now \ | ||
| 13534 | + appears to honour --superres-denominator, and this cell stops being the \ | ||
| 13535 | + flag-ignoring one" | ||
| 13536 | + ); | ||
| 13537 | + } | ||
| 13538 | + | ||
| 13539 | + /// lane-av1superhbd (5): 4:4:4 superres at **12 bits** under | ||
| 13540 | + /// `--superres-mode=2` -- the high-bit-depth random-denominator arm, the | ||
| 13541 | + /// 12-bit twin of the arm above (sha256 | ||
| 13542 | + /// `18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f`, | ||
| 13543 | + /// 14656 bytes, same `mandelbrot` source as the 12-bit fixed-denominator | ||
| 13544 | + /// arms). Its parsed denominators are again 11/14/15/9 at coded widths | ||
| 13545 | + /// 186/146/137/228, so the upscaler is handed FOUR coded-to-upscaled | ||
| 13546 | + /// ratios in one 12-bit decode -- the case a single-denominator gate | ||
| 13547 | + /// cannot reach at any bit depth. | ||
| 13548 | + #[test] | ||
| 13549 | + fn a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact() { | ||
| 13550 | + const NAME: &str = | ||
| 13551 | + "a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact"; | ||
| 13552 | + let heads = a_444_hbd_superres_arm( | ||
| 13553 | + NAME, | ||
| 13554 | + "fixtures/444_lossy_superres_mode2_256x128_12bit.obu", | ||
| 13555 | + 14656, | ||
| 13556 | + 0xef38_3fb7_b284_2166, | ||
| 13557 | + "18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f", | ||
| 13558 | + 12, | ||
| 13559 | + (256, 128), | ||
| 13560 | + &[(11, 186), (14, 146), (15, 137), (9, 228)], | ||
| 13561 | + ); | ||
| 13562 | + let denoms: Vec<u8> = heads.iter().map(|h| h.superres_denom).collect(); | ||
| 13563 | + let mut distinct = denoms.clone(); | ||
| 13564 | + distinct.sort_unstable(); | ||
| 13565 | + distinct.dedup(); | ||
| 13566 | + assert!( | ||
| 13567 | + distinct.len() >= 3, | ||
| 13568 | + "{NAME}: the stream carries denominators {denoms:?} -- fewer than three distinct \ | ||
| 13569 | + values, so this is no longer the per-frame-denominator cell and the pin has to be \ | ||
| 13570 | + re-derived from the stream" | ||
| 13571 | + ); | ||
| 13572 | + let flagged = [9u8, 12, 16]; | ||
| 13573 | + assert!( | ||
| 13574 | + denoms.iter().any(|d| !flagged.contains(d)), | ||
| 13575 | + "{NAME}: every parsed denominator is one of the flag values {flagged:?} -- mode 2 now \ | ||
| 13576 | + appears to honour --superres-denominator, and this cell stops being the \ | ||
| 13577 | + flag-ignoring one" | ||
| 13578 | + ); | ||
| 13579 | + } | ||
| 13580 | + | ||
| 13172 | /// lane-filt1: `EC_AV1_FILTER_THREADS` splits every in-frame filter stage | 13581 | /// lane-filt1: `EC_AV1_FILTER_THREADS` splits every in-frame filter stage |
| 13173 | /// -- deblock (row bands for the vertical-edge pass, column bands for the | 13582 | /// -- deblock (row bands for the vertical-edge pass, column bands for the |
| 13174 | /// horizontal one), CDEF (mi row bands), loop restoration (RU row bands) | 13583 | /// horizontal one), CDEF (mi row bands), loop restoration (RU row bands) |