From 1aeceb36378f8d8de982c00b6194e936d83453c7 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 5 Apr 2022 08:17:32 +0200 Subject: [PATCH] More hacks --- buffer_list.c | 25 ++++++++++++++++++++++--- main_decode.c => main_isp12.c.bak | 4 ++-- main_isp.c.bak => main_isp13.c | 4 ++-- v4l2.c | 4 ++++ 4 files changed, 30 insertions(+), 7 deletions(-) rename main_decode.c => main_isp12.c.bak (98%) rename main_isp.c.bak => main_isp13.c (98%) diff --git a/buffer_list.c b/buffer_list.c index dd11940..b66b0ef 100644 --- a/buffer_list.c +++ b/buffer_list.c @@ -70,6 +70,20 @@ int buffer_list_set_format(buffer_list_t *buf_list, unsigned width, unsigned hei fmt->type = buf_list->type; + bool retried = false; + unsigned orig_width = width; + unsigned orig_height = height; + unsigned stride = 0; + +retry: + + if (strstr(buf_list->name, "JPEG")) { + width = (width) / 16 * 16; + height = (height) / 16 * 16; + stride = orig_width * 2; + printf("JPEG: %dx%d vs %dx%d\n", orig_width, orig_height, width, height); + } + if (buf_list->do_mplanes) { fmt->fmt.pix_mp.colorspace = V4L2_COLORSPACE_JPEG; fmt->fmt.pix_mp.width = width; @@ -77,7 +91,7 @@ int buffer_list_set_format(buffer_list_t *buf_list, unsigned width, unsigned hei fmt->fmt.pix_mp.pixelformat = format; fmt->fmt.pix_mp.field = V4L2_FIELD_ANY; fmt->fmt.pix_mp.num_planes = 1; - //fmt->fmt.pix_mp.plane_fmt[0].bytesperline = width; // fourcc_to_stride(width, format); + fmt->fmt.pix_mp.plane_fmt[0].bytesperline = stride;// fourcc_to_stride(orig_width, format); } else { fmt->fmt.pix.colorspace = V4L2_COLORSPACE_RAW; fmt->fmt.pix.width = width; @@ -90,9 +104,14 @@ int buffer_list_set_format(buffer_list_t *buf_list, unsigned width, unsigned hei E_LOG_DEBUG(buf_list, "Configuring format ..."); E_XIOCTL(buf_list, buf_list->device->fd, VIDIOC_S_FMT, fmt, "Can't set format"); - if (fmt->fmt.pix.width != width || fmt->fmt.pix.height < height) { - E_LOG_ERROR(buf_list, "Requested resolution=%ux%u is unavailable. Got %ux%u.", + if (fmt->fmt.pix.width != width || fmt->fmt.pix.height != height) { + E_LOG_INFO(buf_list, "Requested resolution=%ux%u is unavailable. Got %ux%u.", width, height, fmt->fmt.pix.width, fmt->fmt.pix.height); + if (retried) { + E_LOG_ERROR(buf_list, "Did retry."); + } + retried = true; + goto retry; } if (fmt->fmt.pix.pixelformat != format) { diff --git a/main_decode.c b/main_isp12.c.bak similarity index 98% rename from main_decode.c rename to main_isp12.c.bak index 9fb89c6..f11c40b 100644 --- a/main_decode.c +++ b/main_isp12.c.bak @@ -7,8 +7,8 @@ #include -int camera_width = 1280; -int camera_height = 720; +int camera_width = 1920; +int camera_height = 1080; int camera_format = V4L2_PIX_FMT_SRGGB10P; int camera_nbufs = 1; bool camera_use_low = true; diff --git a/main_isp.c.bak b/main_isp13.c similarity index 98% rename from main_isp.c.bak rename to main_isp13.c index 38853d1..1d824b9 100644 --- a/main_isp.c.bak +++ b/main_isp13.c @@ -7,8 +7,8 @@ #include -int camera_width = 1280; -int camera_height = 720; +int camera_width = 2328; +int camera_height = 1748; int camera_format = V4L2_PIX_FMT_SRGGB10P; int camera_nbufs = 1; bool camera_use_low = true; diff --git a/v4l2.c b/v4l2.c index 09f66c3..977d9c5 100644 --- a/v4l2.c +++ b/v4l2.c @@ -66,6 +66,10 @@ unsigned fourcc_to_stride(unsigned width, unsigned format) case V4L2_PIX_FMT_SRGGB10P: return align_size(width * 5 / 4, 32); + case V4L2_PIX_FMT_JPEG: + case V4L2_PIX_FMT_H264: + return 0; + default: E_LOG_PERROR(NULL, "Unknown format: %s", fourcc_to_string(format).buf); }