SHA256
1
0
forked from pool/dcraw
dcraw/dcraw-omp.patch

209 lines
5.2 KiB
Diff

--- dcraw.c.orig 2008-02-19 00:30:12.000000000 +0100
+++ dcraw.c 2008-02-19 00:30:44.000000000 +0100
@@ -212,7 +212,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 },
@@ -268,7 +268,7 @@
data_error = 1;
}
-ushort CLASS sget2 (uchar *s)
+static ushort CLASS sget2 (uchar *s)
{
if (order == 0x4949) /* "II" means little-endian */
return s[0] | s[1] << 8;
@@ -276,14 +276,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;
@@ -292,26 +292,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;
@@ -335,7 +335,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))
@@ -554,7 +554,7 @@
getbits(-1) initializes the buffer
getbits(n) where 0 <= n <= 25 returns an n-bit integer
*/
-unsigned CLASS getbits (int nbits)
+static unsigned CLASS getbits (int nbits)
{
static unsigned bitbuf=0;
static int vbits=0, reset=0;
@@ -853,7 +853,7 @@
return zero_after_ff = 1;
}
-int CLASS ljpeg_diff (struct decode *dindex)
+static int CLASS ljpeg_diff (struct decode *dindex)
{
int len, diff;
@@ -868,7 +868,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;
ushort mark=0, *row[3];
@@ -904,7 +904,7 @@
return row[2];
}
-void CLASS lossless_jpeg_load_raw()
+static void CLASS lossless_jpeg_load_raw()
{
int jwide, jrow, jcol, val, jidx, i, j, row=0, col=0;
struct jhead jh;
@@ -3753,6 +3753,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;
@@ -3822,7 +3824,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];
@@ -4110,10 +4112,18 @@
if (verbose) fprintf (stderr,_("AHD interpolation...\n"));
+#pragma omp parallel \
+ default(none) \
+ shared(stderr, cbrt, colors, xyz_cam, rgb_cam, height, width, image, filters) \
+ private(top, left, row, col, pix, rix, lix, c, xyz, val, d, tc, tr, i, j, k, ldiff, abdiff, leps, abeps, hm, buffer, rgb, lab, homo, r)
+ {
+#pragma omp for schedule(static) nowait
for (i=0; i < 0x10000; i++) {
r = i / 65535.0;
cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0;
}
+
+#pragma omp for
for (i=0; i < 3; i++)
for (j=0; j < colors; j++)
for (xyz_cam[i][j] = k=0; k < 3; k++)
@@ -4126,6 +4136,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) {
@@ -4219,6 +4230,7 @@
}
}
free (buffer);
+ }
}
#undef TS
@@ -7698,8 +7710,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 {
@@ -7711,8 +7729,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;
}
@@ -7814,6 +7836,10 @@
if (white < val) white = val;
}
white *= 8 / bright;
+#pragma omp parallel for \
+ default(none) \
+ shared(use_gamma, white, lut) \
+ private(i, r, val)
for (i=0; i < 0x10000; i++) {
r = i / white;
val = 256 * ( !use_gamma ? r :