From cee9a3d92a15304f14fb3d9089c9ff54c3d79c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 16:51:35 +0300 Subject: [PATCH] fix(av1): refuse a stream whose bit depth is not 8 Both AV1 files in this box's own library -- a 2160p HDR10 encode and a 1080p one -- are yuv420p10le. Probed through examples/decode_probe, both got past every header refusal this decoder has and stopped at delta_q/delta_lf, which is a header-level refusal: it says the headers parse, nothing about blocks. What it was hiding: Picture's y/u/v are Vec, and nothing in decode.rs reads bit_depth at all. Once delta_q lands -- which is in flight -- those two files would have been reconstructed into 8-bit planes and compared against a 10-bit reference. Not a desync; no symbol goes unread. Just quietly truncated pixels, which is the failure mode this decoder is built not to have. Refused by name until the planes are widened. Both films now say so. Suite 243 passed / 0 failed. --- crates/ec-av1/src/refusal_inventory.rs | 1 + crates/ec-av1/src/stream.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 03746427..31b9dfbd 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -39,6 +39,7 @@ const REFUSALS: &[&str] = &[ "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", "a 32x32 partition type this decoder does not code (value={part32})", "a Golomb tail longer than this decoder reads", + "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", "a tx_type symbol outside its CDF's own set: {t}", "an INTER 32x32 partition type this decoder does not code (value={part32})", "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 2f814320..865f76ce 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -165,6 +165,25 @@ pub fn decode_stream(data: &[u8]) -> Result> { // intrabc call at all -- that symbol is intra-frame-only). A // genuine palette/intrabc use still refuses by name deeper in the // block readers, so no whole-frame refusal is needed here anymore. + // Both AV1 files in this box's own library (a 2160p HDR10 encode and a + // 1080p one, probed 2026-08-30 through `examples/decode_probe`) are + // `yuv420p10le`, and every buffer this decoder reconstructs into -- + // `Picture`'s `y`/`u`/`v` -- is `Vec`. A 10- or 12-bit stream would + // therefore be reconstructed into 8-bit samples and compared against a + // 10-bit reference, which is silent wrongness rather than a desync: no + // symbol goes unread, the pixels are just quietly truncated. Refuse it + // by name until the planes are widened. `bit_depth` defaults to 8 when + // no sequence header has been seen, which is the existing behaviour for + // every fixture in this crate. + if parser + .sequence_header() + .is_some_and(|seq| seq.color_config.bit_depth != 8) + { + return Err(Error::unsupported( + "AV1 decode_stream", + "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", + )); + } if header.delta.q_present || header.delta.lf_present { return Err(Error::unsupported( "AV1 decode_stream",