Update for 5.1.8
[ffmpeg.git] / libavutil / csp.h
1 /*
2 * Copyright (c) 2016 Ronald S. Bultje <rsbultje@gmail.com>
3 * This file is part of FFmpeg.
4 *
5 * FFmpeg is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * FFmpeg is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with FFmpeg; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef AVUTIL_CSP_H
21 #define AVUTIL_CSP_H
22
23 #include "pixfmt.h"
24 #include "rational.h"
25
26 /**
27 * @file Colorspace value utility functions for libavutil.
28 * @author Ronald S. Bultje <rsbultje@gmail.com>
29 * @author Leo Izen <leo.izen@gmail.com>
30 * @defgroup lavu_math_csp Colorspace Utility
31 * @ingroup lavu_math
32 * @{
33 */
34
35 /**
36 * Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar
37 * calculations.
38 */
39 typedef struct AVLumaCoefficients {
40 AVRational cr, cg, cb;
41 } AVLumaCoefficients;
42
43 /**
44 * Struct containing chromaticity x and y values for the standard CIE 1931
45 * chromaticity definition.
46 */
47 typedef struct AVCIExy {
48 AVRational x, y;
49 } AVCIExy;
50
51 /**
52 * Struct defining the red, green, and blue primary locations in terms of CIE
53 * 1931 chromaticity x and y.
54 */
55 typedef struct AVPrimaryCoefficients {
56 AVCIExy r, g, b;
57 } AVPrimaryCoefficients;
58
59 /**
60 * Struct defining white point location in terms of CIE 1931 chromaticity x
61 * and y.
62 */
63 typedef AVCIExy AVWhitepointCoefficients;
64
65 /**
66 * Struct that contains both white point location and primaries location, providing
67 * the complete description of a color gamut.
68 */
69 typedef struct AVColorPrimariesDesc {
70 AVWhitepointCoefficients wp;
71 AVPrimaryCoefficients prim;
72 } AVColorPrimariesDesc;
73
74 /**
75 * Retrieves the Luma coefficients necessary to construct a conversion matrix
76 * from an enum constant describing the colorspace.
77 * @param csp An enum constant indicating YUV or similar colorspace.
78 * @return The Luma coefficients associated with that colorspace, or NULL
79 * if the constant is unknown to libavutil.
80 */
81 const AVLumaCoefficients *av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp);
82
83 /**
84 * Retrieves a complete gamut description from an enum constant describing the
85 * color primaries.
86 * @param prm An enum constant indicating primaries
87 * @return A description of the colorspace gamut associated with that enum
88 * constant, or NULL if the constant is unknown to libavutil.
89 */
90 const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries prm);
91
92 /**
93 * Detects which enum AVColorPrimaries constant corresponds to the given complete
94 * gamut description.
95 * @see enum AVColorPrimaries
96 * @param prm A description of the colorspace gamut
97 * @return The enum constant associated with this gamut, or
98 * AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified.
99 */
100 enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm);
101
102 /**
103 * @}
104 */
105
106 #endif /* AVUTIL_CSP_H */