aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-10-30 10:55:31 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-10-30 10:55:31 +0100
commit0a54a039b62c1b02629482c64b7a0794534a47ae (patch)
tree4baa74517922be0dfe0556299653793062c5e2f8
parent1d00c48a42a86d46bc61cbe66a7eec0aeaedab61 (diff)
downloadv4l-utils-0a54a039b62c1b02629482c64b7a0794534a47ae.tar.gz
v4l2grab: pass fmt to the conversion function
Right now, it colorspace parameters are not passed to the conversion routines. However, those are needed at the conversion routines, in order to be able to properly handle YUV conversion. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--contrib/test/v4l2grab.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/contrib/test/v4l2grab.c b/contrib/test/v4l2grab.c
index 1f4a0988..c907ee58 100644
--- a/contrib/test/v4l2grab.c
+++ b/contrib/test/v4l2grab.c
@@ -263,13 +263,15 @@ static void copy_two_pixels(uint32_t fourcc,
}
}
-static unsigned int convert_to_rgb24(uint32_t fourcc, unsigned char *p_in,
- unsigned char *p_out, uint32_t width,
- uint32_t height)
+static unsigned int convert_to_rgb24(struct v4l2_format *fmt, unsigned char *p_in,
+ unsigned char *p_out)
{
unsigned char *p_start, *p_in_x[2];
unsigned int bytes_per_pixel;
unsigned int x, y, depth;
+ uint32_t fourcc = fmt->fmt.pix.pixelformat;
+ uint32_t width = fmt->fmt.pix.width;
+ uint32_t height = fmt->fmt.pix.height;
switch (fourcc) {
case V4L2_PIX_FMT_BGR24:
@@ -361,11 +363,7 @@ static int read_capture_loop(int fd, struct buffer *buffers,
if (!out_buf) {
out_buf = buffers[0].start;
} else {
- size = convert_to_rgb24(fmt->fmt.pix.pixelformat,
- buffers[0].start,
- out_buf,
- fmt->fmt.pix.width,
- fmt->fmt.pix.height);
+ size = convert_to_rgb24(fmt, buffers[0].start, out_buf);
}
fwrite(out_buf, size, 1, fout);
@@ -441,11 +439,8 @@ static int userptr_capture_loop(int fd, struct buffer *buffers,
out_buf = buffers[buf.index].start;
size = buf.bytesused;
} else {
- size = convert_to_rgb24(fmt->fmt.pix.pixelformat,
- buffers[buf.index].start,
- out_buf,
- fmt->fmt.pix.width,
- fmt->fmt.pix.height);
+ size = convert_to_rgb24(fmt, buffers[buf.index].start,
+ out_buf);
}
fwrite(out_buf, size, 1, fout);
@@ -642,11 +637,8 @@ static int mmap_capture_threads(int fd, struct buffer *buffers,
out_buf = buffers[buf.index].start;
size = buf.bytesused;
} else {
- size = convert_to_rgb24(fmt->fmt.pix.pixelformat,
- buffers[buf.index].start,
- out_buf,
- fmt->fmt.pix.width,
- fmt->fmt.pix.height);
+ size = convert_to_rgb24(fmt, buffers[buf.index].start,
+ out_buf);
}
fwrite(out_buf, size, 1, fout);
@@ -719,11 +711,8 @@ static int mmap_capture_loop(int fd, struct buffer *buffers,
out_buf = buffers[buf.index].start;
size = buf.bytesused;
} else {
- size = convert_to_rgb24(fmt->fmt.pix.pixelformat,
- buffers[buf.index].start,
- out_buf,
- fmt->fmt.pix.width,
- fmt->fmt.pix.height);
+ size = convert_to_rgb24(fmt, buffers[buf.index].start,
+ out_buf);
}
fwrite(out_buf, size, 1, fout);
fclose(fout);