Commit 7a20f398 authored by Ricardo Ribalda Delgado's avatar Ricardo Ribalda Delgado Committed by Mauro Carvalho Chehab

[media] vivid: Fix YUV555 and YUV565 handling

precalculate_color() had a optimization that avoided duplicated
conversion for YUV formats. This optimization did not take into
consideration YUV444, YUV555, YUV565 or limited range quantization.

This patch keeps the optimization, but fixes the wrong handling.
Signed-off-by: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent ca2b32da
...@@ -795,6 +795,8 @@ static void precalculate_color(struct tpg_data *tpg, int k) ...@@ -795,6 +795,8 @@ static void precalculate_color(struct tpg_data *tpg, int k)
int r = tpg_colors[col].r; int r = tpg_colors[col].r;
int g = tpg_colors[col].g; int g = tpg_colors[col].g;
int b = tpg_colors[col].b; int b = tpg_colors[col].b;
int y, cb, cr;
bool ycbcr_valid = false;
if (k == TPG_COLOR_TEXTBG) { if (k == TPG_COLOR_TEXTBG) {
col = tpg_get_textbg_color(tpg); col = tpg_get_textbg_color(tpg);
...@@ -871,7 +873,6 @@ static void precalculate_color(struct tpg_data *tpg, int k) ...@@ -871,7 +873,6 @@ static void precalculate_color(struct tpg_data *tpg, int k)
tpg->saturation != 128 || tpg->hue) && tpg->saturation != 128 || tpg->hue) &&
tpg->color_enc != TGP_COLOR_ENC_LUMA) { tpg->color_enc != TGP_COLOR_ENC_LUMA) {
/* Implement these operations */ /* Implement these operations */
int y, cb, cr;
int tmp_cb, tmp_cr; int tmp_cb, tmp_cr;
/* First convert to YCbCr */ /* First convert to YCbCr */
...@@ -888,12 +889,9 @@ static void precalculate_color(struct tpg_data *tpg, int k) ...@@ -888,12 +889,9 @@ static void precalculate_color(struct tpg_data *tpg, int k)
cb = (128 << 4) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 * 128); cb = (128 << 4) + (tmp_cb * tpg->contrast * tpg->saturation) / (128 * 128);
cr = (128 << 4) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 * 128); cr = (128 << 4) + (tmp_cr * tpg->contrast * tpg->saturation) / (128 * 128);
if (tpg->color_enc == TGP_COLOR_ENC_YCBCR) { if (tpg->color_enc == TGP_COLOR_ENC_YCBCR)
tpg->colors[k][0] = clamp(y >> 4, 1, 254); ycbcr_valid = true;
tpg->colors[k][1] = clamp(cb >> 4, 1, 254); else
tpg->colors[k][2] = clamp(cr >> 4, 1, 254);
return;
}
ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b); ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b);
} else if ((tpg->brightness != 128 || tpg->contrast != 128) && } else if ((tpg->brightness != 128 || tpg->contrast != 128) &&
tpg->color_enc == TGP_COLOR_ENC_LUMA) { tpg->color_enc == TGP_COLOR_ENC_LUMA) {
...@@ -915,8 +913,7 @@ static void precalculate_color(struct tpg_data *tpg, int k) ...@@ -915,8 +913,7 @@ static void precalculate_color(struct tpg_data *tpg, int k)
case TGP_COLOR_ENC_YCBCR: case TGP_COLOR_ENC_YCBCR:
{ {
/* Convert to YCbCr */ /* Convert to YCbCr */
int y, cb, cr; if (!ycbcr_valid)
color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr); color_to_ycbcr(tpg, r, g, b, &y, &cb, &cr);
if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) { if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment