FFmpeg
Macros | Functions | Variables
csp.c File Reference
#include <stdlib.h>
#include "attributes.h"
#include "csp.h"
#include "pixfmt.h"
#include "rational.h"

Go to the source code of this file.

Macros

#define AVR(d)   { (int)(d * 100000 + 0.5), 100000 }
 
#define WP_D65   { AVR(0.3127), AVR(0.3290) }
 
#define WP_C   { AVR(0.3100), AVR(0.3160) }
 
#define WP_DCI   { AVR(0.3140), AVR(0.3510) }
 
#define WP_E   { {1, 3}, {1, 3} }
 

Functions

const struct 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...
 
static av_always_inline AVRational abs_sub_q (AVRational r1, AVRational r2)
 
enum AVColorPrimaries av_csp_primaries_id_from_desc (const AVColorPrimariesDesc *prm)
 Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description. More...
 

Variables

static const struct AVLumaCoefficients luma_coefficients [AVCOL_SPC_NB]
 
static const AVColorPrimariesDesc color_primaries [AVCOL_PRI_NB]
 

Macro Definition Documentation

◆ AVR

#define AVR (   d)    { (int)(d * 100000 + 0.5), 100000 }

Definition at line 33 of file csp.c.

◆ WP_D65

#define WP_D65   { AVR(0.3127), AVR(0.3290) }

Definition at line 66 of file csp.c.

◆ WP_C

#define WP_C   { AVR(0.3100), AVR(0.3160) }

Definition at line 67 of file csp.c.

◆ WP_DCI

#define WP_DCI   { AVR(0.3140), AVR(0.3510) }

Definition at line 68 of file csp.c.

◆ WP_E

#define WP_E   { {1, 3}, {1, 3} }

Definition at line 69 of file csp.c.

Function Documentation

◆ abs_sub_q()

static av_always_inline AVRational abs_sub_q ( AVRational  r1,
AVRational  r2 
)
static

Definition at line 98 of file csp.c.

Referenced by av_csp_primaries_id_from_desc().

Variable Documentation

◆ luma_coefficients

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

Definition at line 41 of file csp.c.

Referenced by av_csp_luma_coeffs_from_avcsp().

◆ color_primaries

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

Definition at line 71 of file csp.c.

Referenced by av_csp_primaries_desc_from_id(), av_csp_primaries_id_from_desc(), color_config(), convert_primaries(), mov_read_colr(), mov_read_vpcc(), print_primaries(), scale_vaapi_init(), and tonemap_vaapi_init().

WP_D65
#define WP_D65
Definition: csp.c:66
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_C
#define WP_C
Definition: csp.c:67
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
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
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
AVCOL_PRI_BT470M
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:476
WP_E
#define WP_E
Definition: csp.c:69
AVR
#define AVR(d)
Definition: csp.c:33
WP_DCI
#define WP_DCI
Definition: csp.c:68
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