A skipped palette block with a split transform predicted DC off its edges
Browse files at this commit1edcdabbb2f086962f834fd5ac51df8943bbbdf9Parent: a77a341- fix
- a skipped palette block with a split transform predicted DC off its edges
2 changed files +61 -4
crates/ec-av1/src/decode.rsmodified+7 -4
| @@ -14236,12 +14236,15 @@ fn decode_block( | |||
| 14236 | // key frame; class override-slot-on-one-arm). Neither prediction is | 14236 | // key frame; class override-slot-on-one-arm). Neither prediction is |
| 14237 | // edge-derived, so the whole-block buffer at the block's own stride is | 14237 | // edge-derived, so the whole-block buffer at the block's own stride is |
| 14238 | // exactly what that single call wants. | 14238 | // exactly what that single call wants. |
| 14239 | - if let Some(buf) = &palette_y_buf | 14239 | + // Counted on the SHAPE, not on the arm below, so a gate can tell a stream |
| 14240 | - && (logical_tx == side) | 14240 | + // that reaches this block apart from one that never does (class |
| 14241 | - { | 14241 | + // gate-blind-to-feature). |
| 14242 | - if skip && logical_tx < side { | 14242 | + if palette_y_buf.is_some() && skip && logical_tx < side { |
| 14243 | hit!(SKIP_SPLIT_TX_OVERRIDE_HITS); | 14243 | hit!(SKIP_SPLIT_TX_OVERRIDE_HITS); |
| 14244 | } | 14244 | } |
| 14245 | + if let Some(buf) = &palette_y_buf | ||
| 14246 | + && (logical_tx == side || skip) | ||
| 14247 | + { | ||
| 14245 | set_palette_pred(buf.clone(), fctx); | 14248 | set_palette_pred(buf.clone(), fctx); |
| 14246 | } | 14249 | } |
| 14247 | // A UV-palette block's own chroma prediction override (lane-palette2 r1), | 14250 | // A UV-palette block's own chroma prediction override (lane-palette2 r1), |
crates/ec-av1/src/stream.rsmodified+54 -0
| @@ -3344,6 +3344,60 @@ pub(crate) mod tests { | |||
| 3344 | .collect() | 3344 | .collect() |
| 3345 | } | 3345 | } |
| 3346 | 3346 | ||
| 3347 | + /// lane-svt1: an SVT-AV1 (v3.1.2, `-preset 8 -crf 35`) screen key frame | ||
| 3348 | + /// codes 16x16 PALETTE blocks with `skip == 1` whose `tx_depth` split the | ||
| 3349 | + /// luma transform. [`crate::decode::decode_block`] armed the palette | ||
| 3350 | + /// prediction only when the transform covered the whole block, so that one | ||
| 3351 | + /// block predicted DC off its own edges instead: the right symbols (the | ||
| 3352 | + /// whole mode ladder diffs clean against an instrumented aomdec) and the | ||
| 3353 | + /// wrong pixels -- 812 luma samples in frame 0, carried by the V_PRED | ||
| 3354 | + /// blocks under it to 10122 samples over the 12-frame stream. | ||
| 3355 | + /// | ||
| 3356 | + /// No lavfi recipe witnesses it in a stream this decoder otherwise decodes: | ||
| 3357 | + /// 6 sources x 5 sizes x 6 crf values through `libsvtav1 -preset 8 | ||
| 3358 | + /// -svtav1-params screen-content-mode=1` produced 8 streams that reach the | ||
| 3359 | + /// path, and every one of them either refuses on an unrelated Golomb tail | ||
| 3360 | + /// or misses by ~200k samples on unrelated inter-frame defects (both | ||
| 3361 | + /// recorded in `lanes/svt1.report.md`). So the gate rides the kept stream | ||
| 3362 | + /// named by `EC_AV1_SVT1_STREAM` and SKIPs when it is unset -- the screen | ||
| 3363 | + /// crop itself is never committed to `fixtures/`. | ||
| 3364 | + /// | ||
| 3365 | + /// `skip_split_tx_override_hits` is asserted non-zero so the row cannot | ||
| 3366 | + /// pass on a stream that never reaches the fixed arm (class | ||
| 3367 | + /// gate-blind-to-feature). | ||
| 3368 | + #[test] | ||
| 3369 | + fn an_svt_screen_palette_block_with_a_split_transform_decodes_exactly() { | ||
| 3370 | + const NAME: &str = "an_svt_screen_palette_block_with_a_split_transform_decodes_exactly"; | ||
| 3371 | + let Ok(path) = std::env::var("EC_AV1_SVT1_STREAM") else { | ||
| 3372 | + eprintln!("SKIP {NAME}: EC_AV1_SVT1_STREAM names no stream"); | ||
| 3373 | + return; | ||
| 3374 | + }; | ||
| 3375 | + if !have_ffmpeg() { | ||
| 3376 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 3377 | + return; | ||
| 3378 | + } | ||
| 3379 | + let data = match std::fs::read(&path) { | ||
| 3380 | + Ok(data) => data, | ||
| 3381 | + Err(e) => { | ||
| 3382 | + eprintln!("SKIP {NAME}: {path}: {e}"); | ||
| 3383 | + return; | ||
| 3384 | + } | ||
| 3385 | + }; | ||
| 3386 | + crate::decode::reset_skip_split_tx_override_hits(); | ||
| 3387 | + let decoded = decode_stream(&data).expect("the kept SVT-AV1 screen stream decodes"); | ||
| 3388 | + assert!( | ||
| 3389 | + crate::decode::skip_split_tx_override_hits() > 0, | ||
| 3390 | + "{NAME}: no skipped split-transform palette block in {path} -- the gate would pass blind" | ||
| 3391 | + ); | ||
| 3392 | + let (width, height) = (decoded[0].width, decoded[0].height); | ||
| 3393 | + let want = ffmpeg_decode_sequence(&data, width, height, decoded.len()); | ||
| 3394 | + for (i, (got, want)) in decoded.iter().zip(&want).enumerate() { | ||
| 3395 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg"); | ||
| 3396 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg"); | ||
| 3397 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg"); | ||
| 3398 | + } | ||
| 3399 | + } | ||
| 3400 | + | ||
| 3347 | /// `decode_stream` agrees with ffmpeg/dav1d on the same wire bytes -- an | 3401 | /// `decode_stream` agrees with ffmpeg/dav1d on the same wire bytes -- an |
| 3348 | /// independent decoder, not just this crate checking its own tile path. | 3402 | /// independent decoder, not just this crate checking its own tile path. |
| 3349 | #[test] | 3403 | #[test] |