FFmpeg
Macros | Functions | Variables
colorspace.c File Reference
#include "libavutil/frame.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/pixdesc.h"
#include "colorspace.h"

Go to the source code of this file.

Macros

#define WP_D65   { 0.3127, 0.3290 }
 
#define WP_C   { 0.3100, 0.3160 }
 
#define WP_DCI   { 0.3140, 0.3510 }
 
#define WP_E   { 1/3.0f, 1/3.0f }
 

Functions

void ff_matrix_invert_3x3 (const double in[3][3], double out[3][3])
 
void ff_matrix_mul_3x3 (double dst[3][3], const double src1[3][3], const double src2[3][3])
 
void ff_fill_rgb2xyz_table (const struct PrimaryCoefficients *coeffs, const struct WhitepointCoefficients *wp, double rgb2xyz[3][3])
 
const struct LumaCoefficientsff_get_luma_coefficients (enum AVColorSpace csp)
 
const struct ColorPrimariesff_get_color_primaries (enum AVColorPrimaries prm)
 
enum AVColorPrimaries ff_detect_color_primaries (const struct ColorPrimaries *prm)
 
void ff_fill_rgb2yuv_table (const struct LumaCoefficients *coeffs, double rgb2yuv[3][3])
 
double ff_determine_signal_peak (AVFrame *in)
 
void ff_update_hdr_metadata (AVFrame *in, double peak)
 

Variables

static const double ycgco_matrix [3][3]
 
static const double gbr_matrix [3][3]
 
static const struct LumaCoefficients luma_coefficients [AVCOL_SPC_NB]
 
static const struct ColorPrimaries color_primaries [AVCOL_PRI_NB]
 

Macro Definition Documentation

◆ WP_D65

#define WP_D65   { 0.3127, 0.3290 }

Definition at line 141 of file colorspace.c.

◆ WP_C

#define WP_C   { 0.3100, 0.3160 }

Definition at line 142 of file colorspace.c.

◆ WP_DCI

#define WP_DCI   { 0.3140, 0.3510 }

Definition at line 143 of file colorspace.c.

◆ WP_E

#define WP_E   { 1/3.0f, 1/3.0f }

Definition at line 144 of file colorspace.c.

Function Documentation

◆ ff_matrix_invert_3x3()

void ff_matrix_invert_3x3 ( const double  in[3][3],
double  out[3][3] 
)

◆ ff_matrix_mul_3x3()

void ff_matrix_mul_3x3 ( double  dst[3][3],
const double  src1[3][3],
const double  src2[3][3] 
)

Definition at line 54 of file colorspace.c.

Referenced by create_filtergraph(), fill_whitepoint_conv_table(), and get_rgb2rgb_matrix().

◆ ff_fill_rgb2xyz_table()

void ff_fill_rgb2xyz_table ( const struct PrimaryCoefficients coeffs,
const struct WhitepointCoefficients wp,
double  rgb2xyz[3][3] 
)

Definition at line 68 of file colorspace.c.

Referenced by create_filtergraph(), and get_rgb2rgb_matrix().

◆ ff_get_luma_coefficients()

const struct LumaCoefficients* ff_get_luma_coefficients ( enum AVColorSpace  csp)

Definition at line 128 of file colorspace.c.

Referenced by create_filtergraph(), init_filter(), and tonemap_opencl_init().

◆ ff_get_color_primaries()

const struct ColorPrimaries* ff_get_color_primaries ( enum AVColorPrimaries  prm)

Definition at line 160 of file colorspace.c.

Referenced by create_filtergraph(), and ff_icc_profile_generate().

◆ ff_detect_color_primaries()

enum AVColorPrimaries ff_detect_color_primaries ( const struct ColorPrimaries prm)

Definition at line 173 of file colorspace.c.

Referenced by iccdetect_filter_frame().

◆ ff_fill_rgb2yuv_table()

void ff_fill_rgb2yuv_table ( const struct LumaCoefficients coeffs,
double  rgb2yuv[3][3] 
)

Definition at line 198 of file colorspace.c.

Referenced by create_filtergraph(), init_filter(), and tonemap_opencl_init().

◆ ff_determine_signal_peak()

double ff_determine_signal_peak ( AVFrame in)

Definition at line 225 of file colorspace.c.

Referenced by filter_frame(), and tonemap_opencl_filter_frame().

◆ ff_update_hdr_metadata()

void ff_update_hdr_metadata ( AVFrame in,
double  peak 
)

Definition at line 250 of file colorspace.c.

Referenced by filter_frame(), and tonemap_opencl_filter_frame().

Variable Documentation

◆ ycgco_matrix

const double ycgco_matrix[3][3]
static
Initial value:
=
{
{ 0.25, 0.5, 0.25 },
{ -0.25, 0.5, -0.25 },
{ 0.5, 0, -0.5 },
}

Definition at line 96 of file colorspace.c.

Referenced by ff_fill_rgb2yuv_table().

◆ gbr_matrix

const double gbr_matrix[3][3]
static
Initial value:
=
{
{ 0, 1, 0 },
{ 0, -0.5, 0.5 },
{ 0.5, -0.5, 0 },
}

Definition at line 103 of file colorspace.c.

Referenced by ff_fill_rgb2yuv_table().

◆ luma_coefficients

const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB]
static
Initial value:
= {
[AVCOL_SPC_FCC] = { 0.30, 0.59, 0.11 },
[AVCOL_SPC_BT470BG] = { 0.299, 0.587, 0.114 },
[AVCOL_SPC_SMPTE170M] = { 0.299, 0.587, 0.114 },
[AVCOL_SPC_BT709] = { 0.2126, 0.7152, 0.0722 },
[AVCOL_SPC_SMPTE240M] = { 0.212, 0.701, 0.087 },
[AVCOL_SPC_YCOCG] = { 0.25, 0.5, 0.25 },
[AVCOL_SPC_RGB] = { 1, 1, 1 },
[AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
[AVCOL_SPC_BT2020_CL] = { 0.2627, 0.6780, 0.0593 },
}

Definition at line 116 of file colorspace.c.

Referenced by ff_get_luma_coefficients().

◆ color_primaries

const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
static
Initial value:
= {
[AVCOL_PRI_BT709] = { WP_D65, { 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 } },
[AVCOL_PRI_BT470M] = { WP_C, { 0.670, 0.330, 0.210, 0.710, 0.140, 0.080 } },
[AVCOL_PRI_BT470BG] = { WP_D65, { 0.640, 0.330, 0.290, 0.600, 0.150, 0.060 } },
[AVCOL_PRI_SMPTE170M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 0.070 } },
[AVCOL_PRI_SMPTE240M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 0.070 } },
[AVCOL_PRI_SMPTE428] = { WP_E, { 0.735, 0.265, 0.274, 0.718, 0.167, 0.009 } },
[AVCOL_PRI_SMPTE431] = { WP_DCI, { 0.680, 0.320, 0.265, 0.690, 0.150, 0.060 } },
[AVCOL_PRI_SMPTE432] = { WP_D65, { 0.680, 0.320, 0.265, 0.690, 0.150, 0.060 } },
[AVCOL_PRI_FILM] = { WP_C, { 0.681, 0.319, 0.243, 0.692, 0.145, 0.049 } },
[AVCOL_PRI_BT2020] = { WP_D65, { 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 } },
[AVCOL_PRI_JEDEC_P22] = { WP_D65, { 0.630, 0.340, 0.295, 0.605, 0.155, 0.077 } },
}

Definition at line 146 of file colorspace.c.

Referenced by color_config(), convert_primaries(), ff_detect_color_primaries(), ff_get_color_primaries(), mov_read_colr(), mov_read_vpcc(), print_primaries(), scale_vaapi_init(), and tonemap_vaapi_init().

AVCOL_SPC_YCOCG
@ AVCOL_SPC_YCOCG
Definition: pixfmt.h:535
AVCOL_PRI_JEDEC_P22
@ AVCOL_PRI_JEDEC_P22
Definition: pixfmt.h:488
AVCOL_SPC_RGB
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition: pixfmt.h:526
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:537
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:531
WP_D65
#define WP_D65
Definition: colorspace.c:141
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:532
AVCOL_PRI_SMPTE428
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: pixfmt.h:483
AVCOL_PRI_SMPTE240M
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
Definition: pixfmt.h:480
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:478
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:479
WP_C
#define WP_C
Definition: colorspace.c:142
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:473
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:482
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:485
AVCOL_PRI_FILM
@ AVCOL_PRI_FILM
colour filters using Illuminant C
Definition: pixfmt.h:481
WP_DCI
#define WP_DCI
Definition: colorspace.c:143
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:533
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:536
WP_E
#define WP_E
Definition: colorspace.c:144
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:476
AVCOL_SPC_FCC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:530
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:486
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:527