|
@@ -7,6 +7,7 @@ libmegapixels_aaa_software_statistics(unsigned int *frame, const int width, cons
|
|
|
{
|
|
|
unsigned int bright = 0;
|
|
|
unsigned int too_bright = 0;
|
|
|
+ unsigned int too_dark = 0;
|
|
|
unsigned int total = 0;
|
|
|
unsigned long long sum_r = 0, sum_g = 0, sum_b = 0;
|
|
|
for (ssize_t p = 0; p < width * height; p++) {
|
|
@@ -14,19 +15,23 @@ libmegapixels_aaa_software_statistics(unsigned int *frame, const int width, cons
|
|
|
unsigned int r = frame[p] >> 16 & 0xff;
|
|
|
unsigned int g = frame[p] >> 8 & 0xff;
|
|
|
unsigned int b = frame[p] & 0xff;
|
|
|
-
|
|
|
- if (g > 240) {
|
|
|
+ if (g > 220 || r > 220) {
|
|
|
too_bright++;
|
|
|
}
|
|
|
- if (g > 200) {
|
|
|
+
|
|
|
+ if (g > 180 || r > 180) {
|
|
|
bright++;
|
|
|
}
|
|
|
+ if (g < 2) {
|
|
|
+ too_dark++;
|
|
|
+ }
|
|
|
sum_r += r;
|
|
|
sum_g += g;
|
|
|
sum_b += b;
|
|
|
}
|
|
|
unsigned int p_bright = (bright * 100) / total;
|
|
|
unsigned int p_too_bright = (too_bright * 100) / total;
|
|
|
+ unsigned int p_dark = (too_dark * 100) / total;
|
|
|
stats->exposure = 0;
|
|
|
if (p_bright < 1) {
|
|
|
stats->exposure = 1;
|
|
@@ -34,9 +39,26 @@ libmegapixels_aaa_software_statistics(unsigned int *frame, const int width, cons
|
|
|
if (p_too_bright > 8) {
|
|
|
stats->exposure = -1;
|
|
|
}
|
|
|
- float r = (float) sum_r / (float) sum_g;
|
|
|
- float b = (float) sum_b / (float) sum_g;
|
|
|
+ stats->blacklevel = 0;
|
|
|
+ if (p_dark == 0) {
|
|
|
+ stats->blacklevel = -1;
|
|
|
+ }
|
|
|
+ if (p_dark > 8) {
|
|
|
+ stats->blacklevel = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ float y = (float) (sum_r + sum_g + sum_b) / 3.0f;
|
|
|
+ float r = (float) sum_r / y - 1.0f;
|
|
|
+ float g = (float) sum_g / y - 1.0f;
|
|
|
+ float b = (float) sum_b / y - 1.0f;
|
|
|
stats->whitebalance = 0;
|
|
|
+ stats->tint = 0;
|
|
|
+ if (g > 0.1f) {
|
|
|
+ stats->tint = 1;
|
|
|
+ }
|
|
|
+ if (g < 0.1f) {
|
|
|
+ stats->tint = -1;
|
|
|
+ }
|
|
|
if (r > b * 1.3) {
|
|
|
stats->whitebalance = -1;
|
|
|
}
|