summaryrefslogtreecommitdiff
path: root/src/gen-image.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2016-09-13 00:36:59 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2016-09-13 00:39:16 +0300
commitf0d6dfc637194a98861e5565556144076fe1b789 (patch)
tree562ee1368572d1e46b9cc7d7bf2683cf4de77fd4 /src/gen-image.c
parent8fb25dd94a574db88a24d3351bca1b8c0e47455d (diff)
gen-image: Subsample YUV chroma on input
When the input format is YUV, subsample the chroma during RGB to YUV conversion based on the YUV format parameters. This matches the RGB to YUV conversion performed to generate the test input frame fed to the RPF. A better fix would be to add support for unpacking all RGB and YUV formats instead of converting the .pnm reference frames. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/gen-image.c')
-rw-r--r--src/gen-image.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gen-image.c b/src/gen-image.c
index a389f77..15107d1 100644
--- a/src/gen-image.c
+++ b/src/gen-image.c
@@ -715,6 +715,7 @@ static void colorspace_rgb2ycbcr(int m[3][3],
static void image_colorspace_rgb_to_yuv(const struct image *input,
struct image *output,
+ const struct format_info *format,
const struct params *params)
{
int matrix[3][3];
@@ -727,10 +728,17 @@ static void image_colorspace_rgb_to_yuv(const struct image *input,
for (y = 0; y < output->height; ++y) {
for (x = 0; x < output->width; ++x) {
- colorspace_rgb2ycbcr(matrix, params->quantization, idata, odata);
- idata += 3;
- odata += 3;
+ colorspace_rgb2ycbcr(matrix, params->quantization,
+ &idata[3*x], &odata[3*x]);
+ }
+ if (format->yuv.xsub == 2) {
+ for (x = 1; x < output->width - 1; x += 2) {
+ odata[3*x + 1] = (odata[3*(x-1) + 1] + odata[3*(x+1) + 1]) / 2;
+ odata[3*x + 2] = (odata[3*(x-1) + 2] + odata[3*(x+1) + 2]) / 2;
+ }
}
+ idata += 3 * output->width;
+ odata += 3 * output->width;
}
}
@@ -1158,7 +1166,8 @@ static int process(const struct options *options)
goto done;
}
- image_colorspace_rgb_to_yuv(input, yuv, &options->params);
+ image_colorspace_rgb_to_yuv(input, yuv, options->input_format,
+ &options->params);
image_delete(input);
input = yuv;
} else if (options->input_format->rgb.bpp < 24) {
@@ -1300,7 +1309,8 @@ static int process(const struct options *options)
goto done;
}
- image_colorspace_rgb_to_yuv(input, converted, &options->params);
+ image_colorspace_rgb_to_yuv(input, converted, format,
+ &options->params);
image_delete(input);
input = converted;
}