Go to the documentation of this file.
38 #define AVR(d) { (int)(d * 100000 + 0.5), 100000 }
71 #define WP_D65 { AVR(0.3127), AVR(0.3290) }
72 #define WP_C { AVR(0.3100), AVR(0.3160) }
73 #define WP_DCI { AVR(0.3140), AVR(0.3510) }
74 #define WP_E { {1, 3}, {1, 3} }
116 if (!
ref->prim.r.x.num)
160 #define BT709_alpha 1.099296826809442
161 #define BT709_beta 0.018053968510807
168 return (0.0 > Lc) ? 0.0
169 : (
b > Lc) ? 4.500 * Lc
170 :
a * pow(Lc, 0.45) - (
a - 1.0);
175 return (0.0 > Lc) ? 0.0 : pow(Lc, 1.0/ 2.2);
180 return (0.0 > Lc) ? 0.0 : pow(Lc, 1.0/ 2.8);
185 const double a = 1.1115;
186 const double b = 0.0228;
188 return (0.0 > Lc) ? 0.0
189 : (
b > Lc) ? 4.000 * Lc
190 :
a * pow(Lc, 0.45) - (
a - 1.0);
200 return (0.01 > Lc) ? 0.0 : 1.0 + log10(Lc) / 2.0;
206 return (0.00316227766 > Lc) ? 0.0 : 1.0 + log10(Lc) / 2.5;
214 return (-
b >= Lc) ? -
a * pow(-Lc, 0.45) + (
a - 1.0)
215 : (
b > Lc) ? 4.500 * Lc
216 :
a * pow( Lc, 0.45) - (
a - 1.0);
224 return (-0.0045 >= Lc) ? -(
a * pow(-4.0 * Lc, 0.45) + (
a - 1.0)) / 4.0
225 : (
b > Lc) ? 4.500 * Lc
226 :
a * pow( Lc, 0.45) - (
a - 1.0);
231 const double a = 1.055;
232 const double b = 0.0031308;
234 return (0.0 > Lc) ? 0.0
235 : (
b > Lc) ? 12.92 * Lc
236 :
a * pow(Lc, 1.0 / 2.4) - (
a - 1.0);
241 const double c1 = 3424.0 / 4096.0;
242 const double c2 = 32.0 * 2413.0 / 4096.0;
243 const double c3 = 32.0 * 2392.0 / 4096.0;
244 const double m = 128.0 * 2523.0 / 4096.0;
245 const double n = 0.25 * 2610.0 / 4096.0;
246 const double L = Lc / 10000.0;
247 const double Ln = pow(
L, n);
249 return (0.0 > Lc) ? 0.0
250 : pow((
c1 +
c2 * Ln) / (1.0 + c3 * Ln), m);
256 return (0.0 > Lc) ? 0.0
257 : pow(48.0 * Lc / 52.37, 1.0 / 2.6);
265 const double a = 0.17883277;
266 const double b = 0.28466892;
267 const double c = 0.55991073;
268 return (0.0 > Lc) ? 0.0 :
269 (Lc <= 1.0 / 12.0 ? sqrt(3.0 * Lc) :
a *
log(12.0 * Lc -
b) +
c);
int(* func)(AVBPrint *dst, const char *in, const char *arg)
static av_always_inline AVRational abs_sub_q(AVRational r1, AVRational r2)
AVColorTransferCharacteristic
Color Transfer Characteristic.
AVWhitepointCoefficients wp
static double trc_smpte240M(double Lc)
Struct that contains both white point location and primaries location, providing the complete descrip...
@ AVCOL_TRC_LINEAR
"Linear transfer characteristics"
@ AVCOL_TRC_NB
Not part of ABI.
const struct AVLumaCoefficients * av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp)
Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant desc...
@ AVCOL_SPC_NB
Not part of ABI.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
@ AVCOL_TRC_BT2020_12
ITU-R BT2020 for 12-bit system.
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
AVRational av_sub_q(AVRational b, AVRational c)
Subtract one rational from another.
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
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.
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
@ AVCOL_TRC_GAMMA28
also ITU-R BT470BG
static double trc_gamma22(double Lc)
@ AVCOL_TRC_LOG_SQRT
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
@ AVCOL_TRC_GAMMA22
also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
static double trc_iec61966_2_1(double Lc)
@ AVCOL_PRI_NB
Not part of ABI.
const AVColorPrimariesDesc * av_csp_primaries_desc_from_id(enum AVColorPrimaries prm)
Retrieves a complete gamut description from an enum constant describing the color primaries.
@ AVCOL_TRC_BT1361_ECG
ITU-R BT1361 Extended Colour Gamut.
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
static const double approximate_gamma[AVCOL_TRC_NB]
@ AVCOL_PRI_SMPTE428
SMPTE ST 428-1 (CIE 1931 XYZ)
enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm)
Detects which enum AVColorPrimaries constant corresponds to the given complete gamut description.
@ AVCOL_PRI_SMPTE240M
identical to above, also called "SMPTE C" even though it uses D65
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Rational number (pair of numerator and denominator).
@ AVCOL_TRC_IEC61966_2_4
IEC 61966-2-4.
static const av_csp_trc_function trc_funcs[AVCOL_TRC_NB]
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
static double trc_bt1361(double Lc)
@ AVCOL_TRC_BT2020_10
ITU-R BT2020 for 10-bit system.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
@ AVCOL_PRI_BT2020
ITU-R BT2020.
static const AVColorPrimariesDesc color_primaries[AVCOL_PRI_NB]
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
@ AVCOL_PRI_FILM
colour filters using Illuminant C
static double trc_log(double Lc)
@ AVCOL_TRC_LOG
"Logarithmic transfer characteristic (100:1 range)"
static double trc_smpte_st2084(double Lc)
static AVRational av_make_q(int num, int den)
Create an AVRational.
double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc)
Determine a suitable 'gamma' value to match the supplied AVColorTransferCharacteristic.
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
@ AVCOL_TRC_BT709
also ITU-R BT1361
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
double(* av_csp_trc_function)(double)
Function pointer representing a double -> double transfer function that performs an EOTF transfer inv...
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
AVColorSpace
YUV colorspace type.
static double trc_bt709(double Lc)
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
@ AVCOL_PRI_BT470M
also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
static double trc_linear(double Lc)
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
static double trc_gamma28(double Lc)
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
static int ref[MAX_W *MAX_W]
@ AVCOL_TRC_SMPTE170M
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
static double trc_log_sqrt(double Lc)
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
AVPrimaryCoefficients prim
static const struct AVLumaCoefficients luma_coefficients[AVCOL_SPC_NB]
@ AVCOL_TRC_SMPTE428
SMPTE ST 428-1.
static double trc_arib_std_b67(double Lc)
static double trc_smpte_st428_1(double Lc)
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
static double trc_iec61966_2_4(double Lc)