From 43b4dbae8d0a9a72f3420df1b3c52ca02a19871c Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Thu, 5 Dec 2024 05:58:02 +0000 Subject: [PATCH 1/2] rename mCDv and cLLi chunks to their new names Fixes #537 --- src/chunk.rs | 4 ++-- src/common.rs | 6 +++--- src/decoder/stream.rs | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/chunk.rs b/src/chunk.rs index 3e5c13f5..3737cd4a 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -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 diff --git a/src/common.rs b/src/common.rs index 952e06dc..9a4e1876 100644 --- a/src/common.rs +++ b/src/common.rs @@ -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. @@ -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 diff --git a/src/decoder/stream.rs b/src/decoder/stream.rs index ee0931b5..7d5de33f 100644 --- a/src/decoder/stream.rs +++ b/src/decoder/stream.rs @@ -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(), @@ -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) @@ -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() { @@ -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(); @@ -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()); From 9bb4da72bbb6178c4017b0f032f18268aac33266 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Thu, 5 Dec 2024 06:10:16 +0000 Subject: [PATCH 2/2] Update chunk names in test file --- tests/bugfixes/cicp_pq.png | Bin 191 -> 191 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/bugfixes/cicp_pq.png b/tests/bugfixes/cicp_pq.png index c17f35d4405d5855799e69ef73c3c24464bfda50..8314eb578d6bf06386e84b835d4e172bcc5cbf38 100644 GIT binary patch delta 31 ncmdnbxSw%Cil`@3QWOK@gqsFFGY%^76 delta 31 ncmdnbxSw%CifATNQWOK@gqsFFGY%^