Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibRawLite/src/libraw_cxx.cpp view on Meta::CPAN
_rawspeed_buffer = 0;
}
const char *p = RDE.what();
if (!strncmp(RDE.what(), "Decoder canceled", strlen("Decoder canceled")))
throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;
}
catch (...)
{
// We may get here due to cancellation flag
imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROBLEM;
if(_rawspeed_buffer)
{
free(_rawspeed_buffer);
_rawspeed_buffer = 0;
}
}
ID.input->seek(spos,SEEK_SET);
}
#endif
if(!imgdata.rawdata.raw_image && !imgdata.rawdata.color4_image && !imgdata.rawdata.color3_image) //RawSpeed failed!
{
// Not allocated on RawSpeed call, try call LibRaw
if(decoder_info.decoder_flags & LIBRAW_DECODER_OWNALLOC)
{
// x3f foveon decoder
// Do nothing! Decoder will allocate data internally
}
else if(imgdata.idata.filters || P1.colors == 1) // Bayer image or single color -> decode to raw_image
{
imgdata.rawdata.raw_alloc = malloc(rwidth*(rheight+8)*sizeof(imgdata.rawdata.raw_image[0]));
imgdata.rawdata.raw_image = (ushort*) imgdata.rawdata.raw_alloc;
if(!S.raw_pitch)
S.raw_pitch = S.raw_width*2; // Bayer case, not set before
}
else // NO LEGACY FLAG if (decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
{
// sRAW and old Foveon decoders only, so extra buffer size is just 1/4
S.iwidth = S.width;
S.iheight= S.height;
IO.shrink = 0;
S.raw_pitch = S.width*8;
// allocate image as temporary buffer, size
imgdata.rawdata.raw_alloc = 0;
imgdata.image = (ushort (*)[4]) calloc(S.iwidth*S.iheight,sizeof(*imgdata.image));
}
ID.input->seek(libraw_internal_data.unpacker_data.data_offset, SEEK_SET);
unsigned m_save = C.maximum;
if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
C.maximum=65535;
(this->*load_raw)();
if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
C.maximum = m_save;
if(decoder_info.decoder_flags & LIBRAW_DECODER_OWNALLOC)
{
// x3f foveon decoder only: do nothing
}
else if (!(imgdata.idata.filters || P1.colors == 1))
{
// successfully decoded legacy image, attach image to raw_alloc
imgdata.rawdata.raw_alloc = imgdata.image;
imgdata.image = 0;
// Restore saved values. Note: Foveon have masked frame
// Other 4-color legacy data: no borders
S.raw_width = S.width;
S.left_margin = 0;
S.raw_height = S.height;
S.top_margin = 0;
}
}
if(imgdata.rawdata.raw_image)
crop_masked_pixels(); // calculate black levels
// recover saved
if( !(imgdata.idata.filters || P1.colors == 1) && !imgdata.rawdata.color4_image)
{
imgdata.image = 0;
imgdata.rawdata.color4_image = (ushort (*)[4]) imgdata.rawdata.raw_alloc;
}
// recover image sizes
S.iwidth = save_iwidth;
S.iheight = save_iheight;
IO.shrink = save_shrink;
// adjust black to possible maximum
unsigned int i = C.cblack[3];
unsigned int c;
for(c=0;c<3;c++)
if (i > C.cblack[c]) i = C.cblack[c];
for (c=0;c<4;c++)
C.cblack[c] -= i;
C.black += i;
// Save color,sizes and internal data into raw_image fields
memmove(&imgdata.rawdata.color,&imgdata.color,sizeof(imgdata.color));
memmove(&imgdata.rawdata.sizes,&imgdata.sizes,sizeof(imgdata.sizes));
memmove(&imgdata.rawdata.iparams,&imgdata.idata,sizeof(imgdata.idata));
memmove(&imgdata.rawdata.ioparams,&libraw_internal_data.internal_output_params,sizeof(libraw_internal_data.internal_output_params));
SET_PROC_FLAG(LIBRAW_PROGRESS_LOAD_RAW);
RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,1,2);
return 0;
}
catch ( LibRaw_exceptions err) {
EXCEPTION_HANDLER(err);
}
catch (std::exception ee) {
EXCEPTION_HANDLER(LIBRAW_EXCEPTION_IO_CORRUPT);
}
}
void LibRaw::nikon_load_sraw()
{
// We're already seeked to data!
unsigned char *rd = (unsigned char *)malloc(3*(imgdata.sizes.raw_width+2));
if(!rd) throw LIBRAW_EXCEPTION_ALLOC;
try {
( run in 1.548 second using v1.01-cache-2.11-cpan-4991d5b9bd9 )