Segmentation fault when called subtract_black() version LibRaw-0.15.0-Beta1

Probed with .CR2 file from canon 350d.

Segmentation fault launch at line 2204 of libraw_cxx.cpp

 
2202           for(i=0; i< size*4; i++)
2203              {
2204               int val = imgdata.image[0][i];
2205                val -= cblk[i & 3];
2205                imgdata.image[0][i] = CLIP(val);
2205                if(C.data_maximum < val) C.data_maximum = val;
2205              }

Forums: 

Do you called raw2image()

Do you called raw2image() before calling subtract_black() ?

-- Alex Tutubalin @LibRaw LLC

No, I try only call unpack(),

No, I try only call unpack(), the application works directly over raw data.

substract_black() works only over demosaicing data ?

Thank's a lot.

LibRaw::raw2image() allocates

LibRaw::raw2image() allocates imgdata.image[] array and copies data from internal storage (different for Bayer and non-bayer images) to this array.
No demosaic, no black subtration, this is for developers who want to do processing by hand.

So, three ways exists:
- unpack() + raw2image() - this produce internal data compatible with old LibRaw (0.9-0.13)
- unpack + dcraw_process() - for full processing
- only unpack() but you need to know LibRaw internals, because different data types (bayer vs non-bayer) are stored in different way.

Sure, internals may change in future LibRaw releases, so it is safer to use unpack() + raw2image, although it requires extra RAM.

-- Alex Tutubalin @LibRaw LLC

BTW, thanks for bugreport. I

BTW, thanks for bugreport. I'll add new processing stage to internals and subtract_black() will check that raw2image is called.

-- Alex Tutubalin @LibRaw LLC

And it is now in 0.15-Beta2:

And it is now in 0.15-Beta2: return type of subtract_black() is changed to int, returns according to LibRaw convention (0 on success, error code on error)

-- Alex Tutubalin @LibRaw LLC