LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
tif_pixarlog.c File Reference

Compand PixarLog samples and transfer zlib-compressed code streams. More...

#include "tiffiop.h"
#include "tif_predict.h"
#include "zlib.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for tif_pixarlog.c:

Go to the source code of this file.

Data Structures

struct  PixarLogState
 Own PixarLog companding tables predictor prefix and zlib progress. More...
 

Macros

#define TSIZE   2048 /* decode table size (11-bit tokens) */
 Count the 2048 eleven-bit code values.
 
#define TSIZEP1   2049 /* Plus one for slop */
 Include one repeated endpoint in decode tables.
 
#define ONE   1250 /* token value of 1.0 exactly */
 Select code 1250 for linear value one.
 
#define RATIO   1.004 /* nominal ratio for log part */
 Choose the nominal log-region step ratio.
 
#define CODE_MASK   0x7ff /* 11 bits. */
 Mask accumulated codes to eleven bits.
 
#define REPEAT(n, op)
 Repeat a statement n times, and at least once.
 
#define SCALE12   2048.0f
 Scale PICIO output by 2048.
 
#define CLAMP12(t)   (((t) < 3071) ? (int16_t)(uint16_t)(t) : (int16_t)3071)
 Cap positive PICIO output at 3071.
 
#define PLSTATE_INIT   1
 Mark dependency stream initialised.
 
#define PixarLogDecoderState(tif)   ((PixarLogState *)(tif)->tif_data)
 Borrow the handle-owned PixarLog decoder state.
 
#define PixarLogEncoderState(tif)   ((PixarLogState *)(tif)->tif_data)
 Borrow the handle-owned PixarLog encoder state.
 
#define PIXARLOGDATAFMT_UNKNOWN   -1
 Mark an application format not yet inferred or selected.
 
#define CLAMP(v)
 Map one float sixteen-bit or byte input to a companded code in its enclosing converter.
 
#define CLAMP(v)   From14[(v) >> 2]
 Map one float sixteen-bit or byte input to a companded code in its enclosing converter.
 
#define CLAMP(v)   (From8[(v)])
 Map one float sixteen-bit or byte input to a companded code in its enclosing converter.
 

Functions

static float PixarLogLoadFloatNativeUnaligned (const uint8_t *cp)
 Read one unaligned native-order float.
 
static void PixarLogStoreFloatNativeUnaligned (uint8_t *cp, float v)
 Write one unaligned native-order float.
 
static uint16_t PixarLogLoad16NativeUnaligned (const uint8_t *cp)
 Read one unaligned native-order sixteen-bit sample.
 
static void PixarLogStore16NativeUnaligned (uint8_t *cp, uint16_t v)
 Write one unaligned native-order sixteen-bit sample.
 
static void horizontalAccumulateF (uint16_t *wp, tmsize_t n, int stride, uint8_t *op, float *ToLinearF)
 Accumulate PixarLog prediction into float32 linear samples.
 
static void horizontalAccumulate12 (uint16_t *wp, tmsize_t n, int stride, uint8_t *op, float *ToLinearF)
 Accumulate PixarLog prediction into twelve-bit PICIO values scaled by 2048 and capped at 3071.
 
static void horizontalAccumulate16 (uint16_t *wp, tmsize_t n, int stride, uint8_t *op, uint16_t *ToLinear16)
 Accumulate PixarLog prediction into clipped unsigned sixteen-bit linear samples.
 
static void horizontalAccumulate11 (uint16_t *wp, tmsize_t n, int stride, uint8_t *op)
 Accumulate PixarLog prediction into raw eleven-bit code words in native uint16_t slots.
 
static void horizontalAccumulate8 (uint16_t *wp, tmsize_t n, int stride, unsigned char *op, unsigned char *ToLinear8)
 Accumulate PixarLog prediction into clipped unsigned eight-bit linear samples.
 
static void horizontalAccumulate8abgr (uint16_t *wp, tmsize_t n, int stride, unsigned char *op, unsigned char *ToLinear8)
 Accumulate PixarLog prediction into eight-bit ABGR bytes.
 
static int PixarLogMakeTables (TIFF *tif, PixarLogState *sp)
 Build linear/log companding tables for PixarLog sample formats.
 
static int PixarLogEncode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s)
 Compand and difference complete input rows then deflate their codes.
 
static int PixarLogDecode (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
 Inflate companded samples and convert complete PixarLog output rows.
 
static int PixarLogGuessDataFmt (TIFFDirectory *td)
 Infer the PixarLog user format from depth and sample format.
 
static tmsize_t multiply_ms (TIFF *tif, const char *module, tmsize_t m1, tmsize_t m2)
 Multiply positive buffer extents with signed-size checking.
 
static tmsize_t add_ms (tmsize_t m1, tmsize_t m2)
 Add positive buffer extents with signed overflow rejection.
 
static int PixarLogFixupTags (TIFF *tif)
 Accept PixarLog tag fixup without changes.
 
static int PixarLogSetupDecode (TIFF *tif)
 Allocate companded row storage and initialise PixarLog inflation.
 
static int PixarLogPreDecode (TIFF *tif, uint16_t s)
 Reset PixarLog inflation over the current raw strile.
 
static int PixarLogSetupEncode (TIFF *tif)
 Allocate PixarLog code staging and initialise zlib deflation.
 
static int PixarLogPreEncode (TIFF *tif, uint16_t s)
 Reset PixarLog deflation with the current raw output buffer.
 
static void horizontalDifferenceF (const uint8_t *ip, tmsize_t n, int stride, uint16_t *wp, uint16_t *FromLT2)
 Compand finite native float32 samples and difference eleven-bit codes.
 
static void horizontalDifference16 (const uint8_t *ip, tmsize_t n, int stride, unsigned short *wp, uint16_t *From14)
 Compand native unsigned sixteen-bit samples and difference eleven-bit codes.
 
static void horizontalDifference8 (unsigned char *ip, tmsize_t n, int stride, unsigned short *wp, uint16_t *From8)
 Compand unsigned eight-bit samples and difference eleven-bit codes.
 
static int PixarLogPostEncode (TIFF *tif)
 Finish PixarLog deflation and flush encoded output.
 
static void PixarLogClose (TIFF *tif)
 Present initialised PixarLog directory metadata as unsigned eight-bit samples.
 
static void PixarLogCleanup (TIFF *tif)
 Restore PixarLog method chains and release companding storage.
 
static int PixarLogVSetField (TIFF *tif, uint32_t tag, va_list ap)
 Set PixarLog quality or user data format and update directory sizes.
 
static int PixarLogVGetField (TIFF *tif, uint32_t tag, va_list ap)
 Retrieve PixarLog quality or format or delegate another query.
 
static uint64_t PixarLogGetMaxCompressionRatio (TIFF *tif)
 Report a conservative PixarLog expansion allocation heuristic.
 
int TIFFInitPixarLog (TIFF *tif, int scheme)
 Install PixarLog codec state methods and companding tables.
 

Variables

static float Fltsize
 Scale low-range float lookup indices.
 
static float LogK1
 Scale logarithmic float companding.
 
static float LogK2
 Normalise logarithmic float companding.
 
static const TIFFField pixarlogFields []
 Define PixarLog format and quality pseudo-tags.
 

Detailed Description

Compand PixarLog samples and transfer zlib-compressed code streams.

Definition in file tif_pixarlog.c.