2
* Copyright (c) 1997 Greg Ward Larson
3
* Copyright (c) 1997 Silicon Graphics, Inc.
5
* Permission to use, copy, modify, distribute, and sell this software and
6
* its documentation for any purpose is hereby granted without fee, provided
7
* that (i) the above copyright notices and this permission notice appear in
8
* all copies of the software and related documentation, and (ii) the names of
9
* Sam Leffler, Greg Larson and Silicon Graphics may not be used in any
10
* advertising or publicity relating to the software without the specific,
11
* prior written permission of Sam Leffler, Greg Larson and Silicon Graphics.
13
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17
* IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE
18
* FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
30
* LogLuv compression support for high dynamic range images.
32
* Contributed by Greg Larson.
34
* LogLuv image support uses the TIFF library to store 16 or 10-bit
35
* log luminance values with 8 bits each of u and v or a 14-bit index.
37
* The codec can take as input and produce as output 32-bit IEEE float values
38
* as well as 16-bit integer values. A 16-bit luminance is interpreted
39
* as a sign bit followed by a 15-bit integer that is converted
40
* to and from a linear magnitude using the transformation:
42
* L = 2^( (Le+.5)/256 - 64 ) # real from 15-bit
44
* Le = floor( 256*(log2(L) + 64) ) # 15-bit from real
46
* The actual conversion to world luminance units in candelas per sq. meter
47
* requires an additional multiplier, which is stored in the TIFFTAG_STONITS.
48
* This value is usually set such that a reasonable exposure comes from
49
* clamping decoded luminances above 1 to 1 in the displayed image.
51
* The 16-bit values for u and v may be converted to real values by dividing
52
* each by 32768. (This allows for negative values, which aren't useful as
53
* far as we know, but are left in case of future improvements in human
56
* Conversion from (u,v), which is actually the CIE (u',v') system for
57
* you color scientists, is accomplished by the following transformation:
59
* u = 4*x / (-2*x + 12*y + 3)
60
* v = 9*y / (-2*x + 12*y + 3)
62
* x = 9*u / (6*u - 16*v + 12)
63
* y = 4*v / (6*u - 16*v + 12)
65
* This process is greatly simplified by passing 32-bit IEEE floats
66
* for each of three CIE XYZ coordinates. The codec then takes care
67
* of conversion to and from LogLuv, though the application is still
68
* responsible for interpreting the TIFFTAG_STONITS calibration factor.
70
* By definition, a CIE XYZ vector of [1 1 1] corresponds to a neutral white
71
* point of (x,y)=(1/3,1/3). However, most color systems assume some other
72
* white point, such as D65, and an absolute color conversion to XYZ then
73
* to another color space with a different white point may introduce an
74
* unwanted color cast to the image. It is often desirable, therefore, to
75
* perform a white point conversion that maps the input white to [1 1 1]
76
* in XYZ, then record the original white point using the TIFFTAG_WHITEPOINT
77
* tag value. A decoder that demands absolute color calibration may use
78
* this white point tag to get back the original colors, but usually it
79
* will be ignored and the new white point will be used instead that
80
* matches the output color space.
82
* Pixel information is compressed into one of two basic encodings, depending
83
* on the setting of the compression tag, which is one of COMPRESSION_SGILOG
84
* or COMPRESSION_SGILOG24. For COMPRESSION_SGILOG, greyscale data is
90
* COMPRESSION_SGILOG color data is stored as:
93
* |-+---------------|--------+--------|
96
* For the 24-bit COMPRESSION_SGILOG24 color format, the data is stored as:
99
* |----------|--------------|
102
* There is no sign bit in the 24-bit case, and the (u,v) chromaticity is
103
* encoded as an index for optimal color resolution. The 10 log bits are
104
* defined by the following conversions:
106
* L = 2^((Le'+.5)/64 - 12) # real from 10-bit
108
* Le' = floor( 64*(log2(L) + 12) ) # 10-bit from real
110
* The 10 bits of the smaller format may be converted into the 15 bits of
111
* the larger format by multiplying by 4 and adding 13314. Obviously,
112
* a smaller range of magnitudes is covered (about 5 orders of magnitude
113
* instead of 38), and the lack of a sign bit means that negative luminances
114
* are not allowed. (Well, they aren't allowed in the real world, either,
115
* but they are useful for certain types of image processing.)
117
* The desired user format is controlled by the setting the internal
118
* pseudo tag TIFFTAG_SGILOGDATAFMT to one of:
119
* SGILOGDATAFMT_FLOAT = IEEE 32-bit float XYZ values
120
* SGILOGDATAFMT_16BIT = 16-bit integer encodings of logL, u and v
121
* Raw data i/o is also possible using:
122
* SGILOGDATAFMT_RAW = 32-bit unsigned integer with encoded pixel
123
* In addition, the following decoding is provided for ease of display:
124
* SGILOGDATAFMT_8BIT = 8-bit default RGB gamma-corrected values
126
* For grayscale images, we provide the following data formats:
127
* SGILOGDATAFMT_FLOAT = IEEE 32-bit float Y values
128
* SGILOGDATAFMT_16BIT = 16-bit integer w/ encoded luminance
129
* SGILOGDATAFMT_8BIT = 8-bit gray monitor values
131
* Note that the COMPRESSION_SGILOG applies a simple run-length encoding
132
* scheme by separating the logL, u and v bytes for each row and applying
133
* a PackBits type of compression. Since the 24-bit encoding is not
134
* adaptive, the 32-bit color format takes less space in many cases.
136
* Further control is provided over the conversion from higher-resolution
137
* formats to final encoded values through the pseudo tag
138
* TIFFTAG_SGILOGENCODE:
139
* SGILOGENCODE_NODITHER = do not dither encoded values
140
* SGILOGENCODE_RANDITHER = apply random dithering during encoding
142
* The default value of this tag is SGILOGENCODE_NODITHER for
143
* COMPRESSION_SGILOG to maximize run-length encoding and
144
* SGILOGENCODE_RANDITHER for COMPRESSION_SGILOG24 to turn
145
* quantization errors into noise.
153
* State block for each open TIFF
154
* file using LogLuv compression/decompression.
156
typedef struct logLuvState LogLuvState;
160
int encoder_state; /* 1 if encoder correctly initialized */
161
int user_datafmt; /* user data format */
162
int encode_meth; /* encoding method */
163
int pixel_size; /* bytes per pixel */
165
uint8_t *tbuf; /* translation buffer */
166
tmsize_t tbuflen; /* buffer length */
167
void (*tfunc)(LogLuvState *, uint8_t *, tmsize_t);
169
TIFFVSetMethod vgetparent; /* super-class method */
170
TIFFVSetMethod vsetparent; /* super-class method */
173
#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data)
174
#define EncoderState(tif) ((LogLuvState *)(tif)->tif_data)
176
#define SGILOGDATAFMT_UNKNOWN -1
178
#define MINRUN 4 /* minimum run length */
181
* Decode a string of 16-bit gray pixels.
183
static int LogL16Decode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
185
static const char module[] = "LogL16Decode";
186
LogLuvState *sp = DecoderState(tif);
200
npixels = occ / sp->pixel_size;
202
if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
206
if (sp->tbuflen < npixels)
208
TIFFErrorExtR(tif, module, "Translation buffer too short");
211
tp = (int16_t *)sp->tbuf;
213
_TIFFmemset((void *)tp, 0, npixels * sizeof(tp[0]));
215
bp = (unsigned char *)tif->tif_rawcp;
217
/* get each byte string */
218
for (shft = 8; shft >= 0; shft -= 8)
220
for (i = 0; i < npixels && cc > 0;)
226
rc = *bp++ + (2 - 128);
227
b = (int16_t)(*bp++ << shft);
229
while (rc-- && i < npixels)
234
rc = *bp++; /* nul is noop */
235
while (--cc && rc-- && i < npixels)
236
tp[i++] |= (int16_t)*bp++ << shft;
241
TIFFErrorExtR(tif, module,
242
"Not enough data at row %" PRIu32
243
" (short %" TIFF_SSIZE_FORMAT " pixels)",
244
tif->tif_row, npixels - i);
245
tif->tif_rawcp = (uint8_t *)bp;
250
(*sp->tfunc)(sp, op, npixels);
251
tif->tif_rawcp = (uint8_t *)bp;
257
* Decode a string of 24-bit pixels.
259
static int LogLuvDecode24(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
261
static const char module[] = "LogLuvDecode24";
262
LogLuvState *sp = DecoderState(tif);
273
npixels = occ / sp->pixel_size;
275
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
279
if (sp->tbuflen < npixels)
281
TIFFErrorExtR(tif, module, "Translation buffer too short");
284
tp = (uint32_t *)sp->tbuf;
286
/* copy to array of uint32_t */
287
bp = (unsigned char *)tif->tif_rawcp;
289
for (i = 0; i < npixels && cc >= 3; i++)
291
tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];
295
tif->tif_rawcp = (uint8_t *)bp;
299
TIFFErrorExtR(tif, module,
300
"Not enough data at row %" PRIu32
301
" (short %" TIFF_SSIZE_FORMAT " pixels)",
302
tif->tif_row, npixels - i);
305
(*sp->tfunc)(sp, op, npixels);
310
* Decode a string of 32-bit pixels.
312
static int LogLuvDecode32(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
314
static const char module[] = "LogLuvDecode32";
327
sp = DecoderState(tif);
330
npixels = occ / sp->pixel_size;
332
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
336
if (sp->tbuflen < npixels)
338
TIFFErrorExtR(tif, module, "Translation buffer too short");
341
tp = (uint32_t *)sp->tbuf;
343
_TIFFmemset((void *)tp, 0, npixels * sizeof(tp[0]));
345
bp = (unsigned char *)tif->tif_rawcp;
347
/* get each byte string */
348
for (shft = 24; shft >= 0; shft -= 8)
350
for (i = 0; i < npixels && cc > 0;)
356
rc = *bp++ + (2 - 128);
357
b = (uint32_t)*bp++ << shft;
359
while (rc-- && i < npixels)
364
rc = *bp++; /* nul is noop */
365
while (--cc && rc-- && i < npixels)
366
tp[i++] |= (uint32_t)*bp++ << shft;
371
TIFFErrorExtR(tif, module,
372
"Not enough data at row %" PRIu32
373
" (short %" TIFF_SSIZE_FORMAT " pixels)",
374
tif->tif_row, npixels - i);
375
tif->tif_rawcp = (uint8_t *)bp;
380
(*sp->tfunc)(sp, op, npixels);
381
tif->tif_rawcp = (uint8_t *)bp;
387
* Decode a strip of pixels. We break it into rows to
388
* maintain synchrony with the encode algorithm, which
391
static int LogLuvDecodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
393
tmsize_t rowlen = TIFFScanlineSize(tif);
398
assert(cc % rowlen == 0);
399
while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
408
* Decode a tile of pixels. We break it into rows to
409
* maintain synchrony with the encode algorithm, which
412
static int LogLuvDecodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
414
tmsize_t rowlen = TIFFTileRowSize(tif);
419
assert(cc % rowlen == 0);
420
while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
429
* Encode a row of 16-bit pixels.
431
static int LogL16Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
433
static const char module[] = "LogL16Encode";
434
LogLuvState *sp = EncoderState(tif);
449
npixels = cc / sp->pixel_size;
451
if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
455
tp = (int16_t *)sp->tbuf;
456
if (sp->tbuflen < npixels)
458
TIFFErrorExtR(tif, module, "Translation buffer too short");
461
(*sp->tfunc)(sp, bp, npixels);
463
/* compress each byte string */
465
occ = tif->tif_rawdatasize - tif->tif_rawcc;
466
for (shft = 8; shft >= 0; shft -= 8)
468
for (i = 0; i < npixels; i += rc)
473
tif->tif_rawcc = tif->tif_rawdatasize - occ;
474
if (!TIFFFlushData1(tif))
477
occ = tif->tif_rawdatasize - tif->tif_rawcc;
479
mask = 0xff << shft; /* find next run */
480
for (beg = i; beg < npixels; beg += rc)
482
b = (int16_t)(tp[beg] & mask);
484
while (rc < 127 + 2 && beg + rc < npixels &&
485
(tp[beg + rc] & mask) == b)
488
break; /* long enough */
490
if (beg - i > 1 && beg - i < MINRUN)
492
b = (int16_t)(tp[i] & mask); /*check short run */
494
while ((tp[j++] & mask) == b)
497
*op++ = (uint8_t)(128 - 2 + j - i);
498
*op++ = (uint8_t)(b >> shft);
505
{ /* write out non-run */
506
if ((j = beg - i) > 127)
511
tif->tif_rawcc = tif->tif_rawdatasize - occ;
512
if (!TIFFFlushData1(tif))
515
occ = tif->tif_rawdatasize - tif->tif_rawcc;
521
*op++ = (uint8_t)(tp[i++] >> shft & 0xff);
526
{ /* write out run */
527
*op++ = (uint8_t)(128 - 2 + rc);
528
*op++ = (uint8_t)(tp[beg] >> shft & 0xff);
536
tif->tif_rawcc = tif->tif_rawdatasize - occ;
542
* Encode a row of 24-bit pixels.
544
static int LogLuvEncode24(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
546
static const char module[] = "LogLuvEncode24";
547
LogLuvState *sp = EncoderState(tif);
557
npixels = cc / sp->pixel_size;
559
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
563
tp = (uint32_t *)sp->tbuf;
564
if (sp->tbuflen < npixels)
566
TIFFErrorExtR(tif, module, "Translation buffer too short");
569
(*sp->tfunc)(sp, bp, npixels);
571
/* write out encoded pixels */
573
occ = tif->tif_rawdatasize - tif->tif_rawcc;
574
for (i = npixels; i--;)
579
tif->tif_rawcc = tif->tif_rawdatasize - occ;
580
if (!TIFFFlushData1(tif))
583
occ = tif->tif_rawdatasize - tif->tif_rawcc;
585
*op++ = (uint8_t)(*tp >> 16);
586
*op++ = (uint8_t)(*tp >> 8 & 0xff);
587
*op++ = (uint8_t)(*tp++ & 0xff);
591
tif->tif_rawcc = tif->tif_rawdatasize - occ;
597
* Encode a row of 32-bit pixels.
599
static int LogLuvEncode32(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
601
static const char module[] = "LogLuvEncode32";
602
LogLuvState *sp = EncoderState(tif);
618
npixels = cc / sp->pixel_size;
620
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
624
tp = (uint32_t *)sp->tbuf;
625
if (sp->tbuflen < npixels)
627
TIFFErrorExtR(tif, module, "Translation buffer too short");
630
(*sp->tfunc)(sp, bp, npixels);
632
/* compress each byte string */
634
occ = tif->tif_rawdatasize - tif->tif_rawcc;
635
for (shft = 24; shft >= 0; shft -= 8)
637
const uint32_t mask = 0xffU << shft; /* find next run */
638
for (i = 0; i < npixels; i += rc)
643
tif->tif_rawcc = tif->tif_rawdatasize - occ;
644
if (!TIFFFlushData1(tif))
647
occ = tif->tif_rawdatasize - tif->tif_rawcc;
649
for (beg = i; beg < npixels; beg += rc)
653
while (rc < 127 + 2 && beg + rc < npixels &&
654
(tp[beg + rc] & mask) == b)
657
break; /* long enough */
659
if (beg - i > 1 && beg - i < MINRUN)
661
b = tp[i] & mask; /* check short run */
663
while ((tp[j++] & mask) == b)
666
*op++ = (uint8_t)(128 - 2 + j - i);
667
*op++ = (uint8_t)(b >> shft);
674
{ /* write out non-run */
675
if ((j = beg - i) > 127)
680
tif->tif_rawcc = tif->tif_rawdatasize - occ;
681
if (!TIFFFlushData1(tif))
684
occ = tif->tif_rawdatasize - tif->tif_rawcc;
690
*op++ = (uint8_t)(tp[i++] >> shft & 0xff);
695
{ /* write out run */
696
*op++ = (uint8_t)(128 - 2 + rc);
697
*op++ = (uint8_t)(tp[beg] >> shft & 0xff);
705
tif->tif_rawcc = tif->tif_rawdatasize - occ;
711
* Encode a strip of pixels. We break it into rows to
712
* avoid encoding runs across row boundaries.
714
static int LogLuvEncodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
716
tmsize_t rowlen = TIFFScanlineSize(tif);
721
assert(cc % rowlen == 0);
722
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
731
* Encode a tile of pixels. We break it into rows to
732
* avoid encoding runs across row boundaries.
734
static int LogLuvEncodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
736
tmsize_t rowlen = TIFFTileRowSize(tif);
741
assert(cc % rowlen == 0);
742
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
751
* Encode/Decode functions for converting to and from user formats.
757
#define U_NEU 0.210526316
758
#define V_NEU 0.473684211
763
#define M_LN2 0.69314718055994530942
766
#define M_PI 3.14159265358979323846
768
#undef log2 /* Conflict with C'99 function */
769
#define log2(x) ((1. / M_LN2) * log(x))
770
#undef exp2 /* Conflict with C'99 function */
771
#define exp2(x) exp(M_LN2 *(x))
773
static int tiff_itrunc(double x, int m)
775
if (m == SGILOGENCODE_NODITHER)
777
/* Silence CoverityScan warning about bad crypto function */
778
/* coverity[dont_call] */
779
return (int)(x + rand() * (1. / RAND_MAX) - .5);
786
LogL16toY(int p16) /* compute luminance from 16-bit LogL */
788
int Le = p16 & 0x7fff;
793
Y = exp(M_LN2 / 256. * (Le + .5) - M_LN2 * 64.);
794
return (!(p16 & 0x8000) ? Y : -Y);
801
LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */
803
if (Y >= 1.8371976e19)
805
if (Y <= -1.8371976e19)
807
if (Y > 5.4136769e-20)
808
return tiff_itrunc(256. * (log2(Y) + 64.), em);
809
if (Y < -5.4136769e-20)
810
return (~0x7fff | tiff_itrunc(256. * (log2(-Y) + 64.), em));
814
static void L16toY(LogLuvState *sp, uint8_t *op, tmsize_t n)
816
int16_t *l16 = (int16_t *)sp->tbuf;
817
float *yp = (float *)op;
820
*yp++ = (float)LogL16toY(*l16++);
823
static void L16toGry(LogLuvState *sp, uint8_t *op, tmsize_t n)
825
int16_t *l16 = (int16_t *)sp->tbuf;
826
uint8_t *gp = (uint8_t *)op;
830
double Y = LogL16toY(*l16++);
831
*gp++ = (uint8_t)((Y <= 0.) ? 0
833
: (int)(256. * sqrt(Y)));
837
static void L16fromY(LogLuvState *sp, uint8_t *op, tmsize_t n)
839
int16_t *l16 = (int16_t *)sp->tbuf;
840
float *yp = (float *)op;
843
*l16++ = (int16_t)(LogL16fromY(*yp++, sp->encode_meth));
850
XYZtoRGB24(float *xyz, uint8_t *rgb)
853
/* assume CCIR-709 primaries */
854
r = 2.690 * xyz[0] + -1.276 * xyz[1] + -0.414 * xyz[2];
855
g = -1.022 * xyz[0] + 1.978 * xyz[1] + 0.044 * xyz[2];
856
b = 0.061 * xyz[0] + -0.224 * xyz[1] + 1.163 * xyz[2];
857
/* assume 2.0 gamma for speed */
858
/* could use integer sqrt approx., but this is probably faster */
859
rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r)));
860
rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g)));
861
rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b)));
868
LogL10toY(int p10) /* compute luminance from 10-bit LogL */
872
return (exp(M_LN2 / 64. * (p10 + .5) - M_LN2 * 12.));
879
LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */
883
else if (Y <= .00024283)
886
return tiff_itrunc(64. * (log2(Y) + 12.), em);
890
#define uv2ang(u, v) \
891
((NANGLES * .499999999 / M_PI) * atan2((v)-V_NEU, (u)-U_NEU) + .5 * NANGLES)
893
static int oog_encode(double u, double v) /* encode out-of-gamut chroma */
895
static int oog_table[NANGLES];
896
static int initialized = 0;
900
{ /* set up perimeter table */
901
double eps[NANGLES], ua, va, ang, epsa;
903
for (i = NANGLES; i--;)
905
for (vi = UV_NVS; vi--;)
907
va = UV_VSTART + (vi + .5) * UV_SQSIZ;
908
ustep = uv_row[vi].nus - 1;
909
if (vi == UV_NVS - 1 || vi == 0 || ustep <= 0)
911
for (ui = uv_row[vi].nus - 1; ui >= 0; ui -= ustep)
913
ua = uv_row[vi].ustart + (ui + .5) * UV_SQSIZ;
914
ang = uv2ang(ua, va);
916
epsa = fabs(ang - (i + .5));
919
oog_table[i] = uv_row[vi].ncum + ui;
924
for (i = NANGLES; i--;) /* fill any holes */
928
for (i1 = 1; i1 < NANGLES / 2; i1++)
929
if (eps[(i + i1) % NANGLES] < 1.5)
931
for (i2 = 1; i2 < NANGLES / 2; i2++)
932
if (eps[(i + NANGLES - i2) % NANGLES] < 1.5)
935
oog_table[i] = oog_table[(i + i1) % NANGLES];
937
oog_table[i] = oog_table[(i + NANGLES - i2) % NANGLES];
941
i = (int)uv2ang(u, v); /* look up hue angle */
942
return (oog_table[i]);
952
uv_encode(double u, double v, int em) /* encode (u',v') coordinates */
957
if (u != u || v != v)
964
return oog_encode(u, v);
965
vi = tiff_itrunc((v - UV_VSTART) * (1. / UV_SQSIZ), em);
967
return oog_encode(u, v);
968
if (u < uv_row[vi].ustart)
969
return oog_encode(u, v);
970
ui = tiff_itrunc((u - uv_row[vi].ustart) * (1. / UV_SQSIZ), em);
971
if (ui >= uv_row[vi].nus)
972
return oog_encode(u, v);
974
return (uv_row[vi].ncum + ui);
981
uv_decode(double *up, double *vp, int c) /* decode (u',v') index */
986
if (c < 0 || c >= UV_NDIVS)
988
lower = 0; /* binary search */
990
while (upper - lower > 1)
992
vi = (lower + upper) >> 1;
993
ui = c - uv_row[vi].ncum;
1005
ui = c - uv_row[vi].ncum;
1006
*up = uv_row[vi].ustart + (ui + .5) * UV_SQSIZ;
1007
*vp = UV_VSTART + (vi + .5) * UV_SQSIZ;
1015
LogLuv24toXYZ(uint32_t p, float *XYZ)
1018
double L, u, v, s, x, y;
1019
/* decode luminance */
1020
L = LogL10toY(p >> 14 & 0x3ff);
1023
XYZ[0] = XYZ[1] = XYZ[2] = 0.;
1028
if (uv_decode(&u, &v, Ce) < 0)
1033
s = 1. / (6. * u - 16. * v + 12.);
1036
/* convert to XYZ */
1037
XYZ[0] = (float)(x / y * L);
1039
XYZ[2] = (float)((1. - x - y) / y * L);
1046
LogLuv24fromXYZ(float *XYZ, int em)
1050
/* encode luminance */
1051
Le = LogL10fromY(XYZ[1], em);
1053
s = XYZ[0] + 15. * XYZ[1] + 3. * XYZ[2];
1061
u = 4. * XYZ[0] / s;
1062
v = 9. * XYZ[1] / s;
1064
Ce = uv_encode(u, v, em);
1065
if (Ce < 0) /* never happens */
1066
Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER);
1067
/* combine encodings */
1068
return (Le << 14 | Ce);
1071
static void Luv24toXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
1073
uint32_t *luv = (uint32_t *)sp->tbuf;
1074
float *xyz = (float *)op;
1078
LogLuv24toXYZ(*luv, xyz);
1084
static void Luv24toLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
1086
uint32_t *luv = (uint32_t *)sp->tbuf;
1087
int16_t *luv3 = (int16_t *)op;
1093
*luv3++ = (int16_t)((*luv >> 12 & 0xffd) + 13314);
1094
if (uv_decode(&u, &v, *luv & 0x3fff) < 0)
1099
*luv3++ = (int16_t)(u * (1L << 15));
1100
*luv3++ = (int16_t)(v * (1L << 15));
1105
static void Luv24toRGB(LogLuvState *sp, uint8_t *op, tmsize_t n)
1107
uint32_t *luv = (uint32_t *)sp->tbuf;
1108
uint8_t *rgb = (uint8_t *)op;
1114
LogLuv24toXYZ(*luv++, xyz);
1115
XYZtoRGB24(xyz, rgb);
1120
static void Luv24fromXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
1122
uint32_t *luv = (uint32_t *)sp->tbuf;
1123
float *xyz = (float *)op;
1127
*luv++ = LogLuv24fromXYZ(xyz, sp->encode_meth);
1132
static void Luv24fromLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
1134
uint32_t *luv = (uint32_t *)sp->tbuf;
1135
int16_t *luv3 = (int16_t *)op;
1143
else if (luv3[0] >= (1 << 12) + 3314)
1145
else if (sp->encode_meth == SGILOGENCODE_NODITHER)
1146
Le = (luv3[0] - 3314) >> 2;
1148
Le = tiff_itrunc(.25 * (luv3[0] - 3314.), sp->encode_meth);
1150
Ce = uv_encode((luv3[1] + .5) / (1 << 15), (luv3[2] + .5) / (1 << 15),
1152
if (Ce < 0) /* never happens */
1153
Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER);
1154
*luv++ = (uint32_t)Le << 14 | Ce;
1163
LogLuv32toXYZ(uint32_t p, float *XYZ)
1165
double L, u, v, s, x, y;
1166
/* decode luminance */
1167
L = LogL16toY((int)p >> 16);
1170
XYZ[0] = XYZ[1] = XYZ[2] = 0.;
1174
u = 1. / UVSCALE * ((p >> 8 & 0xff) + .5);
1175
v = 1. / UVSCALE * ((p & 0xff) + .5);
1176
s = 1. / (6. * u - 16. * v + 12.);
1179
/* convert to XYZ */
1180
XYZ[0] = (float)(x / y * L);
1182
XYZ[2] = (float)((1. - x - y) / y * L);
1189
LogLuv32fromXYZ(float *XYZ, int em)
1191
unsigned int Le, ue, ve;
1193
/* encode luminance */
1194
Le = (unsigned int)LogL16fromY(XYZ[1], em);
1196
s = XYZ[0] + 15. * XYZ[1] + 3. * XYZ[2];
1204
u = 4. * XYZ[0] / s;
1205
v = 9. * XYZ[1] / s;
1210
ue = tiff_itrunc(UVSCALE * u, em);
1216
ve = tiff_itrunc(UVSCALE * v, em);
1219
/* combine encodings */
1220
return (Le << 16 | ue << 8 | ve);
1223
static void Luv32toXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
1225
uint32_t *luv = (uint32_t *)sp->tbuf;
1226
float *xyz = (float *)op;
1230
LogLuv32toXYZ(*luv++, xyz);
1235
static void Luv32toLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
1237
uint32_t *luv = (uint32_t *)sp->tbuf;
1238
int16_t *luv3 = (int16_t *)op;
1244
*luv3++ = (int16_t)(*luv >> 16);
1245
u = 1. / UVSCALE * ((*luv >> 8 & 0xff) + .5);
1246
v = 1. / UVSCALE * ((*luv & 0xff) + .5);
1247
*luv3++ = (int16_t)(u * (1L << 15));
1248
*luv3++ = (int16_t)(v * (1L << 15));
1253
static void Luv32toRGB(LogLuvState *sp, uint8_t *op, tmsize_t n)
1255
uint32_t *luv = (uint32_t *)sp->tbuf;
1256
uint8_t *rgb = (uint8_t *)op;
1262
LogLuv32toXYZ(*luv++, xyz);
1263
XYZtoRGB24(xyz, rgb);
1268
static void Luv32fromXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n)
1270
uint32_t *luv = (uint32_t *)sp->tbuf;
1271
float *xyz = (float *)op;
1275
*luv++ = LogLuv32fromXYZ(xyz, sp->encode_meth);
1280
static void Luv32fromLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n)
1282
uint32_t *luv = (uint32_t *)sp->tbuf;
1283
int16_t *luv3 = (int16_t *)op;
1285
if (sp->encode_meth == SGILOGENCODE_NODITHER)
1289
*luv++ = (uint32_t)luv3[0] << 16 |
1290
(luv3[1] * (uint32_t)(UVSCALE + .5) >> 7 & 0xff00) |
1291
(luv3[2] * (uint32_t)(UVSCALE + .5) >> 15 & 0xff);
1299
(uint32_t)luv3[0] << 16 |
1300
(tiff_itrunc(luv3[1] * (UVSCALE / (1 << 15)), sp->encode_meth)
1303
(tiff_itrunc(luv3[2] * (UVSCALE / (1 << 15)), sp->encode_meth) &
1309
static void _logLuvNop(LogLuvState *sp, uint8_t *op, tmsize_t n)
1316
static int LogL16GuessDataFmt(TIFFDirectory *td)
1318
#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f))
1320
PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat))
1322
case PACK(1, 32, SAMPLEFORMAT_IEEEFP):
1323
return (SGILOGDATAFMT_FLOAT);
1324
case PACK(1, 16, SAMPLEFORMAT_VOID):
1325
case PACK(1, 16, SAMPLEFORMAT_INT):
1326
case PACK(1, 16, SAMPLEFORMAT_UINT):
1327
return (SGILOGDATAFMT_16BIT);
1328
case PACK(1, 8, SAMPLEFORMAT_VOID):
1329
case PACK(1, 8, SAMPLEFORMAT_UINT):
1330
return (SGILOGDATAFMT_8BIT);
1333
return (SGILOGDATAFMT_UNKNOWN);
1336
static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2)
1338
return _TIFFMultiplySSize(NULL, m1, m2, NULL);
1341
static int LogL16InitState(TIFF *tif)
1343
static const char module[] = "LogL16InitState";
1344
TIFFDirectory *td = &tif->tif_dir;
1345
LogLuvState *sp = DecoderState(tif);
1348
assert(td->td_photometric == PHOTOMETRIC_LOGL);
1350
if (td->td_samplesperpixel != 1)
1352
TIFFErrorExtR(tif, module,
1353
"Sorry, can not handle LogL image with %s=%" PRIu16,
1354
"Samples/pixel", td->td_samplesperpixel);
1358
/* for some reason, we can't do this in TIFFInitLogL16 */
1359
if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
1360
sp->user_datafmt = LogL16GuessDataFmt(td);
1361
switch (sp->user_datafmt)
1363
case SGILOGDATAFMT_FLOAT:
1364
sp->pixel_size = sizeof(float);
1366
case SGILOGDATAFMT_16BIT:
1367
sp->pixel_size = sizeof(int16_t);
1369
case SGILOGDATAFMT_8BIT:
1370
sp->pixel_size = sizeof(uint8_t);
1373
TIFFErrorExtR(tif, module,
1374
"No support for converting user data format to LogL");
1378
sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
1379
else if (td->td_rowsperstrip < td->td_imagelength)
1380
sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
1382
sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
1383
if (multiply_ms(sp->tbuflen, sizeof(int16_t)) == 0 ||
1384
(sp->tbuf = (uint8_t *)_TIFFmallocExt(
1385
tif, sp->tbuflen * sizeof(int16_t))) == NULL)
1387
TIFFErrorExtR(tif, module, "No space for SGILog translation buffer");
1393
static int LogLuvGuessDataFmt(TIFFDirectory *td)
1398
* If the user didn't tell us their datafmt,
1399
* take our best guess from the bitspersample.
1401
#define PACK(a, b) (((a) << 3) | (b))
1402
switch (PACK(td->td_bitspersample, td->td_sampleformat))
1404
case PACK(32, SAMPLEFORMAT_IEEEFP):
1405
guess = SGILOGDATAFMT_FLOAT;
1407
case PACK(32, SAMPLEFORMAT_VOID):
1408
case PACK(32, SAMPLEFORMAT_UINT):
1409
case PACK(32, SAMPLEFORMAT_INT):
1410
guess = SGILOGDATAFMT_RAW;
1412
case PACK(16, SAMPLEFORMAT_VOID):
1413
case PACK(16, SAMPLEFORMAT_INT):
1414
case PACK(16, SAMPLEFORMAT_UINT):
1415
guess = SGILOGDATAFMT_16BIT;
1417
case PACK(8, SAMPLEFORMAT_VOID):
1418
case PACK(8, SAMPLEFORMAT_UINT):
1419
guess = SGILOGDATAFMT_8BIT;
1422
guess = SGILOGDATAFMT_UNKNOWN;
1427
* Double-check samples per pixel.
1429
switch (td->td_samplesperpixel)
1432
if (guess != SGILOGDATAFMT_RAW)
1433
guess = SGILOGDATAFMT_UNKNOWN;
1436
if (guess == SGILOGDATAFMT_RAW)
1437
guess = SGILOGDATAFMT_UNKNOWN;
1440
guess = SGILOGDATAFMT_UNKNOWN;
1446
static int LogLuvInitState(TIFF *tif)
1448
static const char module[] = "LogLuvInitState";
1449
TIFFDirectory *td = &tif->tif_dir;
1450
LogLuvState *sp = DecoderState(tif);
1453
assert(td->td_photometric == PHOTOMETRIC_LOGLUV);
1455
/* for some reason, we can't do this in TIFFInitLogLuv */
1456
if (td->td_planarconfig != PLANARCONFIG_CONTIG)
1458
TIFFErrorExtR(tif, module,
1459
"SGILog compression cannot handle non-contiguous data");
1462
if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
1463
sp->user_datafmt = LogLuvGuessDataFmt(td);
1464
switch (sp->user_datafmt)
1466
case SGILOGDATAFMT_FLOAT:
1467
sp->pixel_size = 3 * sizeof(float);
1469
case SGILOGDATAFMT_16BIT:
1470
sp->pixel_size = 3 * sizeof(int16_t);
1472
case SGILOGDATAFMT_RAW:
1473
sp->pixel_size = sizeof(uint32_t);
1475
case SGILOGDATAFMT_8BIT:
1476
sp->pixel_size = 3 * sizeof(uint8_t);
1481
"No support for converting user data format to LogLuv");
1485
sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength);
1486
else if (td->td_rowsperstrip < td->td_imagelength)
1487
sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);
1489
sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength);
1490
if (multiply_ms(sp->tbuflen, sizeof(uint32_t)) == 0 ||
1491
(sp->tbuf = (uint8_t *)_TIFFmallocExt(
1492
tif, sp->tbuflen * sizeof(uint32_t))) == NULL)
1494
TIFFErrorExtR(tif, module, "No space for SGILog translation buffer");
1500
static int LogLuvFixupTags(TIFF *tif)
1506
static int LogLuvSetupDecode(TIFF *tif)
1508
static const char module[] = "LogLuvSetupDecode";
1509
LogLuvState *sp = DecoderState(tif);
1510
TIFFDirectory *td = &tif->tif_dir;
1512
tif->tif_postdecode = _TIFFNoPostDecode;
1513
switch (td->td_photometric)
1515
case PHOTOMETRIC_LOGLUV:
1516
if (!LogLuvInitState(tif))
1518
if (td->td_compression == COMPRESSION_SGILOG24)
1520
tif->tif_decoderow = LogLuvDecode24;
1521
switch (sp->user_datafmt)
1523
case SGILOGDATAFMT_FLOAT:
1524
sp->tfunc = Luv24toXYZ;
1526
case SGILOGDATAFMT_16BIT:
1527
sp->tfunc = Luv24toLuv48;
1529
case SGILOGDATAFMT_8BIT:
1530
sp->tfunc = Luv24toRGB;
1536
tif->tif_decoderow = LogLuvDecode32;
1537
switch (sp->user_datafmt)
1539
case SGILOGDATAFMT_FLOAT:
1540
sp->tfunc = Luv32toXYZ;
1542
case SGILOGDATAFMT_16BIT:
1543
sp->tfunc = Luv32toLuv48;
1545
case SGILOGDATAFMT_8BIT:
1546
sp->tfunc = Luv32toRGB;
1551
case PHOTOMETRIC_LOGL:
1552
if (!LogL16InitState(tif))
1554
tif->tif_decoderow = LogL16Decode;
1555
switch (sp->user_datafmt)
1557
case SGILOGDATAFMT_FLOAT:
1560
case SGILOGDATAFMT_8BIT:
1561
sp->tfunc = L16toGry;
1566
TIFFErrorExtR(tif, module,
1567
"Inappropriate photometric interpretation %" PRIu16
1568
" for SGILog compression; %s",
1569
td->td_photometric, "must be either LogLUV or LogL");
1575
static int LogLuvSetupEncode(TIFF *tif)
1577
static const char module[] = "LogLuvSetupEncode";
1578
LogLuvState *sp = EncoderState(tif);
1579
TIFFDirectory *td = &tif->tif_dir;
1581
switch (td->td_photometric)
1583
case PHOTOMETRIC_LOGLUV:
1584
if (!LogLuvInitState(tif))
1586
if (td->td_compression == COMPRESSION_SGILOG24)
1588
tif->tif_encoderow = LogLuvEncode24;
1589
switch (sp->user_datafmt)
1591
case SGILOGDATAFMT_FLOAT:
1592
sp->tfunc = Luv24fromXYZ;
1594
case SGILOGDATAFMT_16BIT:
1595
sp->tfunc = Luv24fromLuv48;
1597
case SGILOGDATAFMT_RAW:
1605
tif->tif_encoderow = LogLuvEncode32;
1606
switch (sp->user_datafmt)
1608
case SGILOGDATAFMT_FLOAT:
1609
sp->tfunc = Luv32fromXYZ;
1611
case SGILOGDATAFMT_16BIT:
1612
sp->tfunc = Luv32fromLuv48;
1614
case SGILOGDATAFMT_RAW:
1621
case PHOTOMETRIC_LOGL:
1622
if (!LogL16InitState(tif))
1624
tif->tif_encoderow = LogL16Encode;
1625
switch (sp->user_datafmt)
1627
case SGILOGDATAFMT_FLOAT:
1628
sp->tfunc = L16fromY;
1630
case SGILOGDATAFMT_16BIT:
1637
TIFFErrorExtR(tif, module,
1638
"Inappropriate photometric interpretation %" PRIu16
1639
" for SGILog compression; %s",
1640
td->td_photometric, "must be either LogLUV or LogL");
1643
sp->encoder_state = 1;
1646
TIFFErrorExtR(tif, module,
1647
"SGILog compression supported only for %s, or raw data",
1648
td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv");
1652
static void LogLuvClose(TIFF *tif)
1654
LogLuvState *sp = (LogLuvState *)tif->tif_data;
1655
TIFFDirectory *td = &tif->tif_dir;
1659
* For consistency, we always want to write out the same
1660
* bitspersample and sampleformat for our TIFF file,
1661
* regardless of the data format being used by the application.
1662
* Since this routine is called after tags have been set but
1663
* before they have been recorded in the file, we reset them here.
1664
* Note: this is really a nasty approach. See PixarLogClose
1666
if (sp->encoder_state)
1668
/* See PixarLogClose. Might avoid issues with tags whose size depends
1669
* on those below, but not completely sure this is enough. */
1670
td->td_samplesperpixel =
1671
(td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
1672
td->td_bitspersample = 16;
1673
td->td_sampleformat = SAMPLEFORMAT_INT;
1677
static void LogLuvCleanup(TIFF *tif)
1679
LogLuvState *sp = (LogLuvState *)tif->tif_data;
1683
tif->tif_tagmethods.vgetfield = sp->vgetparent;
1684
tif->tif_tagmethods.vsetfield = sp->vsetparent;
1687
_TIFFfreeExt(tif, sp->tbuf);
1688
_TIFFfreeExt(tif, sp);
1689
tif->tif_data = NULL;
1691
_TIFFSetDefaultCompressionState(tif);
1694
static int LogLuvVSetField(TIFF *tif, uint32_t tag, va_list ap)
1696
static const char module[] = "LogLuvVSetField";
1697
LogLuvState *sp = DecoderState(tif);
1702
case TIFFTAG_SGILOGDATAFMT:
1703
sp->user_datafmt = (int)va_arg(ap, int);
1705
* Tweak the TIFF header so that the rest of libtiff knows what
1706
* size of data will be passed between app and library, and
1707
* assume that the app knows what it is doing and is not
1708
* confused by these header manipulations...
1710
switch (sp->user_datafmt)
1712
case SGILOGDATAFMT_FLOAT:
1714
fmt = SAMPLEFORMAT_IEEEFP;
1716
case SGILOGDATAFMT_16BIT:
1718
fmt = SAMPLEFORMAT_INT;
1720
case SGILOGDATAFMT_RAW:
1722
fmt = SAMPLEFORMAT_UINT;
1723
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
1725
case SGILOGDATAFMT_8BIT:
1727
fmt = SAMPLEFORMAT_UINT;
1732
"Unknown data format %d for LogLuv compression",
1736
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
1737
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt);
1739
* Must recalculate sizes should bits/sample change.
1741
tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)-1;
1742
tif->tif_scanlinesize = TIFFScanlineSize(tif);
1744
case TIFFTAG_SGILOGENCODE:
1745
sp->encode_meth = (int)va_arg(ap, int);
1746
if (sp->encode_meth != SGILOGENCODE_NODITHER &&
1747
sp->encode_meth != SGILOGENCODE_RANDITHER)
1749
TIFFErrorExtR(tif, module,
1750
"Unknown encoding %d for LogLuv compression",
1756
return (*sp->vsetparent)(tif, tag, ap);
1760
static int LogLuvVGetField(TIFF *tif, uint32_t tag, va_list ap)
1762
LogLuvState *sp = (LogLuvState *)tif->tif_data;
1766
case TIFFTAG_SGILOGDATAFMT:
1767
*va_arg(ap, int *) = sp->user_datafmt;
1770
return (*sp->vgetparent)(tif, tag, ap);
1774
static const TIFFField LogLuvFields[] = {
1775
{TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT,
1776
TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogDataFmt", NULL},
1777
{TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT,
1778
TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogEncode", NULL}};
1780
int TIFFInitSGILog(TIFF *tif, int scheme)
1782
static const char module[] = "TIFFInitSGILog";
1785
assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG);
1788
* Merge codec-specific tag information.
1790
if (!_TIFFMergeFields(tif, LogLuvFields, TIFFArrayCount(LogLuvFields)))
1792
TIFFErrorExtR(tif, module, "Merging SGILog codec-specific tags failed");
1797
* Allocate state block so tag methods have storage to record values.
1799
tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LogLuvState));
1800
if (tif->tif_data == NULL)
1802
sp = (LogLuvState *)tif->tif_data;
1803
_TIFFmemset((void *)sp, 0, sizeof(*sp));
1804
sp->user_datafmt = SGILOGDATAFMT_UNKNOWN;
1805
sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER
1806
: SGILOGENCODE_NODITHER;
1807
sp->tfunc = _logLuvNop;
1810
* Install codec methods.
1811
* NB: tif_decoderow & tif_encoderow are filled
1814
tif->tif_fixuptags = LogLuvFixupTags;
1815
tif->tif_setupdecode = LogLuvSetupDecode;
1816
tif->tif_decodestrip = LogLuvDecodeStrip;
1817
tif->tif_decodetile = LogLuvDecodeTile;
1818
tif->tif_setupencode = LogLuvSetupEncode;
1819
tif->tif_encodestrip = LogLuvEncodeStrip;
1820
tif->tif_encodetile = LogLuvEncodeTile;
1821
tif->tif_close = LogLuvClose;
1822
tif->tif_cleanup = LogLuvCleanup;
1825
* Override parent get/set field methods.
1827
sp->vgetparent = tif->tif_tagmethods.vgetfield;
1828
tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */
1829
sp->vsetparent = tif->tif_tagmethods.vsetfield;
1830
tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */
1834
TIFFErrorExtR(tif, module, "%s: No space for LogLuv state block",
1838
#endif /* LOGLUV_SUPPORT */