diff options
Diffstat (limited to 'src/3rdparty/libtiff/libtiff/tif_luv.c')
-rw-r--r-- | src/3rdparty/libtiff/libtiff/tif_luv.c | 311 |
1 files changed, 145 insertions, 166 deletions
diff --git a/src/3rdparty/libtiff/libtiff/tif_luv.c b/src/3rdparty/libtiff/libtiff/tif_luv.c index 3bd02e8..13765ea 100644 --- a/src/3rdparty/libtiff/libtiff/tif_luv.c +++ b/src/3rdparty/libtiff/libtiff/tif_luv.c @@ -161,9 +161,9 @@ struct logLuvState { int encode_meth; /* encoding method */ int pixel_size; /* bytes per pixel */ - uint8* tbuf; /* translation buffer */ + uint8_t* tbuf; /* translation buffer */ tmsize_t tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState*, uint8*, tmsize_t); + void (*tfunc)(LogLuvState*, uint8_t*, tmsize_t); TIFFVSetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ @@ -180,7 +180,7 @@ struct logLuvState { * Decode a string of 16-bit gray pixels. */ static int -LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogL16Decode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogL16Decode"; LogLuvState* sp = DecoderState(tif); @@ -188,8 +188,8 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - int16* tp; - int16 b; + int16_t* tp; + int16_t b; tmsize_t cc; int rc; @@ -200,14 +200,14 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) op; + tp = (int16_t*) op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (int16*) sp->tbuf; + tp = (int16_t*) sp->tbuf; } _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); @@ -220,35 +220,28 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( cc < 2 ) break; rc = *bp++ + (2-128); - b = (int16)(*bp++ << shft); + b = (int16_t)(*bp++ << shft); cc -= 2; while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ rc = *bp++; /* nul is noop */ while (--cc && rc-- && i < npixels) - tp[i++] |= (int16)*bp++ << shft; + tp[i++] |= (int16_t)*bp++ << shft; } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif - tif->tif_rawcp = (uint8*) bp; + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); } @@ -257,7 +250,7 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * Decode a string of 24-bit pixels. */ static int -LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogLuvDecode24(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogLuvDecode24"; LogLuvState* sp = DecoderState(tif); @@ -265,7 +258,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - uint32* tp; + uint32_t* tp; (void)s; assert(s == 0); @@ -274,16 +267,16 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32 *)op; + tp = (uint32_t *)op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (uint32 *) sp->tbuf; + tp = (uint32_t *) sp->tbuf; } - /* copy to array of uint32 */ + /* copy to array of uint32_t */ bp = (unsigned char*) tif->tif_rawcp; cc = tif->tif_rawcc; for (i = 0; i < npixels && cc >= 3; i++) { @@ -291,20 +284,13 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) bp += 3; cc -= 3; } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); return (0); } (*sp->tfunc)(sp, op, npixels); @@ -315,7 +301,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * Decode a string of 32-bit pixels. */ static int -LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogLuvDecode32(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogLuvDecode32"; LogLuvState* sp; @@ -323,8 +309,8 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - uint32* tp; - uint32 b; + uint32_t* tp; + uint32_t b; tmsize_t cc; int rc; @@ -336,14 +322,14 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) op; + tp = (uint32_t*) op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; } _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); @@ -356,35 +342,28 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( cc < 2 ) break; rc = *bp++ + (2-128); - b = (uint32)*bp++ << shft; + b = (uint32_t)*bp++ << shft; cc -= 2; while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ rc = *bp++; /* nul is noop */ while (--cc && rc-- && i < npixels) - tp[i++] |= (uint32)*bp++ << shft; + tp[i++] |= (uint32_t)*bp++ << shft; } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif - tif->tif_rawcp = (uint8*) bp; + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); } @@ -395,7 +374,7 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * is row by row. */ static int -LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvDecodeStrip(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFScanlineSize(tif); @@ -416,7 +395,7 @@ LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * is row by row. */ static int -LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvDecodeTile(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFTileRowSize(tif); @@ -435,7 +414,7 @@ LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 16-bit pixels. */ static int -LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogL16Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogL16Encode"; LogLuvState* sp = EncoderState(tif); @@ -443,9 +422,9 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) tmsize_t i; tmsize_t j; tmsize_t npixels; - uint8* op; - int16* tp; - int16 b; + uint8_t* op; + int16_t* tp; + int16_t b; tmsize_t occ; int rc=0, mask; tmsize_t beg; @@ -456,9 +435,9 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) bp; + tp = (int16_t*) bp; else { - tp = (int16*) sp->tbuf; + tp = (int16_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -481,7 +460,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } mask = 0xff << shft; /* find next run */ for (beg = i; beg < npixels; beg += rc) { - b = (int16) (tp[beg] & mask); + b = (int16_t) (tp[beg] & mask); rc = 1; while (rc < 127+2 && beg+rc < npixels && (tp[beg+rc] & mask) == b) @@ -490,12 +469,12 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; /* long enough */ } if (beg-i > 1 && beg-i < MINRUN) { - b = (int16) (tp[i] & mask);/*check short run */ + b = (int16_t) (tp[i] & mask);/*check short run */ j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (uint8)(128-2+j-i); - *op++ = (uint8)(b >> shft); + *op++ = (uint8_t)(128 - 2 + j - i); + *op++ = (uint8_t)(b >> shft); occ -= 2; i = beg; break; @@ -511,15 +490,15 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8) j; occ--; + *op++ = (uint8_t) j; occ--; while (j--) { - *op++ = (uint8) (tp[i++] >> shft & 0xff); + *op++ = (uint8_t) (tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (uint8) (128-2+rc); - *op++ = (uint8) (tp[beg] >> shft & 0xff); + *op++ = (uint8_t) (128 - 2 + rc); + *op++ = (uint8_t) (tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -535,15 +514,15 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 24-bit pixels. */ static int -LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncode24(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogLuvEncode24"; LogLuvState* sp = EncoderState(tif); tmsize_t i; tmsize_t npixels; tmsize_t occ; - uint8* op; - uint32* tp; + uint8_t* op; + uint32_t* tp; (void)s; assert(s == 0); @@ -551,9 +530,9 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; + tp = (uint32_t*) bp; else { - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -573,9 +552,9 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8)(*tp >> 16); - *op++ = (uint8)(*tp >> 8 & 0xff); - *op++ = (uint8)(*tp++ & 0xff); + *op++ = (uint8_t)(*tp >> 16); + *op++ = (uint8_t)(*tp >> 8 & 0xff); + *op++ = (uint8_t)(*tp++ & 0xff); occ -= 3; } tif->tif_rawcp = op; @@ -588,7 +567,7 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 32-bit pixels. */ static int -LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncode32(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogLuvEncode32"; LogLuvState* sp = EncoderState(tif); @@ -596,9 +575,9 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) tmsize_t i; tmsize_t j; tmsize_t npixels; - uint8* op; - uint32* tp; - uint32 b; + uint8_t* op; + uint32_t* tp; + uint32_t b; tmsize_t occ; int rc=0, mask; tmsize_t beg; @@ -610,9 +589,9 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; + tp = (uint32_t*) bp; else { - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -648,8 +627,8 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (uint8)(128-2+j-i); - *op++ = (uint8)(b >> shft); + *op++ = (uint8_t)(128 - 2 + j - i); + *op++ = (uint8_t)(b >> shft); occ -= 2; i = beg; break; @@ -665,15 +644,15 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8) j; occ--; + *op++ = (uint8_t) j; occ--; while (j--) { - *op++ = (uint8)(tp[i++] >> shft & 0xff); + *op++ = (uint8_t)(tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (uint8) (128-2+rc); - *op++ = (uint8)(tp[beg] >> shft & 0xff); + *op++ = (uint8_t) (128 - 2 + rc); + *op++ = (uint8_t)(tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -690,7 +669,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncodeStrip(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFScanlineSize(tif); @@ -710,7 +689,7 @@ LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncodeTile(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFTileRowSize(tif); @@ -790,9 +769,9 @@ LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ } static void -L16toY(LogLuvState* sp, uint8* op, tmsize_t n) +L16toY(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; + int16_t* l16 = (int16_t*) sp->tbuf; float* yp = (float*) op; while (n-- > 0) @@ -800,32 +779,32 @@ L16toY(LogLuvState* sp, uint8* op, tmsize_t n) } static void -L16toGry(LogLuvState* sp, uint8* op, tmsize_t n) +L16toGry(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; - uint8* gp = (uint8*) op; + int16_t* l16 = (int16_t*) sp->tbuf; + uint8_t* gp = (uint8_t*) op; while (n-- > 0) { double Y = LogL16toY(*l16++); - *gp++ = (uint8) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y))); + *gp++ = (uint8_t) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256. * sqrt(Y))); } } static void -L16fromY(LogLuvState* sp, uint8* op, tmsize_t n) +L16fromY(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; + int16_t* l16 = (int16_t*) sp->tbuf; float* yp = (float*) op; while (n-- > 0) - *l16++ = (int16) (LogL16fromY(*yp++, sp->encode_meth)); + *l16++ = (int16_t) (LogL16fromY(*yp++, sp->encode_meth)); } #if !LOGLUV_PUBLIC static #endif void -XYZtoRGB24(float xyz[3], uint8 rgb[3]) +XYZtoRGB24(float xyz[3], uint8_t rgb[3]) { double r, g, b; /* assume CCIR-709 primaries */ @@ -834,9 +813,9 @@ XYZtoRGB24(float xyz[3], uint8 rgb[3]) b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2]; /* assume 2.0 gamma for speed */ /* could use integer sqrt approx., but this is probably faster */ - rgb[0] = (uint8)((r<=0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r))); - rgb[1] = (uint8)((g<=0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g))); - rgb[2] = (uint8)((b<=0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b))); + rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r))); + rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g))); + rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b))); } #if !LOGLUV_PUBLIC @@ -979,7 +958,7 @@ uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ static #endif void -LogLuv24toXYZ(uint32 p, float XYZ[3]) +LogLuv24toXYZ(uint32_t p, float XYZ[3]) { int Ce; double L, u, v, s, x, y; @@ -1006,7 +985,7 @@ LogLuv24toXYZ(uint32 p, float XYZ[3]) #if !LOGLUV_PUBLIC static #endif -uint32 +uint32_t LogLuv24fromXYZ(float XYZ[3], int em) { int Le, Ce; @@ -1030,9 +1009,9 @@ LogLuv24fromXYZ(float XYZ[3], int em) } static void -Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1043,30 +1022,30 @@ Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { double u, v; - *luv3++ = (int16)((*luv >> 12 & 0xffd) + 13314); + *luv3++ = (int16_t)((*luv >> 12 & 0xffd) + 13314); if (uv_decode(&u, &v, *luv&0x3fff) < 0) { u = U_NEU; v = V_NEU; } - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); + *luv3++ = (int16_t)(u * (1L << 15)); + *luv3++ = (int16_t)(v * (1L << 15)); luv++; } } static void -Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toRGB(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + uint8_t* rgb = (uint8_t*) op; while (n-- > 0) { float xyz[3]; @@ -1078,9 +1057,9 @@ Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24fromXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1090,10 +1069,10 @@ Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24fromLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { int Le, Ce; @@ -1111,7 +1090,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) sp->encode_meth); if (Ce < 0) /* never happens */ Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - *luv++ = (uint32)Le << 14 | Ce; + *luv++ = (uint32_t)Le << 14 | Ce; luv3 += 3; } } @@ -1120,7 +1099,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) static #endif void -LogLuv32toXYZ(uint32 p, float XYZ[3]) +LogLuv32toXYZ(uint32_t p, float XYZ[3]) { double L, u, v, s, x, y; /* decode luminance */ @@ -1144,7 +1123,7 @@ LogLuv32toXYZ(uint32 p, float XYZ[3]) #if !LOGLUV_PUBLIC static #endif -uint32 +uint32_t LogLuv32fromXYZ(float XYZ[3], int em) { unsigned int Le, ue, ve; @@ -1171,9 +1150,9 @@ LogLuv32fromXYZ(float XYZ[3], int em) } static void -Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1183,28 +1162,28 @@ Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { double u, v; - *luv3++ = (int16)(*luv >> 16); + *luv3++ = (int16_t)(*luv >> 16); u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5); v = 1./UVSCALE * ((*luv & 0xff) + .5); - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); + *luv3++ = (int16_t)(u * (1L << 15)); + *luv3++ = (int16_t)(v * (1L << 15)); luv++; } } static void -Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toRGB(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + uint8_t* rgb = (uint8_t*) op; while (n-- > 0) { float xyz[3]; @@ -1216,9 +1195,9 @@ Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32fromXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1228,30 +1207,30 @@ Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32fromLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; if (sp->encode_meth == SGILOGENCODE_NODITHER) { while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) | - (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff); + *luv++ = (uint32_t)luv3[0] << 16 | + (luv3[1]*(uint32_t)(UVSCALE + .5) >> 7 & 0xff00) | + (luv3[2]*(uint32_t)(UVSCALE + .5) >> 15 & 0xff); luv3 += 3; } return; } while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | - (tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); + *luv++ = (uint32_t)luv3[0] << 16 | + (tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | + (tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); luv3 += 3; } } static void -_logLuvNop(LogLuvState* sp, uint8* op, tmsize_t n) +_logLuvNop(LogLuvState* sp, uint8_t* op, tmsize_t n) { (void) sp; (void) op; (void) n; } @@ -1294,7 +1273,7 @@ LogL16InitState(TIFF* tif) if( td->td_samplesperpixel != 1 ) { TIFFErrorExt(tif->tif_clientdata, module, - "Sorry, can not handle LogL image with %s=%d", + "Sorry, can not handle LogL image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -1307,10 +1286,10 @@ LogL16InitState(TIFF* tif) sp->pixel_size = sizeof (float); break; case SGILOGDATAFMT_16BIT: - sp->pixel_size = sizeof (int16); + sp->pixel_size = sizeof (int16_t); break; case SGILOGDATAFMT_8BIT: - sp->pixel_size = sizeof (uint8); + sp->pixel_size = sizeof (uint8_t); break; default: TIFFErrorExt(tif->tif_clientdata, module, @@ -1323,8 +1302,8 @@ LogL16InitState(TIFF* tif) sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); else sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength); - if (multiply_ms(sp->tbuflen, sizeof (int16)) == 0 || - (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) { + if (multiply_ms(sp->tbuflen, sizeof (int16_t)) == 0 || + (sp->tbuf = (uint8_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16_t))) == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } @@ -1406,13 +1385,13 @@ LogLuvInitState(TIFF* tif) sp->pixel_size = 3*sizeof (float); break; case SGILOGDATAFMT_16BIT: - sp->pixel_size = 3*sizeof (int16); + sp->pixel_size = 3*sizeof (int16_t); break; case SGILOGDATAFMT_RAW: - sp->pixel_size = sizeof (uint32); + sp->pixel_size = sizeof (uint32_t); break; case SGILOGDATAFMT_8BIT: - sp->pixel_size = 3*sizeof (uint8); + sp->pixel_size = 3*sizeof (uint8_t); break; default: TIFFErrorExt(tif->tif_clientdata, module, @@ -1425,8 +1404,8 @@ LogLuvInitState(TIFF* tif) sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); else sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength); - if (multiply_ms(sp->tbuflen, sizeof (uint32)) == 0 || - (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) { + if (multiply_ms(sp->tbuflen, sizeof (uint32_t)) == 0 || + (sp->tbuf = (uint8_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32_t))) == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } @@ -1495,7 +1474,7 @@ LogLuvSetupDecode(TIFF* tif) return (1); default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); break; } @@ -1559,7 +1538,7 @@ LogLuvSetupEncode(TIFF* tif) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); return (0); } @@ -1617,7 +1596,7 @@ LogLuvCleanup(TIFF* tif) } static int -LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) +LogLuvVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "LogLuvVSetField"; LogLuvState* sp = DecoderState(tif); @@ -1680,7 +1659,7 @@ LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -LogLuvVGetField(TIFF* tif, uint32 tag, va_list ap) +LogLuvVGetField(TIFF* tif, uint32_t tag, va_list ap) { LogLuvState *sp = (LogLuvState *)tif->tif_data; @@ -1719,7 +1698,7 @@ TIFFInitSGILog(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LogLuvState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (LogLuvState)); if (tif->tif_data == NULL) goto bad; sp = (LogLuvState*) tif->tif_data; |