15 |
|
#include <stdlib.h> |
16 |
|
#include <string.h> |
17 |
|
#include <math.h> |
18 |
– |
#include "tmprivat.h" |
18 |
|
#include "tiffio.h" |
19 |
+ |
#include "tmprivat.h" |
20 |
|
#include "tmaptiff.h" |
21 |
|
|
22 |
|
#define uvflgop(p,uv,op) ((p)->rgbflg[(uv)>>5] op (1L<<((uv)&0x1f))) |
23 |
|
#define isuvset(p,uv) uvflgop(p,uv,&) |
24 |
|
#define setuv(p,uv) uvflgop(p,uv,|=) |
25 |
|
#define clruv(p,uv) uvflgop(p,uv,&=~) |
26 |
< |
#define clruvall(p) memset((MEM_PTR)(p)->rgbflg,'\0',sizeof((p)->rgbflg)) |
26 |
> |
#define clruvall(p) memset((p)->rgbflg,'\0',sizeof((p)->rgbflg)) |
27 |
|
|
28 |
|
#ifdef NOPROTO |
29 |
< |
static MEM_PTR luv32Init(); |
29 |
> |
static void * luv32Init(); |
30 |
|
static void luv32NewSpace(); |
31 |
< |
static MEM_PTR luv24Init(); |
31 |
> |
static void * luv24Init(); |
32 |
|
static void luv24NewSpace(); |
33 |
|
#else |
34 |
< |
static MEM_PTR luv32Init(TMstruct *); |
34 |
> |
static void * luv32Init(TMstruct *); |
35 |
|
static void luv32NewSpace(TMstruct *); |
36 |
< |
static MEM_PTR luv24Init(TMstruct *); |
36 |
> |
static void * luv24Init(TMstruct *); |
37 |
|
static void luv24NewSpace(TMstruct *); |
38 |
|
#endif |
39 |
|
|
40 |
|
typedef struct { |
41 |
|
int offset; /* computed luminance offset */ |
42 |
< |
BYTE rgbval[1<<16][3]; /* computed RGB value for given uv */ |
42 |
> |
uby8 rgbval[1<<16][3]; /* computed RGB value for given uv */ |
43 |
|
uint32 rgbflg[1<<(16-5)]; /* flags for computed values */ |
44 |
|
} LUV32DATA; /* LogLuv 32-bit conversion data */ |
45 |
|
|
53 |
|
|
54 |
|
typedef struct { |
55 |
|
int offset; /* computed luminance offset */ |
56 |
< |
BYTE rgbval[1<<14][3]; /* computed rgb value for uv index */ |
56 |
> |
uby8 rgbval[1<<14][3]; /* computed rgb value for uv index */ |
57 |
|
uint32 rgbflg[1<<(14-5)]; /* flags for computed values */ |
58 |
|
} LUV24DATA; /* LogLuv 24-bit conversion data */ |
59 |
|
|
67 |
|
|
68 |
|
static void |
69 |
|
uv2rgb(rgb, tms, uvp) /* compute RGB from uv coordinate */ |
70 |
< |
BYTE rgb[3]; |
71 |
< |
register TMstruct *tms; |
70 |
> |
uby8 rgb[3]; |
71 |
> |
TMstruct *tms; |
72 |
|
double uvp[2]; |
73 |
|
{ /* Should check that tms->inppri==TM_XYZPRIM beforehand... */ |
74 |
|
double d, x, y; |
99 |
|
double uvp[2]; /* world (u',v') -> returned desaturated */ |
100 |
|
{ |
101 |
|
double scotrat; |
102 |
< |
register double d; |
102 |
> |
double d; |
103 |
|
|
104 |
|
if (li >= BMESUPPER) |
105 |
|
return(li); |
127 |
|
tmCvLuv32( /* convert raw 32-bit LogLuv values */ |
128 |
|
TMstruct *tms, |
129 |
|
TMbright *ls, |
130 |
< |
BYTE *cs, |
130 |
> |
uby8 *cs, |
131 |
|
uint32 *luvs, |
132 |
|
int len |
133 |
|
) |
134 |
|
{ |
135 |
|
static const char funcName[] = "tmCvLuv32"; |
136 |
|
double uvp[2]; |
137 |
< |
register LUV32DATA *ld; |
138 |
< |
register int i, j; |
137 |
> |
LUV32DATA *ld; |
138 |
> |
int i, j; |
139 |
|
/* check arguments */ |
140 |
|
if (tms == NULL) |
141 |
|
returnErr(TM_E_TMINVAL); |
189 |
|
tmCvLuv24( /* convert raw 24-bit LogLuv values */ |
190 |
|
TMstruct *tms, |
191 |
|
TMbright *ls, |
192 |
< |
BYTE *cs, |
192 |
> |
uby8 *cs, |
193 |
|
uint32 *luvs, |
194 |
|
int len |
195 |
|
) |
196 |
|
{ |
197 |
|
char funcName[] = "tmCvLuv24"; |
198 |
|
double uvp[2]; |
199 |
< |
register LUV24DATA *ld; |
200 |
< |
register int i, j; |
199 |
> |
LUV24DATA *ld; |
200 |
> |
int i, j; |
201 |
|
/* check arguments */ |
202 |
|
if (tms == NULL) |
203 |
|
returnErr(TM_E_TMINVAL); |
259 |
|
static const char funcName[] = "tmCvL16"; |
260 |
|
static double lastsf; |
261 |
|
static int offset; |
262 |
< |
register int i; |
262 |
> |
int i; |
263 |
|
/* check arguments */ |
264 |
|
if (tms == NULL) |
265 |
|
returnErr(TM_E_TMINVAL); |
285 |
|
luv32NewSpace(tms) /* initialize 32-bit LogLuv color space */ |
286 |
|
TMstruct *tms; |
287 |
|
{ |
288 |
< |
register LUV32DATA *ld; |
288 |
> |
LUV32DATA *ld; |
289 |
|
|
290 |
|
if (tms->inppri != TM_XYZPRIM) { /* panic time! */ |
291 |
|
fputs("Improper input color space in luv32NewSpace!\n", stderr); |
297 |
|
} |
298 |
|
|
299 |
|
|
300 |
< |
static MEM_PTR |
300 |
> |
static void * |
301 |
|
luv32Init(tms) /* allocate data for 32-bit LogLuv decoder */ |
302 |
|
TMstruct *tms; |
303 |
|
{ |
304 |
< |
register LUV32DATA *ld; |
304 |
> |
LUV32DATA *ld; |
305 |
|
|
306 |
|
ld = (LUV32DATA *)malloc(sizeof(LUV32DATA)); |
307 |
|
if (ld == NULL) |
308 |
|
return(NULL); |
309 |
< |
tms->pd[luv32Reg] = (MEM_PTR)ld; |
309 |
> |
tms->pd[luv32Reg] = (void *)ld; |
310 |
|
luv32NewSpace(tms); |
311 |
< |
return((MEM_PTR)ld); |
311 |
> |
return((void *)ld); |
312 |
|
} |
313 |
|
|
314 |
|
|
316 |
|
luv24NewSpace(tms) /* initialize 24-bit LogLuv color space */ |
317 |
|
TMstruct *tms; |
318 |
|
{ |
319 |
< |
register LUV24DATA *ld; |
319 |
> |
LUV24DATA *ld; |
320 |
|
|
321 |
|
if (tms->inppri != TM_XYZPRIM) { /* panic time! */ |
322 |
|
fputs("Improper input color space in luv24NewSpace!\n", stderr); |
328 |
|
} |
329 |
|
|
330 |
|
|
331 |
< |
static MEM_PTR |
331 |
> |
static void * |
332 |
|
luv24Init(tms) /* allocate data for 24-bit LogLuv decoder */ |
333 |
|
TMstruct *tms; |
334 |
|
{ |
335 |
< |
register LUV24DATA *ld; |
335 |
> |
LUV24DATA *ld; |
336 |
|
|
337 |
|
ld = (LUV24DATA *)malloc(sizeof(LUV24DATA)); |
338 |
|
if (ld == NULL) |
339 |
|
return(NULL); |
340 |
< |
tms->pd[luv24Reg] = (MEM_PTR)ld; |
340 |
> |
tms->pd[luv24Reg] = (void *)ld; |
341 |
|
if (uv14neu < 0) /* initialize neutral color index */ |
342 |
|
uv14neu = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); |
343 |
|
luv24NewSpace(tms); |
344 |
< |
return((MEM_PTR)ld); |
344 |
> |
return((void *)ld); |
345 |
|
} |