ReactOS  0.4.14-dev-376-gaedba84
tif_predict.c File Reference
#include <precomp.h>
#include "tif_predict.h"
Include dependency graph for tif_predict.c:

Go to the source code of this file.

Macros

#define PredictorState(tif)   ((TIFFPredictorState*) (tif)->tif_data)
 
#define REPEAT4(n, op)
 
#define FIELD_PREDICTOR   (FIELD_CODEC+0) /* XXX */
 

Functions

static int horAcc8 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int horAcc16 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int horAcc32 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int swabHorAcc16 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int swabHorAcc32 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int horDiff8 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int horDiff16 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int horDiff32 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int swabHorDiff16 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int swabHorDiff32 (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int fpAcc (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int fpDiff (TIFF *tif, uint8 *cp0, tmsize_t cc)
 
static int PredictorDecodeRow (TIFF *tif, uint8 *op0, tmsize_t occ0, uint16 s)
 
static int PredictorDecodeTile (TIFF *tif, uint8 *op0, tmsize_t occ0, uint16 s)
 
static int PredictorEncodeRow (TIFF *tif, uint8 *bp, tmsize_t cc, uint16 s)
 
static int PredictorEncodeTile (TIFF *tif, uint8 *bp0, tmsize_t cc0, uint16 s)
 
static int PredictorSetup (TIFF *tif)
 
static int PredictorSetupDecode (TIFF *tif)
 
static int PredictorSetupEncode (TIFF *tif)
 
static int PredictorVSetField (TIFF *tif, uint32 tag, va_list ap)
 
static int PredictorVGetField (TIFF *tif, uint32 tag, va_list ap)
 
static void PredictorPrintDir (TIFF *tif, FILE *fd, long flags)
 
int TIFFPredictorInit (TIFF *tif)
 
int TIFFPredictorCleanup (TIFF *tif)
 

Variables

static const TIFFField predictFields []
 

Macro Definition Documentation

◆ FIELD_PREDICTOR

#define FIELD_PREDICTOR   (FIELD_CODEC+0) /* XXX */

Definition at line 752 of file tif_predict.c.

◆ PredictorState

#define PredictorState (   tif)    ((TIFFPredictorState*) (tif)->tif_data)

Definition at line 33 of file tif_predict.c.

◆ REPEAT4

#define REPEAT4 (   n,
  op 
)
Value:
switch (n) { \
default: { \
tmsize_t i; for (i = n-4; i > 0; i--) { op; } } /*-fallthrough*/ \
case 4: op; /*-fallthrough*/ \
case 3: op; /*-fallthrough*/ \
case 2: op; /*-fallthrough*/ \
case 1: op; /*-fallthrough*/ \
case 0: ; \
}
GLdouble n
Definition: glext.h:7729
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
Definition: glfuncs.h:248
UINT op
Definition: effect.c:223

Definition at line 261 of file tif_predict.c.

Function Documentation

◆ fpAcc()

static int fpAcc ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 410 of file tif_predict.c.

411 {
412  tmsize_t stride = PredictorState(tif)->stride;
413  uint32 bps = tif->tif_dir.td_bitspersample / 8;
414  tmsize_t wc = cc / bps;
415  tmsize_t count = cc;
416  uint8 *cp = (uint8 *) cp0;
417  uint8 *tmp;
418 
419  if(cc%(bps*stride)!=0)
420  {
421  TIFFErrorExt(tif->tif_clientdata, "fpAcc",
422  "%s", "cc%(bps*stride))!=0");
423  return 0;
424  }
425 
426  tmp = (uint8 *)_TIFFmalloc(cc);
427  if (!tmp)
428  return 0;
429 
430  while (count > stride) {
431  REPEAT4(stride, cp[stride] =
432  (unsigned char) ((cp[stride] + cp[0]) & 0xff); cp++)
433  count -= stride;
434  }
435 
436  _TIFFmemcpy(tmp, cp0, cc);
437  cp = (uint8 *) cp0;
438  for (count = 0; count < wc; count++) {
439  uint32 byte;
440  for (byte = 0; byte < bps; byte++) {
441  #if WORDS_BIGENDIAN
442  cp[bps * count + byte] = tmp[byte * wc + count];
443  #else
444  cp[bps * count + byte] =
445  tmp[(bps - byte - 1) * wc + count];
446  #endif
447  }
448  }
449  _TIFFfree(tmp);
450  return 1;
451 }
#define PredictorState(tif)
Definition: tif_predict.c:33
uint16 td_bitspersample
Definition: tif_dir.h:74
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
GLsizei stride
Definition: glext.h:5848
unsigned char uint8
Definition: types.h:28
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
#define byte(x, n)
Definition: tomcrypt.h:118
TIFFDirectory tif_dir
Definition: tiffiop.h:135
#define REPEAT4(n, op)
Definition: tif_predict.c:261
POINT cp
Definition: magnifier.c:59
void _TIFFfree(void *p)
Definition: tif_unix.c:326
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344

Referenced by PredictorSetupDecode().

◆ fpDiff()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int fpDiff ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 646 of file tif_predict.c.

647 {
648  tmsize_t stride = PredictorState(tif)->stride;
649  uint32 bps = tif->tif_dir.td_bitspersample / 8;
650  tmsize_t wc = cc / bps;
651  tmsize_t count;
652  uint8 *cp = (uint8 *) cp0;
653  uint8 *tmp;
654 
655  if((cc%(bps*stride))!=0)
656  {
657  TIFFErrorExt(tif->tif_clientdata, "fpDiff",
658  "%s", "(cc%(bps*stride))!=0");
659  return 0;
660  }
661 
662  tmp = (uint8 *)_TIFFmalloc(cc);
663  if (!tmp)
664  return 0;
665 
666  _TIFFmemcpy(tmp, cp0, cc);
667  for (count = 0; count < wc; count++) {
668  uint32 byte;
669  for (byte = 0; byte < bps; byte++) {
670  #if WORDS_BIGENDIAN
671  cp[byte * wc + count] = tmp[bps * count + byte];
672  #else
673  cp[(bps - byte - 1) * wc + count] =
674  tmp[bps * count + byte];
675  #endif
676  }
677  }
678  _TIFFfree(tmp);
679 
680  cp = (uint8 *) cp0;
681  cp += cc - stride - 1;
682  for (count = cc; count > stride; count -= stride)
683  REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--)
684  return 1;
685 }
#define PredictorState(tif)
Definition: tif_predict.c:33
uint16 td_bitspersample
Definition: tif_dir.h:74
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
GLsizei stride
Definition: glext.h:5848
unsigned char uint8
Definition: types.h:28
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
#define byte(x, n)
Definition: tomcrypt.h:118
TIFFDirectory tif_dir
Definition: tiffiop.h:135
#define REPEAT4(n, op)
Definition: tif_predict.c:261
POINT cp
Definition: magnifier.c:59
void _TIFFfree(void *p)
Definition: tif_unix.c:326
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:344

Referenced by PredictorSetupEncode().

◆ horAcc16()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int horAcc16 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 348 of file tif_predict.c.

349 {
350  tmsize_t stride = PredictorState(tif)->stride;
351  uint16* wp = (uint16*) cp0;
352  tmsize_t wc = cc / 2;
353 
354  if((cc%(2*stride))!=0)
355  {
356  TIFFErrorExt(tif->tif_clientdata, "horAcc16",
357  "%s", "cc%(2*stride))!=0");
358  return 0;
359  }
360 
361  if (wc > stride) {
362  wc -= stride;
363  do {
364  REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++)
365  wc -= stride;
366  } while (wc > 0);
367  }
368  return 1;
369 }
#define PredictorState(tif)
Definition: tif_predict.c:33
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
GLsizei stride
Definition: glext.h:5848
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
unsigned short uint16
Definition: types.h:30
#define REPEAT4(n, op)
Definition: tif_predict.c:261

Referenced by PredictorSetupDecode(), and swabHorAcc16().

◆ horAcc32()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int horAcc32 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 383 of file tif_predict.c.

384 {
385  tmsize_t stride = PredictorState(tif)->stride;
386  uint32* wp = (uint32*) cp0;
387  tmsize_t wc = cc / 4;
388 
389  if((cc%(4*stride))!=0)
390  {
391  TIFFErrorExt(tif->tif_clientdata, "horAcc32",
392  "%s", "cc%(4*stride))!=0");
393  return 0;
394  }
395 
396  if (wc > stride) {
397  wc -= stride;
398  do {
399  REPEAT4(stride, wp[stride] += wp[0]; wp++)
400  wc -= stride;
401  } while (wc > 0);
402  }
403  return 1;
404 }
#define PredictorState(tif)
Definition: tif_predict.c:33
unsigned int uint32
Definition: types.h:32
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
GLsizei stride
Definition: glext.h:5848
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
#define REPEAT4(n, op)
Definition: tif_predict.c:261

Referenced by PredictorSetupDecode(), and swabHorAcc32().

◆ horAcc8()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int horAcc8 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 280 of file tif_predict.c.

281 {
282  tmsize_t stride = PredictorState(tif)->stride;
283 
284  unsigned char* cp = (unsigned char*) cp0;
285  if((cc%stride)!=0)
286  {
287  TIFFErrorExt(tif->tif_clientdata, "horAcc8",
288  "%s", "(cc%stride)!=0");
289  return 0;
290  }
291 
292  if (cc > stride) {
293  /*
294  * Pipeline the most common cases.
295  */
296  if (stride == 3) {
297  unsigned int cr = cp[0];
298  unsigned int cg = cp[1];
299  unsigned int cb = cp[2];
300  cc -= 3;
301  cp += 3;
302  while (cc>0) {
303  cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
304  cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
305  cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
306  cc -= 3;
307  cp += 3;
308  }
309  } else if (stride == 4) {
310  unsigned int cr = cp[0];
311  unsigned int cg = cp[1];
312  unsigned int cb = cp[2];
313  unsigned int ca = cp[3];
314  cc -= 4;
315  cp += 4;
316  while (cc>0) {
317  cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
318  cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
319  cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
320  cp[3] = (unsigned char) ((ca += cp[3]) & 0xff);
321  cc -= 4;
322  cp += 4;
323  }
324  } else {
325  cc -= stride;
326  do {
327  REPEAT4(stride, cp[stride] =
328  (unsigned char) ((cp[stride] + *cp) & 0xff); cp++)
329  cc -= stride;
330  } while (cc>0);
331  }
332  }
333  return 1;
334 }
#define PredictorState(tif)
Definition: tif_predict.c:33
Definition: fs.h:440
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
unsigned char
Definition: typeof.h:29
GLsizei stride
Definition: glext.h:5848
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
#define REPEAT4(n, op)
Definition: tif_predict.c:261
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
POINT cp
Definition: magnifier.c:59
static const WCHAR ca[]
Definition: main.c:455

Referenced by PredictorSetupDecode().

◆ horDiff16()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int horDiff16 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 563 of file tif_predict.c.

564 {
566  tmsize_t stride = sp->stride;
567  uint16 *wp = (uint16*) cp0;
568  tmsize_t wc = cc/2;
569 
570  if((cc%(2*stride))!=0)
571  {
572  TIFFErrorExt(tif->tif_clientdata, "horDiff8",
573  "%s", "(cc%(2*stride))!=0");
574  return 0;
575  }
576 
577  if (wc > stride) {
578  wc -= stride;
579  wp += wc - 1;
580  do {
581  REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--)
582  wc -= stride;
583  } while (wc > 0);
584  }
585  return 1;
586 }
#define PredictorState(tif)
Definition: tif_predict.c:33
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
GLsizei stride
Definition: glext.h:5848
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
unsigned short uint16
Definition: types.h:30
#define REPEAT4(n, op)
Definition: tif_predict.c:261
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by PredictorSetupEncode(), and swabHorDiff16().

◆ horDiff32()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int horDiff32 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 603 of file tif_predict.c.

604 {
606  tmsize_t stride = sp->stride;
607  uint32 *wp = (uint32*) cp0;
608  tmsize_t wc = cc/4;
609 
610  if((cc%(4*stride))!=0)
611  {
612  TIFFErrorExt(tif->tif_clientdata, "horDiff32",
613  "%s", "(cc%(4*stride))!=0");
614  return 0;
615  }
616 
617  if (wc > stride) {
618  wc -= stride;
619  wp += wc - 1;
620  do {
621  REPEAT4(stride, wp[stride] -= wp[0]; wp--)
622  wc -= stride;
623  } while (wc > 0);
624  }
625  return 1;
626 }
#define PredictorState(tif)
Definition: tif_predict.c:33
unsigned int uint32
Definition: types.h:32
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
GLsizei stride
Definition: glext.h:5848
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
#define REPEAT4(n, op)
Definition: tif_predict.c:261
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by PredictorSetupEncode(), and swabHorDiff32().

◆ horDiff8()

static TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW int horDiff8 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 509 of file tif_predict.c.

510 {
512  tmsize_t stride = sp->stride;
513  unsigned char* cp = (unsigned char*) cp0;
514 
515  if((cc%stride)!=0)
516  {
517  TIFFErrorExt(tif->tif_clientdata, "horDiff8",
518  "%s", "(cc%stride)!=0");
519  return 0;
520  }
521 
522  if (cc > stride) {
523  cc -= stride;
524  /*
525  * Pipeline the most common cases.
526  */
527  if (stride == 3) {
528  unsigned int r1, g1, b1;
529  unsigned int r2 = cp[0];
530  unsigned int g2 = cp[1];
531  unsigned int b2 = cp[2];
532  do {
533  r1 = cp[3]; cp[3] = (unsigned char)((r1-r2)&0xff); r2 = r1;
534  g1 = cp[4]; cp[4] = (unsigned char)((g1-g2)&0xff); g2 = g1;
535  b1 = cp[5]; cp[5] = (unsigned char)((b1-b2)&0xff); b2 = b1;
536  cp += 3;
537  } while ((cc -= 3) > 0);
538  } else if (stride == 4) {
539  unsigned int r1, g1, b1, a1;
540  unsigned int r2 = cp[0];
541  unsigned int g2 = cp[1];
542  unsigned int b2 = cp[2];
543  unsigned int a2 = cp[3];
544  do {
545  r1 = cp[4]; cp[4] = (unsigned char)((r1-r2)&0xff); r2 = r1;
546  g1 = cp[5]; cp[5] = (unsigned char)((g1-g2)&0xff); g2 = g1;
547  b1 = cp[6]; cp[6] = (unsigned char)((b1-b2)&0xff); b2 = b1;
548  a1 = cp[7]; cp[7] = (unsigned char)((a1-a2)&0xff); a2 = a1;
549  cp += 4;
550  } while ((cc -= 4) > 0);
551  } else {
552  cp += cc - 1;
553  do {
554  REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--)
555  } while ((cc -= stride) > 0);
556  }
557  }
558  return 1;
559 }
#define PredictorState(tif)
Definition: tif_predict.c:33
static DNS_RECORDW r1
Definition: record.c:37
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
unsigned char
Definition: typeof.h:29
GLsizei stride
Definition: glext.h:5848
static const struct update_accum a2
Definition: msg.c:586
static DNS_RECORDW r2
Definition: record.c:38
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint32_t cc
Definition: isohybrid.c:75
#define REPEAT4(n, op)
Definition: tif_predict.c:261
POINT cp
Definition: magnifier.c:59
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582
static const WCHAR sp[]
Definition: suminfo.c:288
static const struct update_accum a1
Definition: msg.c:578

Referenced by PredictorSetupEncode().

◆ PredictorDecodeRow()

static int PredictorDecodeRow ( TIFF tif,
uint8 op0,
tmsize_t  occ0,
uint16  s 
)
static

Definition at line 457 of file tif_predict.c.

458 {
460 
461  assert(sp != NULL);
462  assert(sp->decoderow != NULL);
463  assert(sp->decodepfunc != NULL);
464 
465  if ((*sp->decoderow)(tif, op0, occ0, s)) {
466  return (*sp->decodepfunc)(tif, op0, occ0);
467  } else
468  return 0;
469 }
#define PredictorState(tif)
Definition: tif_predict.c:33
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by PredictorSetupDecode().

◆ PredictorDecodeTile()

static int PredictorDecodeTile ( TIFF tif,
uint8 op0,
tmsize_t  occ0,
uint16  s 
)
static

Definition at line 479 of file tif_predict.c.

480 {
482 
483  assert(sp != NULL);
484  assert(sp->decodetile != NULL);
485 
486  if ((*sp->decodetile)(tif, op0, occ0, s)) {
487  tmsize_t rowsize = sp->rowsize;
488  assert(rowsize > 0);
489  if((occ0%rowsize) !=0)
490  {
491  TIFFErrorExt(tif->tif_clientdata, "PredictorDecodeTile",
492  "%s", "occ0%rowsize != 0");
493  return 0;
494  }
495  assert(sp->decodepfunc != NULL);
496  while (occ0 > 0) {
497  if( !(*sp->decodepfunc)(tif, op0, rowsize) )
498  return 0;
499  occ0 -= rowsize;
500  op0 += rowsize;
501  }
502  return 1;
503  } else
504  return 0;
505 }
#define PredictorState(tif)
Definition: tif_predict.c:33
#define assert(x)
Definition: debug.h:53
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
smooth NULL
Definition: ftsmooth.c:416
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
GLdouble s
Definition: gl.h:2039
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by PredictorSetupDecode().

◆ PredictorEncodeRow()

static int PredictorEncodeRow ( TIFF tif,
uint8 bp,
tmsize_t  cc,
uint16  s 
)
static

Definition at line 688 of file tif_predict.c.

689 {
691 
692  assert(sp != NULL);
693  assert(sp->encodepfunc != NULL);
694  assert(sp->encoderow != NULL);
695 
696  /* XXX horizontal differencing alters user's data XXX */
697  if( !(*sp->encodepfunc)(tif, bp, cc) )
698  return 0;
699  return (*sp->encoderow)(tif, bp, cc, s);
700 }
#define PredictorState(tif)
Definition: tif_predict.c:33
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
GLdouble s
Definition: gl.h:2039
uint32_t cc
Definition: isohybrid.c:75
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by PredictorSetupEncode().

◆ PredictorEncodeTile()

static int PredictorEncodeTile ( TIFF tif,
uint8 bp0,
tmsize_t  cc0,
uint16  s 
)
static

Definition at line 703 of file tif_predict.c.

704 {
705  static const char module[] = "PredictorEncodeTile";
707  uint8 *working_copy;
708  tmsize_t cc = cc0, rowsize;
709  unsigned char* bp;
710  int result_code;
711 
712  assert(sp != NULL);
713  assert(sp->encodepfunc != NULL);
714  assert(sp->encodetile != NULL);
715 
716  /*
717  * Do predictor manipulation in a working buffer to avoid altering
718  * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965
719  */
720  working_copy = (uint8*) _TIFFmalloc(cc0);
721  if( working_copy == NULL )
722  {
724  "Out of memory allocating " TIFF_SSIZE_FORMAT " byte temp buffer.",
725  cc0 );
726  return 0;
727  }
728  memcpy( working_copy, bp0, cc0 );
729  bp = working_copy;
730 
731  rowsize = sp->rowsize;
732  assert(rowsize > 0);
733  if((cc0%rowsize)!=0)
734  {
735  TIFFErrorExt(tif->tif_clientdata, "PredictorEncodeTile",
736  "%s", "(cc0%rowsize)!=0");
737  _TIFFfree( working_copy );
738  return 0;
739  }
740  while (cc > 0) {
741  (*sp->encodepfunc)(tif, bp, rowsize);
742  cc -= rowsize;
743  bp += rowsize;
744  }
745  result_code = (*sp->encodetile)(tif, working_copy, cc0, s);
746 
747  _TIFFfree( working_copy );
748 
749  return result_code;
750 }
#define PredictorState(tif)
Definition: tif_predict.c:33
#define assert(x)
Definition: debug.h:53
thandle_t tif_clientdata
Definition: tiffiop.h:191
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
smooth NULL
Definition: ftsmooth.c:416
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
unsigned char uint8
Definition: types.h:28
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLdouble s
Definition: gl.h:2039
#define TIFF_SSIZE_FORMAT
Definition: tif_config.h:105
uint32_t cc
Definition: isohybrid.c:75
static const WCHAR sp[]
Definition: suminfo.c:288
void _TIFFfree(void *p)
Definition: tif_unix.c:326

Referenced by PredictorSetupEncode().

◆ PredictorPrintDir()

static void PredictorPrintDir ( TIFF tif,
FILE fd,
long  flags 
)
static

Definition at line 797 of file tif_predict.c.

798 {
800 
801  (void) flags;
802  if (TIFFFieldSet(tif,FIELD_PREDICTOR)) {
803  fprintf(fd, " Predictor: ");
804  switch (sp->predictor) {
805  case 1: fprintf(fd, "none "); break;
806  case 2: fprintf(fd, "horizontal differencing "); break;
807  case 3: fprintf(fd, "floating point predictor "); break;
808  }
809  fprintf(fd, "%d (0x%x)\n", sp->predictor, sp->predictor);
810  }
811  if (sp->printdir)
812  (*sp->printdir)(tif, fd, flags);
813 }
#define PredictorState(tif)
Definition: tif_predict.c:33
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define FIELD_PREDICTOR
Definition: tif_predict.c:752
static int fd
Definition: io.c:51
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:192
GLbitfield flags
Definition: glext.h:7161
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by TIFFPredictorInit().

◆ PredictorSetup()

static int PredictorSetup ( TIFF tif)
static

Definition at line 53 of file tif_predict.c.

54 {
55  static const char module[] = "PredictorSetup";
56 
58  TIFFDirectory* td = &tif->tif_dir;
59 
60  switch (sp->predictor) /* no differencing */
61  {
62  case PREDICTOR_NONE:
63  return 1;
65  if (td->td_bitspersample != 8
66  && td->td_bitspersample != 16
67  && td->td_bitspersample != 32) {
69  "Horizontal differencing \"Predictor\" not supported with %d-bit samples",
70  td->td_bitspersample);
71  return 0;
72  }
73  break;
77  "Floating point \"Predictor\" not supported with %d data format",
78  td->td_sampleformat);
79  return 0;
80  }
81  if (td->td_bitspersample != 16
82  && td->td_bitspersample != 24
83  && td->td_bitspersample != 32
84  && td->td_bitspersample != 64) { /* Should 64 be allowed? */
86  "Floating point \"Predictor\" not supported with %d-bit samples",
87  td->td_bitspersample);
88  return 0;
89  }
90  break;
91  default:
93  "\"Predictor\" value %d not supported",
94  sp->predictor);
95  return 0;
96  }
97  sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ?
98  td->td_samplesperpixel : 1);
99  /*
100  * Calculate the scanline/tile-width size in bytes.
101  */
102  if (isTiled(tif))
103  sp->rowsize = TIFFTileRowSize(tif);
104  else
105  sp->rowsize = TIFFScanlineSize(tif);
106  if (sp->rowsize == 0)
107  return 0;
108 
109  return 1;
110 }
#define PredictorState(tif)
Definition: tif_predict.c:33
uint16 td_bitspersample
Definition: tif_dir.h:74
#define PREDICTOR_HORIZONTAL
Definition: tiff.h:280
thandle_t tif_clientdata
Definition: tiffiop.h:191
#define PREDICTOR_NONE
Definition: tiff.h:279
uint16 td_planarconfig
Definition: tif_dir.h:88
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:311
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
uint16 td_sampleformat
Definition: tif_dir.h:75
#define isTiled(tif)
Definition: tiffiop.h:213
tmsize_t TIFFTileRowSize(TIFF *tif)
Definition: tif_tile.c:181
tmsize_t TIFFScanlineSize(TIFF *tif)
Definition: tif_strip.c:330
TIFFDirectory tif_dir
Definition: tiffiop.h:135
uint16 td_samplesperpixel
Definition: tif_dir.h:81
static const WCHAR sp[]
Definition: suminfo.c:288
#define PREDICTOR_FLOATINGPOINT
Definition: tiff.h:281
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240

Referenced by PredictorSetupDecode(), and PredictorSetupEncode().

◆ PredictorSetupDecode()

static int PredictorSetupDecode ( TIFF tif)
static

Definition at line 113 of file tif_predict.c.

114 {
116  TIFFDirectory* td = &tif->tif_dir;
117 
118  /* Note: when PredictorSetup() fails, the effets of setupdecode() */
119  /* will not be "cancelled" so setupdecode() might be robust to */
120  /* be called several times. */
121  if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif))
122  return 0;
123 
124  if (sp->predictor == 2) {
125  switch (td->td_bitspersample) {
126  case 8: sp->decodepfunc = horAcc8; break;
127  case 16: sp->decodepfunc = horAcc16; break;
128  case 32: sp->decodepfunc = horAcc32; break;
129  }
130  /*
131  * Override default decoding method with one that does the
132  * predictor stuff.
133  */
134  if( tif->tif_decoderow != PredictorDecodeRow )
135  {
136  sp->decoderow = tif->tif_decoderow;
138  sp->decodestrip = tif->tif_decodestrip;
140  sp->decodetile = tif->tif_decodetile;
142  }
143 
144  /*
145  * If the data is horizontally differenced 16-bit data that
146  * requires byte-swapping, then it must be byte swapped before
147  * the accumulation step. We do this with a special-purpose
148  * routine and override the normal post decoding logic that
149  * the library setup when the directory was read.
150  */
151  if (tif->tif_flags & TIFF_SWAB) {
152  if (sp->decodepfunc == horAcc16) {
153  sp->decodepfunc = swabHorAcc16;
155  } else if (sp->decodepfunc == horAcc32) {
156  sp->decodepfunc = swabHorAcc32;
158  }
159  }
160  }
161 
162  else if (sp->predictor == 3) {
163  sp->decodepfunc = fpAcc;
164  /*
165  * Override default decoding method with one that does the
166  * predictor stuff.
167  */
168  if( tif->tif_decoderow != PredictorDecodeRow )
169  {
170  sp->decoderow = tif->tif_decoderow;
172  sp->decodestrip = tif->tif_decodestrip;
174  sp->decodetile = tif->tif_decodetile;
176  }
177  /*
178  * The data should not be swapped outside of the floating
179  * point predictor, the accumulation routine should return
180  * byres in the native order.
181  */
182  if (tif->tif_flags & TIFF_SWAB) {
184  }
185  /*
186  * Allocate buffer to keep the decoded bytes before
187  * rearranging in the right order
188  */
189  }
190 
191  return 1;
192 }
#define PredictorState(tif)
Definition: tif_predict.c:33
TIFFCodeMethod tif_decoderow
Definition: tiffiop.h:164
static int swabHorAcc32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:372
uint16 td_bitspersample
Definition: tif_dir.h:74
static int horAcc16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:348
#define TIFF_SWAB
Definition: tiffiop.h:113
static int PredictorDecodeTile(TIFF *tif, uint8 *op0, tmsize_t occ0, uint16 s)
Definition: tif_predict.c:479
uint32 tif_flags
Definition: tiffiop.h:106
TIFFCodeMethod tif_decodestrip
Definition: tiffiop.h:166
static int PredictorDecodeRow(TIFF *tif, uint8 *op0, tmsize_t occ0, uint16 s)
Definition: tif_predict.c:457
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:198
static int horAcc8(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:280
static int fpAcc(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:410
TIFFCodeMethod tif_decodetile
Definition: tiffiop.h:168
static int PredictorSetup(TIFF *tif)
Definition: tif_predict.c:53
void _TIFFNoPostDecode(TIFF *tif, uint8 *buf, tmsize_t cc)
Definition: tif_read.c:1533
static int horAcc32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:383
TIFFDirectory tif_dir
Definition: tiffiop.h:135
static int swabHorAcc16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:337
static const WCHAR sp[]
Definition: suminfo.c:288

Referenced by TIFFPredictorInit().

◆ PredictorSetupEncode()

static int PredictorSetupEncode ( TIFF tif)
static

Definition at line 195 of file tif_predict.c.

196 {
198  TIFFDirectory* td = &tif->tif_dir;
199 
200  if (!(*sp->setupencode)(tif) || !PredictorSetup(tif))
201  return 0;
202 
203  if (sp->predictor == 2) {
204  switch (td->td_bitspersample) {
205  case 8: sp->encodepfunc = horDiff8; break;
206  case 16: sp->encodepfunc = horDiff16; break;
207  case 32: sp->encodepfunc = horDiff32; break;
208  }
209  /*
210  * Override default encoding method with one that does the
211  * predictor stuff.
212  */
213  if( tif->tif_encoderow != PredictorEncodeRow )
214  {
215  sp->encoderow = tif->tif_encoderow;
217  sp->encodestrip = tif->tif_encodestrip;
219  sp->encodetile = tif->tif_encodetile;
221  }
222 
223  /*
224  * If the data is horizontally differenced 16-bit data that
225  * requires byte-swapping, then it must be byte swapped after
226  * the differentiation step. We do this with a special-purpose
227  * routine and override the normal post decoding logic that
228  * the library setup when the directory was read.
229  */
230  if (tif->tif_flags & TIFF_SWAB) {
231  if (sp->encodepfunc == horDiff16) {
232  sp->encodepfunc = swabHorDiff16;
234  } else if (sp->encodepfunc == horDiff32) {
235  sp->encodepfunc = swabHorDiff32;
237  }
238  }
239  }
240 
241  else if (sp->predictor == 3) {
242  sp->encodepfunc = fpDiff;
243  /*
244  * Override default encoding method with one that does the
245  * predictor stuff.
246  */
247  if( tif->tif_encoderow != PredictorEncodeRow )
248  {
249  sp->encoderow = tif->tif_encoderow;
251  sp->encodestrip = tif->tif_encodestrip;
253  sp->encodetile = tif->tif_encodetile;
255  }
256  }
257 
258  return 1;
259 }
#define PredictorState(tif)
Definition: tif_predict.c:33
uint16 td_bitspersample
Definition: tif_dir.h:74
TIFFCodeMethod tif_encodestrip
Definition: tiffiop.h:167
static int horDiff16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:563
TIFFCodeMethod tif_encoderow
Definition: tiffiop.h:165
#define TIFF_SWAB
Definition: tiffiop.h:113
static int PredictorEncodeTile(TIFF *tif, uint8 *bp0, tmsize_t cc0, uint16 s)
Definition: tif_predict.c:703
uint32 tif_flags
Definition: tiffiop.h:106
static int fpDiff(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:646
TIFFCodeMethod tif_encodetile
Definition: tiffiop.h:169
static int PredictorEncodeRow(TIFF *tif, uint8 *bp, tmsize_t cc, uint16 s)
Definition: tif_predict.c:688
static int swabHorDiff16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:589
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:198
static int horDiff8(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:509
static int PredictorSetup(TIFF *tif)
Definition: tif_predict.c:53
void _TIFFNoPostDecode(TIFF *tif, uint8 *buf, tmsize_t cc)
Definition: tif_read.c:1533
TIFFDirectory tif_dir
Definition: tiffiop.h:135
static int horDiff32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:603
static const WCHAR sp[]
Definition: suminfo.c:288
static int swabHorDiff32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:629

Referenced by TIFFPredictorInit().

◆ PredictorVGetField()

static int PredictorVGetField ( TIFF tif,
uint32  tag,
va_list  ap 
)
static

Definition at line 779 of file tif_predict.c.

780 {
782 
783  assert(sp != NULL);
784  assert(sp->vgetparent != NULL);
785 
786  switch (tag) {
787  case TIFFTAG_PREDICTOR:
788  *va_arg(ap, uint16*) = (uint16)sp->predictor;
789  break;
790  default:
791  return (*sp->vgetparent)(tif, tag, ap);
792  }
793  return 1;
794 }
#define PredictorState(tif)
Definition: tif_predict.c:33
return
Definition: dirsup.c:529
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
smooth NULL
Definition: ftsmooth.c:416
#define va_arg(ap, T)
Definition: acmsvcex.h:89
unsigned short uint16
Definition: types.h:30
#define TIFFTAG_PREDICTOR
Definition: tiff.h:278
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
static const WCHAR sp[]
Definition: suminfo.c:288
char * tag
Definition: main.c:59

Referenced by TIFFPredictorInit().

◆ PredictorVSetField()

static int PredictorVSetField ( TIFF tif,
uint32  tag,
va_list  ap 
)
static

Definition at line 759 of file tif_predict.c.

760 {
762 
763  assert(sp != NULL);
764  assert(sp->vsetparent != NULL);
765 
766  switch (tag) {
767  case TIFFTAG_PREDICTOR:
768  sp->predictor = (uint16) va_arg(ap, uint16_vap);
770  break;
771  default:
772  return (*sp->vsetparent)(tif, tag, ap);
773  }
774  tif->tif_flags |= TIFF_DIRTYDIRECT;
775  return 1;
776 }
#define PredictorState(tif)
Definition: tif_predict.c:33
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
#define FIELD_PREDICTOR
Definition: tif_predict.c:752
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:109
#define TIFFSetFieldBit(tif, field)
Definition: tif_dir.h:193
uint32 tif_flags
Definition: tiffiop.h:106
smooth NULL
Definition: ftsmooth.c:416
int uint16_vap
Definition: tiff.h:86
#define va_arg(ap, T)
Definition: acmsvcex.h:89
unsigned short uint16
Definition: types.h:30
#define TIFFTAG_PREDICTOR
Definition: tiff.h:278
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
static const WCHAR sp[]
Definition: suminfo.c:288
char * tag
Definition: main.c:59

Referenced by TIFFPredictorInit().

◆ swabHorAcc16()

static int swabHorAcc16 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 337 of file tif_predict.c.

338 {
339  uint16* wp = (uint16*) cp0;
340  tmsize_t wc = cc / 2;
341 
342  TIFFSwabArrayOfShort(wp, wc);
343  return horAcc16(tif, cp0, cc);
344 }
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
static int horAcc16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:348
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint32_t cc
Definition: isohybrid.c:75
unsigned short uint16
Definition: types.h:30

Referenced by PredictorSetupDecode().

◆ swabHorAcc32()

static int swabHorAcc32 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 372 of file tif_predict.c.

373 {
374  uint32* wp = (uint32*) cp0;
375  tmsize_t wc = cc / 4;
376 
377  TIFFSwabArrayOfLong(wp, wc);
378  return horAcc32(tif, cp0, cc);
379 }
unsigned int uint32
Definition: types.h:32
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
static int horAcc32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:383
uint32_t cc
Definition: isohybrid.c:75

Referenced by PredictorSetupDecode().

◆ swabHorDiff16()

static int swabHorDiff16 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 589 of file tif_predict.c.

590 {
591  uint16* wp = (uint16*) cp0;
592  tmsize_t wc = cc / 2;
593 
594  if( !horDiff16(tif, cp0, cc) )
595  return 0;
596 
597  TIFFSwabArrayOfShort(wp, wc);
598  return 1;
599 }
void TIFFSwabArrayOfShort(register uint16 *wp, tmsize_t n)
Definition: tif_swab.c:71
static int horDiff16(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:563
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
uint32_t cc
Definition: isohybrid.c:75
unsigned short uint16
Definition: types.h:30

Referenced by PredictorSetupEncode().

◆ swabHorDiff32()

static int swabHorDiff32 ( TIFF tif,
uint8 cp0,
tmsize_t  cc 
)
static

Definition at line 629 of file tif_predict.c.

630 {
631  uint32* wp = (uint32*) cp0;
632  tmsize_t wc = cc / 4;
633 
634  if( !horDiff32(tif, cp0, cc) )
635  return 0;
636 
637  TIFFSwabArrayOfLong(wp, wc);
638  return 1;
639 }
unsigned int uint32
Definition: types.h:32
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:65
void TIFFSwabArrayOfLong(register uint32 *lp, tmsize_t n)
Definition: tif_swab.c:103
uint32_t cc
Definition: isohybrid.c:75
static int horDiff32(TIFF *tif, uint8 *cp0, tmsize_t cc)
Definition: tif_predict.c:603

Referenced by PredictorSetupEncode().

◆ TIFFPredictorCleanup()

int TIFFPredictorCleanup ( TIFF tif)

Definition at line 857 of file tif_predict.c.

858 {
860 
861  assert(sp != 0);
862 
863  tif->tif_tagmethods.vgetfield = sp->vgetparent;
864  tif->tif_tagmethods.vsetfield = sp->vsetparent;
865  tif->tif_tagmethods.printdir = sp->printdir;
866  tif->tif_setupdecode = sp->setupdecode;
867  tif->tif_setupencode = sp->setupencode;
868 
869  return 1;
870 }
#define PredictorState(tif)
Definition: tif_predict.c:33
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:203
#define assert(x)
Definition: debug.h:53
TIFFPrintMethod printdir
Definition: tiffio.h:340
TIFFVGetMethod vgetfield
Definition: tiffio.h:339
TIFFVSetMethod vsetfield
Definition: tiffio.h:338
static const WCHAR sp[]
Definition: suminfo.c:288
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:160
TIFFBoolMethod tif_setupdecode
Definition: tiffiop.h:158

◆ TIFFPredictorInit()

int TIFFPredictorInit ( TIFF tif)

Definition at line 816 of file tif_predict.c.

817 {
819 
820  assert(sp != 0);
821 
822  /*
823  * Merge codec-specific tag information.
824  */
827  TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit",
828  "Merging Predictor codec-specific tags failed");
829  return 0;
830  }
831 
832  /*
833  * Override parent get/set field methods.
834  */
835  sp->vgetparent = tif->tif_tagmethods.vgetfield;
837  PredictorVGetField;/* hook for predictor tag */
838  sp->vsetparent = tif->tif_tagmethods.vsetfield;
840  PredictorVSetField;/* hook for predictor tag */
841  sp->printdir = tif->tif_tagmethods.printdir;
842  tif->tif_tagmethods.printdir =
843  PredictorPrintDir; /* hook for predictor tag */
844 
845  sp->setupdecode = tif->tif_setupdecode;
847  sp->setupencode = tif->tif_setupencode;
849 
850  sp->predictor = 1; /* default value */
851  sp->encodepfunc = NULL; /* no predictor routine */
852  sp->decodepfunc = NULL; /* no predictor routine */
853  return 1;
854 }
#define PredictorState(tif)
Definition: tif_predict.c:33
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:203
static const TIFFField predictFields[]
Definition: tif_predict.c:754
#define assert(x)
Definition: debug.h:53
thandle_t tif_clientdata
Definition: tiffiop.h:191
static int PredictorVGetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_predict.c:779
static int PredictorSetupDecode(TIFF *tif)
Definition: tif_predict.c:113
TIFFPrintMethod printdir
Definition: tiffio.h:340
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32 n)
Definition: tif_dirinfo.c:369
smooth NULL
Definition: ftsmooth.c:416
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define TIFFArrayCount(a)
Definition: tiffiop.h:267
static int PredictorSetupEncode(TIFF *tif)
Definition: tif_predict.c:195
static void PredictorPrintDir(TIFF *tif, FILE *fd, long flags)
Definition: tif_predict.c:797
TIFFVGetMethod vgetfield
Definition: tiffio.h:339
TIFFVSetMethod vsetfield
Definition: tiffio.h:338
static const WCHAR sp[]
Definition: suminfo.c:288
static int PredictorVSetField(TIFF *tif, uint32 tag, va_list ap)
Definition: tif_predict.c:759
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:160
TIFFBoolMethod tif_setupdecode
Definition: tiffiop.h:158

Variable Documentation

◆ predictFields

const TIFFField predictFields[]
static
Initial value:
= {
}
#define FIELD_PREDICTOR
Definition: tif_predict.c:752
smooth NULL
Definition: ftsmooth.c:416
#define TIFFTAG_PREDICTOR
Definition: tiff.h:278

Definition at line 754 of file tif_predict.c.

Referenced by TIFFPredictorInit().