Author: post
Date: 2012-10-06 15:38:44 +0200 (Sat, 06 Oct 2012)
New Revision: 472
Modified:
RawSpeed/NikonDecompressor.cpp
RawSpeed/NikonDecompressor.h
Log:
Make faster checks to Nikon range to avoid 1 min/max per pixel.
Modified: RawSpeed/NikonDecompressor.cpp
===================================================================
--- RawSpeed/NikonDecompressor.cpp 2012-10-06 13:35:39 UTC (rev 471)
+++ RawSpeed/NikonDecompressor.cpp 2012-10-06 13:38:44 UTC (rev 472)
@@ -26,7 +26,7 @@
NikonDecompressor::NikonDecompressor(FileMap* file, RawImage img) :
LJpegDecompressor(file, img) {
- for (uint32 i = 0; i < 0xffff ; i++) {
+ for (uint32 i = 0; i < 0x8000 ; i++) {
curve[i] = i;
}
bits = 0;
@@ -94,12 +94,15 @@
}
_max = csize;
}
- while (curve[_max-2] == curve[_max-1]) _max--;
initTable(huffSelect);
mRaw->whitePoint = curve[_max-1];
mRaw->blackLevel = curve[0];
+ uint32 top = mRaw->whitePoint;
+ for (int i = _max; i < 0x8000; i++)
+ curve[i] = top;
+
uint32 x, y;
bits = new BitPumpMSB(mFile->getData(offset), size);
uchar8 *draw = mRaw->getData();
@@ -119,12 +122,12 @@
pUp2[y&1] += HuffDecodeNikon();
pLeft1 = pUp1[y&1];
pLeft2 = pUp2[y&1];
- dest[0] = curve[MIN(_max-1, MAX(0,pLeft1))] | (curve[MIN(_max-1,
MAX(0,pLeft2))] << 16);
+ dest[0] = curve[pLeft1&0x7fff] | (curve[pLeft2&0x7fff] << 16);
for (x = 1; x < cw; x++) {
bits->checkPos();
pLeft1 += HuffDecodeNikon();
pLeft2 += HuffDecodeNikon();
- dest[x] = curve[MIN(_max-1, MAX(0,pLeft1))] | (curve[MIN(_max-1,
MAX(0,pLeft2))] << 16);
+ dest[x] = curve[pLeft1&0x7fff] | (curve[pLeft2&0x7fff] << 16);
}
}
}
Modified: RawSpeed/NikonDecompressor.h
===================================================================
--- RawSpeed/NikonDecompressor.h 2012-10-06 13:35:39 UTC (rev 471)
+++ RawSpeed/NikonDecompressor.h 2012-10-06 13:38:44 UTC (rev 472)
@@ -38,7 +38,7 @@
private:
void initTable(uint32 huffSelect);
int HuffDecodeNikon();
- uint32 curve[0xffff];
+ uint32 curve[0x8000];
BitPumpMSB *bits;
};
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit