|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Compress logarithmic luminance and packed LogLuv pixel rows. More...
Files | |
| file | uvcode.h |
| Preserve the historical LogLuv chromaticity-bin table. | |
Data Structures | |
| struct | logLuvState |
| Own SGILog translation pixels and selected format conversion. More... | |
Macros | |
| #define | DecoderState(tif) ((LogLuvState *)(tif)->tif_data) |
| Borrow handle-owned SGILog decode state. | |
| #define | EncoderState(tif) ((LogLuvState *)(tif)->tif_data) |
| Borrow handle-owned SGILog encode state. | |
| #define | SGILOGDATAFMT_UNKNOWN -1 |
| Mark a user representation not yet inferred. | |
| #define | MINRUN 4 /* minimum run length */ |
| Choose four pixels as the minimum byte-plane run. | |
| #define | U_NEU 0.210526316 |
| Select neutral u-prime chromaticity. | |
| #define | V_NEU 0.473684211 |
| Select neutral v-prime chromaticity. | |
| #define | UVSCALE 410. |
| Scale uniform eight-bit chromaticity for LogLuv32. | |
| #define | M_LN2 0.69314718055994530942 |
| Supply the natural logarithm of two when absent. | |
| #define | M_PI 3.14159265358979323846 |
| Supply pi when absent. | |
| #define | TIFF_RAND_MAX 32767 |
| Limit SGILog pseudo-random output to fifteen bits. | |
| #define | NANGLES 100 |
| Partition the gamut perimeter into one hundred hue angles. | |
| #define | uv2ang(u, v) |
| Map finite chromaticity to a bounded hue lookup angle. | |
| #define | PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f)) |
| Combine directory format fields for a local inference switch. | |
| #define | PACK(a, b) (((a) << 3) | (b)) |
| Combine directory format fields for a local inference switch. | |
Typedefs | |
| typedef struct logLuvState | LogLuvState |
| Name the SGILog codec-owned translation state. | |
Functions | |
| static int | LogLuvReserve (TIFF *tif, uint8_t **opp, tmsize_t *occ, tmsize_t need) |
Flush the raw data buffer when fewer than need bytes remain. | |
| static int | LogLuvFits (TIFF *tif, const char *module, const uint8_t *op, tmsize_t need) |
Verify that need bytes fit before the raw buffer end. | |
| static int | LogL16Decode (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) |
| Decode two compressed luminance byte planes and translate one row. | |
| static int | LogLuvDecode24 (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) |
| Decode three stored bytes per packed colour pixel and translate one row. | |
| static int | LogLuvDecode32 (TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) |
| Decode four compressed colour byte planes and translate one row. | |
| static int | LogLuvDecodeStrip (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Decode complete SGILog strip rows through the selected row callback. | |
| static int | LogLuvDecodeTile (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Decode complete SGILog tile rows through the selected row callback. | |
| static int | LogL16Encode (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Translate one input row and emit luminance byte-plane runs. | |
| static int | LogLuvEncode24 (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Translate one input row and emit three-byte packed colour pixels. | |
| static int | LogLuvEncode32 (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Translate one input row and emit colour byte-plane runs. | |
| static int | LogLuvEncodeStrip (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Encode complete SGILog strip rows through the selected row callback. | |
| static int | LogLuvEncodeTile (TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) |
| Encode complete SGILog tile rows through the selected row callback. | |
| static uint32_t | _TIFFRand (void) |
| Advance the shared SGILog pseudo-random dither generator. | |
| static int | tiff_itrunc (double x, int m) |
| Quantise a finite value with optional shared random dithering. | |
| static float | LogLuvLoadFloatNativeUnaligned (const uint8_t *cp) |
| Read one native-order float through unaligned bytes. | |
| static void | LogLuvStoreFloatNativeUnaligned (uint8_t *cp, float v) |
| Write one native-order float through unaligned bytes. | |
| static int16_t | LogLuvLoad16NativeUnaligned (const uint8_t *cp) |
| Read one native-order signed sixteen-bit value through unaligned bytes. | |
| static void | LogLuvStore16NativeUnaligned (uint8_t *cp, int16_t v) |
| Write one native-order signed sixteen-bit value through unaligned bytes. | |
| static uint32_t | LogLuvLoad32NativeUnaligned (const uint8_t *cp) |
| Read one native-order unsigned thirty-two-bit value through unaligned bytes. | |
| static void | LogLuvStore32NativeUnaligned (uint8_t *cp, uint32_t v) |
| Write one native-order unsigned thirty-two-bit value through unaligned bytes. | |
| static void | L16toL16 (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Copy encoded luminance words from staging to native caller bytes. | |
| static void | L16fromL16 (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Copy native caller luminance words into staging. | |
| static void | LuvRawToRaw (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Copy packed LogLuv words from staging to native caller bytes. | |
| static void | LuvRawFromRaw (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Copy native caller LogLuv words into staging. | |
| static void | L16toY (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogL16 values to native float luminance. | |
| static void | L16toGry (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogL16 values to clipped gamma-two grayscale bytes. | |
| static void | L16fromY (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Quantise native float luminance into staged LogL16 codes. | |
| static int | oog_encode (double u, double v) |
| Map out-of-gamut chromaticity to a hue-matched boundary bin. | |
| static void | Luv24toXYZ (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogLuv24 codes to native float XYZ triplets. | |
| static void | Luv24toLuv48 (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogLuv24 codes to native signed Luv triplets. | |
| static void | Luv24toRGB (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogLuv24 codes to clipped gamma-two RGB bytes. | |
| static void | Luv24fromXYZ (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Quantise native float XYZ triplets into LogLuv24 staging. | |
| static void | Luv24fromLuv48 (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Quantise native signed Luv triplets into LogLuv24 staging. | |
| static void | Luv32toXYZ (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogLuv32 codes to native float XYZ triplets. | |
| static void | Luv32toLuv48 (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogLuv32 codes to native signed Luv triplets. | |
| static void | Luv32toRGB (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Convert staged LogLuv32 codes to clipped gamma-two RGB bytes. | |
| static void | Luv32fromXYZ (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Quantise native float XYZ triplets into LogLuv32 staging. | |
| static void | Luv32fromLuv48 (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Quantise native signed Luv triplets into LogLuv32 staging. | |
| static void | _logLuvNop (LogLuvState *sp, uint8_t *op, tmsize_t n) |
| Perform no SGILog pixel translation. | |
| static int | LogL16GuessDataFmt (TIFFDirectory *td) |
| Infer grayscale SGILog input format from directory fields. | |
| static tmsize_t | multiply_ms (TIFF *tif, const char *module, tmsize_t m1, tmsize_t m2) |
| Multiply translation-buffer extents with signed-size checking. | |
| static int | LogL16InitState (TIFF *tif) |
| Validate grayscale SGILog format and allocate translation pixels. | |
| static int | LogLuvGuessDataFmt (TIFFDirectory *td) |
| Infer colour SGILog input format from directory fields. | |
| static int | LogLuvInitState (TIFF *tif) |
| Validate contiguous LogLuv format and allocate packed translation pixels. | |
| static int | LogLuvFixupTags (TIFF *tif) |
| Accept SGILog tag fixup without changes. | |
| static int | LogLuvSetupDecode (TIFF *tif) |
| Select SGILog row decoding and application-format conversion. | |
| static int | LogLuvSetupEncode (TIFF *tif) |
| Select SGILog row encoding and input conversion. | |
| static void | LogLuvClose (TIFF *tif) |
| Normalise encoded SGILog directory sample metadata before writing. | |
| static void | LogLuvCleanup (TIFF *tif) |
| Restore SGILog tag methods and release translation/codec state. | |
| static int | LogLuvVSetField (TIFF *tif, uint32_t tag, va_list ap) |
| Set SGILog user format or dithering and update representation metadata. | |
| static int | LogLuvVGetField (TIFF *tif, uint32_t tag, va_list ap) |
| Retrieve SGILog user format or delegate another tag query. | |
| int | TIFFInitSGILog (TIFF *tif, int scheme) |
| Allocate SGILog codec state and install row dispatch and tag hooks. | |
Variables | ||
| void(* | logLuvState::tfunc )(LogLuvState *, uint8_t *, tmsize_t) | |
| Translate pixels between caller bytes and packed codec staging. | ||
| static const TIFFField | LogLuvFields [] | |
| Define SGILog user format and encoding-method pseudo-tags. | ||
| struct { | ||
| float ustart | ||
| Lower u-prime boundary of this row. More... | ||
| short nus | ||
| Count horizontal bins in this chromaticity row. More... | ||
| short ncum | ||
| Count all bins preceding this row. More... | ||
| } | uv_row [UV_NVS] | |
| Map each v-prime row to its u-prime start and bin index interval. | ||
Compress logarithmic luminance and packed LogLuv pixel rows.
| #define DecoderState | ( | tif | ) | ((LogLuvState *)(tif)->tif_data) |
| #define EncoderState | ( | tif | ) | ((LogLuvState *)(tif)->tif_data) |
| #define M_LN2 0.69314718055994530942 |
| #define M_PI 3.14159265358979323846 |
| #define MINRUN 4 /* minimum run length */ |
| #define NANGLES 100 |
| #define PACK | ( | a, | |
| b | |||
| ) | (((a) << 3) | (b)) |
Combine directory format fields for a local inference switch.
The grayscale three-argument form takes [in] s sample count, [in] b bit depth, and [in] f sample format. The colour two-argument form takes [in] a bit depth and [in] b sample format. These function-local macros share a name; the reference displays the last parsed argument shape. Each argument is evaluated once; each macro is undefined at the end of its function.
| #define PACK | ( | s, | |
| b, | |||
| f | |||
| ) | (((b) << 6) | ((s) << 3) | (f)) |
Combine directory format fields for a local inference switch.
The grayscale three-argument form takes [in] s sample count, [in] b bit depth, and [in] f sample format. The colour two-argument form takes [in] a bit depth and [in] b sample format. These function-local macros share a name; the reference displays the last parsed argument shape. Each argument is evaluated once; each macro is undefined at the end of its function.
| #define SGILOGDATAFMT_UNKNOWN -1 |
Mark a user representation not yet inferred.
Value -1 in LogLuvState::user_datafmt. Set by TIFFInitSGILog and returned by the format guessers; setup then infers the format from the directory and fails if none matches.
| #define TIFF_RAND_MAX 32767 |
| #define U_NEU 0.210526316 |
Select neutral u-prime chromaticity.
Define the neutral CIE u-prime chromaticity used by LogLuv.
Value 4/19 (0.210526316), the CIE 1976 u' of the equal-energy white point. Substituted for chromaticity of zero-luminance or invalid input. Defined here only if UVSCALE is not already defined by tiffio.h.
| #define uv2ang | ( | u, | |
| v | |||
| ) |
Map finite chromaticity to a bounded hue lookup angle.
Evaluates u and v once each and returns the atan2 hue around the neutral point (U_NEU, V_NEU), scaled to a double in [0, NANGLES). Undefined again after oog_encode.
| [in] | u | Finite u-prime chromaticity coordinate. |
| [in] | v | Finite v-prime chromaticity coordinate. |
| #define UVSCALE 410. |
Scale uniform eight-bit chromaticity for LogLuv32.
Define the chromaticity scale factor for 32-bit LogLuv encoding.
Value 410: multiplies u' and v' into the 8-bit fields of a LogLuv32 pixel (u' and v' are below 0.62, so the product fits in 8 bits). Defined here only if not already defined by tiffio.h.
| #define V_NEU 0.473684211 |
Select neutral v-prime chromaticity.
Define the neutral CIE v-prime chromaticity used by LogLuv.
Value 9/19 (0.473684211), the CIE 1976 v' of the equal-energy white point. Substituted for chromaticity of zero-luminance or invalid input. Defined here only if UVSCALE is not already defined by tiffio.h.
| typedef struct logLuvState LogLuvState |
|
static |
Perform no SGILog pixel translation.
Ignores all arguments without touching buffers or state. Installed as the default tfunc by TIFFInitSGILog; decode/encode setup replaces it with a converter for any user format other than the native ones (SGILOGDATAFMT_16BIT for LogL, SGILOGDATAFMT_RAW for LogLuv), which the coders copy directly. No status result.
| [in] | sp | Unused codec state. |
| [in] | op | Unused caller pixel bytes. |
| [in] | n | Unused pixel count. |
Definition at line 2235 of file tif_luv.c.
Referenced by TIFFInitSGILog().
|
static |
Advance the shared SGILog pseudo-random dither generator.
Seeds a static counter from time when zero, advances a fixed linear-congruential recurrence and returns fifteen output bits. State is process-global and unsynchronised; serialise all calls/dithered conversions across threads. No heap allocation, TIFF diagnostics, client I/O, returned storage or ownership transfer.
Definition at line 1163 of file tif_luv.c.
References TIFF_RAND_MAX.
Referenced by tiff_itrunc().
|
static |
Copy native caller luminance words into staging.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Copies n native int16_t words one at a time through the unaligned load helper; no conversion, dithering or shared state. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth is not used. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1383 of file tif_luv.c.
References LogLuvLoad16NativeUnaligned(), and logLuvState::tbuf.
Referenced by LogL16Encode().
|
static |
Quantise native float luminance into staged LogL16 codes.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Encodes one native float per pixel (unaligned input allowed) with LogL16fromY. When encode_meth is SGILOGENCODE_RANDITHER, dithering advances the process-global, unsynchronised _TIFFRand state; serialise such calls across threads. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth selects truncation or random dithering. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1522 of file tif_luv.c.
References logLuvState::encode_meth, LogL16fromY(), LogLuvLoadFloatNativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvSetupEncode().
|
static |
Convert staged LogL16 values to clipped gamma-two grayscale bytes.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Decodes each code with LogL16toY and writes one byte per pixel as 256*sqrt(Y), clipped to 0..255. Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1490 of file tif_luv.c.
References LogL16toY(), and logLuvState::tbuf.
Referenced by LogLuvSetupDecode().
|
static |
Copy encoded luminance words from staging to native caller bytes.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Copies n native int16_t words one at a time through the unaligned store helper; no conversion, dithering or shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1356 of file tif_luv.c.
References LogLuvStore16NativeUnaligned(), and logLuvState::tbuf.
Referenced by LogL16Decode().
|
static |
Convert staged LogL16 values to native float luminance.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Decodes each code with LogL16toY and stores one native float per pixel; unaligned output is allowed. Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1464 of file tif_luv.c.
References LogL16toY(), LogLuvStoreFloatNativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvSetupDecode().
Decode two compressed luminance byte planes and translate one row.
Requires successful setup, sample zero, positive pixel_size and a complete nonnegative pixel extent; a translation buffer shorter than the row is diagnosed and rejected. Reconstructs staging from two run-length coded byte planes, then copies encoded values or invokes tfunc. Compressed runs are clipped to the requested pixel count. Short input diagnoses, commits consumed raw cursors and zeroes the occ caller bytes, as does a too-short translation buffer; output conversion is deferred until staging succeeds. State/tbuf/raw progress can change on failure. No allocation, direct client I/O, shared-state access or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [out] | op | Caller output for occ/pixel_size pixels in the selected user format. |
| [in] | occ | Nonnegative whole-pixel output byte count. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 335 of file tif_luv.c.
References _TIFFmemset(), DecoderState, L16toL16(), SGILOGDATAFMT_16BIT, TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SSIZE_FORMAT, and TIFFErrorExtR().
Referenced by LogLuvSetupDecode().
Translate one input row and emit luminance byte-plane runs.
Requires successful setup, sample zero, positive pixel_size and complete nonnegative pixel input; a translation buffer shorter than the row is diagnosed and rejected. Copies native encoded/raw input or invokes tfunc, then writes cached output and flushes as needed through LogLuvReserve(). Before each write, LogLuvFits() checks the space left in the raw buffer, so a buffer too small for a literal packet (up to 128 bytes) or run is diagnosed and rejected instead of overrun. Input remains caller-owned and unchanged; translation may mutate shared dithering state, requiring cross-thread serialisation. Flush errors diagnose where detected and can leave partial stream/file progress. No rollback or ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle and shared dithering operations. |
| [in] | bp | Caller input of cc bytes. |
| [in] | cc | Nonnegative byte count of whole user pixels. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 739 of file tif_luv.c.
References EncoderState, L16fromL16(), LogLuvFits(), LogLuvReserve(), MINRUN, SGILOGDATAFMT_16BIT, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdatasize, and TIFFErrorExtR().
Referenced by LogLuvSetupEncode().
|
static |
Infer grayscale SGILog input format from directory fields.
Recognises one-sample native float32, sixteen-bit encoded luminance and byte grayscale under the supported sample formats. Pure directory read with no allocation, I/O, diagnostics, mutation or ownership transfer.
| [in] | td | Borrowed directory metadata. |
Definition at line 2253 of file tif_luv.c.
References PACK, SAMPLEFORMAT_IEEEFP, SAMPLEFORMAT_INT, SAMPLEFORMAT_UINT, SAMPLEFORMAT_VOID, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_8BIT, SGILOGDATAFMT_FLOAT, SGILOGDATAFMT_UNKNOWN, TIFFDirectory::td_bitspersample, TIFFDirectory::td_sampleformat, and TIFFDirectory::td_samplesperpixel.
Referenced by LogL16InitState().
|
static |
Validate grayscale SGILog format and allocate translation pixels.
Requires PHOTOMETRIC_LOGL and fresh/released translation storage. Validates one sample, infers format if needed, sets pixel_size and chooses tile or bounded-strip pixel capacity. Checked multiplication guards allocation extent and reports an overflow once; Ext allocation becomes codec-owned. Failure diagnoses after cached state can change. Repeated success can overwrite an unreleased tbuf. No payload I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
Definition at line 2311 of file tif_luv.c.
References _TIFFfreeExt(), _TIFFmallocExt(), DecoderState, isTiled, LogL16GuessDataFmt(), multiply_ms(), PHOTOMETRIC_LOGL, logLuvState::pixel_size, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_8BIT, SGILOGDATAFMT_FLOAT, SGILOGDATAFMT_UNKNOWN, logLuvState::tbuf, logLuvState::tbuflen, tiff::tif_dir, TIFFErrorExtR(), and logLuvState::user_datafmt.
Referenced by LogLuvSetupDecode(), and LogLuvSetupEncode().
|
static |
Restore SGILog tag methods and release translation/codec state.
Frees owned tbuf and outer Ext allocation, clears tif_data, restores saved tag hooks and installs default compression methods. Invalidates codec-owned views. Does not normalise metadata, finish/flush payload, close the handle or return status.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
Definition at line 2797 of file tif_luv.c.
References _TIFFfreeExt(), _TIFFSetDefaultCompressionState(), logLuvState::tbuf, tiff::tif_data, tiff::tif_tagmethods, TIFFTagMethods::vgetfield, logLuvState::vgetparent, TIFFTagMethods::vsetfield, and logLuvState::vsetparent.
Referenced by TIFFInitSGILog().
|
static |
Normalise encoded SGILog directory sample metadata before writing.
If encoder_state is set, directly changes SamplesPerPixel to one for LogL or three for LogLuv, BitsPerSample to sixteen and SampleFormat to signed. This affects advertised directory representation regardless of user format. When SamplesPerPixel or BitsPerSample actually changes, first frees and unsets ColorMap, TransferFunction (clearing their recorded lengths), SMinSampleValue and SMaxSampleValue, whose sizes depend on those values, so the directory writer cannot read past them. Direct assignment bypasses the TIFFSetField() checks that would refuse these changes once writing has begun. Does not free state, flush payload, close the handle or return status; no ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
Definition at line 2731 of file tif_luv.c.
References _TIFFfreeExt(), logLuvState::encoder_state, FIELD_COLORMAP, FIELD_SMAXSAMPLEVALUE, FIELD_SMINSAMPLEVALUE, FIELD_TRANSFERFUNCTION, PHOTOMETRIC_LOGL, SAMPLEFORMAT_INT, TIFFDirectory::td_bitspersample, TIFFDirectory::td_colormap, TIFFDirectory::td_colormap_alloc, TIFFDirectory::td_colormap_count, TIFFDirectory::td_photometric, TIFFDirectory::td_sampleformat, TIFFDirectory::td_samplesperpixel, TIFFDirectory::td_smaxsamplevalue, TIFFDirectory::td_sminsamplevalue, TIFFDirectory::td_transferfunction, TIFFDirectory::td_transferfunction_count, tiff::tif_data, tiff::tif_dir, and TIFFClrFieldBit.
Referenced by TIFFInitSGILog().
Decode three stored bytes per packed colour pixel and translate one row.
Requires successful setup, sample zero, positive pixel_size and a complete nonnegative pixel extent; a translation buffer shorter than the row is diagnosed and rejected. Unpacks fixed three-byte pixels into staging (there is no run coding), then copies raw values or invokes tfunc. Short input diagnoses, commits consumed raw cursors and zeroes the occ caller bytes, as does a too-short translation buffer. State/tbuf/raw progress can change on failure. No allocation, direct client I/O, shared-state access or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [out] | op | Caller output for occ/pixel_size pixels in the selected user format. |
| [in] | occ | Nonnegative whole-pixel output byte count. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 437 of file tif_luv.c.
References _TIFFmemset(), DecoderState, LuvRawToRaw(), SGILOGDATAFMT_RAW, TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SSIZE_FORMAT, and TIFFErrorExtR().
Referenced by LogLuvSetupDecode().
Decode four compressed colour byte planes and translate one row.
Requires successful setup, sample zero, positive pixel_size and a complete nonnegative pixel extent; a translation buffer shorter than the row is diagnosed and rejected. Reconstructs staging from four run-length coded byte planes, then copies raw values or invokes tfunc. Compressed runs are clipped to the requested pixel count. Short input diagnoses, commits consumed raw cursors and zeroes the occ caller bytes, as does a too-short translation buffer; output conversion is deferred until staging succeeds. State/tbuf/raw progress can change on failure. No allocation, direct client I/O, shared-state access or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [out] | op | Caller output for occ/pixel_size pixels in the selected user format. |
| [in] | occ | Nonnegative whole-pixel output byte count. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 516 of file tif_luv.c.
References _TIFFmemset(), DecoderState, LuvRawToRaw(), SGILOGDATAFMT_RAW, TIFFDirectory::td_row, tiff::tif_dir, tiff::tif_rawcc, tiff::tif_rawcp, TIFF_SSIZE_FORMAT, and TIFFErrorExtR().
Referenced by LogLuvSetupDecode().
Decode complete SGILog strip rows through the selected row callback.
Queries the positive decoded scanline byte size, rejects fractional requests and dispatches one row at a time. Requires nonnegative complete-row extent and a selected callback. Continues for nonzero row status; installed SGILog row decoders use zero/one. A zero row size or fractional request zeroes all cc caller bytes; a row failure zeroes the failed row and every later one. Earlier rows, raw state and codec/file progress remain on failure. No result allocation or ownership transfer; row decoder effects apply.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [out] | bp | Caller output of cc bytes. |
| [in] | cc | Byte count; a nonnegative multiple of TIFFScanlineSize. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 619 of file tif_luv.c.
References _TIFFmemset(), tiff::tif_decoderow, TIFFErrorExtR(), and TIFFScanlineSize().
Referenced by TIFFInitSGILog().
Decode complete SGILog tile rows through the selected row callback.
Queries the positive decoded tile-row byte size, rejects fractional requests and dispatches one row at a time. Requires nonnegative complete-row extent and a selected callback. Continues for nonzero row status; installed SGILog row decoders use zero/one. A zero row size or fractional request zeroes all cc caller bytes; a row failure zeroes the failed row and every later one. Earlier rows, raw state and codec/file progress remain on failure. No result allocation or ownership transfer; row decoder effects apply.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [out] | bp | Caller output of cc bytes. |
| [in] | cc | Byte count; a nonnegative multiple of TIFFTileRowSize. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 679 of file tif_luv.c.
References _TIFFmemset(), tiff::tif_decoderow, TIFFErrorExtR(), and TIFFTileRowSize().
Referenced by TIFFInitSGILog().
Translate one input row and emit three-byte packed colour pixels.
Requires successful setup, sample zero, positive pixel_size and complete nonnegative pixel input; a translation buffer shorter than the row is diagnosed and rejected. Copies native encoded/raw input or invokes tfunc, then writes cached output and flushes as needed. A raw buffer that cannot hold three bytes after a flush is diagnosed and rejected instead of overrun. Input remains caller-owned and unchanged; translation may mutate the shared _TIFFRand dithering state and lazily fill the shared oog_encode table, requiring cross-thread serialisation. Flush errors diagnose where detected and can leave partial stream/file progress. No rollback or ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle and shared dithering operations. |
| [in] | bp | Caller input of cc bytes. |
| [in] | cc | Nonnegative byte count of whole user pixels. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 866 of file tif_luv.c.
References EncoderState, LogLuvFits(), LogLuvReserve(), LuvRawFromRaw(), SGILOGDATAFMT_RAW, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdatasize, and TIFFErrorExtR().
Referenced by LogLuvSetupEncode().
Translate one input row and emit colour byte-plane runs.
Requires successful setup, sample zero, positive pixel_size and complete nonnegative pixel input; a translation buffer shorter than the row is diagnosed and rejected. Copies native encoded/raw input or invokes tfunc, then writes cached output and flushes as needed through LogLuvReserve(). Before each write, LogLuvFits() checks the space left in the raw buffer, so a buffer too small for a literal packet (up to 128 bytes) or run is diagnosed and rejected instead of overrun. Input remains caller-owned and unchanged; translation may mutate shared dithering state, requiring cross-thread serialisation. Flush errors diagnose where detected and can leave partial stream/file progress. No rollback or ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle and shared dithering operations. |
| [in] | bp | Caller input of cc bytes. |
| [in] | cc | Nonnegative byte count of whole user pixels. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 938 of file tif_luv.c.
References EncoderState, LogLuvFits(), LogLuvReserve(), LuvRawFromRaw(), MINRUN, SGILOGDATAFMT_RAW, tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdatasize, and TIFFErrorExtR().
Referenced by LogLuvSetupEncode().
Encode complete SGILog strip rows through the selected row callback.
Queries the positive decoded scanline byte size, rejects fractional requests and dispatches one row at a time. Requires nonnegative complete-row extent and a selected callback. Continues only for callback status exactly one. Earlier rows, raw state and codec/file progress remain on failure. No result allocation or ownership transfer; row converter/dither/I/O effects apply.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle and shared dithering operations. |
| [in] | bp | Caller input of cc bytes. |
| [in] | cc | Byte count; a nonnegative multiple of TIFFScanlineSize. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 1063 of file tif_luv.c.
References tiff::tif_encoderow, TIFFErrorExtR(), and TIFFScanlineSize().
Referenced by TIFFInitSGILog().
Encode complete SGILog tile rows through the selected row callback.
Queries the positive decoded tile-row byte size, rejects fractional requests and dispatches one row at a time. Requires nonnegative complete-row extent and a selected callback. Continues only for callback status exactly one. Earlier rows, raw state and codec/file progress remain on failure. No result allocation or ownership transfer; row converter/dither/I/O effects apply.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle and shared dithering operations. |
| [in] | bp | Caller input of cc bytes. |
| [in] | cc | Byte count; a nonnegative multiple of TIFFTileRowSize. |
| [in] | s | Sample zero; row methods assert this for contiguous/gray coding. |
Definition at line 1108 of file tif_luv.c.
References tiff::tif_encoderow, TIFFErrorExtR(), and TIFFTileRowSize().
Referenced by TIFFInitSGILog().
Verify that need bytes fit before the raw buffer end.
One loop iteration of the run-length encoders can emit a 128-byte literal block followed by a 2-byte run; a raw data buffer smaller than that used to be silently overrun. This helper reports an error via TIFFErrorExtR() and returns zero instead. It does not write to the raw buffer or modify any cursor.
| [in] | tif | Live SGILog handle; only tif_rawdata and tif_rawdatasize are read. |
| [in] | module | Borrowed diagnostic prefix string. |
| [in] | op | Borrowed pointer to the current output cursor within the raw buffer. |
| [in] | need | Number of bytes the next write unit requires. |
need bytes fit between op and the buffer end; zero otherwise (error already reported). Definition at line 290 of file tif_luv.c.
References tiff::tif_rawdata, tiff::tif_rawdatasize, TIFF_SSIZE_FORMAT, and TIFFErrorExtR().
Referenced by LogL16Encode(), LogLuvEncode24(), and LogLuvEncode32().
|
static |
Accept SGILog tag fixup without changes.
No allocation, I/O, diagnostics, state or ownership effects.
| [in] | tif | Unused SGILog handle. |
Definition at line 2523 of file tif_luv.c.
Referenced by TIFFInitSGILog().
|
static |
Infer colour SGILog input format from directory fields.
Recognises float XYZ, sixteen-bit Luv triples, byte RGB or one-sample packed raw words, checking the relevant sample-count combinations. Pure directory read with no allocation, I/O, diagnostics, mutation or ownership transfer.
| [in] | td | Borrowed directory metadata. |
Definition at line 2382 of file tif_luv.c.
References PACK, SAMPLEFORMAT_IEEEFP, SAMPLEFORMAT_INT, SAMPLEFORMAT_UINT, SAMPLEFORMAT_VOID, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_8BIT, SGILOGDATAFMT_FLOAT, SGILOGDATAFMT_RAW, SGILOGDATAFMT_UNKNOWN, TIFFDirectory::td_bitspersample, TIFFDirectory::td_sampleformat, and TIFFDirectory::td_samplesperpixel.
Referenced by LogLuvInitState().
|
static |
Validate contiguous LogLuv format and allocate packed translation pixels.
Requires PHOTOMETRIC_LOGLUV, contiguous layout and fresh/released translation storage. Infers supported XYZ/Luv48/raw/RGB format, caches pixel bytes and allocates checked tile/bounded-strip uint32_t staging; an extent overflow is reported once. Failure diagnoses after state can change; repeated setup can overwrite unreleased storage. No payload I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
Definition at line 2452 of file tif_luv.c.
References _TIFFfreeExt(), _TIFFmallocExt(), DecoderState, isTiled, LogLuvGuessDataFmt(), multiply_ms(), PHOTOMETRIC_LOGLUV, logLuvState::pixel_size, PLANARCONFIG_CONTIG, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_8BIT, SGILOGDATAFMT_FLOAT, SGILOGDATAFMT_RAW, SGILOGDATAFMT_UNKNOWN, logLuvState::tbuf, logLuvState::tbuflen, tiff::tif_dir, TIFFErrorExtR(), and logLuvState::user_datafmt.
Referenced by LogLuvSetupDecode(), and LogLuvSetupEncode().
|
static |
Read one native-order signed sixteen-bit value through unaligned bytes.
Uses fixed-size memcpy on sufficient live byte storage. No byte-order conversion, allocation, I/O, diagnostics, retained pointer or ownership transfer.
| [in] | cp | Readable bytes for one native value; unaligned allowed. |
Definition at line 1280 of file tif_luv.c.
Referenced by L16fromL16(), Luv24fromLuv48(), and Luv32fromLuv48().
|
static |
Read one native-order unsigned thirty-two-bit value through unaligned bytes.
Uses fixed-size memcpy on sufficient live byte storage. No byte-order conversion, allocation, I/O, diagnostics, retained pointer or ownership transfer.
| [in] | cp | Readable bytes for one native value; unaligned allowed. |
Definition at line 1316 of file tif_luv.c.
Referenced by LuvRawFromRaw().
|
static |
Read one native-order float through unaligned bytes.
Uses fixed-size memcpy on sufficient live byte storage. No byte-order conversion, allocation, I/O, diagnostics, retained pointer or ownership transfer.
| [in] | cp | Readable bytes for one native value; unaligned allowed. |
Definition at line 1245 of file tif_luv.c.
Referenced by L16fromY(), Luv24fromXYZ(), and Luv32fromXYZ().
Flush the raw data buffer when fewer than need bytes remain.
If the local remaining count (*occ) already satisfies need, returns immediately with no I/O. Otherwise publishes the local cursor into tif->tif_rawcp / tif->tif_rawcc, calls TIFFFlushData1(), and reloads *opp / *occ from the refreshed handle state. A successful flush can never provide more than tif_rawdatasize bytes, so the caller must still verify capacity via LogLuvFits() before writing. On flush failure *opp and *occ are not reloaded; diagnostics are emitted by TIFFFlushData1. No allocation occurs; opp and occ are borrowed in/out pointers.
| [in,out] | tif | Live SGILog handle whose raw cursor and count may change across the flush. |
| [in,out] | opp | Borrowed pointer to the encoder's local raw output cursor; updated on successful flush. |
| [in,out] | occ | Borrowed pointer to the local remaining byte count; updated on successful flush. |
| [in] | need | Minimum bytes the caller requires before writing. |
need bytes or the flush succeeded (a successful flush still does not guarantee need bytes; the caller must re-check, e.g. via LogLuvFits()); zero if TIFFFlushData1() failed. Definition at line 258 of file tif_luv.c.
References tiff::tif_rawcc, tiff::tif_rawcp, tiff::tif_rawdatasize, and TIFFFlushData1().
Referenced by LogL16Encode(), LogLuvEncode24(), and LogLuvEncode32().
|
static |
Select SGILog row decoding and application-format conversion.
Disables ordinary postdecode swapping, validates LogL/LogLuv photometric and allocates translation state through its initialiser. Selects 16-bit luminance, 24-bit raw-packed or 32-bit byte-plane row decoding and the appropriate conversion callback. Raw/encoded-luminance paths use explicit copies; some converter slots remain no-op. Failure can retain allocations and changed methods/postdecode for cleanup. No pixel I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
Definition at line 2546 of file tif_luv.c.
References _TIFFNoPostDecode(), COMPRESSION_SGILOG24, DecoderState, L16toGry(), L16toY(), LogL16Decode(), LogL16InitState(), LogLuvDecode24(), LogLuvDecode32(), LogLuvInitState(), Luv24toLuv48(), Luv24toRGB(), Luv24toXYZ(), Luv32toLuv48(), Luv32toRGB(), Luv32toXYZ(), PHOTOMETRIC_LOGL, PHOTOMETRIC_LOGLUV, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_8BIT, SGILOGDATAFMT_FLOAT, TIFFDirectory::td_compression, TIFFDirectory::td_photometric, tiff::tif_decoderow, tiff::tif_dir, tiff::tif_postdecode, and TIFFErrorExtR().
Referenced by LogLuvVSetField(), and TIFFInitSGILog().
|
static |
Select SGILog row encoding and input conversion.
Initialises LogL/LogLuv translation storage, chooses 16/24/32-bit row coding and supported float/encoded/raw input conversion, then marks encoder_state. Byte display input is not encodable here. Failure can retain allocation/method changes; diagnoses unsupported format/photometric. No pixel I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
Definition at line 2636 of file tif_luv.c.
References COMPRESSION_SGILOG24, EncoderState, L16fromY(), LogL16Encode(), LogL16InitState(), LogLuvEncode24(), LogLuvEncode32(), LogLuvInitState(), Luv24fromLuv48(), Luv24fromXYZ(), Luv32fromLuv48(), Luv32fromXYZ(), PHOTOMETRIC_LOGL, PHOTOMETRIC_LOGLUV, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_FLOAT, SGILOGDATAFMT_RAW, TIFFDirectory::td_compression, TIFFDirectory::td_photometric, tiff::tif_dir, tiff::tif_encoderow, and TIFFErrorExtR().
Referenced by TIFFInitSGILog().
|
static |
Write one native-order signed sixteen-bit value through unaligned bytes.
Uses fixed-size memcpy on sufficient live byte storage. No byte-order conversion, allocation, I/O, diagnostics, retained pointer or ownership transfer.
| [out] | cp | Writable bytes for one native value; unaligned allowed. |
| [in] | v | Value to store. |
Definition at line 1299 of file tif_luv.c.
Referenced by L16toL16(), Luv24toLuv48(), and Luv32toLuv48().
|
static |
Write one native-order unsigned thirty-two-bit value through unaligned bytes.
Uses fixed-size memcpy on sufficient live byte storage. No byte-order conversion, allocation, I/O, diagnostics, retained pointer or ownership transfer.
| [out] | cp | Writable bytes for one native value; unaligned allowed. |
| [in] | v | Value to store. |
Definition at line 1335 of file tif_luv.c.
Referenced by LuvRawToRaw().
|
static |
Write one native-order float through unaligned bytes.
Uses fixed-size memcpy on sufficient live byte storage. No byte-order conversion, allocation, I/O, diagnostics, retained pointer or ownership transfer.
| [out] | cp | Writable bytes for one native value; unaligned allowed. |
| [in] | v | Value to store. |
Definition at line 1263 of file tif_luv.c.
Referenced by L16toY(), Luv24toXYZ(), and Luv32toXYZ().
|
static |
Retrieve SGILog user format or delegate another tag query.
SGILOGDATAFMT consumes non-NULL int* and writes the cached format. SGILOGENCODE is not handled here and follows the parent getter contract, which can reject it. No output allocation or ownership transfer for the format.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [in] | tag | Codec pseudo-tag or delegated identifier. |
| [in,out] | ap | Live tag-specific va_list, consumed synchronously without retention. |
Definition at line 2954 of file tif_luv.c.
References tiff::tif_data, TIFFTAG_SGILOGDATAFMT, logLuvState::user_datafmt, and logLuvState::vgetparent.
Referenced by TIFFInitSGILog().
|
static |
Set SGILog user format or dithering and update representation metadata.
SGILOGDATAFMT consumes int and stores before validation; supported values change depth/sample format through nested TIFFSetField calls, with RAW additionally setting SamplesPerPixel one. The first nested failure returns zero, leaving earlier nested changes and the stored format in place. Recalculates tile/scanline caches. SGILOGENCODE consumes int and stores before rejecting values other than NODITHER/RANDITHER. Failed assignments can retain changed values/metadata; other tags delegate. No ownership transfer.
| [in,out] | tif | Non-NULL live SGILog handle with valid current geometry/state; serialise handle operations. |
| [in] | tag | Codec pseudo-tag or delegated identifier. |
| [in,out] | ap | Live tag-specific va_list, consumed synchronously without retention. |
Definition at line 2836 of file tif_luv.c.
References DecoderState, isTiled, LogLuvSetupDecode(), NOSTRIP, NOTILE, PHOTOMETRIC_LOGLUV, SAMPLEFORMAT_IEEEFP, SAMPLEFORMAT_INT, SAMPLEFORMAT_UINT, SGILOGDATAFMT_16BIT, SGILOGDATAFMT_8BIT, SGILOGDATAFMT_FLOAT, SGILOGDATAFMT_RAW, SGILOGENCODE_NODITHER, SGILOGENCODE_RANDITHER, TIFFDirectory::td_curstrip, TIFFDirectory::td_curtile, TIFFDirectory::td_photometric, TIFFDirectory::td_scanlinesize, TIFFDirectory::td_tilesize, tiff::tif_dir, tiff::tif_flags, tiff::tif_name, TIFF_CODERSETUP, TIFFErrorExtR(), TIFFScanlineSize(), TIFFSetField(), TIFFTAG_BITSPERSAMPLE, TIFFTAG_SAMPLEFORMAT, TIFFTAG_SAMPLESPERPIXEL, TIFFTAG_SGILOGDATAFMT, TIFFTAG_SGILOGENCODE, and TIFFTileSize().
Referenced by TIFFInitSGILog().
|
static |
Quantise native signed Luv triplets into LogLuv24 staging.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Encodes three native int16_t values per pixel (unaligned input allowed): L is clamped to the 10-bit range and u, v (scaled by 2^15) are encoded with uv_encode. When encode_meth is SGILOGENCODE_RANDITHER, dithering advances the process-global, unsynchronised _TIFFRand state. With either method, out-of-gamut chromaticity may lazily initialise the process-global, unsynchronised oog_encode table. Serialise such calls across threads. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth selects truncation or random dithering. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1938 of file tif_luv.c.
References logLuvState::encode_meth, LogLuvLoad16NativeUnaligned(), SGILOGENCODE_NODITHER, logLuvState::tbuf, tiff_itrunc(), U_NEU, uv_encode(), and V_NEU.
Referenced by LogLuvSetupEncode().
|
static |
Quantise native float XYZ triplets into LogLuv24 staging.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Encodes three native floats per pixel (unaligned input allowed) with LogLuv24fromXYZ. When encode_meth is SGILOGENCODE_RANDITHER, dithering advances the process-global, unsynchronised _TIFFRand state. With either method, out-of-gamut chromaticity may lazily initialise the process-global, unsynchronised oog_encode table. Serialise such calls across threads. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth selects truncation or random dithering. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1902 of file tif_luv.c.
References logLuvState::encode_meth, LogLuv24fromXYZ(), LogLuvLoadFloatNativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvSetupEncode().
|
static |
Convert staged LogLuv24 codes to native signed Luv triplets.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Expands each code into three native int16_t values: L rebased from the 10-bit log luminance, and u and v as u' and v' scaled by 2^15. Invalid chromaticity indices decode as the neutral point. Unaligned output is allowed. Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1824 of file tif_luv.c.
References LogLuvStore16NativeUnaligned(), logLuvState::tbuf, U_NEU, uv_decode(), and V_NEU.
Referenced by LogLuvSetupDecode().
|
static |
Convert staged LogLuv24 codes to clipped gamma-two RGB bytes.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Decodes each code with LogLuv24toXYZ and XYZtoRGB24, writing three bytes per pixel (CCIR-709 primaries, gamma 2, clipped to 0..255). Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1867 of file tif_luv.c.
References LogLuv24toXYZ(), logLuvState::tbuf, and XYZtoRGB24().
Referenced by LogLuvSetupDecode().
|
static |
Convert staged LogLuv24 codes to native float XYZ triplets.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Decodes each code with LogLuv24toXYZ and stores three native floats per pixel; unaligned output is allowed. Invalid chromaticity indices decode as the neutral point. Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1791 of file tif_luv.c.
References LogLuv24toXYZ(), LogLuvStoreFloatNativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvSetupDecode().
|
static |
Quantise native signed Luv triplets into LogLuv32 staging.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Packs three native int16_t values per pixel (unaligned input allowed): L is stored unchanged in the upper 16 bits and u, v are rescaled by UVSCALE/2^15 and masked (not clipped) to 8 bits. With SGILOGENCODE_NODITHER this uses integer arithmetic; otherwise each component is dithered through the process-global, unsynchronised _TIFFRand state, so serialise such calls across threads. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth selects truncation or random dithering. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 2185 of file tif_luv.c.
References logLuvState::encode_meth, LogLuvLoad16NativeUnaligned(), SGILOGENCODE_NODITHER, logLuvState::tbuf, tiff_itrunc(), and UVSCALE.
Referenced by LogLuvSetupEncode().
|
static |
Quantise native float XYZ triplets into LogLuv32 staging.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Encodes three native floats per pixel (unaligned input allowed) with LogLuv32fromXYZ; u and v are clipped to 0..255. When encode_meth is SGILOGENCODE_RANDITHER, dithering advances the process-global, unsynchronised _TIFFRand state; serialise such calls across threads. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth selects truncation or random dithering. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 2150 of file tif_luv.c.
References logLuvState::encode_meth, LogLuv32fromXYZ(), LogLuvLoadFloatNativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvSetupEncode().
|
static |
Convert staged LogLuv32 codes to native signed Luv triplets.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Splits each code into three native int16_t values: L copied from the upper 16 bits, and u and v rescaled from the 8-bit fields to u' and v' times 2^15. Unaligned output is allowed. Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 2077 of file tif_luv.c.
References LogLuvStore16NativeUnaligned(), logLuvState::tbuf, and UVSCALE.
Referenced by LogLuvSetupDecode().
|
static |
Convert staged LogLuv32 codes to clipped gamma-two RGB bytes.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Decodes each code with LogLuv32toXYZ and XYZtoRGB24, writing three bytes per pixel (CCIR-709 primaries, gamma 2, clipped to 0..255). Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 2116 of file tif_luv.c.
References LogLuv32toXYZ(), logLuvState::tbuf, and XYZtoRGB24().
Referenced by LogLuvSetupDecode().
|
static |
Convert staged LogLuv32 codes to native float XYZ triplets.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Decodes each code with LogLuv32toXYZ and stores three native floats per pixel; unaligned output is allowed. Touches no shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 2045 of file tif_luv.c.
References LogLuv32toXYZ(), LogLuvStoreFloatNativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvSetupDecode().
|
static |
Copy native caller LogLuv words into staging.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Copies n native uint32_t words one at a time through the unaligned load helper; no conversion, dithering or shared state. No allocation, I/O, diagnostics or status result.
| [in,out] | sp | Borrowed live codec state whose aligned translation storage receives n staged pixels; encode_meth is not used. |
| [in] | op | Caller input of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1437 of file tif_luv.c.
References LogLuvLoad32NativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvEncode24(), and LogLuvEncode32().
|
static |
Copy packed LogLuv words from staging to native caller bytes.
Requires n complete pixels of aligned codec staging and disjoint caller storage for n pixels in the selected native format. Copies n native uint32_t words one at a time through the unaligned store helper; no conversion, dithering or shared state. No allocation, I/O, diagnostics or status result.
| [in] | sp | Borrowed live codec state whose aligned translation storage holds n staged pixels; encode_meth is not used. |
| [out] | op | Caller output of n pixels in the selected native format. |
| [in] | n | Nonnegative pixel count, not bytes, within translation capacity. |
Definition at line 1410 of file tif_luv.c.
References LogLuvStore32NativeUnaligned(), and logLuvState::tbuf.
Referenced by LogLuvDecode24(), and LogLuvDecode32().
Multiply translation-buffer extents with signed-size checking.
Delegates to _TIFFMultiplySSize with the calling handle and label, so an overflow is reported through the per-handle error handler instead of returning a bare zero. No allocation, I/O, state or ownership effects.
| [in] | tif | Open TIFF handle used to report an overflow. |
| [in] | module | Name of the calling function, used as the message label. |
| [in] | m1 | Nonnegative first buffer extent. |
| [in] | m2 | Nonnegative second buffer extent. |
Definition at line 2289 of file tif_luv.c.
References _TIFFMultiplySSize().
Referenced by LogL16InitState(), and LogLuvInitState().
|
static |
Map out-of-gamut chromaticity to a hue-matched boundary bin.
Requires finite coordinates with a representable hue index. Lazily fills a static perimeter lookup from immutable uv_row geometry and nearest populated angles, then indexes it by atan2 hue. First-use initialisation is unsynchronised and must be serialised across threads. No heap allocation, I/O, diagnostics or ownership transfer.
| [in] | u | Finite u-prime chromaticity coordinate. |
| [in] | v | Finite v-prime chromaticity coordinate. |
Definition at line 1596 of file tif_luv.c.
References NANGLES, nus, ustart, uv2ang, UV_NVS, uv_row, UV_SQSIZ, and UV_VSTART.
Referenced by uv_encode().
|
static |
Quantise a finite value with optional shared random dithering.
Requires the input and dithered result to fit int. NODITHER casts directly, otherwise adds uniform approximate half-unit noise from _TIFFRand before truncation. Serialise shared random-state access. No heap allocation, client I/O, diagnostics or ownership transfer.
| [in] | x | Finite value whose quantisation and dithered result fit int. |
| [in] | m | NODITHER for direct truncation, otherwise shared random dithering. |
Definition at line 1189 of file tif_luv.c.
References _TIFFRand(), SGILOGENCODE_NODITHER, and TIFF_RAND_MAX.
Referenced by LogL10fromY(), LogL16fromY(), LogLuv32fromXYZ(), Luv24fromLuv48(), Luv32fromLuv48(), and uv_encode().
|
extern |
Allocate SGILog codec state and install row dispatch and tag hooks.
Requires SGILOG/SGILOG24 and cleaned-up previous codec state. Merges pseudo-tags, allocates zeroed Ext state, saves tag methods and installs strile/setup/close/cleanup dispatch. Row methods are selected at later setup. Defaults no dither for SGILOG and random dither for SGILOG24, unknown user format and no-op translation. Merge/allocation failures diagnose without rollback; no pixel I/O or caller ownership transfer.
| [in,out] | tif | Non-NULL handle whose previous codec state has been cleaned up; receives the new codec state. Serialise access. |
| [in] | scheme | COMPRESSION_SGILOG or COMPRESSION_SGILOG24, selecting default dithering. |
Definition at line 2981 of file tif_luv.c.
References _logLuvNop(), _TIFFmallocExt(), _TIFFmemset(), _TIFFMergeFields(), COMPRESSION_SGILOG, COMPRESSION_SGILOG24, LogLuvCleanup(), LogLuvClose(), LogLuvDecodeStrip(), LogLuvDecodeTile(), LogLuvEncodeStrip(), LogLuvEncodeTile(), LogLuvFields, LogLuvFixupTags(), LogLuvSetupDecode(), LogLuvSetupEncode(), LogLuvVGetField(), LogLuvVSetField(), SGILOGDATAFMT_UNKNOWN, SGILOGENCODE_NODITHER, SGILOGENCODE_RANDITHER, tiff::tif_cleanup, tiff::tif_close, tiff::tif_data, tiff::tif_decodestrip, tiff::tif_decodetile, tiff::tif_encodestrip, tiff::tif_encodetile, tiff::tif_fixuptags, tiff::tif_name, tiff::tif_setupdecode, tiff::tif_setupencode, tiff::tif_tagmethods, TIFFArrayCount, TIFFErrorExtR(), TIFFTagMethods::vgetfield, and TIFFTagMethods::vsetfield.
|
static |
Define SGILog user format and encoding-method pseudo-tags.
Immutable library-lifetime metadata merged into a handle; no caller ownership transfer.
Definition at line 2975 of file tif_luv.c.
Referenced by TIFFInitSGILog().
| short { ... } ::nus |
| void(* logLuvState::tfunc) (LogLuvState *, uint8_t *, tmsize_t) |
Translate pixels between caller bytes and packed codec staging.
Invoked synchronously. First argument [in,out] is borrowed LogLuvState, second [in,out] is borrowed caller pixel storage (input for encoding, output for decoding), third [in] is a nonnegative pixel count within both capacities. Wide caller bytes may be unaligned; tbuf is allocator aligned. No pointer retention or ownership transfer. Encoding can mutate shared dither/perimeter state; there is no return status. The selected concrete converter states its representation and direction.
|
static |
Map each v-prime row to its u-prime start and bin index interval.
Map v-prime rows to u-prime boundaries and bin index intervals.
Immutable library-lifetime storage; do not modify or free it. nus is the horizontal bin count and ncum is the number of preceding bins.
Immutable library-lifetime table; do not modify or free it.
Referenced by oog_encode(), uv_decode(), and uv_encode().