2020-09-15 00:03:41 +02:00
|
|
|
#include "quickdebayer.h"
|
|
|
|
|
|
|
|
// Fast but bad debayer method that scales and rotates by skipping source pixels and
|
|
|
|
// doesn't interpolate any values at all
|
|
|
|
|
2020-09-16 11:55:13 +02:00
|
|
|
int
|
2020-09-15 00:03:41 +02:00
|
|
|
quick_debayer_bggr8(const uint8_t *source, uint8_t *destination, int width, int height, int skip)
|
|
|
|
{
|
|
|
|
int byteskip = 2 * skip;
|
|
|
|
int input_size = width * height;
|
|
|
|
int i;
|
|
|
|
int j=0;
|
|
|
|
int row_left = width;
|
2020-09-16 11:55:13 +02:00
|
|
|
int clipped = 0;
|
|
|
|
int above80 = 0;
|
|
|
|
int above50 = 0;
|
2020-09-15 00:03:41 +02:00
|
|
|
// B G
|
|
|
|
// G R
|
|
|
|
for(i=0;i<input_size;) {
|
|
|
|
destination[j++] = source[i+width+1];
|
|
|
|
destination[j++] = source[i+1];
|
|
|
|
destination[j++] = source[i];
|
2020-09-16 11:55:13 +02:00
|
|
|
if(source[i+1] > 250) {
|
|
|
|
clipped++;
|
|
|
|
}
|
|
|
|
if(source[i+1] > 205) {
|
|
|
|
above80++;
|
|
|
|
}
|
|
|
|
if(source[i+1] > 128) {
|
|
|
|
above50++;
|
|
|
|
}
|
2020-09-15 00:03:41 +02:00
|
|
|
i = i + byteskip;
|
|
|
|
row_left = row_left - byteskip;
|
|
|
|
if(row_left <= 0){
|
|
|
|
row_left = width;
|
|
|
|
i = i+width;
|
|
|
|
i = i + (width * 2 * (skip-1));
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 11:55:13 +02:00
|
|
|
if(clipped > 300) {
|
|
|
|
return -10;
|
|
|
|
}
|
|
|
|
if(clipped > 10) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(above50 < 10) {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
if(above80 < 10) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2020-09-15 00:03:41 +02:00
|
|
|
}
|