Revert "feat: add YCbCr chroma subsampling support for non-JPEG compression"
This reverts commit 83409cbdf3.
This commit is contained in:
1 parent
617dc6eed8
commit
85215e81e3
3 files changed
+14
-107
No files matched your search
+10
-19
@@ -952,10 +952,15 @@ impl Image {
|
||||
|
||||
// Only this color type interprets the tag, which is defined with a default of (2, 2)
|
||||
if matches!(color, ColorType::YCbCr(_)) && self.chroma_subsampling != (1, 1) {
|
||||
// The JPEG library does upsampling for us. For other compression methods,
|
||||
// the expand_chunk pipeline wraps the decompressor in a YCbCrUpsamplingReader
|
||||
// that converts the subsampled block layout to full-resolution pixel rows.
|
||||
if matches!(self.planar_config, PlanarConfiguration::Planar) {
|
||||
// The JPEG library does upsampling for us and defines its buffers correctly
|
||||
// (presumably). All other compression schemes are not supported..
|
||||
//
|
||||
// NOTE: as explained in <fa225e820b96bef35f01bf4685654beeb4a8df0c> we may be better
|
||||
// off supporting this tag by consistently upsampling, not by adjusting the buffer
|
||||
// size. At least as a default this makes more sense and is much more permissive in
|
||||
// case the compression stream disagrees with the tags (we would not have enough / or
|
||||
// the wrong buffer layout if we only asked for subsampled planes in a planar layout).
|
||||
if !matches!(self.compression_method, CompressionMethod::ModernJPEG) {
|
||||
return Err(TiffError::UnsupportedError(
|
||||
TiffUnsupportedError::ChromaSubsampling,
|
||||
));
|
||||
@@ -1155,7 +1160,7 @@ impl Image {
|
||||
let is_all_bits = samples == data_samples;
|
||||
let is_output_chunk_rows = layout.row_stride == chunk_row_bytes;
|
||||
|
||||
let mut reader: Box<dyn Read> = Self::create_reader(
|
||||
let mut reader = Self::create_reader(
|
||||
reader.inner(),
|
||||
compression_method,
|
||||
*compressed_bytes,
|
||||
@@ -1165,20 +1170,6 @@ impl Image {
|
||||
self.fill_order,
|
||||
)?;
|
||||
|
||||
// For non-JPEG YCbCr with chroma subsampling, wrap the decompressor in an
|
||||
// upsampling reader that converts the subsampled block layout to full-resolution
|
||||
// pixel rows. JPEG handles upsampling internally.
|
||||
if matches!(color_type, ColorType::YCbCr(_))
|
||||
&& self.chroma_subsampling != (1, 1)
|
||||
&& !matches!(compression_method, CompressionMethod::ModernJPEG)
|
||||
{
|
||||
reader = Box::new(super::stream::YCbCrUpsamplingReader::new(
|
||||
reader,
|
||||
data_dims,
|
||||
self.chroma_subsampling,
|
||||
));
|
||||
}
|
||||
|
||||
// Extended bit depths (9-15, 17-31): packed N-bit samples must be unpacked to
|
||||
// standard-width output samples before endianness fix and predictor.
|
||||
let needs_unpacking = layout.tiff_bits_per_sample != layout.output_bits_per_sample
|
||||
|
||||
Reference in new issue
Block a user