feat: YCbCr chroma subsampling for non-JPEG compression#366
Open
lilith wants to merge 1 commit intoimage-rs:mainfrom
Open
feat: YCbCr chroma subsampling for non-JPEG compression#366lilith wants to merge 1 commit intoimage-rs:mainfrom
lilith wants to merge 1 commit intoimage-rs:mainfrom
Conversation
Add YCbCrUpsamplingReader that converts chroma-subsampled YCbCr block data to full-resolution 3-bytes-per-pixel output. Each block of h×v pixels stores h*v Y samples plus one shared Cb and Cr sample; the reader expands these into per-pixel (Y, Cb, Cr) triples. This enables decoding YCbCr TIFFs with any supported compression method (uncompressed, LZW, Deflate, etc.), not just JPEG. Two more libtiffpic test images now decode with verified hashes: - dscf0013.tif (uncompressed YCbCr 2,1 subsampling) - ycbcr-cat.tif (LZW-compressed YCbCr 2,2 subsampling) The remaining two YCbCr test images (smallliz.tif, zackthecat.tif) use Old JPEG compression (type 6) which is a separate unsupported feature.
e71b9c8 to
58a76a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
YCbCrUpsamplingReaderthat converts chroma-subsampled block layout (h×v Y samples + shared Cb/Cr) to full-resolution per-pixel (Y, Cb, Cr) triplesexpand_chunk()for non-JPEG compression methodsChromaSubsamplingerror) since the block layout only applies to chunky/interleaved dataSplit out from #363 per review request.
Test plan
dscf0013.tif(uncompressed, YCbCr 2×1 subsampling): CRC32 hash verified0x6896e83aycbcr-cat.tif(LZW, YCbCr 2×2 subsampling): CRC32 hash verified0x388a9d8fsmallliz.tif/zackthecat.tifremain smoke tests (Old JPEG compression type 6, unsupported regardless)