12 |
|
#define LOGLUV_PUBLIC 1 |
13 |
|
|
14 |
|
#include <stdio.h> |
15 |
+ |
#include <stdlib.h> |
16 |
|
#include <string.h> |
17 |
|
#include <math.h> |
18 |
|
#include "tiffio.h" |
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]; |
70 |
> |
uby8 rgb[3]; |
71 |
|
register TMstruct *tms; |
72 |
|
double uvp[2]; |
73 |
|
{ /* Should check that tms->inppri==TM_XYZPRIM beforehand... */ |
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 |
|
) |
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 |
|
) |
267 |
|
returnErr(TM_E_ILLEGAL); |
268 |
|
/* check scaling offset */ |
269 |
|
if (!FEQ(tms->inpsf, lastsf)) { |
270 |
< |
offset = BRT2SCALE(64); |
270 |
< |
if (tms->inpsf > 1.0001) |
271 |
< |
offset -= (int)(TM_BRTSCALE*log(tms->inpsf)+.5); |
272 |
< |
else if (tms->inpsf < 0.9999) |
273 |
< |
offset -= (int)(TM_BRTSCALE*log(tms->inpsf)-.5); |
270 |
> |
offset = BRT2SCALE(64) - tmCvLuminance(tms->inpsf); |
271 |
|
lastsf = tms->inpsf; |
272 |
|
} |
273 |
|
/* convert each pixel */ |
292 |
|
exit(1); |
293 |
|
} |
294 |
|
ld = (LUV32DATA *)tms->pd[luv32Reg]; |
295 |
< |
ld->offset = BRT2SCALE(64); |
299 |
< |
if (tms->inpsf > 1.0001) |
300 |
< |
ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)+.5); |
301 |
< |
else if (tms->inpsf < 0.9999) |
302 |
< |
ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)-.5); |
295 |
> |
ld->offset = BRT2SCALE(64) - tmCvLuminance(tms->inpsf); |
296 |
|
clruvall(ld); |
297 |
|
} |
298 |
|
|
323 |
|
exit(1); |
324 |
|
} |
325 |
|
ld = (LUV24DATA *)tms->pd[luv24Reg]; |
326 |
< |
ld->offset = BRT2SCALE(12); |
334 |
< |
if (tms->inpsf > 1.0001) |
335 |
< |
ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)+.5); |
336 |
< |
else if (tms->inpsf < 0.9999) |
337 |
< |
ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)-.5); |
326 |
> |
ld->offset = BRT2SCALE(12) - tmCvLuminance(tms->inpsf); |
327 |
|
clruvall(ld); |
328 |
|
} |
329 |
|
|