libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

color_encoding.h (5727B)


      1 /* Copyright (c) the JPEG XL Project Authors. All rights reserved.
      2  *
      3  * Use of this source code is governed by a BSD-style
      4  * license that can be found in the LICENSE file.
      5  */
      6 
      7 /** @addtogroup libjxl_color
      8  * @{
      9  * @file color_encoding.h
     10  * @brief Color Encoding definitions used by JPEG XL.
     11  * All CIE units are for the standard 1931 2 degree observer.
     12  */
     13 
     14 #ifndef JXL_COLOR_ENCODING_H_
     15 #define JXL_COLOR_ENCODING_H_
     16 
     17 #include <stdint.h>
     18 
     19 #if defined(__cplusplus) || defined(c_plusplus)
     20 extern "C" {
     21 #endif
     22 
     23 /** Color space of the image data. */
     24 typedef enum {
     25   /** Tristimulus RGB */
     26   JXL_COLOR_SPACE_RGB,
     27   /** Luminance based, the primaries in @ref JxlColorEncoding must be ignored.
     28    * This value implies that num_color_channels in @ref JxlBasicInfo is 1, any
     29    * other value implies num_color_channels is 3. */
     30   JXL_COLOR_SPACE_GRAY,
     31   /** XYB (opsin) color space */
     32   JXL_COLOR_SPACE_XYB,
     33   /** None of the other table entries describe the color space appropriately */
     34   JXL_COLOR_SPACE_UNKNOWN,
     35 } JxlColorSpace;
     36 
     37 /** Built-in whitepoints for color encoding. When decoding, the numerical xy
     38  * whitepoint value can be read from the @ref JxlColorEncoding white_point field
     39  * regardless of the enum value. When encoding, enum values except
     40  * ::JXL_WHITE_POINT_CUSTOM override the numerical fields. Some enum values
     41  * match a subset of CICP (Rec. ITU-T H.273 | ISO/IEC 23091-2:2019(E)), however
     42  * the white point and RGB primaries are separate enums here.
     43  */
     44 typedef enum {
     45   /** CIE Standard Illuminant D65: 0.3127, 0.3290 */
     46   JXL_WHITE_POINT_D65 = 1,
     47   /** White point must be read from the @ref JxlColorEncoding white_point field,
     48    * or as ICC profile. This enum value is not an exact match of the
     49    * corresponding CICP value. */
     50   JXL_WHITE_POINT_CUSTOM = 2,
     51   /** CIE Standard Illuminant E (equal-energy): 1/3, 1/3 */
     52   JXL_WHITE_POINT_E = 10,
     53   /** DCI-P3 from SMPTE RP 431-2: 0.314, 0.351 */
     54   JXL_WHITE_POINT_DCI = 11,
     55 } JxlWhitePoint;
     56 
     57 /** Built-in primaries for color encoding. When decoding, the primaries can be
     58  * read from the @ref JxlColorEncoding primaries_red_xy, primaries_green_xy and
     59  * primaries_blue_xy fields regardless of the enum value. When encoding, the
     60  * enum values except ::JXL_PRIMARIES_CUSTOM override the numerical fields.
     61  * Some enum values match a subset of CICP (Rec. ITU-T H.273 | ISO/IEC
     62  * 23091-2:2019(E)), however the white point and RGB primaries are separate
     63  * enums here.
     64  */
     65 typedef enum {
     66   /** The CIE xy values of the red, green and blue primaries are: 0.639998686,
     67      0.330010138; 0.300003784, 0.600003357; 0.150002046, 0.059997204 */
     68   JXL_PRIMARIES_SRGB = 1,
     69   /** Primaries must be read from the @ref JxlColorEncoding primaries_red_xy,
     70    * primaries_green_xy and primaries_blue_xy fields, or as ICC profile. This
     71    * enum value is not an exact match of the corresponding CICP value. */
     72   JXL_PRIMARIES_CUSTOM = 2,
     73   /** As specified in Rec. ITU-R BT.2100-1 */
     74   JXL_PRIMARIES_2100 = 9,
     75   /** As specified in SMPTE RP 431-2 */
     76   JXL_PRIMARIES_P3 = 11,
     77 } JxlPrimaries;
     78 
     79 /** Built-in transfer functions for color encoding. Enum values match a subset
     80  * of CICP (Rec. ITU-T H.273 | ISO/IEC 23091-2:2019(E)) unless specified
     81  * otherwise. */
     82 typedef enum {
     83   /** As specified in SMPTE RP 431-2 */
     84   JXL_TRANSFER_FUNCTION_709 = 1,
     85   /** None of the other table entries describe the transfer function. */
     86   JXL_TRANSFER_FUNCTION_UNKNOWN = 2,
     87   /** The gamma exponent is 1 */
     88   JXL_TRANSFER_FUNCTION_LINEAR = 8,
     89   /** As specified in IEC 61966-2-1 sRGB */
     90   JXL_TRANSFER_FUNCTION_SRGB = 13,
     91   /** As specified in SMPTE ST 2084 */
     92   JXL_TRANSFER_FUNCTION_PQ = 16,
     93   /** As specified in SMPTE ST 428-1 */
     94   JXL_TRANSFER_FUNCTION_DCI = 17,
     95   /** As specified in Rec. ITU-R BT.2100-1 (HLG) */
     96   JXL_TRANSFER_FUNCTION_HLG = 18,
     97   /** Transfer function follows power law given by the gamma value in @ref
     98      JxlColorEncoding. Not a CICP value. */
     99   JXL_TRANSFER_FUNCTION_GAMMA = 65535,
    100 } JxlTransferFunction;
    101 
    102 /** Renderig intent for color encoding, as specified in ISO 15076-1:2010 */
    103 typedef enum {
    104   /** vendor-specific */
    105   JXL_RENDERING_INTENT_PERCEPTUAL = 0,
    106   /** media-relative */
    107   JXL_RENDERING_INTENT_RELATIVE,
    108   /** vendor-specific */
    109   JXL_RENDERING_INTENT_SATURATION,
    110   /** ICC-absolute */
    111   JXL_RENDERING_INTENT_ABSOLUTE,
    112 } JxlRenderingIntent;
    113 
    114 /** Color encoding of the image as structured information.
    115  */
    116 typedef struct {
    117   /** Color space of the image data.
    118    */
    119   JxlColorSpace color_space;
    120 
    121   /** Built-in white point. If this value is ::JXL_WHITE_POINT_CUSTOM, must
    122    * use the numerical whitepoint values from white_point_xy.
    123    */
    124   JxlWhitePoint white_point;
    125 
    126   /** Numerical whitepoint values in CIE xy space. */
    127   double white_point_xy[2];
    128 
    129   /** Built-in RGB primaries. If this value is ::JXL_PRIMARIES_CUSTOM, must
    130    * use the numerical primaries values below. This field and the custom values
    131    * below are unused and must be ignored if the color space is
    132    * ::JXL_COLOR_SPACE_GRAY or ::JXL_COLOR_SPACE_XYB.
    133    */
    134   JxlPrimaries primaries;
    135 
    136   /** Numerical red primary values in CIE xy space. */
    137   double primaries_red_xy[2];
    138 
    139   /** Numerical green primary values in CIE xy space. */
    140   double primaries_green_xy[2];
    141 
    142   /** Numerical blue primary values in CIE xy space. */
    143   double primaries_blue_xy[2];
    144 
    145   /** Transfer function if have_gamma is 0 */
    146   JxlTransferFunction transfer_function;
    147 
    148   /** Gamma value used when transfer_function is @ref
    149    * JXL_TRANSFER_FUNCTION_GAMMA
    150    */
    151   double gamma;
    152 
    153   /** Rendering intent defined for the color profile. */
    154   JxlRenderingIntent rendering_intent;
    155 } JxlColorEncoding;
    156 
    157 #if defined(__cplusplus) || defined(c_plusplus)
    158 }
    159 #endif
    160 
    161 #endif /* JXL_COLOR_ENCODING_H_ */
    162 
    163 /** @}*/