DNG files from DJI FC6310 open extremely slow, fixes #4888

This commit is contained in:
heckflosse 2018-10-23 15:43:24 +02:00
parent 2696037cb8
commit ed3b54e4eb

View File

@ -6462,17 +6462,20 @@ guess_cfa_pc:
unsigned oldOrder = order;
order = 0x4d4d; // always big endian per definition in https://www.adobe.com/content/dam/acom/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf chapter 7
unsigned ntags = get4(); // read the number of opcodes
while (ntags--) {
unsigned opcode = get4();
fseek (ifp, 8, SEEK_CUR); // skip 8 bytes as they don't interest us currently
if (opcode == 4) { // FixBadPixelsConstant
fseek (ifp, 4, SEEK_CUR); // skip 4 bytes as we know that the opcode 4 takes 4 byte
if(get4() == 0) { // if raw 0 values should be treated as bad pixels, set zero_is_bad to true (1). That's the only value currently supported by rt
zero_is_bad = 1;
if (ntags < ifp->size / 12) { // rough check for wrong value (happens for example with DNG files from DJI FC6310)
while (ntags-- && !ifp->eof) {
unsigned opcode = get4();
fseek (ifp, 8, SEEK_CUR); // skip 8 bytes as they don't interest us currently
if (opcode == 4) { // FixBadPixelsConstant
fseek (ifp, 4, SEEK_CUR); // skip 4 bytes as we know that the opcode 4 takes 4 byte
if(get4() == 0) { // if raw 0 values should be treated as bad pixels, set zero_is_bad to true (1). That's the only value currently supported by rt
zero_is_bad = 1;
}
} else {
fseek (ifp, get4(), SEEK_CUR);
}
}
} else {
fseek (ifp, get4(), SEEK_CUR);
}
}
order = oldOrder;
break;