|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Convert sample representations and colour components. More...
Files | |
| file | tif_color.c |
| Convert Lab, XYZ, and YCbCr colour components. | |
| file | tif_swab.c |
| Reverse sample bytes and per-byte bit order. | |
Macros | |
| #define | RINT(R) ((uint32_t)((R) > 0 ? ((R) + 0.5f) : ((R) - 0.5f))) |
| Round a nonnegative table value to an unsigned channel. | |
| #define | SHIFT 16 |
| Select sixteen fractional bits for YCbCr contributions. | |
| #define | FIX(x) ((int32_t)((double)(x) * (1L << SHIFT) + 0.5)) |
| Convert a bounded coefficient to fixed-point form. | |
| #define | ONE_HALF ((int32_t)(1 << (SHIFT - 1))) |
| Represent a half-unit rounding bias in fixed-point form. | |
| #define | Code2V(c, RB, RW, CR) |
| Scale a code between reference black and white endpoints. | |
| #define | CLAMP(f, min, max) ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f)) |
| Clamp a value and map NaN to the lower bound. | |
| #define | HICLAMP(f, max) ((f) > (max) ? (max) : (f)) |
| Apply only an upper bound. | |
| #define | LumaRed luma[0] |
| Read the red coefficient from the local luma array. | |
| #define | LumaGreen luma[1] |
| Read the green coefficient from the local luma array. | |
| #define | LumaBlue luma[2] |
| Read the blue coefficient from the local luma array. | |
Functions | |
| static float | CLAMPw (float v, float vmin, float vmax) |
| Clamp a finite coefficient to an inclusive interval. | |
| void | TIFFCIELab16ToXYZ (TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b, float *X, float *Y, float *Z) |
| Convert 16-bit TIFF CIE L*a*b* samples to XYZ. | |
Variables | |
| static const unsigned char | TIFFBitRevTable [256] |
| Map each byte to its bit-reversed value. | |
| static const unsigned char | TIFFNoBitRevTable [256] |
| Map each byte to itself. | |
Convert sample representations and colour components.
| #define CLAMP | ( | f, | |
| min, | |||
| max | |||
| ) | ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f)) |
Clamp a value and map NaN to the lower bound.
Arguments can be evaluated repeatedly and must be side-effect free. No allocation, I/O, diagnostics, or ownership transfer.
| [in] | f | Value to clamp. |
| [in] | min | Lower bound, also returned when f is NaN. |
| [in] | max | Upper bound. |
Definition at line 274 of file tif_color.c.
| #define Code2V | ( | c, | |
| RB, | |||
| RW, | |||
| CR | |||
| ) |
Scale a code between reference black and white endpoints.
Uses denominator one when the endpoints compare exactly equal (or their difference is NaN); nearly equal endpoints still divide by the small difference. Macro arguments can be evaluated repeatedly and must be side-effect free. No allocation, I/O, diagnostics, or ownership transfer.
| [in] | c | Integer code value. |
| [in] | RB | Reference black endpoint; truncated to int32_t when subtracted from c, but used unconverted in the denominator. |
| [in] | RW | Reference white endpoint. |
| [in] | CR | Output code range (127 for chroma, 255 for luma). |
Definition at line 258 of file tif_color.c.
| #define FIX | ( | x | ) | ((int32_t)((double)(x) * (1L << SHIFT) + 0.5)) |
Convert a bounded coefficient to fixed-point form.
Requires a representable finite result; argument is evaluated once. No allocation, I/O, diagnostics, or ownership transfer.
| [in] | x | Coefficient to convert; callers clamp it to 0..2. |
Definition at line 233 of file tif_color.c.
| #define HICLAMP | ( | f, | |
| max | |||
| ) | ((f) > (max) ? (max) : (f)) |
Apply only an upper bound.
Arguments can be evaluated repeatedly and must be side-effect free. No allocation, I/O, diagnostics, or ownership transfer.
| [in] | f | Value to bound. |
| [in] | max | Upper bound. |
Definition at line 287 of file tif_color.c.
| #define LumaBlue luma[2] |
Read the blue coefficient from the local luma array.
Expands to luma[2], the blue YCbCrCoefficients entry passed to TIFFYCbCrToRGBInit(); defined only inside that function.
| #define LumaGreen luma[1] |
Read the green coefficient from the local luma array.
Expands to luma[1], the green YCbCrCoefficients entry passed to TIFFYCbCrToRGBInit(); defined only inside that function.
| #define LumaRed luma[0] |
Read the red coefficient from the local luma array.
Expands to luma[0], the red YCbCrCoefficients entry passed to TIFFYCbCrToRGBInit(); defined only inside that function.
| #define ONE_HALF ((int32_t)(1 << (SHIFT - 1))) |
Represent a half-unit rounding bias in fixed-point form.
Value 1 << (SHIFT - 1), added before shifting right by SHIFT so the fixed-point products round to nearest.
Definition at line 241 of file tif_color.c.
| #define RINT | ( | R | ) | ((uint32_t)((R) > 0 ? ((R) + 0.5f) : ((R) - 0.5f))) |
Round a nonnegative table value to an unsigned channel.
Requires representable nonnegative input; argument may be evaluated more than once. No allocation, I/O, diagnostics, or ownership transfer.
| [in] | R | Floating-point table value, normally 0..255 after lookup. |
Definition at line 108 of file tif_color.c.
| #define SHIFT 16 |
Select sixteen fractional bits for YCbCr contributions.
Number of fractional bits in the fixed-point coefficients built by TIFFYCbCrToRGBInit(); table sums are shifted right by this amount.
Definition at line 222 of file tif_color.c.
|
static |
Clamp a finite coefficient to an inclusive interval.
Comparisons leave NaN unchanged. Pure arithmetic with no allocation, I/O, diagnostics, or ownership effects; caller establishes ordered finite limits.
| [in] | v | Value to clamp. |
| [in] | vmin | Lower bound. |
| [in] | vmax | Upper bound. |
Definition at line 323 of file tif_color.c.
Referenced by TIFFYCbCrToRGBInit().
|
extern |
Convert 16-bit TIFF CIE L*a*b* samples to XYZ.
Uses the stored reference white and the piecewise Lab inverse transform. Chrominance is scaled by 256. Writes outputs without allocation, I/O, diagnostics, or ownership transfer. Supply finite valid conversion state; this void interface has no error status.
| [in] | cielab | Non-NULL caller-owned state initialised by TIFFCIELabToRGBInit(); retained by caller. |
| [in] | l | Unsigned luminance in 0..65535. |
| [in] | a | Signed chrominance in -32768..32767, encoding 256*a*. |
| [in] | b | Signed chrominance with the same scale/range as a. |
| [out] | X | Non-NULL caller-owned output slot; must not alias the conversion state. |
| [out] | Y | Non-NULL caller-owned output slot; must not alias the conversion state. |
| [out] | Z | Non-NULL caller-owned output slot; must not alias the conversion state. |
Definition at line 68 of file tif_color.c.
References TIFFCIELabToRGB::X0, TIFFCIELabToRGB::Y0, and TIFFCIELabToRGB::Z0.
Referenced by putcontig8bitCIELab16(), and TIFFCIELabToXYZ().
|
static |
Map each byte to its bit-reversed value.
Immutable library-lifetime table; borrowed views must not be modified or freed.
Definition at line 270 of file tif_swab.c.
Referenced by TIFFGetBitRevTable(), and TIFFReverseBits().
|
static |
Map each byte to itself.
Immutable library-lifetime table; borrowed views must not be modified or freed.
Definition at line 300 of file tif_swab.c.
Referenced by TIFFGetBitRevTable().