camerad: refactor gain index loop for clarity (#33613)

* Refactor Gain Index Loop for Clarity

* Update system/camerad/cameras/camera_qcom2.cc

* Update system/camerad/cameras/camera_qcom2.cc

---------

Co-authored-by: Comma Device <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
Dean Lee
2024-09-30 01:06:34 +08:00
committed by GitHub
parent 8bb7a8d310
commit 2cb526a5a9
+4 -3
View File
@@ -178,9 +178,10 @@ void CameraState::set_camera_exposure(float grey_frac) {
new_exp_t = exposure_time;
enable_dc_gain = false;
} else {
// Simple brute force optimizer to choose sensor parameters
// to reach desired EV
for (int g = std::max((int)sensor->analog_gain_min_idx, gain_idx - 1); g <= std::min((int)sensor->analog_gain_max_idx, gain_idx + 1); g++) {
// Simple brute force optimizer to choose sensor parameters to reach desired EV
int min_g = std::max(gain_idx - 1, sensor->analog_gain_min_idx);
int max_g = std::min(gain_idx + 1, sensor->analog_gain_max_idx);
for (int g = min_g; g <= max_g; g++) {
float gain = sensor->sensor_analog_gains[g] * get_gain_factor();
// Compute optimal time for given gain