26#ifdef PIXARLOG_SUPPORT
104#define CODE_MASK 0x7ff
107static float LogK1, LogK2;
109#define REPEAT(n, op) \
123 register unsigned int cr, cg,
cb,
ca,
mask;
124 register float t0, t1, t2, t3;
131 t0 = ToLinearF[cr = (wp[0] &
mask)];
132 t1 = ToLinearF[cg = (wp[1] &
mask)];
133 t2 = ToLinearF[
cb = (wp[2] &
mask)];
143 t0 = ToLinearF[(cr += wp[0]) &
mask];
144 t1 = ToLinearF[(cg += wp[1]) &
mask];
145 t2 = ToLinearF[(
cb += wp[2]) &
mask];
153 t0 = ToLinearF[cr = (wp[0] &
mask)];
154 t1 = ToLinearF[cg = (wp[1] &
mask)];
155 t2 = ToLinearF[
cb = (wp[2] &
mask)];
156 t3 = ToLinearF[
ca = (wp[3] &
mask)];
167 t0 = ToLinearF[(cr += wp[0]) &
mask];
168 t1 = ToLinearF[(cg += wp[1]) &
mask];
169 t2 = ToLinearF[(
cb += wp[2]) &
mask];
170 t3 = ToLinearF[(
ca += wp[3]) &
mask];
194 register unsigned int cr, cg,
cb,
ca,
mask;
195 register float t0, t1, t2, t3;
197#define SCALE12 2048.0F
198#define CLAMP12(t) (((t) < 3071) ? (uint16_t)(t) : 3071)
205 t0 = ToLinearF[cr = (wp[0] &
mask)] * SCALE12;
206 t1 = ToLinearF[cg = (wp[1] &
mask)] * SCALE12;
207 t2 = ToLinearF[
cb = (wp[2] &
mask)] * SCALE12;
217 t0 = ToLinearF[(cr += wp[0]) &
mask] * SCALE12;
218 t1 = ToLinearF[(cg += wp[1]) &
mask] * SCALE12;
219 t2 = ToLinearF[(
cb += wp[2]) &
mask] * SCALE12;
227 t0 = ToLinearF[cr = (wp[0] &
mask)] * SCALE12;
228 t1 = ToLinearF[cg = (wp[1] &
mask)] * SCALE12;
229 t2 = ToLinearF[
cb = (wp[2] &
mask)] * SCALE12;
230 t3 = ToLinearF[
ca = (wp[3] &
mask)] * SCALE12;
241 t0 = ToLinearF[(cr += wp[0]) &
mask] * SCALE12;
242 t1 = ToLinearF[(cg += wp[1]) &
mask] * SCALE12;
243 t2 = ToLinearF[(
cb += wp[2]) &
mask] * SCALE12;
244 t3 = ToLinearF[(
ca += wp[3]) &
mask] * SCALE12;
254 *
op = CLAMP12(t0); wp++;
op++)
260 *
op = CLAMP12(t0); wp++;
op++)
270 register unsigned int cr, cg,
cb,
ca,
mask;
277 op[0] = ToLinear16[cr = (wp[0] &
mask)];
278 op[1] = ToLinear16[cg = (wp[1] &
mask)];
279 op[2] = ToLinear16[
cb = (wp[2] &
mask)];
286 op[0] = ToLinear16[(cr += wp[0]) &
mask];
287 op[1] = ToLinear16[(cg += wp[1]) &
mask];
288 op[2] = ToLinear16[(
cb += wp[2]) &
mask];
293 op[0] = ToLinear16[cr = (wp[0] &
mask)];
294 op[1] = ToLinear16[cg = (wp[1] &
mask)];
295 op[2] = ToLinear16[
cb = (wp[2] &
mask)];
296 op[3] = ToLinear16[
ca = (wp[3] &
mask)];
303 op[0] = ToLinear16[(cr += wp[0]) &
mask];
304 op[1] = ToLinear16[(cg += wp[1]) &
mask];
305 op[2] = ToLinear16[(
cb += wp[2]) &
mask];
306 op[3] = ToLinear16[(
ca += wp[3]) &
mask];
330 register unsigned int cr, cg,
cb,
ca,
mask;
390 unsigned char *
op,
unsigned char *ToLinear8)
392 register unsigned int cr, cg,
cb,
ca,
mask;
399 op[0] = ToLinear8[cr = (wp[0] &
mask)];
400 op[1] = ToLinear8[cg = (wp[1] &
mask)];
401 op[2] = ToLinear8[
cb = (wp[2] &
mask)];
408 op[0] = ToLinear8[(cr += wp[0]) &
mask];
409 op[1] = ToLinear8[(cg += wp[1]) &
mask];
410 op[2] = ToLinear8[(
cb += wp[2]) &
mask];
415 op[0] = ToLinear8[cr = (wp[0] &
mask)];
416 op[1] = ToLinear8[cg = (wp[1] &
mask)];
417 op[2] = ToLinear8[
cb = (wp[2] &
mask)];
418 op[3] = ToLinear8[
ca = (wp[3] &
mask)];
425 op[0] = ToLinear8[(cr += wp[0]) &
mask];
426 op[1] = ToLinear8[(cg += wp[1]) &
mask];
427 op[2] = ToLinear8[(
cb += wp[2]) &
mask];
428 op[3] = ToLinear8[(
ca += wp[3]) &
mask];
447 unsigned char *ToLinear8)
449 register unsigned int cr, cg,
cb,
ca,
mask;
450 register unsigned char t0, t1, t2, t3;
458 t1 = ToLinear8[
cb = (wp[2] &
mask)];
459 t2 = ToLinear8[cg = (wp[1] &
mask)];
460 t3 = ToLinear8[cr = (wp[0] &
mask)];
471 t1 = ToLinear8[(
cb += wp[2]) &
mask];
472 t2 = ToLinear8[(cg += wp[1]) &
mask];
473 t3 = ToLinear8[(cr += wp[0]) &
mask];
481 t0 = ToLinear8[
ca = (wp[3] &
mask)];
482 t1 = ToLinear8[
cb = (wp[2] &
mask)];
483 t2 = ToLinear8[cg = (wp[1] &
mask)];
484 t3 = ToLinear8[cr = (wp[0] &
mask)];
495 t0 = ToLinear8[(
ca += wp[3]) &
mask];
496 t1 = ToLinear8[(
cb += wp[2]) &
mask];
497 t2 = ToLinear8[(cg += wp[1]) &
mask];
498 t3 = ToLinear8[(cr += wp[0]) &
mask];
533#define PLSTATE_INIT 1
540 unsigned char *ToLinear8;
547static int PixarLogMakeTables(
TIFF *tif, PixarLogState *
sp)
563 double b,
c, linstep,
v;
566 unsigned char *ToLinear8;
572 nlin = (
int)(1. /
c);
575 linstep =
b *
c *
exp(1.);
579 lt2size = (
int)(2. / linstep) + 1;
583 ToLinearF = (
float *)
_TIFFmallocExt(tif, TSIZEP1 *
sizeof(
float));
586 (
unsigned char *)
_TIFFmallocExt(tif, TSIZEP1 *
sizeof(
unsigned char));
587 if (FromLT2 ==
NULL || From14 ==
NULL || From8 ==
NULL ||
588 ToLinearF ==
NULL || ToLinear16 ==
NULL || ToLinear8 ==
NULL)
613 for (
i = 0;
i < nlin;
i++)
619 for (
i = nlin;
i < TSIZE;
i++)
620 ToLinearF[
j++] = (
float)(
b *
exp(
c *
i));
622 ToLinearF[2048] = ToLinearF[2047];
624 for (
i = 0;
i < TSIZEP1;
i++)
626 v = ToLinearF[
i] * 65535.0 + 0.5;
627 ToLinear16[
i] = (
v > 65535.0) ? 65535 : (
uint16_t)
v;
628 v = ToLinearF[
i] * 255.0 + 0.5;
629 ToLinear8[
i] = (
v > 255.0) ? 255 : (
unsigned char)
v;
633 for (
i = 0;
i < lt2size;
i++)
635 if ((
i * linstep) * (
i * linstep) > ToLinearF[
j] * ToLinearF[
j + 1])
646 for (
i = 0;
i < 16384;
i++)
648 while ((
i / 16383.) * (
i / 16383.) > ToLinearF[
j] * ToLinearF[
j + 1])
654 for (
i = 0;
i < 256;
i++)
656 while ((
i / 255.) * (
i / 255.) > ToLinearF[
j] * ToLinearF[
j + 1])
661 Fltsize = (
float)(lt2size / 2);
663 sp->ToLinearF = ToLinearF;
664 sp->ToLinear16 = ToLinear16;
665 sp->ToLinear8 = ToLinear8;
666 sp->FromLT2 = FromLT2;
673#define PixarLogDecoderState(tif) ((PixarLogState *)(tif)->tif_data)
674#define PixarLogEncoderState(tif) ((PixarLogState *)(tif)->tif_data)
679#define PIXARLOGDATAFMT_UNKNOWN -1
683 int guess = PIXARLOGDATAFMT_UNKNOWN;
723 assert(m1 >= 0 && m2 >= 0);
725 if (m1 == 0 || m2 == 0)
733static int PixarLogFixupTags(
TIFF *tif)
739static int PixarLogSetupDecode(
TIFF *tif)
741 static const char module[] =
"PixarLogSetupDecode";
743 PixarLogState *
sp = PixarLogDecoderState(tif);
752 if ((
sp->state & PLSTATE_INIT) != 0)
768 tbuf_size = multiply_ms(
772 tbuf_size = add_ms(tbuf_size,
sizeof(
uint16_t) *
sp->stride);
779 sp->tbuf_size = tbuf_size;
780 if (
sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
781 sp->user_datafmt = PixarLogGuessDataFmt(td);
782 if (
sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
788 "PixarLog compression can't handle bits depth/data "
789 "format combination (depth: %" PRIu16 ")",
800 sp->stream.msg ?
sp->stream.msg :
"(null)");
805 sp->state |= PLSTATE_INIT;
815 static const char module[] =
"PixarLogPreDecode";
816 PixarLogState *
sp = PixarLogDecoderState(tif);
821 assert(
sizeof(
sp->stream.avail_in) == 4);
836 static const char module[] =
"PixarLogDecode";
838 PixarLogState *
sp = PixarLogDecoderState(tif);
844 switch (
sp->user_datafmt)
847 nsamples = occ /
sizeof(
float);
860 "%" PRIu16 " bit input not supported in PixarLog",
874 sp->stream.next_out = (
unsigned char *)
sp->tbuf;
875 assert(
sizeof(
sp->stream.avail_out) == 4);
880 if (
sp->stream.avail_out != nsamples *
sizeof(
uint16_t))
903 tif,
module,
"Decoding error at scanline %" PRIu32 ", %s",
904 tif->
tif_row,
sp->stream.msg ?
sp->stream.msg :
"(null)");
911 sp->stream.msg ?
sp->stream.msg :
"(null)");
915 }
while (
sp->stream.avail_out > 0);
918 if (
sp->stream.avail_out != 0)
921 "Not enough data at scanline %" PRIu32
944 "stride %d is not a multiple of sample count, "
947 nsamples -= nsamples % llen;
950 for (
i = 0;
i < nsamples;
i += llen,
up += llen)
952 switch (
sp->user_datafmt)
955 horizontalAccumulateF(
up, llen,
sp->stride, (
float *)
op,
974 horizontalAccumulate8(
up, llen,
sp->stride, (
unsigned char *)
op,
976 op += llen *
sizeof(
unsigned char);
979 horizontalAccumulate8abgr(
up, llen,
sp->stride,
980 (
unsigned char *)
op,
sp->ToLinear8);
981 op += llen *
sizeof(
unsigned char);
994static int PixarLogSetupEncode(
TIFF *tif)
996 static const char module[] =
"PixarLogSetupEncode";
998 PixarLogState *
sp = PixarLogEncoderState(tif);
1018 if (
sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
1019 sp->user_datafmt = PixarLogGuessDataFmt(td);
1020 if (
sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
1023 "PixarLog compression can't handle %" PRIu16
1024 " bit linear encodings",
1032 sp->stream.msg ?
sp->stream.msg :
"(null)");
1037 sp->state |= PLSTATE_INIT;
1047 static const char module[] =
"PixarLogPreEncode";
1048 PixarLogState *
sp = PixarLogEncoderState(tif);
1053 assert(
sizeof(
sp->stream.avail_out) == 4);
1070 float fltsize = Fltsize;
1073 ((v < (float)0.) ? 0 \
1074 : (v < (float)2.) ? FromLT2[(int)(v * fltsize)] \
1075 : (v > (float)24.2) ? 2047 \
1076 : LogK1 * log(v * LogK2) + 0.5)
1146static void horizontalDifference16(
unsigned short *
ip,
int n,
int stride,
1147 unsigned short *wp,
uint16_t *From14)
1153#define CLAMP(v) From14[(v) >> 2]
1222static void horizontalDifference8(
unsigned char *
ip,
int n,
int stride,
1223 unsigned short *wp,
uint16_t *From8)
1228#define CLAMP(v) (From8[(v)])
1302 static const char module[] =
"PixarLogEncode";
1304 PixarLogState *
sp = PixarLogEncoderState(tif);
1312 switch (
sp->user_datafmt)
1328 "%" PRIu16 " bit input not supported in PixarLog",
1341 for (
i = 0,
up =
sp->tbuf;
i <
n;
i += llen,
up += llen)
1343 switch (
sp->user_datafmt)
1346 horizontalDifferenceF((
float *)bp, llen,
sp->stride,
up,
1348 bp += llen *
sizeof(
float);
1351 horizontalDifference16((
uint16_t *)bp, llen,
sp->stride,
up,
1356 horizontalDifference8((
unsigned char *)bp, llen,
sp->stride,
up,
1358 bp += llen *
sizeof(
unsigned char);
1362 "%" PRIu16 " bit input not supported in PixarLog",
1368 sp->stream.next_in = (
unsigned char *)
sp->tbuf;
1369 assert(
sizeof(
sp->stream.avail_in) == 4);
1385 sp->stream.msg ?
sp->stream.msg :
"(null)");
1388 if (
sp->stream.avail_out == 0)
1394 sp->stream.avail_out =
1399 }
while (
sp->stream.avail_in > 0);
1408static int PixarLogPostEncode(
TIFF *tif)
1410 static const char module[] =
"PixarLogPostEncode";
1411 PixarLogState *
sp = PixarLogEncoderState(tif);
1414 sp->stream.avail_in = 0;
1430 sp->stream.avail_out =
1438 sp->stream.msg ?
sp->stream.msg :
"(null)");
1445static void PixarLogClose(
TIFF *tif)
1447 PixarLogState *
sp = (PixarLogState *)tif->
tif_data;
1460 if (
sp->state & PLSTATE_INIT)
1475static void PixarLogCleanup(
TIFF *tif)
1477 PixarLogState *
sp = (PixarLogState *)tif->
tif_data;
1498 if (
sp->state & PLSTATE_INIT)
1515 static const char module[] =
"PixarLogVSetField";
1516 PixarLogState *
sp = (PixarLogState *)tif->
tif_data;
1529 sp->stream.msg ?
sp->stream.msg :
"(null)");
1541 switch (
sp->user_datafmt)
1582 PixarLogState *
sp = (PixarLogState *)tif->
tif_data;
1593 return (*
sp->vgetparent)(tif,
tag,
ap);
1598static const TIFFField pixarlogFields[] = {
1606 static const char module[] =
"TIFFInitPixarLog";
1619 "Merging PixarLog codec-specific tags failed");
1632 sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN;
1670 PixarLogMakeTables(tif,
sp);
#define REPEAT(statement)
int ZEXPORT deflateReset(z_streamp strm)
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
static int inflateReset(z_streamp strm)
int inflate(z_streamp strm, int flush)
int inflateEnd(z_streamp strm)
#define Z_DEFAULT_STRATEGY
int deflate(z_streamp strm, int flush) DECLSPEC_HIDDEN
int deflateEnd(z_streamp strm) DECLSPEC_HIDDEN
#define Z_DEFAULT_COMPRESSION
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLboolean GLboolean GLboolean b
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static const struct update_accum a1
static const struct update_accum a2
static CRYPT_DATA_BLOB b2[]
static CRYPT_DATA_BLOB b1[]
static float(__cdecl *square_half_float)(float x
#define inflateInit(strm)
#define deflateInit(strm, level)
uint16_t td_bitspersample
uint16_t td_samplesperpixel
TIFFCodeMethod tif_encodestrip
TIFFCodeMethod tif_encodetile
TIFFTagMethods tif_tagmethods
tmsize_t tif_scanlinesize
TIFFPreMethod tif_preencode
TIFFBoolMethod tif_fixuptags
TIFFPreMethod tif_predecode
TIFFCodeMethod tif_decodestrip
TIFFPostMethod tif_postdecode
TIFFCodeMethod tif_decoderow
TIFFBoolMethod tif_setupencode
TIFFBoolMethod tif_postencode
TIFFCodeMethod tif_encoderow
TIFFVoidMethod tif_cleanup
TIFFBoolMethod tif_setupdecode
TIFFCodeMethod tif_decodetile
tmsize_t _TIFFMultiplySSize(TIFF *tif, tmsize_t first, tmsize_t second, const char *where)
#define CLAMP(f, min, max)
void _TIFFSetDefaultCompressionState(TIFF *tif)
#define TIFF_SSIZE_FORMAT
int TIFFSetField(TIFF *tif, uint32_t tag,...)
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
void _TIFFfreeExt(TIFF *tif, void *p)
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
int TIFFPredictorCleanup(TIFF *tif)
int TIFFPredictorInit(TIFF *tif)
void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc)
tmsize_t TIFFScanlineSize(TIFF *tif)
void TIFFSwabArrayOfShort(register uint16_t *wp, tmsize_t n)
tmsize_t TIFFTileSize(TIFF *tif)
void _TIFFmemset(void *p, int v, tmsize_t c)
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt,...)
int TIFFFlushData1(TIFF *tif)
#define TIFFTAG_BITSPERSAMPLE
#define COMPRESSION_PIXARLOG
#define PIXARLOGDATAFMT_8BITABGR
#define PIXARLOGDATAFMT_8BIT
#define SAMPLEFORMAT_UINT
#define PIXARLOGDATAFMT_16BIT
#define PIXARLOGDATAFMT_12BITPICIO
#define TIFFTAG_PIXARLOGDATAFMT
#define TIFFTAG_PIXARLOGQUALITY
#define SAMPLEFORMAT_IEEEFP
#define PIXARLOGDATAFMT_11BITLOG
#define TIFFTAG_SAMPLEFORMAT
#define PIXARLOGDATAFMT_FLOAT
#define SAMPLEFORMAT_VOID
#define PLANARCONFIG_CONTIG
int(* TIFFVSetMethod)(TIFF *, uint32_t, va_list)
#define TIFF_TMSIZE_T_MAX
#define TIFFArrayCount(a)
void int int ULONGLONG int va_list * ap