Exempt JPEG compression from upsampling restriction
I didn't realize we support this in a slightly weird manner where the tag is completely ignored and zune-jpeg performs the upsampling as indicated in the JPEG stream. This is a recurring problem with the compression scheme and tags in TIFF. In the end, decoder can only handle the data as indicated by the JPEG steam and while the specification requires the tags to be consistent with the underlying data, sometimes they are not. The useful fallback is of course to ignore the tag. Ignoring the tag of course buts us in a weird spot for zero-copy decoding since the buffer indication to the caller will be incorrect. For now, maybe the best way of treating subsampling is to upsample all the cases when we add support.
This commit is contained in:
1 parent
ea373bae00
commit
fa225e820b
1 file changed
+7
-3
@@ -738,9 +738,13 @@ impl Image {
|
|||||||
|
|
||||||
// Only this color type interprets the tag, which is defined with a default of (2, 2)
|
// 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) {
|
if matches!(color, ColorType::YCbCr(_)) && self.chroma_subsampling != (1, 1) {
|
||||||
return Err(TiffError::UnsupportedError(
|
// The JPEG library does upsampling for us and defines its buffers correctly
|
||||||
TiffUnsupportedError::ChromaSubsampling,
|
// (presumably). All other compression schemes are not supported..
|
||||||
));
|
if !matches!(self.compression_method, CompressionMethod::ModernJPEG) {
|
||||||
|
return Err(TiffError::UnsupportedError(
|
||||||
|
TiffUnsupportedError::ChromaSubsampling,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ReadoutLayout {
|
Ok(ReadoutLayout {
|
||||||
|
|||||||
Reference in new issue
Block a user