Hi everyone.

Pretext blurb

As you may or may not know, nikon cameras are rather interesting piece of work.

The compression is configurable (three different types), the bitdepth is configurable (2 variants).

That already results in a 6 different raw types.

If only it was that simple.

Under some unknown conditions, some nikon cameras, when configured to store lossy compressed raw files, actually produce some strange modification of raw files, that internally are split in two, with slightly different compression between two halves. I’m not aware of any official documentation about it, but i suppose it is most often refereed to as “lossy after split”.

That oddity does not seem to be stated in the EXIF, only deep within nikon makernotes, and, if decoded properly, there is no difference between normal lossy compressed raws, and these raws with split. Right now i’m aware of 1 J5 1 and D3400 2 producing such raws.

We always create our own problems, don’t we?

After the maintainership of the rawspeed library, which is used by darktable to load the raw files, was transferred to us late last year (2016-12), the RPU was created/resurrected right after that. And then the “cpr” on the library begun.

Now, here is the problem, due to the huge [unnessesary] rush, [which partially led to] and a gross code review mishap, the support for these NEF with split raws was broken. Since RPU was very new back then, and due to the [unnessesary] rush, there was no such sample, so the breakage was not detected. Later, it was finally caught by Wolfgang Goetz, and nowadays we have two 1 2 samples.

That is great, and i will finally be able to work on unbreaking that support. The one small caveat is that both of these samples are 12-bit.

It would be really nice to also find the 14-bit raw with the same problem.

HOW TO DETECT IF THAT IS THE RAW WE ARE LOOKING FOR

Now, as i have already said, i’m not aware of any way to auto-detect that raw easily using exiv2/exiftool. The following command can help you check compression and bitdepth of the raws.

$ find -iname \*.nef -print0 | sort -z | xargs -0 exiftool -compression* -nefcompression -bitspersample ======== name.nef Compression : Nikon NEF Compressed NEF Compression : Lossy (type 2) Bits Per Sample : 14

If the output matches this example, please try opening that raw in a fresh darktable (from git master, NOT 2.2.x or earlier). If it fails to load, and in console you see the following message, you have found it!

[rawspeed] (name.nef) void rawspeed::HuffmanTable::setCodeValues(const rawspeed::Buffer &), line 176: Corrupt Huffman. Code value 92 is bigger than 16

Please help!