Refuse a stream whose bit depth is not 8
Browse files at this commitcee9a3d92a15304f14fb3d9089c9ff54c3d79c79Parent: e7ae36e- fix
- refuse a stream whose bit depth is not 8
2 changed files +20 -0
crates/ec-av1/src/refusal_inventory.rsmodified+1 -0
| @@ -39,6 +39,7 @@ const REFUSALS: &[&str] = &[ | |||
| 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 40 | "a 32x32 partition type this decoder does not code (value={part32})", | 40 | "a 32x32 partition type this decoder does not code (value={part32})", |
| 41 | "a Golomb tail longer than this decoder reads", | 41 | "a Golomb tail longer than this decoder reads", |
| 42 | + "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", | ||
| 42 | "a tx_type symbol outside its CDF's own set: {t}", | 43 | "a tx_type symbol outside its CDF's own set: {t}", |
| 43 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 44 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| 44 | "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)", | 45 | "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)", |
crates/ec-av1/src/stream.rsmodified+19 -0
| @@ -165,6 +165,25 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 165 | // intrabc call at all -- that symbol is intra-frame-only). A | 165 | // intrabc call at all -- that symbol is intra-frame-only). A |
| 166 | // genuine palette/intrabc use still refuses by name deeper in the | 166 | // genuine palette/intrabc use still refuses by name deeper in the |
| 167 | // block readers, so no whole-frame refusal is needed here anymore. | 167 | // block readers, so no whole-frame refusal is needed here anymore. |
| 168 | + // Both AV1 files in this box's own library (a 2160p HDR10 encode and a | ||
| 169 | + // 1080p one, probed 2026-08-30 through `examples/decode_probe`) are | ||
| 170 | + // `yuv420p10le`, and every buffer this decoder reconstructs into -- | ||
| 171 | + // `Picture`'s `y`/`u`/`v` -- is `Vec<u8>`. A 10- or 12-bit stream would | ||
| 172 | + // therefore be reconstructed into 8-bit samples and compared against a | ||
| 173 | + // 10-bit reference, which is silent wrongness rather than a desync: no | ||
| 174 | + // symbol goes unread, the pixels are just quietly truncated. Refuse it | ||
| 175 | + // by name until the planes are widened. `bit_depth` defaults to 8 when | ||
| 176 | + // no sequence header has been seen, which is the existing behaviour for | ||
| 177 | + // every fixture in this crate. | ||
| 178 | + if parser | ||
| 179 | + .sequence_header() | ||
| 180 | + .is_some_and(|seq| seq.color_config.bit_depth != 8) | ||
| 181 | + { | ||
| 182 | + return Err(Error::unsupported( | ||
| 183 | + "AV1 decode_stream", | ||
| 184 | + "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", | ||
| 185 | + )); | ||
| 186 | + } | ||
| 168 | if header.delta.q_present || header.delta.lf_present { | 187 | if header.delta.q_present || header.delta.lf_present { |
| 169 | return Err(Error::unsupported( | 188 | return Err(Error::unsupported( |
| 170 | "AV1 decode_stream", | 189 | "AV1 decode_stream", |