TMI-104: Fixed metadata inconsistency, 1 channel SOF now always interpreted as color space Gray, regardless of Adobe App14 marker.

This commit is contained in:
Harald Kuhr
2015-03-03 14:44:24 +01:00
parent d6f90b0b52
commit 37d4c03548
4 changed files with 38 additions and 8 deletions
@@ -156,10 +156,12 @@ final class JPEGImage10MetadataCleaner {
}
// Special case: Broken AdobeDCT segment, inconsistent with SOF, use values from SOF
if (adobeDCT != null && adobeDCT.getTransform() == AdobeDCTSegment.YCCK && sof.componentsInFrame() < 4) {
if (adobeDCT != null && (adobeDCT.getTransform() == AdobeDCTSegment.YCCK && sof.componentsInFrame() < 4 ||
adobeDCT.getTransform() == AdobeDCTSegment.YCC && sof.componentsInFrame() < 3)) {
reader.processWarningOccurred(String.format(
"Invalid Adobe App14 marker. Indicates YCCK/CMYK data, but SOF%d has %d color components. " +
"Invalid Adobe App14 marker. Indicates %s data, but SOF%d has %d color component(s). " +
"Ignoring Adobe App14 marker.",
adobeDCT.getTransform() == AdobeDCTSegment.YCCK ? "YCCK/CMYK" : "YCC/RGB",
sof.marker & 0xf, sof.componentsInFrame()
));
@@ -323,7 +323,7 @@ public class JPEGImageReader extends ImageReaderBase {
if (adobeDCT != null && (adobeDCT.getTransform() == AdobeDCTSegment.YCC && sof.componentsInFrame() != 3 ||
adobeDCT.getTransform() == AdobeDCTSegment.YCCK && sof.componentsInFrame() != 4)) {
processWarningOccurred(String.format(
"Invalid Adobe App14 marker. Indicates %s data, but SOF%d has %d color components. " +
"Invalid Adobe App14 marker. Indicates %s data, but SOF%d has %d color component(s). " +
"Ignoring Adobe App14 marker.",
adobeDCT.getTransform() == AdobeDCTSegment.YCCK ? "YCCK/CMYK" : "YCC/RGB",
sof.marker & 0xf, sof.componentsInFrame()
@@ -1075,8 +1075,7 @@ public class JPEGImageReader extends ImageReaderBase {
@Override
public IIOMetadata getImageMetadata(int imageIndex) throws IOException {
// TMI-101: As we catch the IndexOutOfBoundsException below, we need to make sure that we don't catch the
// IndexOutOfBoundsException that should be thrown, if (imageIndex < 0 || imageIndex > numImages).
// checkBounds needed, as we catch the IndexOutOfBoundsException below.
checkBounds(imageIndex);
IIOMetadata imageMetadata;