Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jxl-frame: EC upsampling check #34

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/jxl-image/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ impl<Ctx> Bundle<Ctx> for ExtraChannelInfo {

let ty_id = read_bits!(bitstream, Enum(ExtraChannelTypeRaw))?;
let bit_depth = BitDepth::parse(bitstream, ())?;

let dim_shift = read_bits!(bitstream, U32(0, 3, 4, 1 + u(3)))?;
if (1usize << dim_shift) > 8 {
Copy link
Owner

@tirr-c tirr-c Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in jxl discord chat, there's something wrong in the check in libjxl; this makes decoded U32 value of 4 (10 in bitstream) instantly invalid. Instead we could defer the check to the frame header decoding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it seems to be an early check for dim_shift when ec_upsampling is not yet known.

return Err(jxl_bitstream::Error::ValidationFailed("dim_shift too large"))
}

let name = Name::parse(bitstream, ())?;

let ty = match ty_id {
Expand Down