FFmpeg
Files | Data Structures | Typedefs | Functions
Colorspace Utility

Files

file  csp.h
 

Data Structures

struct  AVLumaCoefficients
 Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations. More...
 
struct  AVCIExy
 Struct containing chromaticity x and y values for the standard CIE 1931 chromaticity definition. More...
 
struct  AVPrimaryCoefficients
 Struct defining the red, green, and blue primary locations in terms of CIE 1931 chromaticity x and y. More...
 
struct  AVColorPrimariesDesc
 Struct that contains both white point location and primaries location, providing the complete description of a color gamut. More...
 

Typedefs

typedef AVCIExy AVWhitepointCoefficients
 Struct defining white point location in terms of CIE 1931 chromaticity x and y. More...
 
typedef double(* av_csp_trc_function) (double)
 Function pointer representing a double -> double transfer function that performs either an OETF transfer function, or alternatively an inverse EOTF function (in particular, for SMPTE ST 2084 / PQ). More...
 
typedef void(* av_csp_eotf_function) (double Lw, double Lb, double c[3])
 Function pointer representing an ITU EOTF transfer for a given reference display configuration. More...
 

Functions

const AVLumaCoefficientsav_csp_luma_coeffs_from_avcsp (enum AVColorSpace csp)
 Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant describing the colorspace. More...
 
const AVColorPrimariesDescav_csp_primaries_desc_from_id (enum AVColorPrimaries prm)
 Retrieves a complete gamut description from an enum constant describing the color primaries. More...
 
enum AVColorPrimaries av_csp_primaries_id_from_desc (const AVColorPrimariesDesc *prm)
 Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description. More...
 
double av_csp_approximate_trc_gamma (enum AVColorTransferCharacteristic trc)
 Determine a suitable 'gamma' value to match the supplied AVColorTransferCharacteristic. More...
 
av_csp_trc_function av_csp_trc_func_from_id (enum AVColorTransferCharacteristic trc)
 Determine the function needed to apply the given AVColorTransferCharacteristic to linear input. More...
 
av_csp_trc_function av_csp_trc_func_inv_from_id (enum AVColorTransferCharacteristic trc)
 Returns the mathematical inverse of the corresponding TRC function. More...
 
av_csp_eotf_function av_csp_itu_eotf (enum AVColorTransferCharacteristic trc)
 Returns the ITU EOTF corresponding to a given TRC. More...
 
av_csp_eotf_function av_csp_itu_eotf_inv (enum AVColorTransferCharacteristic trc)
 Returns the mathematical inverse of the corresponding EOTF. More...
 

Detailed Description

Typedef Documentation

◆ AVWhitepointCoefficients

Struct defining white point location in terms of CIE 1931 chromaticity x and y.

Definition at line 72 of file csp.h.

◆ av_csp_trc_function

typedef double(* av_csp_trc_function) (double)

Function pointer representing a double -> double transfer function that performs either an OETF transfer function, or alternatively an inverse EOTF function (in particular, for SMPTE ST 2084 / PQ).

This function inputs linear light, and outputs gamma encoded light.

See ITU-T H.273 for more information.

Definition at line 91 of file csp.h.

◆ av_csp_eotf_function

typedef void(* av_csp_eotf_function) (double Lw, double Lb, double c[3])

Function pointer representing an ITU EOTF transfer for a given reference display configuration.

Parameters
LwThe white point luminance of the display, in nits (cd/m^2).
LbThe black point luminance of the display, in nits (cd/m^2).

Definition at line 162 of file csp.h.

Function Documentation

◆ av_csp_luma_coeffs_from_avcsp()

const AVLumaCoefficients* av_csp_luma_coeffs_from_avcsp ( enum AVColorSpace  csp)

Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant describing the colorspace.

Parameters
cspAn enum constant indicating YUV or similar colorspace.
Returns
The Luma coefficients associated with that colorspace, or NULL if the constant is unknown to libavutil.

Definition at line 58 of file csp.c.

Referenced by create_filtergraph(), ff_draw_init2(), filter_frame(), init(), init_filter(), and tonemap_opencl_init().

◆ av_csp_primaries_desc_from_id()

const AVColorPrimariesDesc* av_csp_primaries_desc_from_id ( enum AVColorPrimaries  prm)

Retrieves a complete gamut description from an enum constant describing the color primaries.

Parameters
prmAn enum constant indicating primaries
Returns
A description of the colorspace gamut associated with that enum constant, or NULL if the constant is unknown to libavutil.

Definition at line 90 of file csp.c.

Referenced by create_filtergraph(), ff_icc_profile_generate(), get_rgb2rgb_matrix(), libjxl_get_primaries(), libjxl_populate_primaries(), and png_get_chrm().

◆ av_csp_primaries_id_from_desc()

enum AVColorPrimaries av_csp_primaries_id_from_desc ( const AVColorPrimariesDesc prm)

Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description.

See also
enum AVColorPrimaries
Parameters
prmA description of the colorspace gamut
Returns
The enum constant associated with this gamut, or AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified.

Definition at line 110 of file csp.c.

Referenced by iccdetect_filter_frame(), libjxl_get_primaries(), and populate_avctx_color_fields().

◆ av_csp_approximate_trc_gamma()

double av_csp_approximate_trc_gamma ( enum AVColorTransferCharacteristic  trc)

Determine a suitable 'gamma' value to match the supplied AVColorTransferCharacteristic.

See Apple Technical Note TN2257 (https://developer.apple.com/library/mac/technotes/tn2257/_index.html)

This function returns the gamma exponent for the OETF. For example, sRGB is approximated by gamma 2.2, not by gamma 0.45455.

Returns
Will return an approximation to the simple gamma function matching the supplied Transfer Characteristic, Will return 0.0 for any we cannot reasonably match against.

Definition at line 149 of file csp.c.

Referenced by mov_write_gama_tag(), and png_get_gama().

◆ av_csp_trc_func_from_id()

av_csp_trc_function av_csp_trc_func_from_id ( enum AVColorTransferCharacteristic  trc)

Determine the function needed to apply the given AVColorTransferCharacteristic to linear input.

The function returned should expect a nominal domain and range of [0.0-1.0] values outside of this range maybe valid depending on the chosen characteristic function.

Returns
Will return pointer to the function matching the supplied Transfer Characteristic. If unspecified will return NULL:

Definition at line 400 of file csp.c.

Referenced by decode_block(), decode_init(), and main().

◆ av_csp_trc_func_inv_from_id()

av_csp_trc_function av_csp_trc_func_inv_from_id ( enum AVColorTransferCharacteristic  trc)

Returns the mathematical inverse of the corresponding TRC function.

Definition at line 426 of file csp.c.

Referenced by main().

◆ av_csp_itu_eotf()

av_csp_eotf_function av_csp_itu_eotf ( enum AVColorTransferCharacteristic  trc)

Returns the ITU EOTF corresponding to a given TRC.

This converts from the signal level [0,1] to the raw output display luminance in nits (cd/m^2). This is done per channel in RGB space, except for AVCOL_TRC_SMPTE428, which assumes CIE XYZ in- and output.

Returns
A pointer to the function implementing the given TRC, or NULL if no such function is defined.
Note
In general, the resulting function is defined (wherever possible) for out-of-range values, even though these values do not have a physical meaning on the given display. Users should clamp inputs (or outputs) if this behavior is not desired.

This is also the case for functions like PQ, which are defined over an absolute signal range independent of the target display capabilities.

Definition at line 605 of file csp.c.

Referenced by main().

◆ av_csp_itu_eotf_inv()

av_csp_eotf_function av_csp_itu_eotf_inv ( enum AVColorTransferCharacteristic  trc)

Returns the mathematical inverse of the corresponding EOTF.

Definition at line 631 of file csp.c.

Referenced by main().