diff -r 978bf9690726 src/raw.c --- a/src/raw.c Sun Oct 06 17:51:13 2013 +0300 +++ b/src/raw.c Fri Jan 10 13:09:18 2014 +0200 @@ -323,7 +323,7 @@ static int autodetect_black_level(float* black_mean, float* black_stdev); static int compute_dynamic_range(float black_mean, float black_stdev, int white_level); -static int autodetect_white_level(); +static int autodetect_white_level(int initial_guess); /* dual ISO interface */ static int (*dual_iso_get_recovery_iso)() = MODULE_FUNCTION(dual_iso_get_recovery_iso); @@ -666,7 +666,7 @@ raw_info.white_level += raw_info.black_level; } - raw_info.white_level = autodetect_white_level(raw_info.white_level); + raw_info.white_level = autodetect_white_level(0); raw_info.dynamic_range = compute_dynamic_range(black_mean, black_stdev, raw_info.white_level); } else if (!is_movie_mode()) @@ -1126,12 +1126,12 @@ int max = white + 500; int confirms = 0; - //~ bmp_printf(FONT_MED, 50, 50, "White..."); + bmp_printf(FONT_MED, 50, 50, "White..."); struct raw_pixblock * start = raw_info.buffer + raw_info.active_area.y1 * raw_info.pitch; struct raw_pixblock * end = raw_info.buffer + raw_info.active_area.y2 * raw_info.pitch; - for (struct raw_pixblock * p = start; p < end; p += 5) + for (struct raw_pixblock * p = start; p < end; p ++) { if (p->a > max) { @@ -1141,14 +1141,14 @@ else if (p->a == max) { confirms++; - if (confirms > 10) + if (confirms > 50) { - white = max - 500; + white = max - 1; } } } - //~ bmp_printf(FONT_MED, 50, 50, "White: %d ", white); + bmp_printf(FONT_MED, 50, 50, "White: %d ", white); return white; } @@ -1164,17 +1164,17 @@ * This is quite close to DxO measurements (within +/- 0.5 EV), * except at very high ISOs where there seems to be noise reduction applied to raw data */ - -#if RAW_DEBUG_DR +#define RAW_DEBUG_DR +#ifdef RAW_DEBUG_DR int mean = black_mean * 100; int stdev = black_stdev * 100; bmp_printf(FONT_MED, 50, 100, "mean=%d.%02d stdev=%d.%02d white=%d", mean/100, mean%100, stdev/100, stdev%100, white_level); - white_level = autodetect_white_level(); + white_level = autodetect_white_level(0); #endif int dr = (int)roundf((log2f(white_level - black_mean) - log2f(black_stdev)) * 100); -#if RAW_DEBUG_DR +#ifdef RAW_DEBUG_DR bmp_printf(FONT_MED, 50, 120, "=> dr=%d.%02d", dr/100, dr%100); #endif