darktable-org / rawspeed

fast raw decoding library
GNU Lesser General Public License v2.1
363 stars 115 forks source link

Phase One decode error #727

Open kmilos opened 6 months ago

kmilos commented 6 months ago

P25 IIQ sample sample throws

ERROR: [rawspeed] C:/msys64/home/kmilos/rawspeed/src/librawspeed/decompressors/PhaseOneDecompressor.cpp:165: void rawspeed::PhaseOneDecompressor::decompress() const: Too many errors encountered. Giving up. First Error:
C:/msys64/home/kmilos/rawspeed/src/librawspeed/decompressors/PhaseOneDecompressor.cpp:112: void rawspeed::PhaseOneDecompressor::decompressStrip(const rawspeed::PhaseOneStrip&) const: Can not initialize lengths. Data is corrupt.

The P30 and P45 .TIF samples decode fine (as do the P25+ and P45+ .IIQ ones). I can also decode the P25 one using LibRaw's unprocessed_raw tool.

kmilos commented 5 months ago

Also reproduced on iXM-100, IQ3 100MP and IQ4 150MP IIQ L samples as well (after bumping allowed width & height):

diff --git a/src/librawspeed/decoders/IiqDecoder.cpp b/src/librawspeed/decoders/IiqDecoder.cpp
index 9d8b98fd..8eb2962d 100644
--- a/src/librawspeed/decoders/IiqDecoder.cpp
+++ b/src/librawspeed/decoders/IiqDecoder.cpp
@@ -233,8 +233,8 @@ RawImage IiqDecoder::decodeRawInternal() {
     }
   }

-  // FIXME: could be wrong. max "active pixels" in "Sensor+" mode - "101 MP"
-  if (width == 0 || height == 0 || width > 11976 || height > 8854)
+  // FIXME: could be wrong. max "active pixels" for IQ4 150MP
+  if (width == 0 || height == 0 || width > 14308 || height > 10760)
     ThrowRDE("Unexpected image dimensions found: (%u; %u)", width, height);

   if (!format)
diff --git a/src/librawspeed/decompressors/PhaseOneDecompressor.cpp b/src/librawspeed/decompressors/PhaseOneDecompressor.cpp
index 0172c6a4..da2a335e 100644
--- a/src/librawspeed/decompressors/PhaseOneDecompressor.cpp
+++ b/src/librawspeed/decompressors/PhaseOneDecompressor.cpp
@@ -50,7 +50,7 @@ PhaseOneDecompressor::PhaseOneDecompressor(RawImage img,
     ThrowRDE("Unexpected cpp: %u", mRaw->getCpp());

   if (!mRaw->dim.hasPositiveArea() || mRaw->dim.x % 2 != 0 ||
-      mRaw->dim.x > 11976 || mRaw->dim.y > 8854) {
+      mRaw->dim.x > 14308 || mRaw->dim.y > 10760) {
     ThrowRDE("Unexpected image dimensions found: (%u; %u)", mRaw->dim.x,
              mRaw->dim.y);
   }