Use the aaav2 code in libmegapixels
This commit is contained in:
@@ -418,20 +418,38 @@ process_image_for_preview(const uint8_t *image)
|
||||
uint32_t *center = g_malloc_n(width * height * sizeof(uint32_t), 1);
|
||||
glReadPixels(
|
||||
0, height, width, height, GL_RGBA, GL_UNSIGNED_BYTE, center);
|
||||
libmegapixels_aaa_software_statistics(
|
||||
center, width, height, &state_proc.stats);
|
||||
|
||||
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;
|
||||
libmegapixels_aaa_set_matrix(&state_proc.stats,
|
||||
state_proc.calibration.color_matrix_1,
|
||||
state_proc.calibration.color_matrix_2);
|
||||
libmegapixels_aaa_software_statistics(
|
||||
&state_proc.stats, center, width, height);
|
||||
|
||||
state_proc.blacklevel -= (float)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);
|
||||
|
||||
float r = state_proc.stats.avg_r;
|
||||
float g = state_proc.stats.avg_g;
|
||||
float b = state_proc.stats.avg_b;
|
||||
|
||||
// Revert the current gains set on the preview
|
||||
b /= state_proc.red;
|
||||
b /= state_proc.blue;
|
||||
|
||||
float t = 2.0f;
|
||||
if (r < t && g < t && b < t) {
|
||||
// Don't try to AWB on very dark frames
|
||||
} else {
|
||||
// Calculate the new R/B gains based on the average color of
|
||||
// the frame
|
||||
float new_r = g / clamp_float(r, 1.0f, 999.0f);
|
||||
float new_b = g / clamp_float(b, 1.0f, 999.0f);
|
||||
|
||||
state_proc.red = clamp_float(new_r, 0.01f, 4.0f);
|
||||
state_proc.blue = clamp_float(new_b, 0.01f, 4.0f);
|
||||
}
|
||||
|
||||
gles2_debayer_set_shading(gles2_debayer,
|
||||
state_proc.red,
|
||||
state_proc.blue,
|
||||
|
Reference in New Issue
Block a user