Skip to content

Commit

Permalink
rename mCDv and cLLi chunks to their new names
Browse files Browse the repository at this point in the history
Fixes #537
  • Loading branch information
Shnatsel committed Dec 5, 2024
1 parent 7e4a5a4 commit 43b4dba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ pub const iCCP: ChunkType = ChunkType(*b"iCCP");
/// Coding-independent code points for video signal type identification chunk
pub const cICP: ChunkType = ChunkType(*b"cICP");
/// Mastering Display Color Volume chunk
pub const mDCv: ChunkType = ChunkType(*b"mDCv");
pub const mDCV: ChunkType = ChunkType(*b"mDCV");
/// Content Light Level Information chunk
pub const cLLi: ChunkType = ChunkType(*b"cLLi");
pub const cLLI: ChunkType = ChunkType(*b"cLLI");
/// EXIF metadata chunk
pub const eXIf: ChunkType = ChunkType(*b"eXIf");
/// Latin-1 uncompressed textual data
Expand Down
6 changes: 3 additions & 3 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,10 @@ pub struct CodingIndependentCodePoints {
pub is_video_full_range_image: bool,
}

/// Mastering Display Color Volume (mDCv) used at the point of content creation,
/// Mastering Display Color Volume (mDCV) used at the point of content creation,
/// as specified in [SMPTE-ST-2086](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8353899).
///
/// See https://www.w3.org/TR/png-3/#mDCv-chunk for more details.
/// See https://www.w3.org/TR/png-3/#mDCV-chunk for more details.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct MasteringDisplayColorVolume {
/// Mastering display chromaticities.
Expand All @@ -533,7 +533,7 @@ pub struct MasteringDisplayColorVolume {

/// Content light level information of HDR content.
///
/// See https://www.w3.org/TR/png-3/#cLLi-chunk for more details.
/// See https://www.w3.org/TR/png-3/#cLLI-chunk for more details.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ContentLightLevelInfo {
/// Maximum Content Light Level indicates the maximum light level of any
Expand Down
14 changes: 7 additions & 7 deletions src/decoder/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,8 @@ impl StreamingDecoder {
chunk::cHRM => self.parse_chrm(),
chunk::sRGB => self.parse_srgb(),
chunk::cICP => Ok(self.parse_cicp()),
chunk::mDCv => Ok(self.parse_mdcv()),
chunk::cLLi => Ok(self.parse_clli()),
chunk::mDCV => Ok(self.parse_mdcv()),
chunk::cLLI => Ok(self.parse_clli()),
chunk::bKGD => Ok(self.parse_bkgd()),
chunk::iCCP if !self.decode_options.ignore_iccp_chunk => self.parse_iccp(),
chunk::tEXt if !self.decode_options.ignore_text_chunk => self.parse_text(),
Expand Down Expand Up @@ -1439,7 +1439,7 @@ impl StreamingDecoder {
// `ScaledFloat::SCALING` is hardcoded to 100_000, which works
// well for the `cHRM` chunk where the spec says that "a value
// of 0.3127 would be stored as the integer 31270". In the
// `mDCv` chunk the spec says that "0.708, 0.292)" is stored as
// `mDCV` chunk the spec says that "0.708, 0.292)" is stored as
// "{ 35400, 14600 }", using a scaling factor of 50_000, so we
// multiply by 2 before converting.
ScaledFloat::from_scaled((chunk as u32) * 2)
Expand All @@ -1462,8 +1462,8 @@ impl StreamingDecoder {
})
}

// The spec requires that the mDCv chunk MUST come before the PLTE and IDAT chunks.
// Additionally, we ignore a second, duplicated mDCv chunk (if any).
// The spec requires that the mDCV chunk MUST come before the PLTE and IDAT chunks.
// Additionally, we ignore a second, duplicated mDCV chunk (if any).
let info = self.info.as_mut().unwrap();
let is_before_plte_and_idat = !self.have_idat && info.palette.is_none();
if is_before_plte_and_idat && info.mastering_display_color_volume.is_none() {
Expand All @@ -1489,7 +1489,7 @@ impl StreamingDecoder {
})
}

// We ignore a second, duplicated cLLi chunk (if any).
// We ignore a second, duplicated cLLI chunk (if any).
let info = self.info.as_mut().unwrap();
if info.content_light_level.is_none() {
info.content_light_level = parse(&self.current_chunk.raw_bytes[..]).ok();
Expand Down Expand Up @@ -2117,7 +2117,7 @@ mod tests {
assert!(decoder.read_info().is_ok());
}

/// Test handling of `mDCv` and `cLLi` chunks.`
/// Test handling of `mDCV` and `cLLI` chunks.`
#[test]
fn test_mdcv_and_clli_chunks() {
let decoder = crate::Decoder::new(File::open("tests/bugfixes/cicp_pq.png").unwrap());
Expand Down

0 comments on commit 43b4dba

Please sign in to comment.