#include "dcraw.h"
+//const static data
+const double DCRaw_data::xyz_rgb[3][3] = { /* XYZ from RGB */
+ { 0.412453, 0.357580, 0.180423 },
+ { 0.212671, 0.715160, 0.072169 },
+ { 0.019334, 0.119193, 0.950227 } };
+const float DCRaw_data::d65_white[3] = {
+ 0.950456, 1.000000, 1.088754 };
+
/*
All global variables are defined here, and all functions that
access them are prefixed with "CLASS". Note that a thread-safe
#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
#define CLIP(x) LIM((int)(x),0,65535)
#define SWAP(a,b) { a=a+b; b=a-b; a=a-b; }
+#define ZERO(var) memset(&var, 0, sizeof var)
/*
In order to inline this calculation, I make the risky
assumption that all filter patterns can be described
void CLASS reset()
{
-// uninitialized
-#define ZERO(var) memset(&var, 0, sizeof var);
- aperture = 0;
- ZERO(artist);
- black = 0;
- ZERO(cam_mul)
- canon_ev = 0;
- ZERO(cblack);
- ZERO(cmatrix);
- ZERO(cdesc);
- colors = 0;
- ZERO(cr2_slice);
- ZERO(curve);
- data_error = 0;
- data_offset = 0;
- dng_version = 0;
- exif_cfa = 0;
- ZERO(failure);
- filters = 0;
- ZERO(first_decode);
- flash_used = 0;
- flip = 0;
- focal_len = 0;
- fuji_layout = 0;
- fuji_width = 0;
- ZERO(gpsdata);
- height = 0;
- ZERO(histogram);
- ifname = 0;
- ifp = 0;
- iheight = 0;
- is_foveon = 0;
- iso_speed = 0;
- is_raw = 0;
- iwidth = 0;
- kodak_cbpp = 0;
- left_margin = 0;
- load_flags = 0;
- load_raw = 0;
- maximum = 0;
- meta_data = 0;
- meta_length = 0;
- meta_offset = 0;
- mix_green = 0;
- ZERO(model);
- ZERO(model2);
- ofp = 0;
- oprof = 0;
- order = 0;
- ZERO(ph1);
- pixel_aspect = 0;
- memset(pre_mul, 0, sizeof pre_mul);
- profile_length = 0;
- profile_offset = 0;
- raw_color = 0;
- raw_height = 0;
- raw_width = 0;
- raw_image = 0;
- memset(rgb_cam, 0, sizeof rgb_cam);
- shot_order = 0;
- shrink = 0;
- shutter = 0;
- strip_offset = 0;
- thumb_height = 0;
- thumb_length = 0;
- thumb_load_raw = 0;
- thumb_misc = 0;
- thumb_offset = 0;
- thumb_width = 0;
- tiff_bps = 0;
- tiff_compress = 0;
- tiff_flip = 0;
- tiff_nifds = 0;
- tiff_samples = 0;
- tile_length = 0;
- tile_width = 0;
- timestamp = 0;
- top_margin = 0;
- unique_id = 0;
- ZERO(white);
- width = 0;
- zero_after_ff = 0;
- zero_is_bad = 0;
-
-// initializer data
- shot_select = 0;
- multi_out = 0;
+// zero data segment
+ DCRaw_data *data = (DCRaw_data *)this;
+ memset(data, 0, sizeof(*data));
+// non-zero init data
aber[0] = aber[1] = aber[2] = aber[3] = 1;
- gamm[0] = 0.45; gamm[1] = 4.5; gamm[2] = 0;
- gamm[3] = 0; gamm[4] = 0; gamm[5] = 0;
+ gamm[0] = 0.45; gamm[1] = 4.5;
bright = 1;
- ZERO(user_mul);
- threshold = 0;
- half_size = 0;
- four_color_rgb = 0;
- document_mode = 0;
- highlight = 0;
- verbose = 0;
- use_auto_wb = 0;
- use_camera_wb = 0;
use_camera_matrix = 1;
output_color = 1;
output_bps = 8;
- output_tiff = 0;
- med_passes = 0;
- no_auto_bright = 0;
- greybox[0] = 0; greybox[1] = 0;
greybox[2] = UINT_MAX; greybox[3] = UINT_MAX;
-// local static
- gbh_bitbuf = 0; gbh_vbits = 0; gbh_reset = 0;
- ph1_bitbuf = 0; ph1_vbits = 0;
- ZERO(ljpeg_cs);
- ZERO(sony_pad); sony_p = 0;
- ZERO(fov_huff);
- ZERO(clb_cbrt); ZERO(clb_xyz_cam);
- ZERO(pana_buf); pana_vbits = 0;
}
#if 0
if (!filt) filt = 0.8;
size = 4*M_PI*max / filt;
- if (size == UINT_MAX) size--;
+ if (size > INT_MAX-1) size = INT_MAX-1;
curve = (short *) calloc (size+1, sizeof *curve);
merror (curve, "foveon_make_curve()");
curve[0] = size;
{
static const short hood[] = { -1,-1, -1,0, -1,1, 0,-1, 0,1, 1,-1, 1,0, 1,1 };
short *pix, prev[3], *curve[8], (*shrink)[3];
- float cfilt=0, ddft[3][3][2], ppm[3][3][3];
+ float cfilt, ddft[3][3][2], ppm[3][3][3];
float cam_xyz[3][3], correct[3][3], last[3][3], trans[3][3];
float chroma_dq[3], color_dq[3], diag[3][3], div[3];
float (*black)[3], (*sgain)[3], (*sgrow)[3];
float fsum[3], val, frow, num;
int row, col, c, i, j, diff, sgx, irow, sum, min, max, limit;
int dscr[2][2], dstb[4], (*smrow[7])[3], total[4], ipix[3];
- int work[3][3], smlast, smred, smred_p=0, dev[3];
+ int work[3][3], smlast, smred, smred_p, dev[3];
int satlev[3], keep[4], active[4];
unsigned dim[3], *badpix;
- double dsum=0, trsum[3];
+ double dsum, trsum[3];
char str[128];
const char* cp;
+// clear local storage
+ pix = 0; ZERO(prev); ZERO(curve); ZERO(shrink);
+ cfilt = 0; ZERO(ddft); ZERO(ppm);
+ ZERO(cam_xyz); ZERO(correct); ZERO(last); ZERO(trans);
+ ZERO(chroma_dq); ZERO(color_dq); ZERO(diag); ZERO(div);
+ ZERO(black); ZERO(sgain); ZERO(sgrow);
+ ZERO(fsum); val = frow = num = 0;
+ row = col = c = i = j = diff = sgx = irow = sum = min = max = limit = 0;
+ ZERO(dscr); ZERO(dstb); ZERO(smrow); ZERO(total); ZERO(ipix);
+ ZERO(work); ZERO(smlast); ZERO(smred); smred_p=0; ZERO(dev);
+ ZERO(satlev); ZERO(keep); ZERO(active);
+ ZERO(dim); badpix = 0;
+ dsum = 0; ZERO(trsum);
+ ZERO(str);
+ cp = 0;
if (verbose)
fprintf (stderr,_("Foveon interpolation...\n"));
case 61450:
cblack[4] = cblack[5] = MIN(sqrt(len),64);
case 50714: /* BlackLevel */
- if (!(cblack[4] * cblack[5]))
+ if ((cblack[4] * cblack[5])==0)
cblack[4] = cblack[5] = 1;
FORC (cblack[4] * cblack[5])
cblack[6+c] = getreal(type);
reset(); // Globals must be reset
#ifndef LOCALTIME
- putenv ((char *) "TZ=UTC");
+// putenv ((char *) "TZ=UTC");
#endif
#ifdef LOCALEDIR
setlocale (LC_CTYPE, "");