Skip to content

Commit

Permalink
[media] v4l2-tpg: don't clamp XV601/709 to lim range
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hverkuil authored and mchehab committed Apr 10, 2017
1 parent 86c7eb4 commit 4aed35c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4aed35c

Please sign in to comment.