summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2017-04-10 10:54:30 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-04-10 20:58:06 +0300
commit4aed35ca73f6d9cfd5f7089ba5d04f5fb8623080 (patch)
treed3bd2500617c8e9f534a65ad0c5f4ac613636649 /drivers/media
parent86c7eb411b2450dafee3b0ec5c4c191f83e6511f (diff)
downloadlinux-4aed35ca73f6d9cfd5f7089ba5d04f5fb8623080.tar.xz
[media] v4l2-tpg: don't clamp XV601/709 to lim range
The XV601/709 encodings are special: they signal limited range, but use the full range to encode a larger gamut with R', G' and B' values outside the [0-1] range. So don't clamp to limited range for these two encodings. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/v4l2-tpg/v4l2-tpg-core.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index e47b46e2d26c..3dd22da7e17d 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -927,7 +927,14 @@ static void precalculate_color(struct tpg_data *tpg, int k)
y >>= 4;
cb >>= 4;
cr >>= 4;
- if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
+ /*
+ * XV601/709 use the header/footer margins to encode R', G'
+ * and B' values outside the range [0-1]. So do not clamp
+ * XV601/709 values.
+ */
+ if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE &&
+ tpg->real_ycbcr_enc != V4L2_YCBCR_ENC_XV601 &&
+ tpg->real_ycbcr_enc != V4L2_YCBCR_ENC_XV709) {
y = clamp(y, 16, 235);
cb = clamp(cb, 16, 240);
cr = clamp(cr, 16, 240);