|
|
|
|
@ -371,17 +371,9 @@ void debayer_grbg8_bilinear (uint8_t * src, int src_w, int src_h,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define P_U (*(psrc-src_w*(10/8)))
|
|
|
|
|
#define P_D (*(psrc+src_w*(10/8)))
|
|
|
|
|
#define P_L (*(psrc-1))
|
|
|
|
|
#define P_R (*(psrc+1))
|
|
|
|
|
#define P_UL (*(psrc-1-src_w*(10/8)))
|
|
|
|
|
#define P_UR (*(psrc+1-src_w*(10/8)))
|
|
|
|
|
#define P_DL (*(psrc-1+src_w*(10/8)))
|
|
|
|
|
#define P_DR (*(psrc+1+src_w*(10/8)))
|
|
|
|
|
void debayer_rggb10packet_simple (uint8_t * src, int src_w, int src_h,
|
|
|
|
|
uint8_t * dst, int dst_w, int dst_h) {
|
|
|
|
|
int s, d;
|
|
|
|
|
/* int s, d;
|
|
|
|
|
int xs, ys, xd, yd;
|
|
|
|
|
unsigned char r, g, b;
|
|
|
|
|
int max = dst_w * dst_h * 3;
|
|
|
|
|
@ -441,7 +433,7 @@ void debayer_rggb10packet_simple (uint8_t * src, int src_w, int src_h,
|
|
|
|
|
// if (xs >= src_w -1) psrc += src_w / 4;
|
|
|
|
|
if (xs && (xs % 4 == 0)) psrc++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -465,26 +457,80 @@ void debayer_rggb10packet_bilinear (uint8_t * src, int src_w, int src_h,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline int swap16(uint16_t i) {
|
|
|
|
|
uint16_t r;
|
|
|
|
|
|
|
|
|
|
*(((unsigned char *)&r)) = *(((unsigned char *)&i)+1);
|
|
|
|
|
*(((unsigned char *)&r)+1) = *(((unsigned char *)&i));
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PRGGB10_U ((uint16_t)(*(psrc-src_w*2)))
|
|
|
|
|
#define PRGGB10_D ((uint16_t)(*(psrc+src_w*2)))
|
|
|
|
|
#define PRGGB10_L ((uint16_t)(*(psrc-2)))
|
|
|
|
|
#define PRGGB10_R ((uint16_t)(*(psrc+2)))
|
|
|
|
|
#define PRGGB10_UL ((uint16_t)(*(psrc-2-src_w*2)))
|
|
|
|
|
#define PRGGB10_UR ((uint16_t)(*(psrc+2-src_w*2)))
|
|
|
|
|
#define PRGGB10_DL ((uint16_t)(*(psrc-2-src_w*2)))
|
|
|
|
|
#define PRGGB10_DR ((uint16_t)(*(psrc+2+src_w*2)))
|
|
|
|
|
void debayer_rggb10_simple (uint8_t * src, int src_w, int src_h,
|
|
|
|
|
uint8_t * dst, int dst_w, int dst_h) {
|
|
|
|
|
int s, d;
|
|
|
|
|
for (s = 0, d = 0; d < dst_w * dst_h * 3; d++) {
|
|
|
|
|
dst[d] = src[s];
|
|
|
|
|
if (++s >= src_h * src_h) s = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int xs, ys, xd, yd;
|
|
|
|
|
uint16_t r, g, b, data;
|
|
|
|
|
int max = dst_w * dst_h * 3;
|
|
|
|
|
unsigned char *pdst;
|
|
|
|
|
unsigned char *psrc;
|
|
|
|
|
|
|
|
|
|
for (ys = 0, yd = 0, psrc = src, pdst = dst; ys < dst_h; ys++, yd++) {
|
|
|
|
|
r = 0;
|
|
|
|
|
g = 0;
|
|
|
|
|
b = 0;
|
|
|
|
|
for (xs = 0, xd = 0; xd < dst_w; xs++, xd++) {
|
|
|
|
|
r = 0; b = 0; g = 0;
|
|
|
|
|
if (ys > 0 && ys < src_h-1 && xs > 0 && xs < src_w-1) {
|
|
|
|
|
if (ys&1) {
|
|
|
|
|
if (xs&1) {
|
|
|
|
|
b = *psrc;
|
|
|
|
|
g = (PRGGB10_L + PRGGB10_R + PRGGB10_U + PRGGB10_D)/4;
|
|
|
|
|
r = (PRGGB10_UL + PRGGB10_DL + PRGGB10_UR + PRGGB10_UL)/4;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
b = (PRGGB10_L + PRGGB10_R)/2;
|
|
|
|
|
g = *psrc;
|
|
|
|
|
r = (PRGGB10_U + PRGGB10_D)/2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (xs&1) {
|
|
|
|
|
b = (PRGGB10_U + PRGGB10_D)/2;
|
|
|
|
|
g = *psrc;
|
|
|
|
|
r = (PRGGB10_L + PRGGB10_R)/2;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
g = (PRGGB10_L + PRGGB10_R + PRGGB10_U + PRGGB10_D)/4;
|
|
|
|
|
b = (PRGGB10_UL + PRGGB10_DL + PRGGB10_UR + PRGGB10_UL)/4;
|
|
|
|
|
r = *psrc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pdst - dst > max) {
|
|
|
|
|
printf ("debayer error. dpst out of bounds size:%dx%d pos:%dx%d \n", dst_w, dst_h, xd, yd);
|
|
|
|
|
}
|
|
|
|
|
if ((ys == 10 || ys == 11) && xs < 10) printf ("%dx%d - %d, %d, %d\n", xs, ys, r, g, b);
|
|
|
|
|
pdst[0] = (r);
|
|
|
|
|
pdst[1] = (g);
|
|
|
|
|
pdst[2] = (b);
|
|
|
|
|
pdst += 3;
|
|
|
|
|
psrc += 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void debayer_rggb10_bilinear (uint8_t * src, int src_w, int src_h,
|
|
|
|
|
uint8_t * dst, int dst_w, int dst_h) {
|
|
|
|
|
int s, d;
|
|
|
|
|
for (s = 0, d = 0; d < dst_w * dst_h * 3; d++) {
|
|
|
|
|
dst[d] = src[s];
|
|
|
|
|
if (++s >= src_h * src_h) s = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debayer_rggb10_simple(src, src_w, src_h, dst, dst_w, dst_h);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|