Q about BlackLevels and Maximum values

Hi,
I am using libraw to read CFA data into my application and build my own RAW processing pipeline. To this effect, I am trying to understand how the black level and saturation values are handled by libraw.

My workflow is primarily going to be:
LibRaw rp;
rp.open_file(fileName);
rp.unpack();
// Read the rawdata and inspect the rp.imgdata to get the necessary metadata for building my own pipeline.

I noticed the fields black, cblack, data_maximum, maximum and linear_max in the colordata_t structure. I went through the annotated dcraw page and it does not appear to explain this part quite effectively.

I tried to inspect the values of these fields for various kinds of NEF, CR2 and DNG files I have but really could not understand which ones I can use reliably.

My questions are below:
1. The field black appears to be a scalar. Is this read from the file or obtained from the adobe_coeffs table?

2. The cblack appears to refer to a pattern of black level. Is this similar to the BlackLevel DNG tag? If so, does this pattern start at the top-left corner of the visible area of the CFA data for all formats? For many files I noticed cblack[4] and cblack[5] to be 0. For an image from a Nikon D70s camera, black = 0, cblack is all zeros. What do I do in these cases?

3. What is the difference between maximum and linear_max? Is linear_max per channel? For an image from a Nikon D70s camera, maximum = 4095 and linear_max = {3827, 3827, 3827, 3827}. Which one should I use?

Dinesh

Forums: