--- dcraw.c.orig 2011-01-29 09:43:38.000000000 +0200 +++ dcraw.c 2011-03-20 22:53:08.976000042 +0200 @@ -217,7 +217,7 @@ #define BAYER2(row,col) \ image[((row) >> shrink)*iwidth + ((col) >> shrink)][fc(row,col)] -int CLASS fc (int row, int col) +static int CLASS fc (int row, int col) { static const char filter[16][16] = { { 2,1,1,3,2,3,2,0,3,2,3,0,1,2,1,0 }, @@ -273,7 +273,7 @@ data_error++; } -ushort CLASS sget2 (uchar *s) +static ushort CLASS sget2 (uchar *s) { if (order == 0x4949) /* "II" means little-endian */ return s[0] | s[1] << 8; @@ -281,14 +281,14 @@ return s[0] << 8 | s[1]; } -ushort CLASS get2() +static ushort CLASS get2() { uchar str[2] = { 0xff,0xff }; fread (str, 1, 2, ifp); return sget2(str); } -unsigned CLASS sget4 (uchar *s) +static unsigned CLASS sget4 (uchar *s) { if (order == 0x4949) return s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24; @@ -297,26 +297,26 @@ } #define sget4(s) sget4((uchar *)s) -unsigned CLASS get4() +static unsigned CLASS get4() { uchar str[4] = { 0xff,0xff,0xff,0xff }; fread (str, 1, 4, ifp); return sget4(str); } -unsigned CLASS getint (int type) +static unsigned CLASS getint (int type) { return type == 3 ? get2() : get4(); } -float CLASS int_to_float (int i) +static float CLASS int_to_float (int i) { union { int i; float f; } u; u.i = i; return u.f; } -double CLASS getreal (int type) +static double CLASS getreal (int type) { union { char c[8]; double d; } u; int i, rev; @@ -340,7 +340,7 @@ } } -void CLASS read_shorts (ushort *pixel, int count) +static void CLASS read_shorts (ushort *pixel, int count) { if (fread (pixel, 2, count, ifp) < count) derror(); if ((order == 0x4949) == (ntohs(0x1234) == 0x1234)) @@ -846,7 +846,7 @@ return diff; } -ushort * CLASS ljpeg_row (int jrow, struct jhead *jh) +static ushort * CLASS ljpeg_row (int jrow, struct jhead *jh) { int col, c, diff, pred, spred=0; ushort mark=0, *row[3]; @@ -885,7 +885,7 @@ return row[2]; } -void CLASS lossless_jpeg_load_raw() +static void CLASS lossless_jpeg_load_raw() { int jwide, jrow, jcol, val, jidx, c, i, j, row=0, col=0; struct jhead jh; @@ -3713,6 +3713,8 @@ fputc ('\n', stderr); } size = iheight*iwidth; + +#pragma omp parallel for default(none) private(i, val) shared(size,stderr,image,black,scale_mul) for (i=0; i < size*4; i++) { val = image[0][i]; if (!val) continue; @@ -3782,7 +3784,7 @@ if (half_size) filters = 0; } -void CLASS border_interpolate (int border) +static void CLASS border_interpolate (int border) { unsigned row, col, y, x, f, c, sum[8]; @@ -4070,6 +4072,7 @@ lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS); homo = (char (*)[TS][TS]) (buffer + 24*TS*TS); +#pragma omp for for (top=2; top < height-5; top += TS-6) for (left=2; left < width-5; left += TS-6) { @@ -8308,8 +8311,14 @@ _("Converting to %s colorspace...\n"), name[output_color-1]); memset (histogram, 0, sizeof histogram); - for (img=image[0], row=0; row < height; row++) - for (col=0; col < width; col++, img+=4) { + +#pragma omp parallel for \ + default(none) \ + shared(height, width, image, raw_color, out_cam, colors, document_mode, filters, histogram) \ + private(row, col, out, c, img) + for (row = 0; row < height; row++) { + img = image[0] + row * width * 4; + for (col = 0; col < width; col++, img += 4) { if (!raw_color) { out[0] = out[1] = out[2] = 0; FORCC { @@ -8321,8 +8330,12 @@ } else if (document_mode) img[0] = img[FC(row,col)]; - FORCC histogram[c][img[c] >> 3]++; + FORCC { +#pragma omp atomic + histogram[c][img[c] >> 3]++; + } } + } if (colors == 4 && output_color) colors = 3; if (document_mode && filters) colors = 1; }