More hacks
This commit is contained in:
parent
ffd3ac4157
commit
1aeceb3637
@ -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) {
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
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;
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
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;
|
4
v4l2.c
4
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user