Author: post
Date: 2010-07-15 16:23:13 +0200 (Thu, 15 Jul 2010)
New Revision: 259
Modified:
RawSpeed/Rw2Decoder.cpp
Log:
Add support for old Panasonic RAW format (tested on FZ50)
Modified: RawSpeed/Rw2Decoder.cpp
===================================================================
--- RawSpeed/Rw2Decoder.cpp 2010-07-15 13:44:17 UTC (rev 258)
+++ RawSpeed/Rw2Decoder.cpp 2010-07-15 14:23:13 UTC (rev 259)
@@ -38,17 +38,16 @@
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(PANASONIC_STRIPOFFSET);
- if (data.empty())
- ThrowRDE("RW2 Decoder: No image data found");
+ bool isOldPanasonic = FALSE;
- TiffIFD* raw = data[0];
-
- TiffEntry *offsets = raw->getEntry(PANASONIC_STRIPOFFSET);
-
- if (offsets->count != 1) {
- ThrowRDE("RW2 Decoder: Multiple Strips found: %u", offsets->count);
+ if (data.empty()) {
+ if (!mRootIFD->hasEntryRecursive(STRIPOFFSETS))
+ ThrowRDE("RW2 Decoder: No image data found");
+ isOldPanasonic = TRUE;
+ data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
}
+ TiffIFD* raw = data[0];
uint32 height = raw->getEntry((TiffTag)3)->getShort();
uint32 width = raw->getEntry((TiffTag)2)->getShort();
@@ -56,14 +55,42 @@
mRaw->bpp = 2;
mRaw->createData();
- load_flags = 0x2008;
- int off = offsets->getInt();
+ if (isOldPanasonic) {
+ TiffEntry *offsets = raw->getEntry(STRIPOFFSETS);
+ TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS);
- if (!mFile->isValid(off))
- ThrowRDE("RW2 Decoder: Invalid image data offset, cannot decode.");
+ if (offsets->count != 1) {
+ ThrowRDE("RW2 Decoder: Multiple Strips found: %u", offsets->count);
+ }
+ int off = offsets->getInt();
+ if (!mFile->isValid(off))
+ ThrowRDE("Panasonic RAW Decoder: Invalid image data offset, cannot
decode.");
- input_start = new ByteStream(mFile->getData(off), mFile->getSize() - off);
- DecodeRw2();
+ int count = counts->getInt();
+ if (count != width*height*2)
+ ThrowRDE("Panasonic RAW Decoder: Byte count is wrong.");
+
+ ByteStream input_start(mFile->getData(off), mFile->getSize() - off);
+ iPoint2D pos(0, 0);
+ readUncompressedRaw(input_start, mRaw->dim,pos, width*2, 16, FALSE);
+
+ } else {
+
+ TiffEntry *offsets = raw->getEntry(PANASONIC_STRIPOFFSET);
+
+ if (offsets->count != 1) {
+ ThrowRDE("RW2 Decoder: Multiple Strips found: %u", offsets->count);
+ }
+
+ load_flags = 0x2008;
+ int off = offsets->getInt();
+
+ if (!mFile->isValid(off))
+ ThrowRDE("RW2 Decoder: Invalid image data offset, cannot decode.");
+
+ input_start = new ByteStream(mFile->getData(off), mFile->getSize() - off);
+ DecodeRw2();
+ }
return mRaw;
}
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit