Improve ISP compatibility (fractional resizing)

This commit is contained in:
Kamil Trzcinski
2022-04-05 11:26:06 +02:00
parent cdcac155f6
commit 863acbbde5
7 changed files with 30 additions and 21 deletions

View File

@@ -43,7 +43,7 @@ typedef struct camera_s {
void camera_init(camera_t *camera);
void camera_close(camera_t *camera);
int camera_open(camera_t *camera, const char *path);
int camera_configure_srgb_isp(camera_t *camera, bool use_half);
int camera_configure_srgb_legacy_isp(camera_t *camera);
int camera_configure_srgb_isp(camera_t *camera, float high_div, float low_div);
int camera_configure_srgb_legacy_isp(camera_t *camera, float div);
int camera_set_params(camera_t *camera);
int camera_run(camera_t *camera);

View File

@@ -12,7 +12,7 @@ extern bool check_streaming();
void write_yuvu(buffer_t *buffer);
int camera_configure_srgb_isp(camera_t *camera, bool use_half)
int camera_configure_srgb_isp(camera_t *camera, float high_div, float low_div)
{
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, V4L2_PIX_FMT_SRGGB10P, 0, camera->nbufs) < 0) {
return -1;
@@ -26,14 +26,14 @@ int camera_configure_srgb_isp(camera_t *camera, bool use_half)
camera->codec_h264 = device_open("H264", "/dev/video11");
if (device_open_buffer_list(camera->isp.isp_srgb, false, src->fmt_width, src->fmt_height, src->fmt_format, src->fmt_bytesperline, camera->nbufs) < 0 ||
device_open_buffer_list(camera->isp.isp_yuuv, true, src->fmt_width, src->fmt_height, V4L2_PIX_FMT_YUYV, 0, camera->nbufs) < 0) {
device_open_buffer_list(camera->isp.isp_yuuv, true, src->fmt_width / high_div, src->fmt_height / high_div, V4L2_PIX_FMT_YUYV, 0, camera->nbufs) < 0) {
return -1;
}
if (use_half) {
if (low_div >= 1) {
camera->isp.isp_yuuv_low = device_open("ISP-YUUV-LOW", "/dev/video15");
if (device_open_buffer_list(camera->isp.isp_yuuv_low, true, src->fmt_width / 2, src->fmt_height / 2, V4L2_PIX_FMT_YUYV, 0, camera->nbufs) < 0) {
if (device_open_buffer_list(camera->isp.isp_yuuv_low, true, src->fmt_width / low_div, src->fmt_height / low_div, V4L2_PIX_FMT_YUYV, 0, camera->nbufs) < 0) {
return -1;
}
@@ -60,7 +60,7 @@ int camera_configure_srgb_isp(camera_t *camera, bool use_half)
*links++ = (link_t){ camera->camera, { camera->isp.isp_srgb }, { NULL, check_streaming } };
if (use_half) {
if (camera->isp.isp_yuuv_low) {
*links++ = (link_t){ camera->isp.isp_yuuv, { } };
*links++ = (link_t){ camera->isp.isp_yuuv_low, { camera->codec_jpeg, camera->codec_h264 }, { write_yuvu } };
} else {

View File

@@ -12,7 +12,7 @@ extern bool check_streaming();
void write_yuvu(buffer_t *buffer)
{
#if 1
#if 0
FILE *fp = fopen("/tmp/capture-yuyv.raw.tmp", "wb");
if (fp) {
fwrite(buffer->start, 1, buffer->used, fp);
@@ -22,7 +22,7 @@ void write_yuvu(buffer_t *buffer)
#endif
}
int camera_configure_srgb_legacy_isp(camera_t *camera)
int camera_configure_srgb_legacy_isp(camera_t *camera, float div)
{
if (device_open_buffer_list(camera->camera, true, camera->width, camera->height, V4L2_PIX_FMT_SRGGB10P, 0, camera->nbufs) < 0) {
return -1;
@@ -35,7 +35,7 @@ int camera_configure_srgb_legacy_isp(camera_t *camera)
camera->codec_h264 = device_open("H264", "/dev/video11");
if (device_open_buffer_list(camera->legacy_isp.isp, false, src->fmt_width, src->fmt_height, src->fmt_format, src->fmt_bytesperline, camera->nbufs) < 0 ||
device_open_buffer_list(camera->legacy_isp.isp, true, src->fmt_width, src->fmt_height, V4L2_PIX_FMT_YUYV, 0, camera->nbufs) < 0) {
device_open_buffer_list(camera->legacy_isp.isp, true, src->fmt_width / div, src->fmt_height / div, V4L2_PIX_FMT_YUYV, 0, camera->nbufs) < 0) {
return -1;
}

View File

@@ -33,20 +33,22 @@ int main(int argc, char *argv[])
camera_init(&camera);
// camera.width = 2328;
// camera.height = 1748;
// camera.nbufs = 4;
// camera.width = 1920; camera.height = 1080;
camera.width = 2328; camera.height = 1748; // 1164x874
//camera.width = 4656; camera.height = 3496;
//camera.width = 3840; camera.height = 2160;
camera.nbufs = 4;
if (camera_open(&camera, "/dev/video0") < 0) {
goto error;
}
#if 0
if (camera_configure_srgb_isp(&camera, true) < 0) {
#if 1
if (camera_configure_srgb_isp(&camera, 1.6, 0) < 0) {
goto error;
}
#else
if (camera_configure_srgb_legacy_isp(&camera) < 0) {
if (camera_configure_srgb_legacy_isp(&camera, 1.3) < 0) {
goto error;
}
#endif