From 9a685eb8399293ecb344b76cda7d88a3cc0cb993 Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Sat, 22 Jul 2023 16:41:38 +0200 Subject: [PATCH] Use xfer function from libmegapixels instead of v4l --- src/gles2_debayer.c | 4 ++-- src/gles2_debayer.h | 2 +- src/io_pipeline.c | 4 ---- src/process_pipeline.c | 3 +-- src/state.h | 2 -- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/gles2_debayer.c b/src/gles2_debayer.c index cd20671..7eb23f7 100644 --- a/src/gles2_debayer.c +++ b/src/gles2_debayer.c @@ -23,7 +23,7 @@ struct _GLES2Debayer { }; GLES2Debayer * -gles2_debayer_new(int format, uint32_t colorspace) +gles2_debayer_new(int format, int xfer) { uint32_t pixfmt = libmegapixels_format_to_v4l_pixfmt(format); if (pixfmt != V4L2_PIX_FMT_SBGGR8 && pixfmt != V4L2_PIX_FMT_SGBRG8 && @@ -38,7 +38,7 @@ gles2_debayer_new(int format, uint32_t colorspace) check_gl(); char format_def[96]; - bool is_srgb = colorspace == V4L2_COLORSPACE_SRGB; + bool is_srgb = xfer == LIBMEGAPIXELS_XFER_SRGB; snprintf(format_def, 96, "#define CFA_%s\n#define BITS_%d\n#define COLORSPACE_%s\n", diff --git a/src/gles2_debayer.h b/src/gles2_debayer.h index 1a21e09..f719a0f 100644 --- a/src/gles2_debayer.h +++ b/src/gles2_debayer.h @@ -5,7 +5,7 @@ typedef struct _GLES2Debayer GLES2Debayer; -GLES2Debayer *gles2_debayer_new(int format, uint32_t colorspace); +GLES2Debayer *gles2_debayer_new(int format, int xfer); void gles2_debayer_free(GLES2Debayer *self); void gles2_debayer_use(GLES2Debayer *self); diff --git a/src/io_pipeline.c b/src/io_pipeline.c index dad3fad..6e7445f 100644 --- a/src/io_pipeline.c +++ b/src/io_pipeline.c @@ -81,7 +81,6 @@ update_process_pipeline() .preview_width = state_io.preview_width, .preview_height = state_io.preview_height, .device_rotation = state_io.device_rotation, - .colorspace = state_io.colorspace, .gain.control = state_io.gain.control, .gain.auto_control = state_io.gain.auto_control, @@ -145,7 +144,6 @@ capture(MPPipeline *pipeline, const void *data) mp_camera_stop_capture(mpcamera); struct v4l2_format format = { 0 }; libmegapixels_select_mode(state_io.camera, state_io.mode_capture, &format); - state_io.colorspace = format.fmt.pix.colorspace; state_io.flush_pipeline = true; mp_camera_start_capture(mpcamera); @@ -328,7 +326,6 @@ on_frame(MPBuffer buffer, void *_data) struct v4l2_format format = { 0 }; libmegapixels_select_mode( state_io.camera, state_io.mode_preview, &format); - state_io.colorspace = format.fmt.pix.colorspace; state_io.flush_pipeline = true; mp_camera_start_capture(mpcamera); @@ -501,7 +498,6 @@ update_state(MPPipeline *pipeline, const mp_state_io *new_state) libmegapixels_select_mode(state_io.camera, state_io.mode_preview, &format); - state_io.colorspace = format.fmt.pix.colorspace; } mp_camera_start_capture(mpcamera); diff --git a/src/process_pipeline.c b/src/process_pipeline.c index 722734b..68f20fb 100644 --- a/src/process_pipeline.c +++ b/src/process_pipeline.c @@ -927,7 +927,7 @@ on_output_changed(bool format_changed) if (gles2_debayer) gles2_debayer_free(gles2_debayer); - gles2_debayer = gles2_debayer_new(state_proc.mode->format, state_proc.colorspace); + gles2_debayer = gles2_debayer_new(state_proc.mode->format, state_proc.mode->xfer); check_gl(); gles2_debayer_use(gles2_debayer); @@ -990,7 +990,6 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state) } state_proc.mode = new_state->camera->current_mode; - state_proc.colorspace = new_state->colorspace; state_proc.preview_width = new_state->preview_width; state_proc.preview_height = new_state->preview_height; diff --git a/src/state.h b/src/state.h index fd3d1a1..a3452b1 100644 --- a/src/state.h +++ b/src/state.h @@ -51,7 +51,6 @@ typedef struct state_io { int captures_remaining; bool flush_pipeline; int blank_frame_count; - uint32_t colorspace; // Control state controlstate gain; @@ -80,7 +79,6 @@ typedef struct state_proc { int counter; int preview_width; int preview_height; - uint32_t colorspace; // Device orientation in degrees int device_rotation;