Narrow bit_depth != 8 refusals for film_grain and superres
Browse files at this commitc0c9f9b6637ceb6d11efbdd1d1f5838ace141474Parent: 1da7ad6- feat
- narrow bit_depth != 8 refusals for film_grain and superres
2 changed files +32 -0
crates/ec-av1/src/refusal_inventory.rsmodified+2 -0
| @@ -40,6 +40,8 @@ const REFUSALS: &[&str] = &[ | ||
| 40 | 40 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 41 | 41 | "a 32x32 partition type this decoder does not code (value={part32})", |
| 42 | 42 | "a Golomb tail longer than this decoder reads", |
| 43 | + "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)", | |
| 44 | + "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)", | |
| 43 | 45 | "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", |
| 44 | 46 | "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)", |
| 45 | 47 | "a tx_type symbol outside its CDF's own set: {t}", |
crates/ec-av1/src/stream.rsmodified+30 -0
| @@ -128,6 +128,19 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | let output = if header.film_grain.apply_grain { |
| 131 | + // lane-hbd r5: `film_grain.rs`'s grain LUT and blend are | |
| 132 | + // hardcoded 8-bit (`[i32; 256]`, clamps at 255) -- narrowed | |
| 133 | + // from the old blanket bit-depth refusal to only the case | |
| 134 | + // that actually reaches unported code. | |
| 135 | + let bit_depth = parser | |
| 136 | + .sequence_header() | |
| 137 | + .map_or(8, |seq| seq.color_config.bit_depth); | |
| 138 | + if bit_depth != 8 { | |
| 139 | + return Err(Error::unsupported( | |
| 140 | + "AV1 decode_stream", | |
| 141 | + "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)", | |
| 142 | + )); | |
| 143 | + } | |
| 131 | 144 | let mc_identity = parser |
| 132 | 145 | .sequence_header() |
| 133 | 146 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); |
| @@ -501,6 +514,15 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 501 | 514 | // call above, right before anything else can overwrite it) -- |
| 502 | 515 | // see `decode::take_last_key_frame_wide_margin`'s doc. |
| 503 | 516 | let wide_margin = crate::decode::take_last_key_frame_wide_margin(); |
| 517 | + // lane-hbd r5: `upscale_row` (superres.rs) is `&[u8]`, clamping at | |
| 518 | + // 255 -- narrowed from the old blanket bit-depth refusal to only | |
| 519 | + // the case that actually reaches unported code. | |
| 520 | + if header.use_superres && bit_depth != 8 { | |
| 521 | + return Err(Error::unsupported( | |
| 522 | + "AV1 decode_stream", | |
| 523 | + "a bit depth other than 8 with use_superres set (superres.rs's upscale_row is hardcoded 8-bit)", | |
| 524 | + )); | |
| 525 | + } | |
| 504 | 526 | let picture = if header.use_superres { |
| 505 | 527 | crate::superres::upscale_picture( |
| 506 | 528 | &picture, |
| @@ -667,6 +689,14 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 667 | 689 | } |
| 668 | 690 | if header.show_frame { |
| 669 | 691 | let output = if header.film_grain.apply_grain { |
| 692 | + // lane-hbd r5: same 8-bit-only LUT/blend as the | |
| 693 | + // show_existing_frame arm above. | |
| 694 | + if bit_depth != 8 { | |
| 695 | + return Err(Error::unsupported( | |
| 696 | + "AV1 decode_stream", | |
| 697 | + "a bit depth other than 8 with film grain applied (film_grain.rs's LUT and blend are hardcoded 8-bit)", | |
| 698 | + )); | |
| 699 | + } | |
| 670 | 700 | let mc_identity = parser |
| 671 | 701 | .sequence_header() |
| 672 | 702 | .is_some_and(|seq| seq.color_config.matrix_coefficients == 0); |