diff options
Diffstat (limited to 'src/3rdparty/libtiff/libtiff/tif_color.c')
-rw-r--r-- | src/3rdparty/libtiff/libtiff/tif_color.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/3rdparty/libtiff/libtiff/tif_color.c b/src/3rdparty/libtiff/libtiff/tif_color.c index 8fae40e..2b962af 100644 --- a/src/3rdparty/libtiff/libtiff/tif_color.c +++ b/src/3rdparty/libtiff/libtiff/tif_color.c @@ -41,8 +41,8 @@ * Convert color value from the CIE L*a*b* 1976 space to CIE XYZ. */ void -TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, - float *X, float *Y, float *Z) +TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b, + float *X, float *Y, float *Z) { float L = (float)l * 100.0F / 255.0F; float cby, tmp; @@ -68,13 +68,13 @@ TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, *Z = cielab->Z0 * tmp * tmp * tmp; } -#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5))) +#define RINT(R) ((uint32_t)((R)>0?((R)+0.5):((R)-0.5))) /* * Convert color value from the XYZ space to RGB. */ void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, - uint32 *r, uint32 *g, uint32 *b) + uint32_t *r, uint32_t *g, uint32_t *b) { int i; float Yr, Yg, Yb; @@ -171,17 +171,17 @@ TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, * see below for more information on how it works. */ #define SHIFT 16 -#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5)) -#define ONE_HALF ((int32)(1<<(SHIFT-1))) -#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1)) +#define FIX(x) ((int32_t)((x) * (1L<<SHIFT) + 0.5)) +#define ONE_HALF ((int32_t)(1<<(SHIFT-1))) +#define Code2V(c, RB, RW, CR) ((((c)-(int32_t)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1)) #define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f)) #define HICLAMP(f,max) ((f)>(max)?(max):(f)) void -TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, - uint32 *r, uint32 *g, uint32 *b) +TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr, + uint32_t *r, uint32_t *g, uint32_t *b) { - int32 i; + int32_t i; /* XXX: Only 8-bit YCbCr input supported for now */ Y = HICLAMP(Y, 255); @@ -241,7 +241,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) #define LumaBlue luma[2] clamptab = (TIFFRGBValue*)( - (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); + (uint8_t*) ycbcr + TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) @@ -249,14 +249,14 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; - ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); + ycbcr->Cr_g_tab = (int32_t*) (ycbcr->Cb_b_tab + 256); ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; ycbcr->Y_tab = ycbcr->Cb_g_tab + 256; - { float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F)); - float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F)); - float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F)); - float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F)); + { float f1 = 2-2*LumaRed; int32_t D1 = FIX(CLAMP(f1, 0.0F, 2.0F)); + float f2 = LumaRed*f1/LumaGreen; int32_t D2 = -FIX(CLAMP(f2, 0.0F, 2.0F)); + float f3 = 2-2*LumaBlue; int32_t D3 = FIX(CLAMP(f3, 0.0F, 2.0F)); + float f4 = LumaBlue*f3/LumaGreen; int32_t D4 = -FIX(CLAMP(f4, 0.0F, 2.0F)); int x; #undef LumaBlue @@ -271,19 +271,19 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) * constructing tables indexed by the raw pixel data. */ for (i = 0, x = -128; i < 256; i++, x++) { - int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, + int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, refBlackWhite[5] - 128.0F, 127), -128.0F * 32, 128.0F * 32); - int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, + int32_t Cb = (int32_t)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, refBlackWhite[3] - 128.0F, 127), -128.0F * 32, 128.0F * 32); - ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT); - ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT); + ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT); + ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT); ycbcr->Cr_g_tab[i] = D2*Cr; ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF; ycbcr->Y_tab[i] = - (int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), + (int32_t)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), -128.0F * 32, 128.0F * 32); } } |