--- ray/src/common/tmaptiff.c 2005/01/07 22:05:30 3.6 +++ ray/src/common/tmaptiff.c 2024/11/21 17:15:54 3.13 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tmaptiff.c,v 3.6 2005/01/07 22:05:30 greg Exp $"; +static const char RCSid[] = "$Id: tmaptiff.c,v 3.13 2024/11/21 17:15:54 greg Exp $"; #endif /* * Perform tone mapping on TIFF input. @@ -10,6 +10,7 @@ static const char RCSid[] = "$Id: tmaptiff.c,v 3.6 200 #include "copyright.h" #include +#include #include "tiffio.h" #include "tmprivat.h" #include "tmaptiff.h" @@ -78,7 +79,7 @@ getTIFFtype(TIFF *tif) /* load and convert TIFF */ int -tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp, +tmLoadTIFF(TMstruct *tms, TMbright **lpp, uby8 **cpp, int *xp, int *yp, char *fname, TIFF *tp) { char *funcName = fname==NULL ? "tmLoadTIFF" : fname; @@ -87,7 +88,7 @@ tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp, float *fa; TIFF *tif; int err; - union {uint16 *w; uint32 *l; float *f; MEM_PTR p;} sl; + union {uint16 *w; uint32 *l; float *f; void *p;} sl; uint32 width, height; int tcase; double stonits; @@ -133,28 +134,28 @@ tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp, case TC_LOGLUV24: TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_RAW); sl.l = (uint32 *)malloc(width*sizeof(uint32)); - tmSetSpace(tms, TM_XYZPRIM, stonits, NULL); + tmSetSpace(tms, TM_XYZPRIM, stonits); break; case TC_LOGL16: TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_16BIT); sl.w = (uint16 *)malloc(width*sizeof(uint16)); - tmSetSpace(tms, tms->monpri, stonits, NULL); + tmSetSpace(tms, tms->monpri, stonits); break; case TC_RGBFLOAT: sl.f = (float *)malloc(width*3*sizeof(float)); - tmSetSpace(tms, inppri, stonits, NULL); + tmSetSpace(tms, inppri, stonits); break; case TC_GRYFLOAT: sl.f = (float *)malloc(width*sizeof(float)); - tmSetSpace(tms, tms->monpri, stonits, NULL); + tmSetSpace(tms, tms->monpri, stonits); break; case TC_RGBSHORT: sl.w = (uint16 *)malloc(width*3*sizeof(uint16)); - tmSetSpace(tms, inppri, stonits, NULL); + tmSetSpace(tms, inppri, stonits); break; case TC_GRYSHORT: sl.w = (uint16 *)malloc(width*sizeof(uint16)); - tmSetSpace(tms, tms->monpri, stonits, NULL); + tmSetSpace(tms, tms->monpri, stonits); break; default: err = TM_E_CODERR1; @@ -172,7 +173,7 @@ tmLoadTIFF(TMstruct *tms, TMbright **lpp, BYTE **cpp, case TC_RGBSHORT: if (cpp == TM_NOCHROMP) break; - *cpp = (BYTE *)malloc(width*height*3*sizeof(BYTE)); + *cpp = (uby8 *)malloc(width*height*3*sizeof(uby8)); if (*cpp == NULL) { err = TM_E_NOMEM; goto done; @@ -230,11 +231,11 @@ done: /* clean up */ free(sl.p); if (err != TM_E_OK) { /* free buffers on error */ if (*lpp != NULL) - free((MEM_PTR)*lpp); + free(*lpp); *lpp = NULL; if (cpp != TM_NOCHROMP) { if (*cpp != TM_NOCHROM) - free((MEM_PTR)*cpp); + free(*cpp); *cpp = NULL; } *xp = *yp = 0; @@ -251,13 +252,13 @@ done: /* clean up */ * As in tmMapPicture(), grey values are also returned if flags&TM_F_BW. */ int -tmMapTIFF(BYTE **psp, int *xp, int *yp, int flags, RGBPRIMP monpri, +tmMapTIFF(uby8 **psp, int *xp, int *yp, int flags, RGBPRIMP monpri, double gamval, double Lddyn, double Ldmax, char *fname, TIFF *tp) { char *funcName = fname==NULL ? "tmMapTIFF" : fname; - TMstruct *tms; + TMstruct *tms = NULL; TMbright *lp; - BYTE *cp; + uby8 *cp; int err; /* check arguments */ if ((psp == NULL) | (xp == NULL) | (yp == NULL) | (monpri == NULL) | @@ -279,9 +280,9 @@ tmMapTIFF(BYTE **psp, int *xp, int *yp, int flags, RGB return(err); } if (cp == TM_NOCHROM) { - *psp = (BYTE *)malloc(*xp * *yp * sizeof(BYTE)); + *psp = (uby8 *)malloc(*xp * *yp * sizeof(uby8)); if (*psp == NULL) { - free((MEM_PTR)lp); + free(lp); tmDone(tms); returnErr(TM_E_NOMEM); } @@ -298,10 +299,10 @@ tmMapTIFF(BYTE **psp, int *xp, int *yp, int flags, RGB err = tmMapPixels(tms, *psp, lp, cp, *xp * *yp); done: /* clean up */ - free((MEM_PTR)lp); + free(lp); tmDone(tms); if (err != TM_E_OK) { /* free memory on error */ - free((MEM_PTR)*psp); + free(*psp); *psp = NULL; *xp = *yp = 0; returnErr(err);