Refactor controls more

This commit is contained in:
Martijn Braam
2023-07-21 13:19:26 +02:00
parent d4806d6ab6
commit f26f81e3f1
5 changed files with 152 additions and 110 deletions

View File

@@ -460,7 +460,7 @@ process_image_for_preview(const uint8_t *image)
mp_process_pipeline_buffer_ref(output_buffer);
mp_main_set_preview(output_buffer);
if (!state_proc.exposure.manual) {
if (!state_proc.exposure.manual && state_proc.exposure.auto_control == 0) {
int width = output_buffer_width / 3;
int height = output_buffer_height / 3;
uint32_t *center = g_malloc_n(width * height * sizeof(uint32_t), 1);
@@ -473,9 +473,6 @@ process_image_for_preview(const uint8_t *image)
center);
libmegapixels_aaa_software_statistics(
center, width, height, &state_proc.stats);
printf("STAT: %d %d\n",
state_proc.stats.exposure,
state_proc.stats.whitebalance);
}
// Create a thumbnail from the preview for the last capture
@@ -961,16 +958,19 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state)
state_proc.camera = new_state->camera;
state_proc.gain.control = new_state->gain.control;
state_proc.gain.auto_control = new_state->gain.auto_control;
state_proc.gain.value = new_state->gain.value;
state_proc.gain.max = new_state->gain.max;
state_proc.gain.manual = new_state->gain.manual;
state_proc.exposure.control = new_state->exposure.control;
state_proc.exposure.auto_control = new_state->exposure.auto_control;
state_proc.exposure.value = new_state->exposure.value;
state_proc.exposure.max = new_state->exposure.max;
state_proc.exposure.manual = new_state->exposure.manual;
state_proc.focus.control = new_state->focus.control;
state_proc.focus.auto_control = new_state->focus.auto_control;
state_proc.focus.value = new_state->focus.value;
state_proc.focus.max = new_state->focus.max;
state_proc.focus.manual = new_state->focus.manual;
@@ -1010,19 +1010,29 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state)
mp_state_main new_main = {
.camera = pr_camera,
.gain_is_manual = new_state->gain.manual,
.gain = state_proc.gain.value,
.gain_max = state_proc.gain.max,
.exposure_is_manual = state_proc.exposure.manual,
.exposure = state_proc.exposure.value,
.has_auto_focus_continuous = false,
.has_auto_focus_start = false,
.preview_buffer_width = output_buffer_width,
.preview_buffer_height = output_buffer_height,
.control_gain = new_state->gain.control != 0,
.control_exposure = state_proc.exposure.control != 0,
.control_focus = state_proc.focus.control != 0,
.control_flash = false,
.gain.control = state_proc.gain.control,
.gain.auto_control = state_proc.gain.auto_control,
.gain.value = state_proc.gain.value,
.gain.max = state_proc.gain.max,
.gain.manual = state_proc.gain.manual,
.exposure.control = state_proc.exposure.control,
.exposure.auto_control = state_proc.exposure.auto_control,
.exposure.value = state_proc.exposure.value,
.exposure.max = state_proc.exposure.max,
.exposure.manual = state_proc.exposure.manual,
.focus.control = state_proc.focus.control,
.focus.auto_control = state_proc.focus.auto_control,
.focus.value = state_proc.focus.value,
.focus.max = state_proc.focus.max,
.focus.manual = state_proc.focus.manual,
};
mp_main_update_state(&new_main);
}