Author: post
Date: 2010-04-25 14:43:23 +0200 (Sun, 25 Apr 2010)
New Revision: 228

Modified:
   RawSpeed/RawDecoder.cpp
Log:
Raw Decoder: Ensure that input pitch == w, before using 12 bit decoder, and fix 
size calculation, broken in rev 227.

Modified: RawSpeed/RawDecoder.cpp
===================================================================
--- RawSpeed/RawDecoder.cpp     2010-04-25 12:37:10 UTC (rev 227)
+++ RawSpeed/RawDecoder.cpp     2010-04-25 12:43:23 UTC (rev 228)
@@ -80,7 +80,7 @@
              input.getData(), inputPitch, w*mRaw->bpp, h - y);
       return;
     }
-    if (bitPerPixel == 12)  {
+    if (bitPerPixel == 12 && w == inputPitch * 8 / 12)  {
       Decode12BitRaw(input, w, h);
       return;
     }
@@ -102,9 +102,9 @@
   guchar* data = mRaw->getData();
   guint pitch = mRaw->pitch;
   const guchar *in = input.getData();
-  if (input.getRemainSize() < (w*h)) {
-    if ((int)input.getRemainSize() > w)
-      h = input.getRemainSize() / w - 1;
+  if (input.getRemainSize() < ((w*12/8)*h)) {
+    if ((int)input.getRemainSize() > (w*12/8))
+      h = input.getRemainSize() / (w*12/8) - 1;
     else
       ThrowIOE("readUncompressedRaw: Not enough data to decode a single line. 
Image file truncated.");
   }


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to