Fix gain and exposure being switched in io pipeline

This commit is contained in:
Benjamin Schaaf 2021-04-26 22:21:15 +10:00
parent d03d4b99e3
commit 36b7b2b38d
2 changed files with 5 additions and 85 deletions

View File

@ -497,15 +497,15 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state)
pipeline, info->camera, on_frame, NULL);
current_controls.gain_is_manual =
mp_camera_control_get_int32(
info->camera, V4L2_CID_EXPOSURE_AUTO) ==
V4L2_EXPOSURE_MANUAL;
mp_camera_control_get_bool(info->camera,
V4L2_CID_AUTOGAIN) == 0;
current_controls.gain = mp_camera_control_get_int32(
info->camera, info->gain_ctrl);
current_controls.exposure_is_manual =
mp_camera_control_get_bool(info->camera,
V4L2_CID_AUTOGAIN) == 0;
mp_camera_control_get_int32(
info->camera, V4L2_CID_EXPOSURE_AUTO) ==
V4L2_EXPOSURE_MANUAL;
current_controls.exposure = mp_camera_control_get_int32(
info->camera, V4L2_CID_EXPOSURE);
}

View File

@ -712,86 +712,6 @@ open_shutter_controls(GtkWidget *button, gpointer user_data)
open_controls(button, "Shutter", 1.0, 360.0, exposure, !exposure_is_manual, set_shutter, set_shutter_auto);
}
/*
static void
on_control_auto_toggled(GtkToggleButton *widget, gpointer user_data)
{
bool is_manual = gtk_toggle_button_get_active(widget) ? false : true;
bool has_changed;
switch (current_control) {
case USER_CONTROL_ISO:
if (gain_is_manual != is_manual) {
gain_is_manual = is_manual;
has_changed = true;
}
break;
case USER_CONTROL_SHUTTER:
if (exposure_is_manual != is_manual) {
exposure_is_manual = is_manual;
has_changed = true;
}
break;
}
if (has_changed) {
// The slider might have been moved while Auto mode is active. When entering
// Manual mode, first read the slider value to sync with those changes.
double value = gtk_adjustment_get_value(control_slider);
switch (current_control) {
case USER_CONTROL_ISO:
if (value != gain) {
gain = (int)value;
}
break;
case USER_CONTROL_SHUTTER: {
// So far all sensors use exposure time in number of sensor rows
int new_exposure =
(int)(value / 360.0 * camera->capture_mode.height);
if (new_exposure != exposure) {
exposure = new_exposure;
}
break;
}
}
update_io_pipeline();
draw_controls();
}
}
static void
on_control_slider_changed(GtkAdjustment *widget, gpointer user_data)
{
double value = gtk_adjustment_get_value(widget);
bool has_changed = false;
switch (current_control) {
case USER_CONTROL_ISO:
if (value != gain) {
gain = (int)value;
has_changed = true;
}
break;
case USER_CONTROL_SHUTTER: {
// So far all sensors use exposure time in number of sensor rows
int new_exposure =
(int)(value / 360.0 * camera->capture_mode.height);
if (new_exposure != exposure) {
exposure = new_exposure;
has_changed = true;
}
break;
}
}
if (has_changed) {
update_io_pipeline();
draw_controls();
}
}
*/
static void
on_realize(GtkWidget *window, gpointer *data)
{