lane-av112bitg: lift the 12-bit film grain refusal to the witnessed set
Browse files at this commit04d785155a6d3c78d29588e7c22756e58f4a0bf9Parent: 70849e03 changed files +190 -52
- crates/ec-av1/src/refusal_inventory.rs +7 -5
- crates/ec-av1/src/stream.rs +93 -47
- lanes/av112bitg.report.md +90 -0
crates/ec-av1/src/refusal_inventory.rsmodified+7 -5
| @@ -80,8 +80,11 @@ const REFUSALS: &[&str] = &[ | |||
| 80 | // lane-av112bitc: compound joined the witnessed set (six-frame 12-bit | 80 | // lane-av112bitc: compound joined the witnessed set (six-frame 12-bit |
| 81 | // compound stream byte-exact vs ffmpeg; the combines already absorbed | 81 | // compound stream byte-exact vs ffmpeg; the combines already absorbed |
| 82 | // the CONV_BUF gain drop through `INTER_POST_ROUND - delta`). | 82 | // the CONV_BUF gain drop through `INTER_POST_ROUND - delta`). |
| 83 | + // lane-av112bitg: film grain joined the witnessed set (two-frame | ||
| 84 | + // `--film-grain-test=5` stream byte-exact vs ffmpeg; the gate that | ||
| 85 | + // replaced the refusal is | ||
| 86 | + // `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`). | ||
| 83 | "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)", | 87 | "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)", |
| 84 | - "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)", | ||
| 85 | "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)", | 88 | "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)", |
| 86 | // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to | 89 | // lane-av1txr: the silent-garbage guard. A 4:4:4/4:2:2 stream used to |
| 87 | // decode with no refusal and wrong pixels (every chroma extent is | 90 | // decode with no refusal and wrong pixels (every chroma extent is |
| @@ -363,14 +366,13 @@ const PROVEN: &[(&str, &str)] = &[ | |||
| 363 | // lane-av112bitc: the compound pair left with its refusal -- the | 366 | // lane-av112bitc: the compound pair left with its refusal -- the |
| 364 | // six-frame compound stream now DECODES byte-exact | 367 | // six-frame compound stream now DECODES byte-exact |
| 365 | // (`a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact`). | 368 | // (`a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact`). |
| 369 | + // lane-av112bitg: the grain refusal left with its witness -- the | ||
| 370 | + // two-frame 12-bit grain stream now DECODES byte-exact | ||
| 371 | + // (`a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`). | ||
| 366 | ( | 372 | ( |
| 367 | "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)", | 373 | "warped motion at 12 bits (warp's reduce bits inherit the 12-bit round_0 and no 12-bit warp witness exists)", |
| 368 | "a_12bit_warped_motion_stream_is_refused_by_name", | 374 | "a_12bit_warped_motion_stream_is_refused_by_name", |
| 369 | ), | 375 | ), |
| 370 | - ( | ||
| 371 | - "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)", | ||
| 372 | - "a_12bit_film_grain_stream_is_refused_by_name", | ||
| 373 | - ), | ||
| 374 | ( | 376 | ( |
| 375 | "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)", | 377 | "a 12-bit frame with screen content tools (allow_screen_content_tools=1: neither palette nor intrabc has a 12-bit witness)", |
| 376 | "a_12bit_screen_content_stream_is_refused_by_name", | 378 | "a_12bit_screen_content_stream_is_refused_by_name", |
crates/ec-av1/src/stream.rsmodified+93 -47
| @@ -38,21 +38,6 @@ fn no_grain() -> bool { | |||
| 38 | std::env::var_os("EC_AV1_NO_GRAIN").is_some() | 38 | std::env::var_os("EC_AV1_NO_GRAIN").is_some() |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -/// lane-av112bit: film grain synthesis has no 12-bit byte-exact witness (the | ||
| 42 | -/// lane's witnesses encode with grain off), so a 12-bit frame that would | ||
| 43 | -/// synthesise grain is refused by name at output rather than trusted -- | ||
| 44 | -/// `film_grain.rs` is bit-depth generic since lane-hbd10, but generic is not | ||
| 45 | -/// proven until a real 12-bit grain stream compares exact. | ||
| 46 | -fn grain_refusal(bit_depth: u32) -> Result<()> { | ||
| 47 | - if bit_depth == 12 { | ||
| 48 | - return Err(Error::unsupported( | ||
| 49 | - "AV1 decode_stream", | ||
| 50 | - "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)", | ||
| 51 | - )); | ||
| 52 | - } | ||
| 53 | - Ok(()) | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | // lane-hidden r1: where `EC_AV1_FINAL_DUMP`'s per-frame dump goes for the | 41 | // lane-hidden r1: where `EC_AV1_FINAL_DUMP`'s per-frame dump goes for the |
| 57 | // current thread, overriding the environment variable. Every ffmpeg/aomdec | 42 | // current thread, overriding the environment variable. Every ffmpeg/aomdec |
| 58 | // pixel gate in this repo compares SHOWN frames only (class | 43 | // pixel gate in this repo compares SHOWN frames only (class |
| @@ -699,7 +684,6 @@ pub fn decode_stream_with_threads( | |||
| 699 | pictures_shown += 1; | 684 | pictures_shown += 1; |
| 700 | let grain = header.film_grain; | 685 | let grain = header.film_grain; |
| 701 | let seq = SeqFlags::read(&parser); | 686 | let seq = SeqFlags::read(&parser); |
| 702 | - grain_refusal(u32::from(seq.bit_depth))?; | ||
| 703 | let tx = tx.clone(); | 687 | let tx = tx.clone(); |
| 704 | jobs.submit(move || { | 688 | jobs.submit(move || { |
| 705 | let reply = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { | 689 | let reply = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { |
| @@ -751,13 +735,6 @@ pub fn decode_stream_with_threads( | |||
| 751 | } | 735 | } |
| 752 | picture | 736 | picture |
| 753 | }; | 737 | }; |
| 754 | - if header.film_grain.apply_grain { | ||
| 755 | - grain_refusal( | ||
| 756 | - parser | ||
| 757 | - .sequence_header() | ||
| 758 | - .map_or(8, |seq| u32::from(seq.color_config.bit_depth)), | ||
| 759 | - )?; | ||
| 760 | - } | ||
| 761 | let output = if header.film_grain.apply_grain && !no_grain() { | 738 | let output = if header.film_grain.apply_grain && !no_grain() { |
| 762 | // lane-hbd10 r1: grain synthesis is bit-depth generic | 739 | // lane-hbd10 r1: grain synthesis is bit-depth generic |
| 763 | // (`film_grain.rs`'s `grain_range`/`scale_lut`, spec 7.18.3). | 740 | // (`film_grain.rs`'s `grain_range`/`scale_lut`, spec 7.18.3). |
| @@ -1097,9 +1074,6 @@ pub fn decode_stream_with_threads( | |||
| 1097 | // Grain is synthesised for OUTPUT only: a hidden frame is | 1074 | // Grain is synthesised for OUTPUT only: a hidden frame is |
| 1098 | // reported to the sink clean, exactly as the inline path | 1075 | // reported to the sink clean, exactly as the inline path |
| 1099 | // below reports it (spec 7.18.3.1). | 1076 | // below reports it (spec 7.18.3.1). |
| 1100 | - if header.film_grain.apply_grain { | ||
| 1101 | - grain_refusal(u32::from(seq.bit_depth))?; | ||
| 1102 | - } | ||
| 1103 | let output = if shown && header.film_grain.apply_grain && !no_grain() { | 1077 | let output = if shown && header.film_grain.apply_grain && !no_grain() { |
| 1104 | std::sync::Arc::new(crate::film_grain::apply_grain( | 1078 | std::sync::Arc::new(crate::film_grain::apply_grain( |
| 1105 | &picture, | 1079 | &picture, |
| @@ -1234,9 +1208,6 @@ pub fn decode_stream_with_threads( | |||
| 1234 | decode::note_fwd_kf(); | 1208 | decode::note_fwd_kf(); |
| 1235 | } | 1209 | } |
| 1236 | if header.show_frame { | 1210 | if header.show_frame { |
| 1237 | - if header.film_grain.apply_grain { | ||
| 1238 | - grain_refusal(u32::from(seq.bit_depth))?; | ||
| 1239 | - } | ||
| 1240 | let output = if header.film_grain.apply_grain && !no_grain() { | 1211 | let output = if header.film_grain.apply_grain && !no_grain() { |
| 1241 | let mc_identity = seq.mc_identity; | 1212 | let mc_identity = seq.mc_identity; |
| 1242 | std::sync::Arc::new(crate::film_grain::apply_grain( | 1213 | std::sync::Arc::new(crate::film_grain::apply_grain( |
| @@ -1676,10 +1647,12 @@ fn decode_frame( | |||
| 1676 | // the CONV_BUF gain), and CDEF/deblock/quant tables/SGR/palette reads/ | 1647 | // the CONV_BUF gain), and CDEF/deblock/quant tables/SGR/palette reads/ |
| 1677 | // superres upscale were already bit-depth generic (10-bit-proven). | 1648 | // superres upscale were already bit-depth generic (10-bit-proven). |
| 1678 | // Everything no 12-bit witness reached stays refused BY NAME at its own | 1649 | // Everything no 12-bit witness reached stays refused BY NAME at its own |
| 1679 | - // site: warp (decode.rs, warp's reduce bits inherit the 12-bit round_0), | 1650 | + // site: warp (decode.rs, warp's reduce bits inherit the 12-bit round_0) |
| 1680 | - // film grain (`grain_refusal`, the witnesses run with grain off), and | 1651 | + // and any per-feature gap the witnesses' counters prove unreached -- see |
| 1681 | - // any per-feature gap the witnesses' counters prove unreached -- see the | 1652 | + // the 12-bit refusals in decode.rs and `refusal_inventory.rs`. |
| 1682 | - // 12-bit refusals in decode.rs and `refusal_inventory.rs`. | 1653 | + // lane-av112bitg: film grain joined the witnessed set (`grain_refusal` |
| 1654 | + // deleted; the two-arm witness is | ||
| 1655 | + // `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`). | ||
| 1683 | // lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2) are parsed by | 1656 | // lane-av1txr: `color_config.subsampling_x/y` (spec 5.5.2) are parsed by |
| 1684 | // `ec-av1-syntax` -- profile 1 forces 4:4:4, profile 2 below 12-bit forces | 1657 | // `ec-av1-syntax` -- profile 1 forces 4:4:4, profile 2 below 12-bit forces |
| 1685 | // 4:2:2, and the sRGB identity description forces full-range 4:4:4 -- but | 1658 | // 4:2:2, and the sRGB identity description forces full-range 4:4:4 -- but |
| @@ -7794,9 +7767,12 @@ pub(crate) mod tests { | |||
| 7794 | // restoration (Wiener AND SGR), and translational subpel motion | 7767 | // restoration (Wiener AND SGR), and translational subpel motion |
| 7795 | // compensation through the bit-depth-parameterised `round_0`/`round_1` | 7768 | // compensation through the bit-depth-parameterised `round_0`/`round_1` |
| 7796 | // (libaom `convolve.h:81..86`). Everything else stays refused by name: | 7769 | // (libaom `convolve.h:81..86`). Everything else stays refused by name: |
| 7797 | - // warp, film grain, screen content tools (palette/intrabc) at the frame | 7770 | + // warp and screen content tools (palette/intrabc) at the frame level, |
| 7798 | - // level, compound inter blocks at the mode read, each with its own | 7771 | + // each with its own real-stream refusal gate below. |
| 7799 | - // real-stream refusal gate below. | 7772 | + // lane-av112bitc: compound joined the witnessed set (refusal gate became |
| 7773 | + // the six-frame compound witness). | ||
| 7774 | + // lane-av112bitg: film grain joined the witnessed set (refusal gate became | ||
| 7775 | + // `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`). | ||
| 7800 | // ------------------------------------------------------------------- | 7776 | // ------------------------------------------------------------------- |
| 7801 | 7777 | ||
| 7802 | /// The 12-bit witness source, byte-identical to the lane's committed | 7778 | /// The 12-bit witness source, byte-identical to the lane's committed |
| @@ -8123,25 +8099,95 @@ pub(crate) mod tests { | |||
| 8123 | } | 8099 | } |
| 8124 | } | 8100 | } |
| 8125 | 8101 | ||
| 8126 | - /// The 12-bit film grain refusal: a real `--film-grain-test=1` stream | 8102 | + /// lane-av112bitg: the 12-bit film grain witness. A real |
| 8127 | - /// (grain params present AND applied) is refused by name at output. | 8103 | + /// `aomenc --bit-depth=12 --profile=2 --film-grain-test=5` stream -- grain |
| 8104 | + /// params present AND applied (2 luma + 9 cb + 9 cr scaling points, | ||
| 8105 | + /// overlap blending on, clip-to-restricted-range on; the second frame is | ||
| 8106 | + /// an INTER frame that inherits the params via `update_grain = 0`) -- | ||
| 8107 | + /// decoded byte-exact against ffmpeg's own 12-bit decode of the identical | ||
| 8108 | + /// bytes (ffmpeg synthesizes grain by default; no grain-disable flag is | ||
| 8109 | + /// passed anywhere in this file). Proves the bit-depth-generic grain path | ||
| 8110 | + /// at 12 bits: `grain_range`'s ±(128 << 4) AR clamp and overlap-blend | ||
| 8111 | + /// clamp, the `gauss_sec_shift = 12 - bd` Gaussian shift, the 4096-entry | ||
| 8112 | + /// expanded scaling-LUT interpolation, and the `<< (bit_depth - 8)` | ||
| 8113 | + /// chroma offsets and legal-range clamps. HARD-asserts the parsed headers | ||
| 8114 | + /// really carry that coverage and `film_grain::grain_hits()` fired, so | ||
| 8115 | + /// neither a params-without-apply stream nor a silently-skipped synthesis | ||
| 8116 | + /// can pass vacuously. | ||
| 8128 | #[test] | 8117 | #[test] |
| 8129 | - fn a_12bit_film_grain_stream_is_refused_by_name() { | 8118 | + fn a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact() { |
| 8130 | - const NAME: &str = "a_12bit_film_grain_stream_is_refused_by_name"; | 8119 | + const NAME: &str = "a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact"; |
| 8131 | let _gate_lock = lock_gate_counters(); | 8120 | let _gate_lock = lock_gate_counters(); |
| 8121 | + if !have_ffmpeg() { | ||
| 8122 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 8123 | + return; | ||
| 8124 | + } | ||
| 8132 | if !have_aomenc() { | 8125 | if !have_aomenc() { |
| 8133 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | 8126 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 8134 | return; | 8127 | return; |
| 8135 | } | 8128 | } |
| 8136 | - let y4m = y4m_12bit_subpel_source(1); | 8129 | + let y4m = y4m_12bit_subpel_source(2); |
| 8137 | - let stream = encode_12bit(&y4m, 1, &["--film-grain-test=1"]); | 8130 | + // Warp stays refused at 12 bits (lane-av112bitg lifts GRAIN only), so |
| 8138 | - let err = decode_stream(&stream).unwrap_err().to_string(); | 8131 | + // the arm pins both motion tools off exactly once each -- aomenc |
| 8132 | + // otherwise picks warped motion on this fixture's sub-pel motion. | ||
| 8133 | + let stream = encode_12bit( | ||
| 8134 | + &y4m, | ||
| 8135 | + 2, | ||
| 8136 | + &[ | ||
| 8137 | + "--film-grain-test=5", | ||
| 8138 | + "--enable-warped-motion=0", | ||
| 8139 | + "--enable-global-motion=0", | ||
| 8140 | + ], | ||
| 8141 | + ); | ||
| 8142 | + assert_12bit_sequence_header(&stream, NAME); | ||
| 8143 | + // The arm is only honest if the stream itself carries the coverage: | ||
| 8144 | + // grain applied on every frame, scaling points on all three planes, | ||
| 8145 | + // overlap blending and restricted-range clipping on. | ||
| 8146 | + let mut probe = Av1Parser::new(); | ||
| 8147 | + let mut pos = 0usize; | ||
| 8148 | + let mut grain_frames = 0usize; | ||
| 8149 | + while pos < stream.len() { | ||
| 8150 | + let obu = probe.parse_obu(&stream[pos..]).unwrap(); | ||
| 8151 | + pos += obu.total_size; | ||
| 8152 | + if let ObuKind::Frame(header, _) = obu.kind { | ||
| 8153 | + let fg = &header.film_grain; | ||
| 8154 | + assert!( | ||
| 8155 | + fg.apply_grain, | ||
| 8156 | + "{NAME}: frame without apply_grain -- aomenc emitted params it does not apply" | ||
| 8157 | + ); | ||
| 8158 | + assert!( | ||
| 8159 | + fg.num_y_points > 0 && fg.num_cb_points > 0 && fg.num_cr_points > 0, | ||
| 8160 | + "{NAME}: grain without all three planes' scaling points -- the bit-depth \ | ||
| 8161 | + LUT math would not be exercised" | ||
| 8162 | + ); | ||
| 8163 | + assert!( | ||
| 8164 | + fg.overlap_flag, | ||
| 8165 | + "{NAME}: overlap off -- the grain_min/grain_max blend clamp is not exercised" | ||
| 8166 | + ); | ||
| 8167 | + assert!( | ||
| 8168 | + fg.clip_to_restricted_range, | ||
| 8169 | + "{NAME}: clip_to_restricted_range off -- the << (bd - 8) legal-range clamps \ | ||
| 8170 | + are not exercised" | ||
| 8171 | + ); | ||
| 8172 | + grain_frames += 1; | ||
| 8173 | + } | ||
| 8174 | + } | ||
| 8175 | + assert_eq!(grain_frames, 2, "{NAME}: expected grain on both frames"); | ||
| 8176 | + let before = crate::film_grain::grain_hits(); | ||
| 8177 | + let frames = decode_stream(&stream) | ||
| 8178 | + .unwrap_or_else(|e| panic!("{NAME}: decode_stream refused a real 12-bit grain stream: {e}")); | ||
| 8179 | + assert_eq!(frames.len(), 2); | ||
| 8139 | assert!( | 8180 | assert!( |
| 8140 | - err.contains( | 8181 | + crate::film_grain::grain_hits() > before, |
| 8141 | - "film grain synthesis at 12 bits (no byte-exact 12-bit grain witness exists: the 12-bit gates encode with grain off)" | 8182 | + "{NAME}: matched but zero grain_hits -- grain synthesis never ran" |
| 8142 | - ), | ||
| 8143 | - "{NAME}: expected the 12-bit grain refusal, got: {err}" | ||
| 8144 | ); | 8183 | ); |
| 8184 | + let ffmpeg_frames = ffmpeg_decode_sequence_12bit(&stream, 160, 128, 2); | ||
| 8185 | + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 8186 | + assert_eq!(ours.y, theirs.y, "{NAME}: luma vs ffmpeg (12-bit grain, frame {i})"); | ||
| 8187 | + assert_eq!(ours.u, theirs.u, "{NAME}: U vs ffmpeg (12-bit grain, frame {i})"); | ||
| 8188 | + assert_eq!(ours.v, theirs.v, "{NAME}: V vs ffmpeg (12-bit grain, frame {i})"); | ||
| 8189 | + } | ||
| 8190 | + eprintln!("{NAME}: byte-exact, grain_hits={}", crate::film_grain::grain_hits()); | ||
| 8145 | } | 8191 | } |
| 8146 | 8192 | ||
| 8147 | /// The 12-bit screen-content refusal: a real `--tune-content=screen | 8193 | /// The 12-bit screen-content refusal: a real `--tune-content=screen |
lanes/av112bitg.report.mdadded+90 -0
| @@ -0,0 +1,90 @@ | |||
| 1 | +# lane-av112bitg — 12-bit film grain joins the witnessed set | ||
| 2 | + | ||
| 3 | +Base 786c15b6 (lane-av112bitc), worktree `edith_codecs-av112bg`. The charter: | ||
| 4 | +lift the `film grain synthesis at 12 bits` refusal exactly as far as a real | ||
| 5 | +`aomenc --bit-depth=12` grain stream proves byte-exactness against ffmpeg, and | ||
| 6 | +leave warp and screen content refused. Sibling lane av112bitw owns warp; | ||
| 7 | +`film_grain.rs` needed no arithmetic change, so the two lanes share no code | ||
| 8 | +except the refusal inventory rows (grain rows only here). | ||
| 9 | + | ||
| 10 | +## Emission (charter gate 1: passed on try 1) | ||
| 11 | + | ||
| 12 | +`--film-grain-test=N` maps to libaom's `film_grain_test_vectors[N-1]` | ||
| 13 | +(`av1/encoder/grain_test_vectors.h`); `av1_update_film_grain_parameters` | ||
| 14 | +overwrites the vector's static `bit_depth: 8` with the sequence's | ||
| 15 | +(`encoder_utils.c:792`), and `av1_update_film_grain_parameters_seq` turns on | ||
| 16 | +`film_grain_params_present`. Probed all of vectors 1..8 on the lane's 12-bit | ||
| 17 | +sub-pel fixture: every one emits `apply_grain=1` on BOTH the key and the inter | ||
| 18 | +frame header (vectors 1..8, 2-frame streams, all parsed and printed by a | ||
| 19 | +scratch gate before the lift). No try failed, so the "8 tries" stop condition | ||
| 20 | +never came close. | ||
| 21 | + | ||
| 22 | +## The bit-depth audit (no assumptions) | ||
| 23 | + | ||
| 24 | +Every bit-depth-sensitive site of `film_grain.rs` re-diffed against the oracle | ||
| 25 | +`~/.cache/aom-oracle/src/av1/decoder/grain_synthesis.c` (v3.13.3 @ 92d4c37): | ||
| 26 | + | ||
| 27 | +| site | oracle | ours | | ||
| 28 | +|---|---|---| | ||
| 29 | +| `grain_min/max = ±(128 << (bd-8))` AR + blend clamp | `:1043-1045` | `grain_range` | | ||
| 30 | +| `gauss_sec_shift = 12 - bd + grain_scale_shift` | `:468`, `:503` | both `generate_*_grain_block`s | | ||
| 31 | +| `scale_LUT` shift-4 interpolation, `x == 255` short-circuit | `:616-626` | `scale_lut` | | ||
| 32 | +| expanded LUT (4096 entries at 12-bit) | per-call `scale_LUT` | `expand_scaling_lut` (same function tabulated) | | ||
| 33 | +| chroma index combine `((avg*luma_mult + mult*chroma) >> 6) + offset`, clamp `0..(256 << (bd-8)) - 1` | `:815-819`, `:830-834` | `chroma_noise_row_scalar` + ChromaNoise | | ||
| 34 | +| `cb/cr_offset = (x << (bd-8)) - (1 << bd)` | `:752`, `:757` | `add_noise_to_block` | | ||
| 35 | +| legal-range clamps `16/235/240 << (bd-8)`, `mc_identity` chroma quirk | `:781-795` | `add_noise_to_block` | | ||
| 36 | +| 4:2:0 chroma luma average `(l0 + l1 + 1) >> 1` (horizontal PAIR, not a quad) | `:801-806` | `chroma_noise_row_scalar` | | ||
| 37 | +| ver/hor overlap blends clamped to `grain_min/grain_max` | `:912-970` | `ver_overlap_inplace`/`hor_overlap_inplace` | | ||
| 38 | + | ||
| 39 | +The AVX2 kernels are parameter-shaped (`index_max`, min/max, LUT length all | ||
| 40 | +inputs; the `vpmaddwd` luma pair sum stays exact at 12-bit since | ||
| 41 | +`2 * 4095 < 2^15`) and this machine's decode path runs them (chroma blocks are | ||
| 42 | +15 wide -> 8+4+3 tails; luma 30 wide -> 8+8+8+4+2), so the witness exercised | ||
| 43 | +SIMD and scalar alike. `apply_grain` call sites already thread the parsed | ||
| 44 | +sequence `bit_depth` (the `map_or(8, ...)` site included). | ||
| 45 | + | ||
| 46 | +## The witness | ||
| 47 | + | ||
| 48 | +`stream.rs`: `grain_refusal` and its four call sites deleted; the refusal gate | ||
| 49 | +became `a_real_aomenc_12bit_film_grain_stream_decodes_pixel_exact`: | ||
| 50 | + | ||
| 51 | +- `aomenc --profile=2 --bit-depth=12 --film-grain-test=5 | ||
| 52 | + --enable-warped-motion=0 --enable-global-motion=0`, 2 frames over the lane's | ||
| 53 | + 160x128 C420p12 sub-pel fixture. Vector 5 carries 2 luma + 9 cb + 9 cr | ||
| 54 | + scaling points, `overlap_flag=1`, `clip_to_restricted_range=1`; the inter | ||
| 55 | + frame codes `update_grain=0` (params inherited from the ref slot, new seed | ||
| 56 | + only), so the gate also exercises the spec 5.9.30 persistence path and grain | ||
| 57 | + on a non-key output. | ||
| 58 | +- Warp is pinned OFF by name: the unpinned first run tripped the (sibling's, | ||
| 59 | + intact) `warped motion at 12 bits` refusal — this lane lifts GRAIN only, so | ||
| 60 | + the arm stays inside the witnessed set. Each flag spelled exactly once | ||
| 61 | + (aomenc LAST-occurrence precedence). | ||
| 62 | +- Non-vacuity: parsed-header asserts demand `apply_grain`, all three planes' | ||
| 63 | + scaling points, overlap and restricted-range clipping on BOTH frames; | ||
| 64 | + `film_grain::grain_hits()` must advance; ffmpeg decodes with grain ON by | ||
| 65 | + default and must produce exactly 2 yuv420p12le frames. | ||
| 66 | +- Result: **byte-exact on every plane of both frames** (grain_hits=2). ffmpeg | ||
| 67 | + synthesized the identical grain from the identical reconstruction. | ||
| 68 | + | ||
| 69 | +## Inventory | ||
| 70 | + | ||
| 71 | +`refusal_inventory.rs`: grain REFUSALS string and PROVEN row deleted (37 -> 36 | ||
| 72 | +refusals), lane-av112bitg notes added next to the lane-av112bitc ones. | ||
| 73 | +`the_decode_path_refuses_exactly_the_listed_cases` and | ||
| 74 | +`every_proven_refusal_names_a_test_that_exists` both green. | ||
| 75 | + | ||
| 76 | +## Regression (all green, same run) | ||
| 77 | + | ||
| 78 | +- `a_real_aomenc_12bit_stream_decodes_pixel_exact` — parent 12-bit KEY fixture, grain off, byte-exact. | ||
| 79 | +- `a_real_aomenc_12bit_inter_sequence_decodes_pixel_exact`, | ||
| 80 | + `a_real_aomenc_12bit_compound_inter_sequence_decodes_pixel_exact` — 12-bit inter/compound witnesses. | ||
| 81 | +- `a_real_aomenc_10bit_film_grain_stream_decodes_pixel_exact` + the other four `10bit_film` gates. | ||
| 82 | +- `a_12bit_warped_motion_stream_is_refused_by_name`, | ||
| 83 | + `a_12bit_screen_content_stream_is_refused_by_name` — sibling refusals intact. | ||
| 84 | +- Full `refusal_inventory` module. 26/26 tests, 0 warnings on | ||
| 85 | + `cargo check --all-targets -p ec-av1`. | ||
| 86 | + | ||
| 87 | +## Open | ||
| 88 | + | ||
| 89 | +None for grain. Warp (`a_12bit_warped_motion_stream_is_refused_by_name`, | ||
| 90 | +sibling lane av112bitw) and screen content tools stay refused by name. | ||