summaryrefslogtreecommitdiff
path: root/libavfilter/vf_colorspace.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2017-06-05 16:05:11 -0400
committerVittorio Giovara <vittorio.giovara@gmail.com>2017-06-06 11:22:52 -0400
commitd9909b11d9b044e023daefb75de219d643af4d7f (patch)
tree298e80fd01223455604fcd551110a4cd9fdbe701 /libavfilter/vf_colorspace.c
parent18bca25adbae9d010d75f9fc197c0af656af758d (diff)
vf_colorspace: Add support for gbr color space
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavfilter/vf_colorspace.c')
-rw-r--r--libavfilter/vf_colorspace.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 0024505a44..0b1bc81f99 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -183,6 +183,13 @@ static const double ycgco_matrix[3][3] =
{ 0.5, 0, -0.5 },
};
+static const double gbr_matrix[3][3] =
+{
+ { 0, 1, 0 },
+ { 0, -0.5, 0.5 },
+ { 0.5, -0.5, 0 },
+};
+
/*
* All constants explained in e.g. https://linuxtv.org/downloads/v4l-dvb-apis/ch02s06.html
* The older ones (bt470bg/m) are also explained in their respective ITU docs
@@ -196,6 +203,7 @@ static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB] = {
[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 },
};
@@ -222,6 +230,9 @@ static void fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
if (coeffs->cr == 0.25 && coeffs->cg == 0.5 && coeffs->cb == 0.25) {
memcpy(rgb2yuv, ycgco_matrix, sizeof(double) * 9);
return;
+ } else if (coeffs->cr == 1 && coeffs->cg == 1 && coeffs->cb == 1) {
+ memcpy(rgb2yuv, gbr_matrix, sizeof(double) * 9);
+ return;
}
rgb2yuv[0][0] = coeffs->cr;
@@ -1074,6 +1085,7 @@ static const AVOption colorspace_options[] = {
ENUM("smpte170m", AVCOL_SPC_SMPTE170M, "csp"),
ENUM("smpte240m", AVCOL_SPC_SMPTE240M, "csp"),
ENUM("ycgco", AVCOL_SPC_YCGCO, "csp"),
+ ENUM("gbr", AVCOL_SPC_RGB, "csp"),
ENUM("bt2020ncl", AVCOL_SPC_BT2020_NCL, "csp"),
{ "range", "Output color range",