Merge branch 'dev' into ph1speedup
This commit is contained in:
@@ -3202,34 +3202,60 @@ void CLASS sony_arw_load_raw()
|
||||
|
||||
void CLASS sony_arw2_load_raw()
|
||||
{
|
||||
uchar *data, *dp;
|
||||
ushort pix[16];
|
||||
int row, col, val, max, min, imax, imin, sh, bit, i;
|
||||
|
||||
data = (uchar *) malloc (raw_width+1);
|
||||
merror (data, "sony_arw2_load_raw()");
|
||||
for (row=0; row < height; row++) {
|
||||
fread (data, 1, raw_width, ifp);
|
||||
for (dp=data, col=0; col < raw_width-30; dp+=16) {
|
||||
max = 0x7ff & (val = sget4(dp));
|
||||
min = 0x7ff & val >> 11;
|
||||
imax = 0x0f & val >> 22;
|
||||
imin = 0x0f & val >> 26;
|
||||
for (sh=0; sh < 4 && 0x80 << sh <= max-min; sh++);
|
||||
for (bit=30, i=0; i < 16; i++)
|
||||
if (i == imax) pix[i] = max;
|
||||
else if (i == imin) pix[i] = min;
|
||||
else {
|
||||
pix[i] = ((sget2(dp+(bit >> 3)) >> (bit & 7) & 0x7f) << sh) + min;
|
||||
if (pix[i] > 0x7ff) pix[i] = 0x7ff;
|
||||
bit += 7;
|
||||
}
|
||||
for (i=0; i < 16; i++, col+=2)
|
||||
RAW(row,col) = curve[pix[i] << 1]; // >> 2; RT: disabled shifting to avoid precision loss
|
||||
col -= col & 1 ? 1:31;
|
||||
#if defined( _OPENMP ) && defined( MYFILE_MMAP )
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
uchar *data = new (std::nothrow) uchar[raw_width + 1];
|
||||
merror(data, "sony_arw2_load_raw()");
|
||||
IMFILE ifpthr = *ifp;
|
||||
int pos = ifpthr.pos;
|
||||
ushort pix[16];
|
||||
|
||||
#if defined( _OPENMP ) && defined( MYFILE_MMAP )
|
||||
// only master thread will update the progress bar
|
||||
ifpthr.plistener = nullptr;
|
||||
#pragma omp master
|
||||
{
|
||||
ifpthr.plistener = ifp->plistener;
|
||||
}
|
||||
}
|
||||
free (data);
|
||||
#pragma omp for schedule(dynamic,16) nowait
|
||||
#endif
|
||||
|
||||
for (int row = 0; row < height; row++) {
|
||||
fseek(&ifpthr, pos + row * raw_width, SEEK_SET);
|
||||
fread(data, 1, raw_width, &ifpthr);
|
||||
uchar *dp = data;
|
||||
for (int col = 0; col < raw_width - 30; dp += 16) {
|
||||
int val = sget4(dp);
|
||||
int max = 0x7ff & val;
|
||||
int min = 0x7ff & val >> 11;
|
||||
int imax = 0x0f & val >> 22;
|
||||
int imin = 0x0f & val >> 26;
|
||||
int bit = 30;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (i == imax) {
|
||||
pix[i] = max;
|
||||
} else if (i == imin) {
|
||||
pix[i] = min;
|
||||
} else {
|
||||
int sh;
|
||||
for (sh = 0; sh < 4 && 0x80 << sh <= max - min; sh++)
|
||||
;
|
||||
pix[i] = ((sget2(dp + (bit >> 3)) >> (bit & 7) & 0x7f) << sh) + min;
|
||||
pix[i] = std::min(pix[i], (ushort)0x7ff);
|
||||
bit += 7;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 16; i++, col += 2) {
|
||||
RAW(row,col) = curve[pix[i] << 1]; // >> 2; RT: disabled shifting to avoid precision loss
|
||||
}
|
||||
col -= col & 1 ? 1:31;
|
||||
}
|
||||
}
|
||||
delete [] data;
|
||||
}
|
||||
maximum = curve[0x7ff << 1]; // RT: fix maximum.
|
||||
maximum = 16300; // RT: conservative white level tested on various ARW2 cameras. This constant was set in 2013-12-17, may need re-evaluation in the future.
|
||||
}
|
||||
|
||||
@@ -112,7 +112,10 @@ void RawImage::get_colorsCoeff( float *pre_mul_, float *scale_mul_, float *cblac
|
||||
}
|
||||
}
|
||||
|
||||
if (data && (this->get_cam_mul(0) == -1 || forceAutoWB)) {
|
||||
if (this->get_cam_mul(0) == -1 || forceAutoWB) {
|
||||
if(!data) { // this happens only for thumbnail creation when get_cam_mul(0) == -1
|
||||
compress_image(0, false);
|
||||
}
|
||||
memset(dsum, 0, sizeof dsum);
|
||||
|
||||
if (this->isBayer()) {
|
||||
@@ -673,7 +676,7 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
|
||||
return 0;
|
||||
}
|
||||
|
||||
float** RawImage::compress_image(int frameNum)
|
||||
float** RawImage::compress_image(int frameNum, bool freeImage)
|
||||
{
|
||||
if( !image ) {
|
||||
return nullptr;
|
||||
@@ -757,8 +760,10 @@ float** RawImage::compress_image(int frameNum)
|
||||
}
|
||||
}
|
||||
|
||||
free(image); // we don't need this anymore
|
||||
image = nullptr;
|
||||
if(freeImage) {
|
||||
free(image); // we don't need this anymore
|
||||
image = nullptr;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
{
|
||||
return image;
|
||||
}
|
||||
float** compress_image(int frameNum); // revert to compressed pixels format and release image data
|
||||
float** compress_image(int frameNum, bool freeImage = true); // revert to compressed pixels format and release image data
|
||||
float** data; // holds pixel values, data[i][j] corresponds to the ith row and jth column
|
||||
unsigned prefilters; // original filters saved ( used for 4 color processing )
|
||||
unsigned int getFrameCount() const { return is_raw; }
|
||||
|
||||
Reference in New Issue
Block a user