problem of decoding apple proRAW dng file

Hi all, I decode some new iphone raw DNG files (maybe proRaw file) with Libraw 0.20 release, VS2015 compiler, and I got some problems:
1. I use command "dcraw_emu -T -6 -q 0 e:\Image_1_2020-11-14_20-51-45.dng" to decode the sample DNG file, and I got a tiff file and with no error, it seems all is good.

2. When I try to get that DNG file's unprocessed raw data with unprocessed_raw project, I got error message from output:
Processing file e:\Image_1_2020-11-14_20-51-45.dng
e:\Image_1_2020-11-14_20-51-45.dng: data corrupted at 11799960
Processing file e:\raw\All\mobile\iphone_proraw\Image_1_2020-11-14_20-51-45.dng
Unpacked....
Only Bayer-pattern RAW files supported, sorry....

it seems decode failed. :-(

after I checked the callstack, "data corrupted.." error should be thrown in decoders_dcraw.cpp:
ushort *LibRaw::ljpeg_row_unrolled(int jrow, struct jhead *jh)
{
...
if ((**row = pred + diff) >> jh->bits) //**row=4119 pred=4073 diff=46 jh->bits=12
derror(); // <---- here
}

3. Then I compiled the Adobe DNG SDK 1.5.1 with Libraw and USE_ZLIB and USE_DNGSDK macro, and add some code lines to unprocessed_raw project before RawProcessor open_file():
dng_host host;
RawProcessor.set_dng_host(&host);
RawProcessor.imgdata.params.use_dngsdk = LIBRAW_DNG_FLOAT | LIBRAW_DNG_LINEAR | LIBRAW_DNG_XTRANS | LIBRAW_DNG_OTHER;

and again I got the same error message output:
Processing file e:\Image_1_2020-11-14_20-51-45.dng
e:\Image_1_2020-11-14_20-51-45.dng: data corrupted at 11799960
Processing file e:\raw\All\mobile\iphone_proraw\Image_1_2020-11-14_20-51-45.dng
Unpacked....
Only Bayer-pattern RAW files supported, sorry...

I debug and noticed:
RawProcessor.imgdata.idata.filters is 0, so output "Only Bayer-pattern RAW files supported, sorry...",
and RawProcessor.imgdata.rawdata.raw_image is NULL

so, How can I get that file's unprocessed raw data ? Thanks for all your help in advance.

Ye.

BTW, the sample DNG file can download from here: https://www.dropbox.com/s/9fdweixwd17pe9w/Image_1_2020-11-14_20-51-45.dn...

Forums: 

1) This is 'linear DNG'

1) This is 'linear DNG' (demosaiced) with 12 bit data
| | 3) BitsPerSample = 12 12 12

So, expected 'real max' value is 4095. In reality it is 4136, that's why LibRaw's decoder warns about data corruption (data value is outside manifested limit)

2) unprocessed_raw sample supports only bayer (not demosaiced) files right now, so you may need to write some code
After LibRaw::open_file() and LibRaw::unpack(), the (unprocessed) data is accessble via
-imgdata.rawdata.color3_image as an array of 3-component pixels
or
- imgdata.rawdata.color4_image as an array of 4-component pixels (for 3-color DNG, 4th component will be always zero)

Only one pointer is not NULL, check before use.
Historically, Adobe DNG SDK fills colr3_image array, but libraw internal decoder(s) use color4_array

-- Alex Tutubalin

BTW, if you have more samples

BTW, if you have more samples from this camera, could you please share it, if possible?

In this specific sample, BaselineExposure tag is set way to high (+2.32), that results in too light rendering in Adobe tools.

it would be interesting to know is that tag setting is systematic, or resulted from some camera settings (e.g. highlight priority, resulting in underexposure)

-- Alex Tutubalin

Thanks a lot.

Thanks a lot.
It looks like BaselineExposure +2... is common for these files. Also, these samples displays correctly if BaselineExposure is applied.

BTW, in 1st file (11_2.5x) data maximum is 503 in green channel, so only 9 bits out of 12 are used.

-- Alex Tutubalin

Hi Alex, I decode a leica M8

Hi Alex, I decode a leica M8 DNG file with unprocessed_raw compiled with adobe DNG SDK 1.5.1, after RawProcessor.unpack() with LIBRAW_SUCCESS return, I found both RawProcessor.imgdata.rawdata.color3_image and RawProcessor.imgdata.rawdata.color4_image is NULL. I can not get that unprocessed raw data. But use dcraw_emu without adobe DNG SDK, I can get a tiff file. and I can get an unprocessed data tiff file (called stage 1 data) with dng_validate, which is a sample of adobe dng sdk.
the sample file is here: https://www.dropbox.com/s/yheqp9lkvuut2ee/LEICA_M8.DNG?dl=0
another sample of Leica DMR DNG: https://www.dropbox.com/s/n9iee4b5rse4ukv/Leica_DMR_R8_L1185423.DNG?dl=0
the same problem as M8. :-(
thank you for your response

-- Ye.