LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
Functions
LogL and LogLuv representations

Convert logarithmic luminance chromaticity and XYZ representations. More...

Collaboration diagram for LogL and LogLuv representations:

Functions

double LogL16toY (int p16)
 Decode 16-bit logarithmic luminance to a linear value.
 
double LogL10toY (int p10)
 Decode 10-bit logarithmic luminance to a linear value.
 
void XYZtoRGB24 (float *xyz, uint8_t *rgb)
 Convert a linear XYZ triplet to display RGB bytes.
 
int uv_decode (double *up, double *vp, int c)
 Decode a quantised chromaticity index to a bin-centre pair.
 
void LogLuv24toXYZ (uint32_t p, float *XYZ)
 Decode one packed 24-bit LogLuv pixel to linear XYZ.
 
void LogLuv32toXYZ (uint32_t p, float *XYZ)
 Decode one packed 32-bit LogLuv pixel to linear XYZ.
 
int LogL16fromY (double Y, int em)
 Encode linear luminance as a 16-bit logarithmic value.
 
int LogL10fromY (double Y, int em)
 Encode linear luminance as a 10-bit logarithmic value.
 
int uv_encode (double u, double v, int em)
 Encode chromaticity using the irregular LogLuv quantisation table.
 
uint32_t LogLuv24fromXYZ (float *XYZ, int em)
 Encode linear XYZ as one packed 24-bit LogLuv pixel.
 
uint32_t LogLuv32fromXYZ (float *XYZ, int em)
 Encode linear XYZ as one packed 32-bit LogLuv pixel.
 

Detailed Description

Convert logarithmic luminance chromaticity and XYZ representations.

Function Documentation

◆ LogL10fromY()

int LogL10fromY ( double  Y,
int  em 
)
extern

Encode linear luminance as a 10-bit logarithmic value.

Saturates Y>=15.742 to 1023 and Y<=0.00024283 to zero; quantises the intermediate log2 range. Requires finite Y; NaN can reach an invalid integer conversion. SGILOGENCODE_NODITHER truncates deterministically; other method values use the shared pseudo-random dither state. Serialise dithering across threads; state is seeded from time on first use and is not caller-owned. C++ defaults em to SGILOGENCODE_NODITHER. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]YFinite linear luminance; LogL16 supports signed values, LogL10 clips low/nonpositive values to zero.
[in]emEncoding method, normally SGILOGENCODE_NODITHER or SGILOGENCODE_RANDITHER.
Returns
Encoded code pattern; not a Boolean status or ownership result.

Definition at line 1567 of file tif_luv.c.

References tiff_itrunc().

Referenced by LogLuv24fromXYZ().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogL10toY()

double LogL10toY ( int  p10)
extern

Decode 10-bit logarithmic luminance to a linear value.

Requires a code in 0..1023; zero returns zero, otherwise returns the bin-centre exponential. Does not mask or range-check arbitrary int input. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]p10Encoded 10-bit luminance code in 0..1023.
Returns
Nonnegative decoded linear luminance.

Definition at line 1557 of file tif_luv.c.

References M_LN2.

Referenced by LogLuv24toXYZ().

Here is the caller graph for this function:

◆ LogL16fromY()

int LogL16fromY ( double  Y,
int  em 
)
extern

Encode linear luminance as a 16-bit logarithmic value.

Saturates magnitudes at approximately 1.8371976e19, maps magnitudes below approximately 5.4136769e-20 to zero, and quantises log2 magnitude with its sign. Negative encodings can be returned as sign-extended int values; inspect the low sixteen bits rather than interpreting a negative result as an error. SGILOGENCODE_NODITHER truncates deterministically; other method values use the shared pseudo-random dither state. Serialise dithering across threads; state is seeded from time on first use and is not caller-owned. C++ defaults em to SGILOGENCODE_NODITHER. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]YFinite linear luminance; LogL16 supports signed values, LogL10 clips low/nonpositive values to zero.
[in]emEncoding method, normally SGILOGENCODE_NODITHER or SGILOGENCODE_RANDITHER.
Returns
Encoded code pattern; not a Boolean status or ownership result.

Definition at line 1213 of file tif_luv.c.

References tiff_itrunc().

Referenced by L16fromY(), and LogLuv32fromXYZ().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogL16toY()

double LogL16toY ( int  p16)
extern

Decode 16-bit logarithmic luminance to a linear value.

Uses the low fifteen magnitude bits and bit fifteen as sign; zero magnitude returns zero, otherwise returns the bin-centre exponential with its encoded sign. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]p16Encoded signed LogL16 luminance; only the low sixteen bits are used, with bit fifteen as the sign.
Returns
Decoded linear luminance; negative when the sign bit is set.

Definition at line 1199 of file tif_luv.c.

References M_LN2.

Referenced by L16toGry(), L16toY(), and LogLuv32toXYZ().

Here is the caller graph for this function:

◆ LogLuv24fromXYZ()

uint32_t LogLuv24fromXYZ ( float *  XYZ,
int  em 
)
extern

Encode linear XYZ as one packed 24-bit LogLuv pixel.

Encodes luminance and derives u-prime/v-prime from X+15Y+3Z. Zero encoded luminance or nonpositive sum uses neutral chromaticity. Uses the irregular chromaticity table and hue-preserving perimeter fallback; serialise its first-use initialisation. SGILOGENCODE_NODITHER truncates deterministically; other method values use the shared pseudo-random dither state. Serialise dithering across threads; state is seeded from time on first use and is not caller-owned. C++ defaults em to SGILOGENCODE_NODITHER. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]XYZBorrowed readable three-float finite XYZ triplet; arithmetic/quantisation must remain representable.
[in]emQuantisation/dithering method; C++ defaults to no dither.
Returns
Quantised packed code; upper eight bits zero for LogLuv24, no independent error status.

Definition at line 1750 of file tif_luv.c.

References LogL10fromY(), SGILOGENCODE_NODITHER, U_NEU, uv_encode(), and V_NEU.

Referenced by Luv24fromXYZ().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogLuv24toXYZ()

void LogLuv24toXYZ ( uint32_t  p,
float *  XYZ 
)
extern

Decode one packed 24-bit LogLuv pixel to linear XYZ.

Extracts ten-bit luminance and fourteen-bit table chromaticity from the low twenty-four bits; invalid chromaticity codes use the neutral pair. Nonpositive luminance produces an all-zero triplet; positive luminance converts bin-centre chromaticity to XYZ. This is quantised representation conversion, not exact round-trip recovery. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]pPacked 24-bit LogLuv code in the low twenty-four bits; upper eight bits ignored.
[out]XYZNon-NULL caller-owned writable three-float result.

Definition at line 1720 of file tif_luv.c.

References LogL10toY(), U_NEU, uv_decode(), and V_NEU.

Referenced by Luv24toRGB(), and Luv24toXYZ().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogLuv32fromXYZ()

uint32_t LogLuv32fromXYZ ( float *  XYZ,
int  em 
)
extern

Encode linear XYZ as one packed 32-bit LogLuv pixel.

Encodes luminance and derives u-prime/v-prime from X+15Y+3Z. Zero encoded luminance or nonpositive sum uses neutral chromaticity. Quantises scaled chromaticity components and clips codes to 0..255; signed luminance codes are retained in the high word. SGILOGENCODE_NODITHER truncates deterministically; other method values use the shared pseudo-random dither state. Serialise dithering across threads; state is seeded from time on first use and is not caller-owned. C++ defaults em to SGILOGENCODE_NODITHER. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]XYZBorrowed readable three-float finite XYZ triplet; arithmetic/quantisation must remain representable.
[in]emQuantisation/dithering method; C++ defaults to no dither.
Returns
Quantised packed code; upper eight bits zero for LogLuv24, no independent error status.

Definition at line 1995 of file tif_luv.c.

References LogL16fromY(), tiff_itrunc(), U_NEU, UVSCALE, and V_NEU.

Referenced by Luv32fromXYZ().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogLuv32toXYZ()

void LogLuv32toXYZ ( uint32_t  p,
float *  XYZ 
)
extern

Decode one packed 32-bit LogLuv pixel to linear XYZ.

Extracts signed sixteen-bit luminance and two eight-bit chromaticity components scaled by UVSCALE. Nonpositive luminance produces an all-zero triplet; positive luminance converts bin-centre chromaticity to XYZ. This is quantised representation conversion, not exact round-trip recovery. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]pPacked 32-bit LogLuv code: signed 16-bit LogL in the high word, 8-bit u and v codes in the low word.
[out]XYZNon-NULL caller-owned writable three-float result.

Definition at line 1970 of file tif_luv.c.

References LogL16toY(), and UVSCALE.

Referenced by Luv32toRGB(), and Luv32toXYZ().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uv_decode()

int uv_decode ( double *  up,
double *  vp,
int  c 
)
extern

Decode a quantised chromaticity index to a bin-centre pair.

Rejects c outside 0..UV_NDIVS-1 before writing outputs; binary-searches the immutable uv_row table and returns u-prime/v-prime bin centres. Output slots must be separate and non-NULL. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[out]upCaller-owned u-prime result; unchanged on invalid code.
[out]vpCaller-owned v-prime result; unchanged on invalid code.
[in]cQuantised chromaticity code, valid range 0..16288.
Returns
Zero on decoded coordinates, minus one for invalid code.

Definition at line 1686 of file tif_luv.c.

References ustart, UV_NDIVS, UV_NVS, uv_row, UV_SQSIZ, and UV_VSTART.

Referenced by LogLuv24toXYZ(), and Luv24toLuv48().

Here is the caller graph for this function:

◆ uv_encode()

int uv_encode ( double  u,
double  v,
int  em 
)
extern

Encode chromaticity using the irregular LogLuv quantisation table.

Maps NaN coordinates to neutral chromaticity, then selects a table bin. Out-of-gamut values map to a hue-indexed perimeter bin through a lazily initialised shared table. Require finite coordinates after NaN handling and representable quantisation arithmetic; infinities are not generally safe. Serialise first-use perimeter-table initialisation and dithering across threads. SGILOGENCODE_NODITHER truncates deterministically; other method values use the shared pseudo-random dither state. Serialise dithering across threads; state is seeded from time on first use and is not caller-owned. C++ defaults em to SGILOGENCODE_NODITHER. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]uFinite CIE u-prime coordinate.
[in]vFinite CIE v-prime coordinate.
[in]emQuantisation/dithering method; C++ default is no dither.
Returns
Quantised chromaticity code; no independent success/failure channel.

Definition at line 1655 of file tif_luv.c.

References ncum, nus, oog_encode(), tiff_itrunc(), U_NEU, ustart, UV_NVS, uv_row, UV_SQSIZ, UV_VSTART, and V_NEU.

Referenced by LogLuv24fromXYZ(), and Luv24fromLuv48().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XYZtoRGB24()

void XYZtoRGB24 ( float *  xyz,
uint8_t *  rgb 
)
extern

Convert a linear XYZ triplet to display RGB bytes.

Uses fixed CCIR-709 primary coefficients, clips each linear channel to 0..1 and applies an approximate gamma of two via square root. Requires finite XYZ inputs and disjoint input/output storage. This display transform loses precision and clips out-of-range colours. No allocation, TIFF handle access, client I/O, diagnostics, retained pointers, or ownership transfer occurs. There is no separate error status unless stated.

Parameters
[in]xyzBorrowed readable three-float XYZ triplet.
[out]rgbBorrowed writable three-byte RGB triplet.

Definition at line 1537 of file tif_luv.c.

Referenced by Luv24toRGB(), and Luv32toRGB().

Here is the caller graph for this function: