|
@@ -388,6 +388,17 @@ mp_process_pipeline_init_gl(GdkSurface *surface)
|
|
|
sizeof(GdkSurface *));
|
|
|
}
|
|
|
|
|
|
+float
|
|
|
+clamp_float(float value, float min, float max) {
|
|
|
+ if(value > max)
|
|
|
+ return max;
|
|
|
+
|
|
|
+ if(value < min)
|
|
|
+ return min;
|
|
|
+
|
|
|
+ return value;
|
|
|
+}
|
|
|
+
|
|
|
static GdkTexture *
|
|
|
process_image_for_preview(const uint8_t *image)
|
|
|
{
|
|
@@ -461,10 +472,10 @@ process_image_for_preview(const uint8_t *image)
|
|
|
mp_main_set_preview(output_buffer);
|
|
|
|
|
|
if (!state_proc.exposure.manual && state_proc.exposure.auto_control == 0) {
|
|
|
- int width = output_buffer_width / 3;
|
|
|
+ int width = output_buffer_width;
|
|
|
int height = output_buffer_height / 3;
|
|
|
uint32_t *center = g_malloc_n(width * height * sizeof(uint32_t), 1);
|
|
|
- glReadPixels(width,
|
|
|
+ glReadPixels(0,
|
|
|
height,
|
|
|
width,
|
|
|
height,
|
|
@@ -474,9 +485,14 @@ process_image_for_preview(const uint8_t *image)
|
|
|
libmegapixels_aaa_software_statistics(
|
|
|
center, width, height, &state_proc.stats);
|
|
|
|
|
|
- state_proc.red += (state_proc.stats.whitebalance * -0.02f) + (state_proc.stats.tint * 0.01f);
|
|
|
- state_proc.blue += (state_proc.stats.whitebalance * +0.02f) + (state_proc.stats.tint * 0.01f);
|
|
|
- state_proc.blacklevel += state_proc.stats.blacklevel * 0.01f;
|
|
|
+ float w_gain = 0.02f;
|
|
|
+ float t_gain = 0.01f;
|
|
|
+ state_proc.red += (state_proc.stats.temp * +w_gain) + (state_proc.stats.tint * t_gain);
|
|
|
+ state_proc.blue += (state_proc.stats.temp * -w_gain) + (state_proc.stats.tint * t_gain);
|
|
|
+ state_proc.blacklevel -= state_proc.stats.blacklevel * 0.001f;
|
|
|
+ state_proc.blacklevel = clamp_float(state_proc.blacklevel, 0.0f, 0.07f);
|
|
|
+ state_proc.red = clamp_float(state_proc.red, 0.5f, 3.0f);
|
|
|
+ state_proc.blue = clamp_float(state_proc.blue, 0.5f, 3.0f);
|
|
|
gles2_debayer_set_shading(gles2_debayer, state_proc.red, state_proc.blue, state_proc.blacklevel);
|
|
|
}
|
|
|
|
|
@@ -1052,7 +1068,8 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state)
|
|
|
.focus.manual = state_proc.focus.manual,
|
|
|
|
|
|
.stats.exposure = state_proc.stats.exposure,
|
|
|
- .stats.whitebalance = state_proc.stats.whitebalance,
|
|
|
+ .stats.temp = state_proc.stats.temp,
|
|
|
+ .stats.tint = state_proc.stats.tint,
|
|
|
.stats.focus = state_proc.stats.focus,
|
|
|
};
|
|
|
mp_main_update_state(&new_main);
|