Merge branch 'lane-golomb2' (6675a24b): the straddle gate generates its segmented streams by recipe and asserts the block-q span; the Golomb reader bound is libaom's to the bit, comments corrected
Browse files at this commit5 changed files +230 -69
- crates/ec-av1/src/decode.rs +33 -11
- crates/ec-av1/src/refusal_inventory.rs +4 -3
- crates/ec-av1/src/stream.rs +80 -44
- lanes/d792.report.md +22 -11
- lanes/golomb2.report.md +91 -0
crates/ec-av1/src/decode.rsmodified+33 -11
| @@ -857,6 +857,12 @@ thread_local! { | |||
| 857 | /// ids any block ended up with -- the gate's proof the feature fired. | 857 | /// ids any block ended up with -- the gate's proof the feature fired. |
| 858 | static SEG_ID_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 858 | static SEG_ID_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 859 | static SEG_IDS_SEEN: std::cell::Cell<u8> = const { std::cell::Cell::new(0) }; | 859 | static SEG_IDS_SEEN: std::cell::Cell<u8> = const { std::cell::Cell::new(0) }; |
| 860 | + /// lane-golomb2: the (lowest, highest) quantizer index any block has been | ||
| 861 | + /// dequantized with, i.e. `block_q_idx`'s own span. A gate that means to | ||
| 862 | + /// exercise `SEG_LVL_ALT_Q` needs a stream where this span is WIDER than | ||
| 863 | + /// zero (class `gate-blind-to-feature`): segmentation being enabled says | ||
| 864 | + /// nothing about the segments carrying distinct quantizers. | ||
| 865 | + static BLOCK_Q_SPAN: std::cell::Cell<(i32, i32)> = const { std::cell::Cell::new((i32::MAX, i32::MIN)) }; | ||
| 860 | /// How many `seg_id_predicted` symbols were read (temporal update). | 866 | /// How many `seg_id_predicted` symbols were read (temporal update). |
| 861 | static SEG_PRED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 867 | static SEG_PRED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 862 | } | 868 | } |
| @@ -906,6 +912,13 @@ pub(crate) fn segment_ids_seen() -> usize { | |||
| 906 | SEG_IDS_SEEN.with(|c| c.get().count_ones() as usize) | 912 | SEG_IDS_SEEN.with(|c| c.get().count_ones() as usize) |
| 907 | } | 913 | } |
| 908 | 914 | ||
| 915 | +/// The lowest and highest quantizer index any decoded block was dequantized | ||
| 916 | +/// with (`(i32::MAX, i32::MIN)` when nothing decoded). | ||
| 917 | +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates | ||
| 918 | +pub(crate) fn block_q_span() -> (i32, i32) { | ||
| 919 | + BLOCK_Q_SPAN.with(|c| c.get()) | ||
| 920 | +} | ||
| 921 | + | ||
| 909 | /// How many `seg_id_predicted` symbols have been read (temporal update). | 922 | /// How many `seg_id_predicted` symbols have been read (temporal update). |
| 910 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates | 923 | #[allow(dead_code)] // read only from the `#[cfg(test)]` gates |
| 911 | pub(crate) fn segment_pred_hits() -> usize { | 924 | pub(crate) fn segment_pred_hits() -> usize { |
| @@ -918,6 +931,7 @@ pub(crate) fn reset_segment_hits() { | |||
| 918 | SEG_ID_HITS.with(|c| c.set(0)); | 931 | SEG_ID_HITS.with(|c| c.set(0)); |
| 919 | SEG_IDS_SEEN.with(|c| c.set(0)); | 932 | SEG_IDS_SEEN.with(|c| c.set(0)); |
| 920 | SEG_PRED_HITS.with(|c| c.set(0)); | 933 | SEG_PRED_HITS.with(|c| c.set(0)); |
| 934 | + BLOCK_Q_SPAN.with(|c| c.set((i32::MAX, i32::MIN))); | ||
| 921 | } | 935 | } |
| 922 | 936 | ||
| 923 | /// `seg_feature_active_idx(segment_id, feature)` for the frame currently | 937 | /// `seg_feature_active_idx(segment_id, feature)` for the frame currently |
| @@ -947,6 +961,10 @@ fn block_q_idx(fctx: &crate::decode::FrameCtx) -> i32 { | |||
| 947 | if crate::envflags::env_flag!("EC_DQCOEFF") { | 961 | if crate::envflags::env_flag!("EC_DQCOEFF") { |
| 948 | eprintln!("OUR_Q base={base} seg={seg_id} q={q}"); | 962 | eprintln!("OUR_Q base={base} seg={seg_id} q={q}"); |
| 949 | } | 963 | } |
| 964 | + hit_do!(BLOCK_Q_SPAN.with(|c| { | ||
| 965 | + let (lo, hi) = c.get(); | ||
| 966 | + c.set((lo.min(q), hi.max(q))); | ||
| 967 | + });); | ||
| 950 | q | 968 | q |
| 951 | } | 969 | } |
| 952 | 970 | ||
| @@ -6026,18 +6044,22 @@ pub(crate) fn tx_type_symbol(cdf_len: usize, tx_type: TxType) -> Option<usize> { | |||
| 6026 | /// (spec 5.11.40): its bit length in unary, then that many of its own bits, | 6044 | /// (spec 5.11.40): its bit length in unary, then that many of its own bits, |
| 6027 | /// most significant first — the exact inverse of [`crate::tile::write_golomb`]. | 6045 | /// most significant first — the exact inverse of [`crate::tile::write_golomb`]. |
| 6028 | pub(crate) fn read_golomb(dec: &mut SymbolDecoder) -> Result<u32> { | 6046 | pub(crate) fn read_golomb(dec: &mut SymbolDecoder) -> Result<u32> { |
| 6029 | - // lane-scaledref r1: this cap MASKS A REAL DEFECT and must not be lifted | 6047 | + // THIS CAP IS libaom's OWN, TO THE BIT -- do not "widen" it (lane-golomb2 |
| 6030 | - // on its own. Reading up to 32 leading zeros (dav1d's `len < 32`; libaom | 6048 | + // re-read the source: `av1/decoder/decodetxb.c:22-43` counts the same |
| 6031 | - // itself calls a 21st bit a corrupt frame, decodetxb.c:30) is bit-identical | 6049 | + // prefix and calls the 21st zero bit `AOM_CODEC_CORRUPT_FRAME`, "Invalid |
| 6032 | - // for every tail any encoder writes -- our own writer tops out at 19 zeros | 6050 | + // length in read_golomb"; spec 5.11.40 BREAKS at `length == 20` and 5.11.39 |
| 6033 | - // (`tile::MAX_LEVEL == MAX_BR_LEVEL + (1 << 19)`) -- and was implemented | 6051 | + // masks the level with `0xFFFFF`, so no conformant stream carries a longer |
| 6034 | - // and round-trip tested here (commit ee1f980, reverted in 314ee08). It | 6052 | + // tail). `refusal_inventory::read_golomb_reads_every_value_a_conformant_ |
| 6053 | + // stream_can_carry` enumerates that whole value domain. | ||
| 6054 | + // | ||
| 6055 | + // So this refusal never names a reader gap: it is always the SYMPTOM of an | ||
| 6056 | + // earlier desync (class `refusal-hides-a-defect`), and every historical | ||
| 6057 | + // instance was closed by fixing that desync -- lane-dgolomb's | ||
| 6058 | + // `force_integer_mv`, lane-dkey's palette, lane-t900 r12's `uv_mode_grid`. | ||
| 6059 | + // Raising the cap only trades a clean refusal for silent corruption: | ||
| 6060 | + // lane-scaledref r1 tried it (commit ee1f980, reverted in 314ee08) and | ||
| 6035 | // turned `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` | 6061 | // turned `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` |
| 6036 | - // RED: seed 67 stops here today, and with the cap raised it decodes to a | 6062 | + // from a refusal into a frame-0 LUMA MISMATCH. |
| 6037 | - // frame-0 LUMA MISMATCH instead. A key frame cannot legitimately carry a | ||
| 6038 | - // level above 1<<19, so the long tail is the SYMPTOM of an earlier desync | ||
| 6039 | - // in that intra rect64 stream -- class `refusal-hides-a-defect`. Lift this | ||
| 6040 | - // together with that defect's fix, not before. | ||
| 6041 | let mut length = 1u32; | 6063 | let mut length = 1u32; |
| 6042 | while dec.literal(1) == 0 { | 6064 | while dec.literal(1) == 0 { |
| 6043 | length += 1; | 6065 | length += 1; |
crates/ec-av1/src/refusal_inventory.rsmodified+4 -3
| @@ -890,9 +890,10 @@ mod tests { | |||
| 890 | /// | 890 | /// |
| 891 | /// The residue is a bit pattern, not a value: the spec's break makes the | 891 | /// The residue is a bit pattern, not a value: the spec's break makes the |
| 892 | /// 20th prefix bit a don't-care, so a stream whose 20th prefix bit is 0 | 892 | /// 20th prefix bit a don't-care, so a stream whose 20th prefix bit is 0 |
| 893 | - /// decodes to the same value there and is refused here. Every encoder | 893 | + /// decodes to the same value there and is refused here. libaom refuses the |
| 894 | - /// writes the terminating 1 (our own writer tops out at 19 zeros), and | 894 | + /// same bit (`av1/decoder/decodetxb.c:30`, `AOM_CODEC_CORRUPT_FRAME` at |
| 895 | - /// lifting the cap is blocked on the defect it currently masks -- see the | 895 | + /// `length > 20`), so this refusal is NOT a reader gap to widen: when it |
| 896 | + /// fires on a real stream it is an earlier desync's symptom -- see the | ||
| 896 | /// comment on `read_golomb`. | 897 | /// comment on `read_golomb`. |
| 897 | #[test] | 898 | #[test] |
| 898 | fn read_golomb_reads_every_value_a_conformant_stream_can_carry() { | 899 | fn read_golomb_reads_every_value_a_conformant_stream_can_carry() { |
crates/ec-av1/src/stream.rsmodified+80 -44
| @@ -35201,55 +35201,91 @@ pub(crate) mod tests { | |||
| 35201 | } | 35201 | } |
| 35202 | const FRAMES: usize = 4; | 35202 | const FRAMES: usize = 4; |
| 35203 | let mut checked = 0usize; | 35203 | let mut checked = 0usize; |
| 35204 | - // The PINNED half of this gate. The generated rows below are the | 35204 | + // The SEGMENTED half of this gate, built BY RECIPE. |
| 35205 | - // general regression; these two files are rav1e's own answer to a | 35205 | + // |
| 35206 | - // 384x152 crop of a REAL film (`speed=6`, quantizer 100 and 150, | 35206 | + // The defect this gate exists for only shows on a stream whose |
| 35207 | - // `-g 4`), which is the only recipe measured to turn on the | 35207 | + // segments carry distinct `SEG_LVL_ALT_Q`, and neither `testsrc2` nor |
| 35208 | - // activity segmentation whose `SEG_LVL_ALT_Q` the rect dequant path | 35208 | + // the repo's own clip turns activity segmentation on at all (ledger |
| 35209 | - // dropped -- a `testsrc2` or repo-fixture source codes one segment | 35209 | + // dead-end: 16 ladder points all pass with the defect still in). The |
| 35210 | - // and passes this gate with the defect still in (both verified by | 35210 | + // contrast is therefore built here -- half flat grey, half heavy |
| 35211 | - // reverting the fix under it). Bytes live in the shared `fixtures` | 35211 | + // noise -- and libaom's `-aq-mode 1` answers it with segments whose |
| 35212 | - // directory, which is gitignored, so a missing file SKIPs. | 35212 | + // quantizer indices differ; `block_q_span()` asserts exactly that, so |
| 35213 | - for name in [ | 35213 | + // the gate cannot go quietly blind (class `gate-blind-to-feature`). |
| 35214 | - "d792_straddle_rav1e_384x152_q100.obu", | 35214 | + // This replaces two crops of a real film that could never be |
| 35215 | - "d792_straddle_rav1e_384x152_q150.obu", | 35215 | + // committed and so SKIPped on every fresh clone. |
| 35216 | - ] { | 35216 | + for (w, h) in [(384usize, 152usize), (384, 184)] { |
| 35217 | - let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | 35217 | + for crf in ["20", "35"] { |
| 35218 | - .join("../../fixtures") | 35218 | + let half = (w / 2).to_string(); |
| 35219 | - .join(name); | 35219 | + let flat = format!("color=c=gray:s={half}x{h}:r=25:d=1"); |
| 35220 | - let Ok(stream) = std::fs::read(&path) else { | 35220 | + let busy = format!("{flat},noise=alls=80:all_seed=7:allf=t+u"); |
| 35221 | - eprintln!("SKIP {NAME}: {name} missing"); | 35221 | + let args: Vec<String> = [ |
| 35222 | - continue; | 35222 | + "-v", "error", "-f", "lavfi", "-i", &flat, "-f", "lavfi", "-i", &busy, |
| 35223 | - }; | 35223 | + "-filter_complex", "[0:v][1:v]hstack=inputs=2,format=yuv420p", |
| 35224 | - let (w, h) = (384usize, 152usize); | 35224 | + "-frames:v", &FRAMES.to_string(), "-pix_fmt", "yuv420p", "-an", |
| 35225 | - let want = ffmpeg_decode_sequence(&stream, w, h, FRAMES); | 35225 | + "-threads", "1", "-g", &FRAMES.to_string(), "-c:v", "libaom-av1", |
| 35226 | - let got = decode_stream(&stream) | 35226 | + "-cpu-used", "6", "-b:v", "0", "-crf", crf, |
| 35227 | - .unwrap_or_else(|e| panic!("{NAME}: {name} refused: {e}")); | 35227 | + // libaom's activity segmentation, i.e. `SEG_LVL_ALT_Q`. |
| 35228 | - assert_eq!(got.len(), want.len(), "{NAME}: {name} frame count"); | 35228 | + "-aq-mode", "1", "-f", "obu", "-", |
| 35229 | - for (f, (o, r)) in got.iter().zip(&want).enumerate() { | 35229 | + ] |
| 35230 | - for (plane, a, b) in [("Y", &o.y, &r.y), ("U", &o.u, &r.u), ("V", &o.v, &r.v)] { | 35230 | + .iter() |
| 35231 | - if let Some(i) = a.iter().zip(b.iter()).position(|(x, y)| x != y) { | 35231 | + .map(|s| (*s).to_string()) |
| 35232 | - let stride = if plane == "Y" { w } else { w / 2 }; | 35232 | + .collect(); |
| 35233 | - panic!( | 35233 | + let out = Command::new("ffmpeg") |
| 35234 | - "{NAME}: {name}, frame {f} plane {plane} sample ({}, {}): ours {} \ | 35234 | + .args(&args) |
| 35235 | - vs ffmpeg {}", | 35235 | + .stdin(Stdio::null()) |
| 35236 | - i % stride, | 35236 | + .stdout(Stdio::piped()) |
| 35237 | - i / stride, | 35237 | + .stderr(Stdio::piped()) |
| 35238 | - a[i], | 35238 | + .output() |
| 35239 | - b[i], | 35239 | + .expect("ffmpeg failed to run"); |
| 35240 | - ); | 35240 | + if !out.status.success() { |
| 35241 | + eprintln!( | ||
| 35242 | + "SKIP {NAME}: ffmpeg cannot encode the segmented {w}x{h} recipe ({})", | ||
| 35243 | + String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("") | ||
| 35244 | + ); | ||
| 35245 | + continue; | ||
| 35246 | + } | ||
| 35247 | + let stream = out.stdout; | ||
| 35248 | + let want = ffmpeg_decode_sequence(&stream, w, h, FRAMES); | ||
| 35249 | + crate::decode::reset_segment_hits(); | ||
| 35250 | + let got = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 35251 | + panic!("{NAME}: the segmented {w}x{h} crf {crf} recipe refused: {e}") | ||
| 35252 | + }); | ||
| 35253 | + let (lo, hi) = crate::decode::block_q_span(); | ||
| 35254 | + assert!( | ||
| 35255 | + hi > lo, | ||
| 35256 | + "{NAME}: the segmented {w}x{h} crf {crf} recipe dequantized every block \ | ||
| 35257 | + with q {lo} -- no segment carried a distinct SEG_LVL_ALT_Q, so this row \ | ||
| 35258 | + would pass with the rect dequant defect back in ({} segment ids seen)", | ||
| 35259 | + crate::decode::segment_ids_seen() | ||
| 35260 | + ); | ||
| 35261 | + assert_eq!(got.len(), want.len(), "{NAME}: segmented {w}x{h} frame count"); | ||
| 35262 | + for (f, (o, r)) in got.iter().zip(&want).enumerate() { | ||
| 35263 | + for (plane, a, b) in [("Y", &o.y, &r.y), ("U", &o.u, &r.u), ("V", &o.v, &r.v)] { | ||
| 35264 | + if let Some(i) = a.iter().zip(b.iter()).position(|(x, y)| x != y) { | ||
| 35265 | + let stride = if plane == "Y" { w } else { w / 2 }; | ||
| 35266 | + panic!( | ||
| 35267 | + "{NAME}: segmented {w}x{h} crf {crf}, frame {f} plane {plane} \ | ||
| 35268 | + sample ({}, {}): ours {} vs ffmpeg {} (block q span {lo}..{hi})", | ||
| 35269 | + i % stride, | ||
| 35270 | + i / stride, | ||
| 35271 | + a[i], | ||
| 35272 | + b[i], | ||
| 35273 | + ); | ||
| 35274 | + } | ||
| 35241 | } | 35275 | } |
| 35242 | } | 35276 | } |
| 35277 | + eprintln!( | ||
| 35278 | + "{NAME}: segmented {w}x{h} crf {crf} exact, block q span {lo}..{hi}" | ||
| 35279 | + ); | ||
| 35280 | + checked += 1; | ||
| 35243 | } | 35281 | } |
| 35244 | - checked += 1; | ||
| 35245 | } | 35282 | } |
| 35246 | for (w, h) in [(384usize, 152usize), (384, 184)] { | 35283 | for (w, h) in [(384usize, 152usize), (384, 184)] { |
| 35247 | - // REAL content, not colour bars (class `gate film rows are colour | 35284 | + // The ENCODER-LADDER half: both reference encoders, every |
| 35248 | - // bars`): both encoders only turn segmentation on -- the feature | 35285 | + // ladder point, on real (non-bars) content. These rows code ONE |
| 35249 | - // this gate is about -- when the picture's activity varies, and | 35286 | + // segment, so they do not gate `SEG_LVL_ALT_Q` -- that is the |
| 35250 | - // `testsrc2` codes one segment, so a bars source passes this gate | 35287 | + // recipe rows' job above -- but they are the rectangular |
| 35251 | - // with the defect still in (verified by reverting the fix under | 35288 | + // partition coverage rav1e's straddle answer adds. |
| 35252 | - // it). | ||
| 35253 | let clip = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | 35289 | let clip = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |
| 35254 | .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4"); | 35290 | .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4"); |
| 35255 | if !clip.exists() { | 35291 | if !clip.exists() { |
lanes/d792.report.mdmodified+22 -11
| @@ -176,17 +176,28 @@ counter. | |||
| 176 | (quantizer 50/100/150/200) and libaom (`-cpu-used 6 -crf 5/20/35/45 | 176 | (quantizer 50/100/150/200) and libaom (`-cpu-used 6 -crf 5/20/35/45 |
| 177 | -aq-mode 1`), each decoded by ffmpeg and by us and compared sample by | 177 | -aq-mode 1`), each decoded by ffmpeg and by us and compared sample by |
| 178 | sample. | 178 | sample. |
| 179 | -* **Pinned rows** -- `fixtures/d792_straddle_rav1e_384x152_q100.obu` and | 179 | +* **Recipe rows (lane-golomb2)** -- a SYNTHETIC source built for the feature: |
| 180 | - `..._q150.obu`, rav1e's own answer to a 384x152 crop of a real film. | 180 | + half flat grey, half heavy `noise` (hstacked in lavfi), encoded by libaom |
| 181 | - | 181 | + `-cpu-used 6 -crf 20/35 -aq-mode 1` at both straddling sizes. libaom's |
| 182 | -That split is not decoration. **The generated rows alone do NOT catch this | 182 | + activity segmentation answers that contrast with segments whose quantizers |
| 183 | -defect**: with the fix reverted under them, first a `testsrc2` source and then | 183 | + differ, which the row asserts through the decoder's own |
| 184 | -the repo's own `h264-1080p-23.976-8bit.mp4` fixture (which is colour bars, | 184 | + `decode::block_q_span()` (measured: q 33..106 at crf 20, 89..160 at crf 35). |
| 185 | -per the standing note) both PASSED at all 16 points, because neither codes | 185 | + |
| 186 | -more than one segment, and the defect only exists where `SEG_LVL_ALT_Q` does | 186 | +That split is not decoration. **The generated ladder rows alone do NOT catch |
| 187 | -(class `gate-blind-to-feature`). The pinned rows fail pre-fix at | 187 | +this defect**: with the fix reverted under them, first a `testsrc2` source and |
| 188 | -`frame 0 plane Y sample (17, 140): ours 41 vs ffmpeg 42` and pass after, so | 188 | +then the repo's own `h264-1080p-23.976-8bit.mp4` fixture (which is colour |
| 189 | -the gate's defect-catching power is measured, not assumed. | 189 | +bars, per the standing note) both PASSED at all 16 points, because neither |
| 190 | +codes more than one segment, and the defect only exists where `SEG_LVL_ALT_Q` | ||
| 191 | +does (class `gate-blind-to-feature`). The recipe rows fail pre-fix at | ||
| 192 | +`segmented 384x152 crf 20, frame 0 plane U sample (160, 64): ours 126 vs | ||
| 193 | +ffmpeg 123` (the six sites of `e4cab216` reverted by hand, gate re-run) and | ||
| 194 | +pass after, so the gate's defect-catching power is measured, not assumed. | ||
| 195 | + | ||
| 196 | +The two pinned streams this gate used to carry | ||
| 197 | +(`fixtures/d792_straddle_rav1e_384x152_q{100,150}.obu`) were crops of a real | ||
| 198 | +film: untracked, uncommittable, and SKIPped on any fresh clone, i.e. blind | ||
| 199 | +where it mattered most (class `gate-skips-on-its-own-failure`). They are | ||
| 200 | +deleted; the recipe rows replace them. | ||
| 190 | 201 | ||
| 191 | ## Verification | 202 | ## Verification |
| 192 | 203 | ||
lanes/golomb2.report.mdadded+91 -0
| @@ -0,0 +1,91 @@ | |||
| 1 | +# lane-golomb2 — the straddle gate's fixtures, and the Golomb bound | ||
| 2 | + | ||
| 3 | +Two tasks. (A) landed a fix-equivalent gate; (B) is a REFUTED premise plus a | ||
| 4 | +found defect that is not the chartered one. | ||
| 5 | + | ||
| 6 | +## (A) the straddle gate's SEG_LVL_ALT_Q rows are a recipe now | ||
| 7 | + | ||
| 8 | +`stream::tests::a_straddling_frame_decodes_exactly_on_both_reference_encoders_ladders` | ||
| 9 | +used to pin two crops of a real film (`fixtures/d792_straddle_rav1e_384x152_ | ||
| 10 | +q{100,150}.obu`). `fixtures/` is gitignored, the files could never be | ||
| 11 | +committed, and the test `continue`d when they were missing, so the only half | ||
| 12 | +of the gate that saw the rect-dequant defect was blind on every fresh clone | ||
| 13 | +(class `gate-skips-on-its-own-failure`). | ||
| 14 | + | ||
| 15 | +**Recipe** (in the test, no new script): two lavfi inputs hstacked -- | ||
| 16 | +`color=c=gray:s={w/2}x{h}` and the same with `noise=alls=80:all_seed=7:allf= | ||
| 17 | +t+u` -- encoded by `ffmpeg -c:v libaom-av1 -cpu-used 6 -b:v 0 -crf {20,35} | ||
| 18 | +-aq-mode 1 -g 4 -threads 1` at 384x152 and 384x184, 4 frames, decoded by | ||
| 19 | +ffmpeg and by us and compared on all three planes. The flat/noise contrast is | ||
| 20 | +what turns libaom's activity segmentation on; a `testsrc2` or repo-clip source | ||
| 21 | +codes ONE segment (ledger dead-end) and would pass with the defect in. | ||
| 22 | + | ||
| 23 | +**The property is asserted, not hoped for**: new `decode::block_q_span()` (a | ||
| 24 | +`hit_do!` counter on `block_q_idx`, so it compiles out without | ||
| 25 | +`gate-counters`) reports the lowest and highest quantizer index any block was | ||
| 26 | +dequantized with, and each row asserts `hi > lo`. Measured: **q 33..106 at | ||
| 27 | +crf 20, 89..160 at crf 35**, both sizes. `EC_DQCOEFF=1` on the same stream | ||
| 28 | +prints `base=79 seg=0 q=33 / seg=5 q=98 / seg=6 q=106` -- three segments with | ||
| 29 | +distinct `SEG_LVL_ALT_Q`. | ||
| 30 | + | ||
| 31 | +**Sensitivity proof (measured, not asserted)**: the six sites of `e4cab216` | ||
| 32 | +reverted by hand (`block_q_idx(fctx)` -> `current_q_idx`), gate re-run -> | ||
| 33 | + | ||
| 34 | +``` | ||
| 35 | +a_straddling_frame...: segmented 384x152 crf 20, frame 0 plane U sample (160, 64): | ||
| 36 | +ours 126 vs ffmpeg 123 (block q span 33..106) | ||
| 37 | +``` | ||
| 38 | + | ||
| 39 | +i.e. the FIRST recipe row fails pre-fix. Restored, gate green: **20 | ||
| 40 | +straddling reference points sample-exact, 4.1 s** (4 recipe + 16 ladder). | ||
| 41 | + | ||
| 42 | +**Deleted**: `fixtures/d792_straddle_rav1e_384x152_q100.obu` and `..._q150.obu` | ||
| 43 | +from the shared fixtures dir; the only references (this test, and the "Pinned | ||
| 44 | +rows" section of `lanes/d792.report.md`) are rewritten. The gate still SKIPs | ||
| 45 | +with a printed reason when ffmpeg or libaom is absent. | ||
| 46 | + | ||
| 47 | +## (B) the Golomb bound is libaom's own — REFUTED, no widening | ||
| 48 | + | ||
| 49 | +The charter asked to widen `decode.rs read_golomb` "to the spec/libaom bound | ||
| 50 | +(up to 32 leading zeros)". libaom does not have that bound: | ||
| 51 | + | ||
| 52 | +```c | ||
| 53 | +/* av1/decoder/decodetxb.c:22-43 */ | ||
| 54 | +static int read_golomb(MACROBLOCKD *xd, aom_reader *r) { | ||
| 55 | + ... | ||
| 56 | + if (length > 20) { | ||
| 57 | + aom_internal_error(xd->error_info, AOM_CODEC_CORRUPT_FRAME, | ||
| 58 | + "Invalid length in read_golomb"); | ||
| 59 | +``` | ||
| 60 | + | ||
| 61 | +which is our `if length > 20` to the bit (ours starts `length = 1` and bumps | ||
| 62 | +before the test, libaom starts 0 and bumps after: both error on the 21st zero | ||
| 63 | +bit). Spec 5.11.40 BREAKS at `length == 20` and 5.11.39 masks the level with | ||
| 64 | +`0xFFFFF`, and `refusal_inventory::read_golomb_reads_every_value_a_conformant_ | ||
| 65 | +stream_can_carry` already enumerates that whole value domain. So there is no | ||
| 66 | +reader gap and nothing to lift: this refusal is always an earlier desync's | ||
| 67 | +SYMPTOM (every historical instance closed that way -- lane-dgolomb's | ||
| 68 | +`force_integer_mv`, lane-dkey's palette, lane-t900 r12's `uv_mode_grid`), and | ||
| 69 | +raising the cap trades a clean refusal for silent corruption (lane-scaledref | ||
| 70 | +r1 measured exactly that). The two doc comments that suggested otherwise are | ||
| 71 | +corrected in place; the refusal stays in the inventory. | ||
| 72 | + | ||
| 73 | +**The chartered refusal does not reproduce at `aba89feb`**: film A, | ||
| 74 | +`crop=1920:792`, 12 frames, libaom `-cpu-used 6 -crf 5/20/35/45 -aq-mode 1` | ||
| 75 | +and rav1e `speed=6 quantizer=50/100/150/200` -> **8/8 sample-exact vs ffmpeg** | ||
| 76 | +(crf 5 included). No `EC_GOLOMB` line fired on any ladder stream in this lane. | ||
| 77 | + | ||
| 78 | +## FOUND (not chartered, not fixed): libaom `-aq-mode 1` at 1920x1024 on film B | ||
| 79 | + | ||
| 80 | +Same ladder at `crop=1920:1024` on film B: **rav1e 4/4 exact, all four libaom | ||
| 81 | +points DIFFER** -- crf 45 diverges on the KEY frame at luma (883, 888), 188k | ||
| 82 | +samples, growing to 530k by frame 10. Dropping `-aq-mode 1` from the same | ||
| 83 | +recipe makes crf 45 **12/12 exact**, so it is the segmentation path again | ||
| 84 | +(sibling of the (A) defect, class `parsed-then-discarded`). It does NOT | ||
| 85 | +reproduce on 640x384 or 384x152 crops of the same source at the same recipe, | ||
| 86 | +so a witness needs the large frame. Streams kept at | ||
| 87 | +`$HOME/.cache/golomb2/streams/filmB_aom{5,20,35,45}.obu`. | ||
| 88 | + | ||
| 89 | +`deferred: the film B -aq-mode 1 divergence — out of this lane's scope and no | ||
| 90 | +small witness yet — unblocked by an aomdec EC_TRACE_COEFF/EC_IMODE diff at | ||
| 91 | +mi(222, 220) of frame 0 of filmB_aom45.obu` | ||