Skip to content

Commit fe15989

Browse files
pmjdebruijnPascal de Bruijn
authored andcommitted
Vendordrop Rawspeed r423
1 parent e61c46f commit fe15989

4 files changed

Lines changed: 60 additions & 10 deletions

File tree

src/external/rawspeed/RawSpeed/DngDecoder.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ RawImage DngDecoder::decodeRawInternal() {
313313
} catch (TiffParserException e) {
314314
ThrowRDE("DNG Decoder: Image could not be read:\n%s", e.what());
315315
}
316-
iPoint2D new_size(mRaw->dim.x, mRaw->dim.y);
317316

318317
// Crop
319318
if (raw->hasEntry(ACTIVEAREA)) {
319+
iPoint2D new_size(mRaw->dim.x, mRaw->dim.y);
320320
const uint32 *corners = raw->getEntry(ACTIVEAREA)->getIntArray();
321321
if (iPoint2D(corners[1], corners[0]).isThisInside(mRaw->dim)) {
322322
if (iPoint2D(corners[3], corners[2]).isThisInside(mRaw->dim)) {
@@ -325,11 +325,11 @@ RawImage DngDecoder::decodeRawInternal() {
325325
mRaw->subFrame(top_left, new_size);
326326
}
327327
}
328+
}
328329

329-
} else if (raw->hasEntry(DEFAULTCROPORIGIN)) {
330-
330+
if (raw->hasEntry(DEFAULTCROPORIGIN)) {
331331
iPoint2D top_left(0, 0);
332-
332+
iPoint2D new_size(mRaw->dim.x, mRaw->dim.y);
333333
if (raw->getEntry(DEFAULTCROPORIGIN)->type == TIFF_LONG) {
334334
const uint32* tl = raw->getEntry(DEFAULTCROPORIGIN)->getIntArray();
335335
const uint32* sz = raw->getEntry(DEFAULTCROPSIZE)->getIntArray();
@@ -344,15 +344,23 @@ RawImage DngDecoder::decodeRawInternal() {
344344
top_left = iPoint2D(tl[0], tl[1]);
345345
new_size = iPoint2D(sz[0], sz[1]);
346346
}
347+
} else if (raw->getEntry(DEFAULTCROPORIGIN)->type == TIFF_RATIONAL) {
348+
// Crop as rational numbers, really?
349+
const uint32* tl = raw->getEntry(DEFAULTCROPORIGIN)->getIntArray();
350+
const uint32* sz = raw->getEntry(DEFAULTCROPSIZE)->getIntArray();
351+
if (iPoint2D(tl[0]/tl[1],tl[2]/tl[3]).isThisInside(mRaw->dim) && iPoint2D(sz[0]/sz[1],sz[2]/sz[3]).isThisInside(mRaw->dim)) {
352+
top_left = iPoint2D(tl[0]/tl[1],tl[2]/tl[3]);
353+
new_size = iPoint2D(iPoint2D(sz[0]/sz[1],sz[2]/sz[3]));
354+
}
347355
}
348356
mRaw->subFrame(top_left, new_size);
349357
if (top_left.x %2 == 1)
350358
mRaw->cfa.shiftLeft();
351359
if (top_left.y %2 == 1)
352360
mRaw->cfa.shiftDown();
353361
}
354-
// Linearization
355362

363+
// Linearization
356364
if (raw->hasEntry(LINEARIZATIONTABLE)) {
357365
const ushort16* intable = raw->getEntry(LINEARIZATIONTABLE)->getShortArray();
358366
uint32 len = raw->getEntry(LINEARIZATIONTABLE)->count;

src/external/rawspeed/RawSpeed/OrfDecoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void OrfDecoder::checkSupport(CameraMetaData *meta) {
256256

257257
void OrfDecoder::decodeMetaData(CameraMetaData *meta) {
258258
int iso = 0;
259-
mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
259+
mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN, CFA_BLUE);
260260
vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
261261

262262
if (data.empty())

src/external/rawspeed/RawSpeed/SrwDecoder.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace RawSpeed {
3030

3131
SrwDecoder::SrwDecoder(TiffIFD *rootIFD, FileMap* file):
3232
RawDecoder(file), mRootIFD(rootIFD) {
33-
decoderVersion = 1;
33+
decoderVersion = 2;
3434
}
3535

3636
SrwDecoder::~SrwDecoder(void) {
@@ -55,13 +55,21 @@ RawImage SrwDecoder::decodeRawInternal() {
5555

5656
if (32769 == compression)
5757
{
58-
this->decodeUncompressed(raw, false);
58+
bool bit_order = false; // Default guess
59+
map<string,string>::iterator msb_hint = hints.find("msb_override");
60+
if (msb_hint != hints.end())
61+
bit_order = (0 == (msb_hint->second).compare("true"));
62+
this->decodeUncompressed(raw, bit_order);
5963
return mRaw;
6064
}
6165

6266
if (32770 == compression)
6367
{
64-
this->decodeUncompressed(raw, bits == 12);
68+
bool bit_order = (bits == 12); // Default guess
69+
map<string,string>::iterator msb_hint = hints.find("msb_override");
70+
if (msb_hint != hints.end())
71+
bit_order = (0 == (msb_hint->second).compare("true"));
72+
this->decodeUncompressed(raw, bit_order);
6573
return mRaw;
6674
}
6775
ThrowRDE("Srw Decoder: Unsupported compression");

src/external/rawspeed/data/cameras.xml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,16 @@
749749
<Crop x="0" y="0" width="3898" height="2610"/>
750750
<Sensor black="0" white="16383"/>
751751
</Camera>
752+
<Camera make="NIKON CORPORATION" model="NIKON D3200">
753+
<CFA width="2" height="2">
754+
<Color x="0" y="0">RED</Color>
755+
<Color x="1" y="0">GREEN</Color>
756+
<Color x="0" y="1">GREEN</Color>
757+
<Color x="1" y="1">BLUE</Color>
758+
</CFA>
759+
<Crop x="0" y="0" width="-48" height="0"/>
760+
<Sensor black="0" white="16383"/>
761+
</Camera>
752762
<Camera make="NIKON CORPORATION" model="NIKON D4">
753763
<CFA width="2" height="2">
754764
<Color x="0" y="0">RED</Color>
@@ -1204,6 +1214,16 @@
12041214
<Crop x="0" y="0" width="2576" height="1924"/>
12051215
<Sensor black="32" white="1023"/>
12061216
</Camera>
1217+
<Camera make="OLYMPUS IMAGING CORP." model="E-M5">
1218+
<CFA width="2" height="2">
1219+
<Color x="0" y="0">RED</Color>
1220+
<Color x="1" y="0">GREEN</Color>
1221+
<Color x="0" y="1">GREEN</Color>
1222+
<Color x="1" y="1">BLUE</Color>
1223+
</CFA>
1224+
<Crop x="0" y="0" width="0" height="0"/>
1225+
<Sensor black="250" white="4095"/>
1226+
</Camera>
12071227
<Camera make="OLYMPUS IMAGING CORP." model="E-P1">
12081228
<CFA width="2" height="2">
12091229
<Color x="0" y="0">RED</Color>
@@ -1894,13 +1914,27 @@
18941914
<Horizontal y="0" height="2"/>
18951915
</BlackAreas>
18961916
</Camera>
1897-
<Camera make="SAMSUNG" model="NX200" decoder_version="1">
1917+
<Camera make="SAMSUNG" model="NX20" decoder_version="2">
1918+
<CFA width="2" height="2">
1919+
<Color x="0" y="0">GREEN</Color><Color x="1" y="0">BLUE</Color>
1920+
<Color x="0" y="1">RED</Color><Color x="1" y="1">GREEN</Color>
1921+
</CFA>
1922+
<Crop x="48" y="4" width="-60" height="-28"/>
1923+
<Sensor black="0" white="4095"/>
1924+
<Hints>
1925+
<Hint name="msb_override" value="false"/>
1926+
</Hints>
1927+
</Camera>
1928+
<Camera make="SAMSUNG" model="NX200" decoder_version="2">
18981929
<CFA width="2" height="2">
18991930
<Color x="0" y="0">GREEN</Color><Color x="1" y="0">BLUE</Color>
19001931
<Color x="0" y="1">RED</Color><Color x="1" y="1">GREEN</Color>
19011932
</CFA>
19021933
<Crop x="48" y="4" width="-60" height="-28"/>
19031934
<Sensor black="0" white="4095"/>
1935+
<Hints>
1936+
<Hint name="msb_override" value="false"/>
1937+
</Hints>
19041938
</Camera>
19051939
<Camera make="SAMSUNG" model="NX5">
19061940
<CFA width="2" height="2">

0 commit comments

Comments
 (0)