diff --git a/libkdcraw/dcraw/dcraw.c b/libkdcraw/dcraw/dcraw.c index 70964cd..1b9dce6 100644 --- a/libkdcraw/dcraw/dcraw.c +++ b/libkdcraw/dcraw/dcraw.c @@ -3931,30 +3931,37 @@ void CLASS lin_interpolate() */ void CLASS vng_interpolate() { - static const signed char *cp, terms[] = { - -2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01, - -2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01, - -2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03, - -2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06, - -2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04, - -1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01, - -1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40, - -1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11, - -1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11, - -1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22, - -1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44, - -1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10, - -1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04, - +0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40, - +0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20, - +0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08, - +0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20, - +0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44, - +0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60, - +0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80, - +1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40, - +1,+0,+2,+1,0,0x10 - }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 }; + struct interpolate_terms { + signed char y1, x1, y2, x2, weight; + unsigned char grads; + }; + static const interpolate_terms terms[] = { + {-2,-2,+0,-1,0,0x01}, {-2,-2,+0,+0,1,0x01}, {-2,-1,-1,+0,0,0x01}, + {-2,-1,+0,-1,0,0x02}, {-2,-1,+0,+0,0,0x03}, {-2,-1,+0,+1,1,0x01}, + {-2,+0,+0,-1,0,0x06}, {-2,+0,+0,+0,1,0x02}, {-2,+0,+0,+1,0,0x03}, + {-2,+1,-1,+0,0,0x04}, {-2,+1,+0,-1,1,0x04}, {-2,+1,+0,+0,0,0x06}, + {-2,+1,+0,+1,0,0x02}, {-2,+2,+0,+0,1,0x04}, {-2,+2,+0,+1,0,0x04}, + {-1,-2,-1,+0,0,0x80}, {-1,-2,+0,-1,0,0x01}, {-1,-2,+1,-1,0,0x01}, + {-1,-2,+1,+0,1,0x01}, {-1,-1,-1,+1,0,0x88}, {-1,-1,+1,-2,0,0x40}, + {-1,-1,+1,-1,0,0x22}, {-1,-1,+1,+0,0,0x33}, {-1,-1,+1,+1,1,0x11}, + {-1,+0,-1,+2,0,0x08}, {-1,+0,+0,-1,0,0x44}, {-1,+0,+0,+1,0,0x11}, + {-1,+0,+1,-2,1,0x40}, {-1,+0,+1,-1,0,0x66}, {-1,+0,+1,+0,1,0x22}, + {-1,+0,+1,+1,0,0x33}, {-1,+0,+1,+2,1,0x10}, {-1,+1,+1,-1,1,0x44}, + {-1,+1,+1,+0,0,0x66}, {-1,+1,+1,+1,0,0x22}, {-1,+1,+1,+2,0,0x10}, + {-1,+2,+0,+1,0,0x04}, {-1,+2,+1,+0,1,0x04}, {-1,+2,+1,+1,0,0x04}, + {+0,-2,+0,+0,1,0x80}, {+0,-1,+0,+1,1,0x88}, {+0,-1,+1,-2,0,0x40}, + {+0,-1,+1,+0,0,0x11}, {+0,-1,+2,-2,0,0x40}, {+0,-1,+2,-1,0,0x20}, + {+0,-1,+2,+0,0,0x30}, {+0,-1,+2,+1,1,0x10}, {+0,+0,+0,+2,1,0x08}, + {+0,+0,+2,-2,1,0x40}, {+0,+0,+2,-1,0,0x60}, {+0,+0,+2,+0,1,0x20}, + {+0,+0,+2,+1,0,0x30}, {+0,+0,+2,+2,1,0x10}, {+0,+1,+1,+0,0,0x44}, + {+0,+1,+1,+2,0,0x10}, {+0,+1,+2,-1,1,0x40}, {+0,+1,+2,+0,0,0x60}, + {+0,+1,+2,+1,0,0x20}, {+0,+1,+2,+2,0,0x10}, {+1,-2,+1,+0,0,0x80}, + {+1,-1,+1,+1,0,0x88}, {+1,+0,+1,+2,0,0x08}, {+1,+0,+2,-1,0,0x40}, + {+1,+0,+2,+1,0,0x10} + }; + const interpolate_terms *cpt; + signed char *cp; + signed char chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 }; ushort (*brow[5])[4], *pix; int prow=7, pcol=1, *ip, *code[16][16], gval[8], gmin, gmax, sum[4]; int row, col, x, y, x1, x2, y1, y2, t, weight, grads, color, diag; @@ -3969,11 +3976,11 @@ void CLASS vng_interpolate() for (row=0; row <= prow; row++) /* Precalculate for VNG */ for (col=0; col <= pcol; col++) { code[row][col] = ip; - for (cp=terms, t=0; t < 64; t++) { - y1 = *cp++; x1 = *cp++; - y2 = *cp++; x2 = *cp++; - weight = *cp++; - grads = *cp++; + for (cpt=&terms[0], t=0; t < 64, cpt = &terms[t]; t++) { + y1 = cpt->y1; x1 = cpt->x1; + y2 = cpt->y2; x2 = cpt->x2; + weight = cpt->weight; + grads = cpt->grads; color = fc(row+y1,col+x1); if (fc(row+y2,col+x2) != color) continue; diag = (fc(row,col+1) == color && fc(row+1,col) == color) ? 2:1; diff --git a/libkdcraw/libraw/internal/dcraw_common.cpp b/libkdcraw/libraw/internal/dcraw_common.cpp index 215a76b..11304d4 100644 --- a/libkdcraw/libraw/internal/dcraw_common.cpp +++ b/libkdcraw/libraw/internal/dcraw_common.cpp @@ -3597,30 +3597,37 @@ void CLASS lin_interpolate() */ void CLASS vng_interpolate() { - static const signed char *cp, terms[] = { - -2,-2,+0,-1,0,'\x01', -2,-2,+0,+0,1,'\x01', -2,-1,-1,+0,0,'\x01', - -2,-1,+0,-1,0,'\x02', -2,-1,+0,+0,0,'\x03', -2,-1,+0,+1,1,'\x01', - -2,+0,+0,-1,0,'\x06', -2,+0,+0,+0,1,'\x02', -2,+0,+0,+1,0,'\x03', - -2,+1,-1,+0,0,'\x04', -2,+1,+0,-1,1,'\x04', -2,+1,+0,+0,0,'\x06', - -2,+1,+0,+1,0,'\x02', -2,+2,+0,+0,1,'\x04', -2,+2,+0,+1,0,'\x04', - -1,-2,-1,+0,0,'\x80', -1,-2,+0,-1,0,'\x01', -1,-2,+1,-1,0,'\x01', - -1,-2,+1,+0,1,'\x01', -1,-1,-1,+1,0,'\x88', -1,-1,+1,-2,0,'\x40', - -1,-1,+1,-1,0,'\x22', -1,-1,+1,+0,0,'\x33', -1,-1,+1,+1,1,'\x11', - -1,+0,-1,+2,0,'\x08', -1,+0,+0,-1,0,'\x44', -1,+0,+0,+1,0,'\x11', - -1,+0,+1,-2,1,'\x40', -1,+0,+1,-1,0,'\x66', -1,+0,+1,+0,1,'\x22', - -1,+0,+1,+1,0,'\x33', -1,+0,+1,+2,1,'\x10', -1,+1,+1,-1,1,'\x44', - -1,+1,+1,+0,0,'\x66', -1,+1,+1,+1,0,'\x22', -1,+1,+1,+2,0,'\x10', - -1,+2,+0,+1,0,'\x04', -1,+2,+1,+0,1,'\x04', -1,+2,+1,+1,0,'\x04', - +0,-2,+0,+0,1,'\x80', +0,-1,+0,+1,1,'\x88', +0,-1,+1,-2,0,'\x40', - +0,-1,+1,+0,0,'\x11', +0,-1,+2,-2,0,'\x40', +0,-1,+2,-1,0,'\x20', - +0,-1,+2,+0,0,'\x30', +0,-1,+2,+1,1,'\x10', +0,+0,+0,+2,1,'\x08', - +0,+0,+2,-2,1,'\x40', +0,+0,+2,-1,0,'\x60', +0,+0,+2,+0,1,'\x20', - +0,+0,+2,+1,0,'\x30', +0,+0,+2,+2,1,'\x10', +0,+1,+1,+0,0,'\x44', - +0,+1,+1,+2,0,'\x10', +0,+1,+2,-1,1,'\x40', +0,+1,+2,+0,0,'\x60', - +0,+1,+2,+1,0,'\x20', +0,+1,+2,+2,0,'\x10', +1,-2,+1,+0,0,'\x80', - +1,-1,+1,+1,0,'\x88', +1,+0,+1,+2,0,'\x08', +1,+0,+2,-1,0,'\x40', - +1,+0,+2,+1,0,'\x10' - }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 }; + struct interpolate_terms { + signed char y1, x1, y2, x2, weight; + unsigned char grads; + }; + static const interpolate_terms terms[] = { + {-2,-2,+0,-1,0,0x01}, {-2,-2,+0,+0,1,0x01}, {-2,-1,-1,+0,0,0x01}, + {-2,-1,+0,-1,0,0x02}, {-2,-1,+0,+0,0,0x03}, {-2,-1,+0,+1,1,0x01}, + {-2,+0,+0,-1,0,0x06}, {-2,+0,+0,+0,1,0x02}, {-2,+0,+0,+1,0,0x03}, + {-2,+1,-1,+0,0,0x04}, {-2,+1,+0,-1,1,0x04}, {-2,+1,+0,+0,0,0x06}, + {-2,+1,+0,+1,0,0x02}, {-2,+2,+0,+0,1,0x04}, {-2,+2,+0,+1,0,0x04}, + {-1,-2,-1,+0,0,0x80}, {-1,-2,+0,-1,0,0x01}, {-1,-2,+1,-1,0,0x01}, + {-1,-2,+1,+0,1,0x01}, {-1,-1,-1,+1,0,0x88}, {-1,-1,+1,-2,0,0x40}, + {-1,-1,+1,-1,0,0x22}, {-1,-1,+1,+0,0,0x33}, {-1,-1,+1,+1,1,0x11}, + {-1,+0,-1,+2,0,0x08}, {-1,+0,+0,-1,0,0x44}, {-1,+0,+0,+1,0,0x11}, + {-1,+0,+1,-2,1,0x40}, {-1,+0,+1,-1,0,0x66}, {-1,+0,+1,+0,1,0x22}, + {-1,+0,+1,+1,0,0x33}, {-1,+0,+1,+2,1,0x10}, {-1,+1,+1,-1,1,0x44}, + {-1,+1,+1,+0,0,0x66}, {-1,+1,+1,+1,0,0x22}, {-1,+1,+1,+2,0,0x10}, + {-1,+2,+0,+1,0,0x04}, {-1,+2,+1,+0,1,0x04}, {-1,+2,+1,+1,0,0x04}, + {+0,-2,+0,+0,1,0x80}, {+0,-1,+0,+1,1,0x88}, {+0,-1,+1,-2,0,0x40}, + {+0,-1,+1,+0,0,0x11}, {+0,-1,+2,-2,0,0x40}, {+0,-1,+2,-1,0,0x20}, + {+0,-1,+2,+0,0,0x30}, {+0,-1,+2,+1,1,0x10}, {+0,+0,+0,+2,1,0x08}, + {+0,+0,+2,-2,1,0x40}, {+0,+0,+2,-1,0,0x60}, {+0,+0,+2,+0,1,0x20}, + {+0,+0,+2,+1,0,0x30}, {+0,+0,+2,+2,1,0x10}, {+0,+1,+1,+0,0,0x44}, + {+0,+1,+1,+2,0,0x10}, {+0,+1,+2,-1,1,0x40}, {+0,+1,+2,+0,0,0x60}, + {+0,+1,+2,+1,0,0x20}, {+0,+1,+2,+2,0,0x10}, {+1,-2,+1,+0,0,0x80}, + {+1,-1,+1,+1,0,0x88}, {+1,+0,+1,+2,0,0x08}, {+1,+0,+2,-1,0,0x40}, + {+1,+0,+2,+1,0,0x10} + }; + const interpolate_terms *cpt; + signed char *cp; + signed char chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 }; ushort (*brow[5])[4], *pix; int prow=7, pcol=1, *ip, *code[16][16], gval[8], gmin, gmax, sum[4]; int row, col, x, y, x1, x2, y1, y2, t, weight, grads, color, diag; @@ -3636,11 +3643,11 @@ void CLASS vng_interpolate() for (row=0; row <= prow; row++) /* Precalculate for VNG */ for (col=0; col <= pcol; col++) { code[row][col] = ip; - for (cp=terms, t=0; t < 64; t++) { - y1 = *cp++; x1 = *cp++; - y2 = *cp++; x2 = *cp++; - weight = *cp++; - grads = *cp++; + for (cpt=&terms[0], t=0; t < 64, cpt = &terms[t]; t++) { + y1 = cpt->y1; x1 = cpt->x1; + y2 = cpt->y2; x2 = cpt->x2; + weight = cpt->weight; + grads = cpt->grads; color = fc(row+y1,col+x1); if (fc(row+y2,col+x2) != color) continue; diag = (fc(row,col+1) == color && fc(row+1,col) == color) ? 2:1; diff --git a/libkdcraw/libraw/libraw/libraw_const.h b/libkdcraw/libraw/libraw/libraw_const.h index 0ba708d..20f3430 100644 --- a/libkdcraw/libraw/libraw/libraw_const.h +++ b/libkdcraw/libraw/libraw/libraw_const.h @@ -119,8 +119,7 @@ enum LibRaw_progress LIBRAW_PROGRESS_THUMB_LOAD = 1<<28, LIBRAW_PROGRESS_TRESERVED1 = 1<<29, - LIBRAW_PROGRESS_TRESERVED2 = 1<<30, - LIBRAW_PROGRESS_TRESERVED3 = 1<<31 + LIBRAW_PROGRESS_TRESERVED2 = 1<<30 }; #define LIBRAW_PROGRESS_THUMB_MASK 0x0fffffff