Merge lane-av1superhbd @ a2da03e4 — 4:4:4 superres at 10 and 12 bits, measured exact
Browse files at this commit7 changed files +642 -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
- lanes/av1superhbd.report.md +233 -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
| @@ -13878,6 +13878,415 @@ pub(crate) mod tests { | ||
| 13878 | 13878 | assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); |
| 13879 | 13879 | } |
| 13880 | 13880 | |
| 13881 | + /// Shared body for the lane-av1superhbd HIGH-BIT-DEPTH 4:4:4 superres | |
| 13882 | + /// arms: 10-bit and 12-bit, `--superres-mode=1` at a fixed denominator | |
| 13883 | + /// and `--superres-mode=2` (a per-frame denominator libaom picks itself). | |
| 13884 | + /// | |
| 13885 | + /// Everything the 8-bit 4:4:4 superres cell is non-vacuous by, repeated | |
| 13886 | + /// here, plus the one thing that only matters above 8 bits: the gate | |
| 13887 | + /// asserts the PARSED `bit_depth` equals the depth it names, because a | |
| 13888 | + /// 10-bit recipe whose flags were mistyped still decodes -- it just | |
| 13889 | + /// decodes a DIFFERENT cell than the gate claims, which is the same | |
| 13890 | + /// "phantom cell" trap lane-av1444edge r3 recorded for | |
| 13891 | + /// `use_superres=false`. | |
| 13892 | + /// | |
| 13893 | + /// The per-frame table is `(denominator, coded_width)` in DECODE order. | |
| 13894 | + /// The coded width is re-derived as `(UpscaledWidth*8 + denom/2)/denom` | |
| 13895 | + /// from that frame's OWN parsed denominator rather than only compared to | |
| 13896 | + /// a literal, so a re-pinned fixture cannot satisfy the literals while | |
| 13897 | + /// the scaled-size arithmetic moves under them. `superres_hits` and | |
| 13898 | + /// `predict_scaled_hits` are asserted as DELTAS (both are process-wide | |
| 13899 | + /// counters with no reset). | |
| 13900 | + #[allow(clippy::too_many_arguments)] | |
| 13901 | + fn a_444_hbd_superres_arm( | |
| 13902 | + name: &str, | |
| 13903 | + fixture: &str, | |
| 13904 | + fixture_len: usize, | |
| 13905 | + fixture_fnv: u64, | |
| 13906 | + fixture_sha: &str, | |
| 13907 | + bit_depth: u8, | |
| 13908 | + upscaled: (usize, usize), | |
| 13909 | + per_frame: &[(u8, usize)], | |
| 13910 | + ) -> Vec<FrameHeader> { | |
| 13911 | + let obu = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(fixture); | |
| 13912 | + let stream = std::fs::read(&obu).unwrap_or_else(|e| { | |
| 13913 | + panic!( | |
| 13914 | + "{name}: pinned fixture {fixture} is missing ({e}) -- the gate cannot run, \ | |
| 13915 | + which is a failure, not a skip" | |
| 13916 | + ) | |
| 13917 | + }); | |
| 13918 | + assert_eq!(stream.len(), fixture_len, "{name}: fixture length moved"); | |
| 13919 | + assert_eq!(fnv1a64(&stream), fixture_fnv, "{name}: fixture bytes moved"); | |
| 13920 | + | |
| 13921 | + // --- the header facts the CELL depends on, parsed not assumed ------ | |
| 13922 | + let mut parser = Av1Parser::new(); | |
| 13923 | + let mut pos = 0usize; | |
| 13924 | + let mut seq = None; | |
| 13925 | + let mut heads: Vec<FrameHeader> = Vec::new(); | |
| 13926 | + while pos < stream.len() { | |
| 13927 | + let parsed = parser | |
| 13928 | + .parse_obu(&stream[pos..]) | |
| 13929 | + .unwrap_or_else(|e| panic!("{name}: aomenc OBU does not parse: {e:?}")); | |
| 13930 | + if parsed.total_size == 0 { | |
| 13931 | + break; | |
| 13932 | + } | |
| 13933 | + pos += parsed.total_size; | |
| 13934 | + match parsed.kind { | |
| 13935 | + ObuKind::SequenceHeader(s) => seq = Some(s), | |
| 13936 | + ObuKind::FrameHeader(h) => heads.push(*h), | |
| 13937 | + ObuKind::Frame(h, _) => heads.push(*h), | |
| 13938 | + _ => {} | |
| 13939 | + } | |
| 13940 | + } | |
| 13941 | + let seq = seq.unwrap_or_else(|| panic!("{name}: the stream carries no sequence header")); | |
| 13942 | + assert_eq!( | |
| 13943 | + ( | |
| 13944 | + seq.color_config.subsampling_x, | |
| 13945 | + seq.color_config.subsampling_y | |
| 13946 | + ), | |
| 13947 | + (0, 0), | |
| 13948 | + "{name}: the stream is not 4:4:4 (ss = ({}, {}))", | |
| 13949 | + seq.color_config.subsampling_x, | |
| 13950 | + seq.color_config.subsampling_y | |
| 13951 | + ); | |
| 13952 | + // The high-bit-depth claim itself. A `--bit-depth` flag that silently | |
| 13953 | + // did not take effect still produces a decodable 4:4:4 superres | |
| 13954 | + // stream -- at 8 bits -- and every other assertion below would pass. | |
| 13955 | + assert_eq!( | |
| 13956 | + seq.color_config.bit_depth, bit_depth, | |
| 13957 | + "{name}: the sequence header parses bit_depth {}, not the {bit_depth} this gate \ | |
| 13958 | + names -- the encoder flags did not take effect and this is a different cell", | |
| 13959 | + seq.color_config.bit_depth | |
| 13960 | + ); | |
| 13961 | + assert!( | |
| 13962 | + seq.enable_superres, | |
| 13963 | + "{name}: the sequence header does not enable superres at all" | |
| 13964 | + ); | |
| 13965 | + assert_eq!( | |
| 13966 | + heads.len(), | |
| 13967 | + per_frame.len(), | |
| 13968 | + "{name}: {} frame headers, expected {}", | |
| 13969 | + heads.len(), | |
| 13970 | + per_frame.len() | |
| 13971 | + ); | |
| 13972 | + for (i, (h, (denom, coded))) in heads.iter().zip(per_frame).enumerate() { | |
| 13973 | + assert!( | |
| 13974 | + h.use_superres, | |
| 13975 | + "{name}: frame {i} has use_superres = false -- this is an UNSCALED stream and \ | |
| 13976 | + the gate would measure something other than the cell it names (class \ | |
| 13977 | + gate-blind-to-feature)" | |
| 13978 | + ); | |
| 13979 | + assert_eq!( | |
| 13980 | + h.superres_denom, *denom, | |
| 13981 | + "{name}: frame {i} PARSED denominator moved from {denom} -- read the header, \ | |
| 13982 | + never the encoder flag (mode 2 chooses its own)" | |
| 13983 | + ); | |
| 13984 | + assert_eq!( | |
| 13985 | + (h.upscaled_width as usize, h.frame_height as usize), | |
| 13986 | + upscaled, | |
| 13987 | + "{name}: frame {i} upscaled size moved" | |
| 13988 | + ); | |
| 13989 | + assert_eq!( | |
| 13990 | + (h.frame_width as usize, h.frame_height as usize), | |
| 13991 | + (*coded, upscaled.1), | |
| 13992 | + "{name}: frame {i} CODED size moved -- this is the scaled half of the cell and \ | |
| 13993 | + the part an unsized stream gets wrong" | |
| 13994 | + ); | |
| 13995 | + let d = u32::from(*denom); | |
| 13996 | + assert_eq!( | |
| 13997 | + (h.upscaled_width * 8 + d / 2) / d, | |
| 13998 | + h.frame_width, | |
| 13999 | + "{name}: frame {i}: FrameWidth is not (UpscaledWidth*8 + denom/2)/denom -- the \ | |
| 14000 | + scaled size the cell rests on is not the spec's" | |
| 14001 | + ); | |
| 14002 | + } | |
| 14003 | + | |
| 14004 | + // --- the pixels ----------------------------------------------------- | |
| 14005 | + let _guard = lock_gate_counters(); | |
| 14006 | + let before_sr = crate::superres::superres_hits(); | |
| 14007 | + let before_scaled = crate::mc::predict_scaled_hits(); | |
| 14008 | + let frames = decode_stream(&stream).unwrap_or_else(|e| { | |
| 14009 | + panic!("{name}: the pinned {bit_depth}-bit 4:4:4 superres stream was refused: {e}") | |
| 14010 | + }); | |
| 14011 | + let scaled_up = crate::superres::superres_hits() - before_sr; | |
| 14012 | + let scaled_mc = crate::mc::predict_scaled_hits() - before_scaled; | |
| 14013 | + assert!( | |
| 14014 | + scaled_up > 0, | |
| 14015 | + "{name}: zero superres_hits -- the upscaler never ran (class gate-blind-to-feature)" | |
| 14016 | + ); | |
| 14017 | + assert!( | |
| 14018 | + scaled_mc > 0, | |
| 14019 | + "{name}: zero predict_scaled_hits -- no inter block read a scaled reference, so the \ | |
| 14020 | + scaled-PREDICTION half of the cell is unexercised (class gate-blind-to-feature)" | |
| 14021 | + ); | |
| 14022 | + assert_eq!(frames.len(), per_frame.len(), "{name}: decoded frame count"); | |
| 14023 | + let max = (1u32 << bit_depth) - 1; | |
| 14024 | + for (i, f) in frames.iter().enumerate() { | |
| 14025 | + assert_eq!( | |
| 14026 | + (f.width, f.height), | |
| 14027 | + upscaled, | |
| 14028 | + "{name}: frame {i} came back {}x{}, not the UPSCALED {}x{}", | |
| 14029 | + f.width, | |
| 14030 | + f.height, | |
| 14031 | + upscaled.0, | |
| 14032 | + upscaled.1 | |
| 14033 | + ); | |
| 14034 | + for (plane, samples) in [("Y", &f.y), ("U", &f.u), ("V", &f.v)] { | |
| 14035 | + assert_eq!( | |
| 14036 | + samples.len(), | |
| 14037 | + upscaled.0 * upscaled.1, | |
| 14038 | + "{name}: frame {i} {plane} plane is {} samples; at 4:4:4 upscaled it must be \ | |
| 14039 | + full resolution ({}x{})", | |
| 14040 | + samples.len(), | |
| 14041 | + upscaled.0, | |
| 14042 | + upscaled.1 | |
| 14043 | + ); | |
| 14044 | + // The depth claim, on the pixels: a decoder that lost the | |
| 14045 | + // high bits (or produced 8-bit values padded into a u16 | |
| 14046 | + // plane) would satisfy every length and geometry assert above | |
| 14047 | + // and only be caught here. | |
| 14048 | + assert!( | |
| 14049 | + samples.iter().all(|&s| u32::from(s) <= max), | |
| 14050 | + "{name}: frame {i} {plane} carries a sample above the {bit_depth}-bit \ | |
| 14051 | + maximum {max} -- the bit depth of the OUTPUT does not match the header" | |
| 14052 | + ); | |
| 14053 | + } | |
| 14054 | + } | |
| 14055 | + if aomdec_path().is_file() { | |
| 14056 | + let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, name); | |
| 14057 | + eprintln!( | |
| 14058 | + "{name}: {decoded} decode-order frame(s) ({hidden} hidden) byte-exact vs aomdec \ | |
| 14059 | + at {bit_depth}-bit {upscaled:?} upscaled from {per_frame:?} (denominator, coded \ | |
| 14060 | + width) per frame, {scaled_up} upscale(s), {scaled_mc} scaled MC block(s); \ | |
| 14061 | + fixture sha256 {fixture_sha}" | |
| 14062 | + ); | |
| 14063 | + } else { | |
| 14064 | + eprintln!("{name}: no oracle aomdec, pixel arm skipped"); | |
| 14065 | + } | |
| 14066 | + heads | |
| 14067 | + } | |
| 14068 | + | |
| 14069 | + /// lane-av1superhbd (1): 4:4:4 superres at **10 bits**, `--superres-mode=1 | |
| 14070 | + /// --superres-denominator=12` on all four frames -- coded 171x128 upscaled | |
| 14071 | + /// to 256x128 at `denom = 12`. | |
| 14072 | + /// | |
| 14073 | + /// **What it closes.** Every superres fixture the crate carried parsed | |
| 14074 | + /// `bit_depth = 8` (4:2:0 `superres_kf_cdef_lr_64x64.obu`) or was 4:2:0 | |
| 14075 | + /// (`superres_alltools_sb128_320x180.obu`), and the 4:4:4 superres cells | |
| 14076 | + /// were 8-bit. The chroma-format sweep's not-measured list kept "4:4:4 | |
| 14077 | + /// superres at 10/12 bits" open on that basis. This arm is the 10-bit | |
| 14078 | + /// measurement: a 4:4:4 chroma plane upscaled at FULL resolution, where | |
| 14079 | + /// the upscaler and the scaled inter predictor both run with a | |
| 14080 | + /// 10-bit sample width and the 4:4:4 chroma gather has no subsampling | |
| 14081 | + /// halving to hide behind. | |
| 14082 | + /// | |
| 14083 | + /// **The recipe** (sha256 | |
| 14084 | + /// `95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223`, | |
| 14085 | + /// 15803 bytes, 4 frames, `testsrc2 256x128 rate=25` yuv444p10le): | |
| 14086 | + /// ```text | |
| 14087 | + /// ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \ | |
| 14088 | + /// -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \ | |
| 14089 | + /// aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \ | |
| 14090 | + /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | |
| 14091 | + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | |
| 14092 | + /// --superres-mode=1 --superres-denominator=12 \ | |
| 14093 | + /// --superres-kf-denominator=12 --obu -o - - | |
| 14094 | + /// ``` | |
| 14095 | + /// `-strict -1` is load-bearing: without it ffmpeg refuses to write | |
| 14096 | + /// `yuv444p10le` into a y4m pipe at all (zero bytes out). | |
| 14097 | + #[test] | |
| 14098 | + fn a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact() { | |
| 14099 | + a_444_hbd_superres_arm( | |
| 14100 | + "a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact", | |
| 14101 | + "fixtures/444_lossy_superres_256x128_d12_10bit.obu", | |
| 14102 | + 15803, | |
| 14103 | + 0x9fad_3227_6e91_792c, | |
| 14104 | + "95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223", | |
| 14105 | + 10, | |
| 14106 | + (256, 128), | |
| 14107 | + &[(12, 171); 4], | |
| 14108 | + ); | |
| 14109 | + } | |
| 14110 | + | |
| 14111 | + /// lane-av1superhbd (2): 4:4:4 superres at **12 bits**, | |
| 14112 | + /// `--superres-mode=1 --superres-denominator=12`, coded 171x128 upscaled | |
| 14113 | + /// to 256x128. | |
| 14114 | + /// | |
| 14115 | + /// **Why the source is `mandelbrot` and not `testsrc2`.** The 12-bit | |
| 14116 | + /// frame gate refuses a frame carrying `allow_screen_content_tools = 1` | |
| 14117 | + /// by name (palette and intrabc have no 12-bit witness). libaom sets | |
| 14118 | + /// that bit from its own content detection | |
| 14119 | + /// (`av1_set_screen_content_options` -> `encoder_utils.c:1153`, keyed on | |
| 14120 | + /// the palette-pixel ratio of the FIRST pass), and `testsrc2` -- flat | |
| 14121 | + /// colour bars and hard edges -- trips it at 12 bits while the very same | |
| 14122 | + /// recipe at 10 bits does not. `--enable-palette=0 --enable-intrabc=0` | |
| 14123 | + /// and `--tune-content=film` do NOT suppress it (measured: all four | |
| 14124 | + /// still parse `allow_screen_content_tools = true`), because the | |
| 14125 | + /// detection is a property of the CONTENT, not of those flags. A | |
| 14126 | + /// photographic source (`mandelbrot`, same geometry and frame count) | |
| 14127 | + /// parses `allow_screen_content_tools = false` and decodes. This is a | |
| 14128 | + /// source choice, stated so the next lane does not re-derive it. | |
| 14129 | + /// | |
| 14130 | + /// **The recipe** (sha256 | |
| 14131 | + /// `973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04`, | |
| 14132 | + /// 11023 bytes, 4 frames, `mandelbrot 256x128 rate=25` yuv444p12le): | |
| 14133 | + /// ```text | |
| 14134 | + /// ffmpeg -f lavfi -i "mandelbrot=size=256x128:rate=25" -frames:v 4 \ | |
| 14135 | + /// -pix_fmt yuv444p12le -strict -1 -f yuv4mpegpipe - | \ | |
| 14136 | + /// aomenc --codec=av1 --profile=1 --bit-depth=12 --input-bit-depth=12 \ | |
| 14137 | + /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | |
| 14138 | + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | |
| 14139 | + /// --superres-mode=1 --superres-denominator=12 \ | |
| 14140 | + /// --superres-kf-denominator=12 --obu -o - - | |
| 14141 | + /// ``` | |
| 14142 | + /// Byte-reproducible: two independent encodes produced the same 11023 | |
| 14143 | + /// bytes. | |
| 14144 | + #[test] | |
| 14145 | + fn a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact() { | |
| 14146 | + a_444_hbd_superres_arm( | |
| 14147 | + "a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact", | |
| 14148 | + "fixtures/444_lossy_superres_256x128_d12_12bit.obu", | |
| 14149 | + 11023, | |
| 14150 | + 0xd6cf_bb83_2b42_8e2d, | |
| 14151 | + "973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04", | |
| 14152 | + 12, | |
| 14153 | + (256, 128), | |
| 14154 | + &[(12, 171); 4], | |
| 14155 | + ); | |
| 14156 | + } | |
| 14157 | + | |
| 14158 | + /// lane-av1superhbd (3): 4:4:4 superres at **12 bits** at the WIDEST | |
| 14159 | + /// denominator this geometry allows, `--superres-denominator=9` -- coded | |
| 14160 | + /// 228x128 upscaled to 256x128, so 28 of the 256 columns are the frame's | |
| 14161 | + /// right-edge upscale margin, against 12's 85. | |
| 14162 | + /// | |
| 14163 | + /// It is a separate gate from the den=12 arm because the margin is | |
| 14164 | + /// where a round-trip is most likely to read past the coded picture: a | |
| 14165 | + /// decoder that sized the upscale source from `UpscaledWidth` instead of | |
| 14166 | + /// `FrameWidth` is exact at den=12 on this content and wrong here. Its | |
| 14167 | + /// recipe is the 12-bit one above with `--superres-denominator=9 | |
| 14168 | + /// --superres-kf-denominator=9` (sha256 | |
| 14169 | + /// `898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99`, | |
| 14170 | + /// 13015 bytes). | |
| 14171 | + #[test] | |
| 14172 | + fn a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact() { | |
| 14173 | + a_444_hbd_superres_arm( | |
| 14174 | + "a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact", | |
| 14175 | + "fixtures/444_lossy_superres_256x128_d9_12bit.obu", | |
| 14176 | + 13015, | |
| 14177 | + 0x4110_ce7b_cd85_901b, | |
| 14178 | + "898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99", | |
| 14179 | + 12, | |
| 14180 | + (256, 128), | |
| 14181 | + &[(9, 228); 4], | |
| 14182 | + ); | |
| 14183 | + } | |
| 14184 | + | |
| 14185 | + /// lane-av1superhbd (4): 4:4:4 superres at **10 bits** under | |
| 14186 | + /// `--superres-mode=2` -- the random-denominator arm, where libaom picks | |
| 14187 | + /// a DIFFERENT denominator for every frame and IGNORES | |
| 14188 | + /// `--superres-denominator` entirely. | |
| 14189 | + /// | |
| 14190 | + /// This is what keeps the high-bit-depth superres cell from silently | |
| 14191 | + /// degenerating into a single-denominator cell: the per-frame parsed | |
| 14192 | + /// denominators are 11, 14, 15, 9 -- three of them values no flag on the | |
| 14193 | + /// command line ever named -- so a gate that read the flag instead of | |
| 14194 | + /// the header would be wrong on three of four frames. The assertion | |
| 14195 | + /// below makes that structural rather than incidental, and it is the | |
| 14196 | + /// assertion that fails if a future libaom starts honouring the flag | |
| 14197 | + /// under mode 2. | |
| 14198 | + /// | |
| 14199 | + /// **The recipe** (sha256 | |
| 14200 | + /// `699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668`, | |
| 14201 | + /// 17776 bytes, 4 frames, `testsrc2 256x128 rate=25` yuv444p10le): | |
| 14202 | + /// ```text | |
| 14203 | + /// ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \ | |
| 14204 | + /// -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \ | |
| 14205 | + /// aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \ | |
| 14206 | + /// --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | |
| 14207 | + /// --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | |
| 14208 | + /// --superres-mode=2 --obu -o - - | |
| 14209 | + /// ``` | |
| 14210 | + #[test] | |
| 14211 | + fn a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact() { | |
| 14212 | + const NAME: &str = | |
| 14213 | + "a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact"; | |
| 14214 | + let heads = a_444_hbd_superres_arm( | |
| 14215 | + NAME, | |
| 14216 | + "fixtures/444_lossy_superres_mode2_256x128_10bit.obu", | |
| 14217 | + 17776, | |
| 14218 | + 0x164f_4099_7576_7ae4, | |
| 14219 | + "699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668", | |
| 14220 | + 10, | |
| 14221 | + (256, 128), | |
| 14222 | + &[(11, 186), (14, 146), (15, 137), (9, 228)], | |
| 14223 | + ); | |
| 14224 | + // Distinct-denominator assert: the cell must stay a MULTI-denominator | |
| 14225 | + // one. A libaom that collapsed mode 2 onto a single denominator (or | |
| 14226 | + // stopped scaling) would still decode, and the gate above would still | |
| 14227 | + // hold only because the literals would have been re-pinned with it -- | |
| 14228 | + // so the property is asserted from the parsed headers directly. | |
| 14229 | + let denoms: Vec<u8> = heads.iter().map(|h| h.superres_denom).collect(); | |
| 14230 | + let mut distinct = denoms.clone(); | |
| 14231 | + distinct.sort_unstable(); | |
| 14232 | + distinct.dedup(); | |
| 14233 | + assert!( | |
| 14234 | + distinct.len() >= 3, | |
| 14235 | + "{NAME}: the stream carries denominators {denoms:?} -- fewer than three distinct \ | |
| 14236 | + values, so this is no longer the per-frame-denominator cell and the pin has to be \ | |
| 14237 | + re-derived from the stream" | |
| 14238 | + ); | |
| 14239 | + let flagged = [9u8, 12, 16]; | |
| 14240 | + assert!( | |
| 14241 | + denoms.iter().any(|d| !flagged.contains(d)), | |
| 14242 | + "{NAME}: every parsed denominator is one of the flag values {flagged:?} -- mode 2 now \ | |
| 14243 | + appears to honour --superres-denominator, and this cell stops being the \ | |
| 14244 | + flag-ignoring one" | |
| 14245 | + ); | |
| 14246 | + } | |
| 14247 | + | |
| 14248 | + /// lane-av1superhbd (5): 4:4:4 superres at **12 bits** under | |
| 14249 | + /// `--superres-mode=2` -- the high-bit-depth random-denominator arm, the | |
| 14250 | + /// 12-bit twin of the arm above (sha256 | |
| 14251 | + /// `18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f`, | |
| 14252 | + /// 14656 bytes, same `mandelbrot` source as the 12-bit fixed-denominator | |
| 14253 | + /// arms). Its parsed denominators are again 11/14/15/9 at coded widths | |
| 14254 | + /// 186/146/137/228, so the upscaler is handed FOUR coded-to-upscaled | |
| 14255 | + /// ratios in one 12-bit decode -- the case a single-denominator gate | |
| 14256 | + /// cannot reach at any bit depth. | |
| 14257 | + #[test] | |
| 14258 | + fn a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact() { | |
| 14259 | + const NAME: &str = | |
| 14260 | + "a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact"; | |
| 14261 | + let heads = a_444_hbd_superres_arm( | |
| 14262 | + NAME, | |
| 14263 | + "fixtures/444_lossy_superres_mode2_256x128_12bit.obu", | |
| 14264 | + 14656, | |
| 14265 | + 0xef38_3fb7_b284_2166, | |
| 14266 | + "18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f", | |
| 14267 | + 12, | |
| 14268 | + (256, 128), | |
| 14269 | + &[(11, 186), (14, 146), (15, 137), (9, 228)], | |
| 14270 | + ); | |
| 14271 | + let denoms: Vec<u8> = heads.iter().map(|h| h.superres_denom).collect(); | |
| 14272 | + let mut distinct = denoms.clone(); | |
| 14273 | + distinct.sort_unstable(); | |
| 14274 | + distinct.dedup(); | |
| 14275 | + assert!( | |
| 14276 | + distinct.len() >= 3, | |
| 14277 | + "{NAME}: the stream carries denominators {denoms:?} -- fewer than three distinct \ | |
| 14278 | + values, so this is no longer the per-frame-denominator cell and the pin has to be \ | |
| 14279 | + re-derived from the stream" | |
| 14280 | + ); | |
| 14281 | + let flagged = [9u8, 12, 16]; | |
| 14282 | + assert!( | |
| 14283 | + denoms.iter().any(|d| !flagged.contains(d)), | |
| 14284 | + "{NAME}: every parsed denominator is one of the flag values {flagged:?} -- mode 2 now \ | |
| 14285 | + appears to honour --superres-denominator, and this cell stops being the \ | |
| 14286 | + flag-ignoring one" | |
| 14287 | + ); | |
| 14288 | + } | |
| 14289 | + | |
| 13881 | 14290 | /// lane-filt1: `EC_AV1_FILTER_THREADS` splits every in-frame filter stage |
| 13882 | 14291 | /// -- deblock (row bands for the vertical-edge pass, column bands for the |
| 13883 | 14292 | /// horizontal one), CDEF (mi row bands), loop restoration (RU row bands) |
lanes/av1superhbd.report.mdadded+233 -0
| @@ -0,0 +1,233 @@ | ||
| 1 | +# lane-av1superhbd — 4:4:4 SUPERRES at 10-bit and 12-bit | |
| 2 | + | |
| 3 | +**Verdict: EXACT at both depths. Five gates added, all green, all mutation-proved red-before.** | |
| 4 | + | |
| 5 | +Branch `lane-av1superhbd` (base `a21f3680`); the gate+fixture commit is the | |
| 6 | +parent of this report's commit. | |
| 7 | +Oracle: libaom `v3.13.3-7-g9bb526a` (`~/.cache/aom-oracle/build/aomdec`). | |
| 8 | + | |
| 9 | +--- | |
| 10 | + | |
| 11 | +## 1. Parsed headers — read from each stream's OWN sequence/frame header | |
| 12 | + | |
| 13 | +Every number below comes from `ec_av1_syntax`'s `Av1Parser` walking the pinned | |
| 14 | +bytes, never from the encoder flags. A stream that parses `use_superres=false` | |
| 15 | +was discarded, not pinned. | |
| 16 | + | |
| 17 | +### Accepted (all five) | |
| 18 | + | |
| 19 | +| stream | bytes | sha256 | SEQ `bit_depth` | SEQ `ss` | SEQ `enable_superres` | per-frame `use_superres` | per-frame `superres_denom` | per-frame `upscaled_width` | per-frame coded `frame_width x frame_height` | | |
| 20 | +|---|---|---|---|---|---|---|---|---|---| | |
| 21 | +| `444_lossy_superres_256x128_d12_10bit.obu` | 15803 | `95b49d7aa81843399ee3aa64bdadfec8f4037bcc3f861923c9b2da3bc868b223` | 10 | (0,0) | true | true x4 | 12, 12, 12, 12 | 256, 256, 256, 256 | 171x128 x4 | | |
| 22 | +| `444_lossy_superres_mode2_256x128_10bit.obu` | 17776 | `699398aba58fb53b80e05d3d214eb746a3c91945e01da6b47488513f20b55668` | 10 | (0,0) | true | true x4 | 11, 14, 15, 9 | 256, 256, 256, 256 | 186x128, 146x128, 137x128, 228x128 | | |
| 23 | +| `444_lossy_superres_256x128_d12_12bit.obu` | 11023 | `973bf374c0185c4e6301509ce834cef01318e6cdb9488fd258118d7ec89bdd04` | 12 | (0,0) | true | true x4 | 12, 12, 12, 12 | 256, 256, 256, 256 | 171x128 x4 | | |
| 24 | +| `444_lossy_superres_256x128_d9_12bit.obu` | 13015 | `898c775108495b998cb5ec9b08e194d4656ed0140aa8e7e7236892d468bbad99` | 12 | (0,0) | true | true x4 | 9, 9, 9, 9 | 256, 256, 256, 256 | 228x128 x4 | | |
| 25 | +| `444_lossy_superres_mode2_256x128_12bit.obu` | 14656 | `18aa8b3124ab10672f22577a8eea81e44141a3d0bb506104aee2f950254a2e9f` | 12 | (0,0) | true | true x4 | 11, 14, 15, 9 | 256, 256, 256, 256 | 186x128, 146x128, 137x128, 228x128 | | |
| 26 | + | |
| 27 | +Scaled-size arithmetic re-derived per frame and held on all 20 frame headers: | |
| 28 | +`(upscaled_width*8 + denom/2)/denom == frame_width` — | |
| 29 | +`(256*8+6)/12 = 171`, `(256*8+1)/9 = 228`, `(256*8+5)/11 = 186`, | |
| 30 | +`(256*8+7)/14 = 146`, `(256*8+7)/15 = 137`. | |
| 31 | + | |
| 32 | +### Discarded | |
| 33 | + | |
| 34 | +Nothing was discarded for `use_superres=false` — every stream above was built | |
| 35 | +with an explicit `--superres-denominator` / `--superres-kf-denominator` pair, so | |
| 36 | +the libaom no-op (denominator flag absent -> denom 8, nothing scaled) could not | |
| 37 | +occur. The two mode-2 arms carry denominators 11/14/15/9, three of which no | |
| 38 | +command-line flag ever named, which is itself the proof that the headers are | |
| 39 | +what the gates read. | |
| 40 | + | |
| 41 | +--- | |
| 42 | + | |
| 43 | +## 2. Verdicts — exactness against the instrumented oracle | |
| 44 | + | |
| 45 | +Frame counts and per-frame byte lengths are asserted by | |
| 46 | +`decode_all_frames_vs_oracle` BEFORE the pixel compare; it writes | |
| 47 | +`EC_AV1_FINAL_DUMP` frames on both sides and compares them byte-for-byte in | |
| 48 | +DECODE order, so a frame-length mismatch is a hard failure, not a short compare. | |
| 49 | + | |
| 50 | +| gate | frames compared | hidden | divergent | `superres_hits` delta | `predict_scaled_hits` delta | | |
| 51 | +|---|---|---|---|---|---| | |
| 52 | +| `a_444_lossy_superres_10bit_d12_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 2097 | | |
| 53 | +| `a_444_lossy_superres_10bit_mode2_random_denom_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 2181 | | |
| 54 | +| `a_444_lossy_superres_12bit_d12_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 1311 | | |
| 55 | +| `a_444_lossy_superres_12bit_d9_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 1956 | | |
| 56 | +| `a_444_lossy_superres_12bit_mode2_random_denom_stream_decodes_pixel_exact` | 4/4 | 0 | **0** | 4 | 1737 | | |
| 57 | + | |
| 58 | +`test result: ok. 5 passed; 0 failed; 0 ignored` (712 filtered out). | |
| 59 | + | |
| 60 | +--- | |
| 61 | + | |
| 62 | +## 3. Gates | |
| 63 | + | |
| 64 | +`crates/ec-av1/src/stream.rs`, one shared body `a_444_hbd_superres_arm` plus | |
| 65 | +five `#[test]` arms. Every arm asserts: | |
| 66 | + | |
| 67 | +- the pinned bytes (length + FNV-1a), read at full decode order; | |
| 68 | +- `ss (0,0)` from the sequence header, and **`bit_depth` equal to the depth the | |
| 69 | + gate names** — the high-bit-depth claim is otherwise unprovable, because a | |
| 70 | + mistyped `--bit-depth` still yields a decodable scaled 4:4:4 stream, just at | |
| 71 | + a different cell (the same phantom-cell trap as the `use_superres=false` | |
| 72 | + case lane-av1444edge r3 recorded); | |
| 73 | +- `enable_superres` on the sequence header and `use_superres` on every parsed | |
| 74 | + frame header; | |
| 75 | +- the per-frame PARSED `superres_denom` against a `(denominator, coded width)` | |
| 76 | + table in decode order, the upscaled size, and the coded size; | |
| 77 | +- `FrameWidth == (UpscaledWidth*8 + denom/2)/denom` re-derived from that frame's | |
| 78 | + own parsed denominator — not a literal comparison alone, so a re-pinned | |
| 79 | + fixture cannot satisfy the numbers while the scaled-size arithmetic moves | |
| 80 | + under them; | |
| 81 | +- `superres_hits` and `predict_scaled_hits` as **DELTAS** (both are | |
| 82 | + process-wide counters with no reset, so absolute values would pass on residue | |
| 83 | + from another stream); | |
| 84 | +- every returned frame at the UPSCALED size with full-resolution 4:4:4 chroma | |
| 85 | + plane lengths, and every sample bounded by `(1 << bit_depth) - 1` — a decoder | |
| 86 | + that produced 8-bit values padded into a `u16` plane would satisfy every | |
| 87 | + geometry assert and only be caught here; | |
| 88 | +- all decode-order frames byte-exact against the instrumented `aomdec`. | |
| 89 | + | |
| 90 | +The two mode-2 arms add the **distinct-denominator assert** the charter asked | |
| 91 | +for: `distinct.len() >= 3` across the parsed denominators, and at least one | |
| 92 | +denominator not in `{9, 12, 16}`. So neither arm can silently stop being a | |
| 93 | +scaled, multi-ratio cell — a libaom that collapsed mode 2 onto one denominator, | |
| 94 | +or started honouring `--superres-denominator` under mode 2, turns the arm red | |
| 95 | +instead of quietly re-pinning it into a different claim. | |
| 96 | + | |
| 97 | +### Red-before (both mutations on the committed tree, then reverted) | |
| 98 | + | |
| 99 | +| mutation | site | result | | |
| 100 | +|---|---|---| | |
| 101 | +| tap alignment in the upscale filter: `let idx = base + int_pel + k as i64 + 1;` | `superres.rs:141` (`upscale_row`) | **5/5 RED at pixel level.** e.g. 10-bit d12: `decode-order frame 0 of 4 differs from the oracle at byte 0 (ours 40 vs 38), 54916 bytes differ`; 10-bit mode-2: `byte 0 (ours 41 vs 40), 53206 bytes differ` | | |
| 102 | +| counter: `note_upscaled_picture` body emptied (`hit!(SUPERRES_HITS)` removed) | `superres.rs:188` | **5/5 RED** on the non-vacuity assert: `zero superres_hits -- the upscaler never ran (class gate-blind-to-feature)` | | |
| 103 | + | |
| 104 | +Both reverted; `git status --porcelain` clean; the five gates re-run green on | |
| 105 | +the committed tree afterwards. | |
| 106 | + | |
| 107 | +--- | |
| 108 | + | |
| 109 | +## 4. Recipes | |
| 110 | + | |
| 111 | +`-strict -1` is load-bearing on the y4m pipe: without it ffmpeg refuses to | |
| 112 | +write `yuv444p10le` / `yuv444p12le` at all (zero bytes out). | |
| 113 | + | |
| 114 | +10-bit (`testsrc2`, both arms): | |
| 115 | + | |
| 116 | +```text | |
| 117 | +ffmpeg -f lavfi -i "testsrc2=size=256x128:rate=25" -frames:v 4 \ | |
| 118 | + -pix_fmt yuv444p10le -strict -1 -f yuv4mpegpipe - | \ | |
| 119 | +aomenc --codec=av1 --profile=1 --bit-depth=10 --input-bit-depth=10 \ | |
| 120 | + --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | |
| 121 | + --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | |
| 122 | + --superres-mode=1 --superres-denominator=12 \ | |
| 123 | + --superres-kf-denominator=12 --obu -o - - | |
| 124 | +``` | |
| 125 | + | |
| 126 | +Swap the last three lines for `--superres-mode=2 --obu -o - -` for the mode-2 arm. | |
| 127 | + | |
| 128 | +12-bit (`mandelbrot`, see §5): | |
| 129 | + | |
| 130 | +```text | |
| 131 | +ffmpeg -f lavfi -i "mandelbrot=size=256x128:rate=25" -frames:v 4 \ | |
| 132 | + -pix_fmt yuv444p12le -strict -1 -f yuv4mpegpipe - | \ | |
| 133 | +aomenc --codec=av1 --profile=1 --bit-depth=12 --input-bit-depth=12 \ | |
| 134 | + --passes=1 --end-usage=q --cq-level=20 --cpu-used=2 --threads=1 \ | |
| 135 | + --row-mt=0 --lag-in-frames=0 --kf-max-dist=100 --limit=4 \ | |
| 136 | + --superres-mode=1 --superres-denominator=<9|12> \ | |
| 137 | + --superres-kf-denominator=<9|12> --obu -o - - | |
| 138 | +``` | |
| 139 | + | |
| 140 | +Byte-reproducible: two independent encodes of the 12-bit den=12 recipe produced | |
| 141 | +the same 11023 bytes, sha256 `973bf374…`. | |
| 142 | + | |
| 143 | +--- | |
| 144 | + | |
| 145 | +## 5. The 12-bit source: `mandelbrot`, not `testsrc2` | |
| 146 | + | |
| 147 | +`testsrc2` at 12 bits parses `allow_screen_content_tools = true` on every | |
| 148 | +frame, which the crate refuses by name | |
| 149 | +(`a 12-bit frame with screen content tools (allow_screen_content_tools=1: …)`) | |
| 150 | +— palette and intrabc have no 12-bit witness. The identical recipe at **10 bits** | |
| 151 | +does not trip it, so the flag set is not the variable; the source content is. | |
| 152 | + | |
| 153 | +Flag-combination attempt table, all read from the pinned-then-parsed headers | |
| 154 | +(same geometry, same 12-bit depth, `--superres-mode=1 --superres-denominator=12`): | |
| 155 | + | |
| 156 | +| attempt | `allow_screen_content_tools` (parsed) | our decoder | | |
| 157 | +|---|---|---| | |
| 158 | +| `testsrc2` yuv444p12le, base flags | true | REFUSED by name | | |
| 159 | +| + `--enable-palette=0 --enable-intrabc=0` | true | REFUSED by name | | |
| 160 | +| + `--tune-content=film` | true | REFUSED by name | | |
| 161 | +| + both, `--tune-content=film` | true | REFUSED by name | | |
| 162 | +| `--cpu-used=8` | true | REFUSED by name | | |
| 163 | +| `--cq-level=40` | true | REFUSED by name | | |
| 164 | +| `testsrc` yuv444p12le | true | REFUSED by name | | |
| 165 | +| `mandelbrot` yuv444p12le | **false** | **decodes, 4 frames 256x128** | | |
| 166 | +| `nullsrc` yuv444p12le (135-byte stream) | false | decodes — but vacuous, no content | | |
| 167 | + | |
| 168 | +Root cause in the oracle source, so the next lane does not re-derive it: | |
| 169 | +`av1_set_screen_content_options` (`av1/encoder/encoder.c:2427`) defers to | |
| 170 | +`encoder_utils.c:1153`, which keys the decision on the **first pass's | |
| 171 | +palette-pixel ratio**, not on `--enable-palette` / `--enable-intrabc` / | |
| 172 | +`--tune-content`. A photographic source keeps the ratio below threshold. | |
| 173 | +Recorded in the gate doc comment as well. | |
| 174 | + | |
| 175 | +--- | |
| 176 | + | |
| 177 | +## 6. Correction to `lanes/av1formatsweep.report.md` | |
| 178 | + | |
| 179 | +The not-measured list is closed for this cell. Proposed replacement text only — | |
| 180 | +this lane does not edit that file (another lane corrected parts of it today and | |
| 181 | +the merge must apply cleanly). | |
| 182 | + | |
| 183 | +**Line 83** (the 4:4:4 matrix row) — current: | |
| 184 | + | |
| 185 | +```markdown | |
| 186 | +| superres | – | – | – | | |
| 187 | +``` | |
| 188 | + | |
| 189 | +proposed: | |
| 190 | + | |
| 191 | +```markdown | |
| 192 | +| superres | Y (5 gates, `444_lossy_superres_*` pins) | **Y (gates, this lane)** | **Y (gates, this lane)** | | |
| 193 | +``` | |
| 194 | + | |
| 195 | +**Line 493** (§6.5 "Still not measured after this round") — current fragment: | |
| 196 | + | |
| 197 | +```markdown | |
| 198 | +Still not measured after this round: 4:4:4 at 10/12 bits with **tile rows | |
| 199 | +actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 superres at | |
| 200 | +10/12 bits; 4:4:4 odd dims at 10/12 bits and at dimensions other than 66x66 / | |
| 201 | +``` | |
| 202 | + | |
| 203 | +proposed: | |
| 204 | + | |
| 205 | +```markdown | |
| 206 | +Still not measured after this round: 4:4:4 at 10/12 bits with **tile rows | |
| 207 | +actually enabled** (needs a >= 256-high geometry — trap 2); 4:4:4 odd dims at 10/12 bits and at dimensions other than 66x66 / | |
| 208 | +``` | |
| 209 | + | |
| 210 | +**Line 438** (§6.2 table) — the `sr444` DIVERGENT row predates lane-av1444edge | |
| 211 | +r3, which showed that stream passes `--superres-mode=1` with no denominator and | |
| 212 | +therefore parses `use_superres=false denom=8` on all four frames: it was never a | |
| 213 | +scaled cell. The 8-bit 4:4:4 superres coverage is `lane-av1superpin`'s | |
| 214 | +(`444_lossy_superres_256x128_d12.obu`, `_d9`, `_mode2`). I did not touch this | |
| 215 | +row — that correction belongs to the lane that made the measurement, and it is | |
| 216 | +already landed on `lane-av1superpin` (`9646f74d` "correct the published cells | |
| 217 | +the superres no-op got wrong"). Flagged here only so the merge does not | |
| 218 | +reintroduce the stale `D` next to the new `Y`s. | |
| 219 | + | |
| 220 | +--- | |
| 221 | + | |
| 222 | +## 7. What is NOT claimed | |
| 223 | + | |
| 224 | +- Only 4:4:4 (`ss 0,0`) at 10 and 12 bits, 256x128 upscaled geometry, lossy | |
| 225 | + cq-20 cpu-used-2, and denominators 9/11/12/14/15. Not claimed: 4:2:0 HBD | |
| 226 | + superres (the sweep's `sr420_12` already covers 4:2:0 12-bit), lossless HBD | |
| 227 | + superres, tile-geometry interaction, or any other source. | |
| 228 | +- The 12-bit arms run on `mandelbrot` content only. `testsrc2`-class content at | |
| 229 | + 12 bits is still refused by the screen-content gate — that refusal is | |
| 230 | + unchanged and this lane did not touch it. | |
| 231 | +- Frame counts are 4 per stream, all shown, zero hidden; these are | |
| 232 | + `--lag-in-frames=0 --auto-alt-ref` default single-layer streams, so the | |
| 233 | + hidden-frame arm of the oracle compare is exercised but has nothing to find. |