68 static float RGBYUV02990[256], RGBYUV05870[256], RGBYUV01140[256];
69 static float RGBYUV01684[256], RGBYUV03316[256];
70 static float RGBYUV04187[256], RGBYUV00813[256];
76 void ccvt_yuyv_rgb32(
int width,
int height,
const void *src,
void *dst)
83 const unsigned char *s;
86 int r, g, b, cr, cg, cb, y1, y2;
97 cb = ((*s - 128) * 454) >> 8;
98 cg = (*s++ - 128) * 88;
100 cr = ((*s - 128) * 359) >> 8;
101 cg = (cg + (*s++ - 128) * 183) >> 8;
129 const unsigned char *s;
132 int r, g, b, cr, cg, cb, y1, y2;
143 cb = ((*s - 128) * 454) >> 8;
144 cg = (*s++ - 128) * 88;
146 cr = ((*s - 128) * 359) >> 8;
147 cg = (cg + (*s++ - 128) * 183) >> 8;
175 const unsigned char *s;
178 int r, g, b, cr, cg, cb, y1, y2;
189 cb = ((*s - 128) * 454) >> 8;
190 cg = (*s++ - 128) * 88;
192 cr = ((*s - 128) * 359) >> 8;
193 cg = (cg + (*s++ - 128) * 183) >> 8;
219 void ccvt_yuyv_420p(
int width,
int height,
const void *src,
void *dsty,
void *dstu,
void *dstv)
222 const unsigned char *s1, *s2;
223 unsigned char *dy, *du, *dv;
229 dy = (
unsigned char *)dsty;
230 du = (
unsigned char *)dstu;
231 dv = (
unsigned char *)dstv;
232 s1 = (
unsigned char *)src;
245 for (l = 0; l < height; l += 2)
248 for (j = 0; j < width; j += 2)
250 *du = (*s1 + *s2) / 2;
254 *dv = (*s1 + *s2) / 2;
263 void bayer2rgb24(
unsigned char *dst,
unsigned char *src,
long int WIDTH,
long int HEIGHT)
266 unsigned char *rawpt, *scanpt;
271 size = WIDTH * HEIGHT;
273 for (i = 0; i < size; i++)
275 if ((i / WIDTH) % 2 == 0)
280 if ((i > WIDTH) && ((i % WIDTH) > 0))
283 (*(rawpt - WIDTH - 1) + *(rawpt - WIDTH + 1) + *(rawpt + WIDTH - 1) + *(rawpt + WIDTH + 1)) /
285 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt + WIDTH) + *(rawpt - WIDTH)) / 4;
291 *scanpt++ = *(rawpt + WIDTH + 1);
292 *scanpt++ = (*(rawpt + 1) + *(rawpt + WIDTH)) / 2;
299 if ((i > WIDTH) && ((i % WIDTH) < (WIDTH - 1)))
301 *scanpt++ = (*(rawpt + WIDTH) + *(rawpt - WIDTH)) / 2;
303 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2;
308 *scanpt++ = *(rawpt + WIDTH);
310 *scanpt++ = *(rawpt - 1);
319 if ((i < (WIDTH * (HEIGHT - 1))) && ((i % WIDTH) > 0))
321 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2;
323 *scanpt++ = (*(rawpt + WIDTH) + *(rawpt - WIDTH)) / 2;
328 *scanpt++ = *(rawpt + 1);
330 *scanpt++ = *(rawpt - WIDTH);
336 if (i < (WIDTH * (HEIGHT - 1)) && ((i % WIDTH) < (WIDTH - 1)))
339 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt - WIDTH) + *(rawpt + WIDTH)) / 4;
341 (*(rawpt - WIDTH - 1) + *(rawpt - WIDTH + 1) + *(rawpt + WIDTH - 1) + *(rawpt + WIDTH + 1)) /
348 *scanpt++ = (*(rawpt - 1) + *(rawpt - WIDTH)) / 2;
349 *scanpt++ = *(rawpt - WIDTH - 1);
357 void bayer16_2_rgb24(
unsigned short *dst,
unsigned short *src,
long int WIDTH,
long int HEIGHT)
360 unsigned short *rawpt, *scanpt;
365 size = WIDTH * HEIGHT;
367 for (i = 0; i < size; i++)
369 if ((i / WIDTH) % 2 == 0)
374 if ((i > WIDTH) && ((i % WIDTH) > 0))
377 (*(rawpt - WIDTH - 1) + *(rawpt - WIDTH + 1) + *(rawpt + WIDTH - 1) + *(rawpt + WIDTH + 1)) /
379 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt + WIDTH) + *(rawpt - WIDTH)) / 4;
385 *scanpt++ = *(rawpt + WIDTH + 1);
386 *scanpt++ = (*(rawpt + 1) + *(rawpt + WIDTH)) / 2;
393 if ((i > WIDTH) && ((i % WIDTH) < (WIDTH - 1)))
395 *scanpt++ = (*(rawpt + WIDTH) + *(rawpt - WIDTH)) / 2;
397 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2;
402 *scanpt++ = *(rawpt + WIDTH);
404 *scanpt++ = *(rawpt - 1);
413 if ((i < (WIDTH * (HEIGHT - 1))) && ((i % WIDTH) > 0))
415 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2;
417 *scanpt++ = (*(rawpt + WIDTH) + *(rawpt - WIDTH)) / 2;
422 *scanpt++ = *(rawpt + 1);
424 *scanpt++ = *(rawpt - WIDTH);
430 if (i < (WIDTH * (HEIGHT - 1)) && ((i % WIDTH) < (WIDTH - 1)))
433 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt - WIDTH) + *(rawpt + WIDTH)) / 4;
435 (*(rawpt - WIDTH - 1) + *(rawpt - WIDTH + 1) + *(rawpt + WIDTH - 1) + *(rawpt + WIDTH + 1)) /
442 *scanpt++ = (*(rawpt - 1) + *(rawpt - WIDTH)) / 2;
443 *scanpt++ = *(rawpt - WIDTH - 1);
454 unsigned char *rawpt, *scanpt;
459 size = WIDTH * HEIGHT;
461 for (i = 0; i < size; i++)
463 if ((i / WIDTH) % 2 == 0)
468 if ((i > WIDTH) && ((i % WIDTH) > 0))
471 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt + WIDTH) + *(rawpt - WIDTH)) / 4;
473 (*(rawpt - WIDTH - 1) + *(rawpt - WIDTH + 1) + *(rawpt + WIDTH - 1) + *(rawpt + WIDTH + 1)) /
480 *scanpt++ = (*(rawpt + 1) + *(rawpt + WIDTH)) / 2;
481 *scanpt++ = *(rawpt + WIDTH + 1);
487 if ((i > WIDTH) && ((i % WIDTH) < (WIDTH - 1)))
489 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2;
491 *scanpt++ = (*(rawpt + WIDTH) + *(rawpt - WIDTH)) / 2;
496 *scanpt++ = *(rawpt - 1);
498 *scanpt++ = *(rawpt + WIDTH);
507 if ((i < (WIDTH * (HEIGHT - 1))) && ((i % WIDTH) > 0))
509 *scanpt++ = (*(rawpt + WIDTH) + *(rawpt - WIDTH)) / 2;
511 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1)) / 2;
516 *scanpt++ = *(rawpt - WIDTH);
518 *scanpt++ = *(rawpt + 1);
524 if (i < (WIDTH * (HEIGHT - 1)) && ((i % WIDTH) < (WIDTH - 1)))
527 (*(rawpt - WIDTH - 1) + *(rawpt - WIDTH + 1) + *(rawpt + WIDTH - 1) + *(rawpt + WIDTH + 1)) /
529 *scanpt++ = (*(rawpt - 1) + *(rawpt + 1) + *(rawpt - WIDTH) + *(rawpt + WIDTH)) / 4;
535 *scanpt++ = *(rawpt - WIDTH - 1);
536 *scanpt++ = (*(rawpt - 1) + *(rawpt - WIDTH)) / 2;
559 long int width=WIDTH;
563 for (row = 0; row < HEIGHT; row++) {
564 for (col = 0; col < WIDTH; col++) {
569 if (col != 0 && col != WIDTH -1) {
570 dst[(row*width+col)*3+RED]=(src[row*width+col+1]+src[row*width+col-1])/2;
572 if (col == 0) { dst[(row*width+col)*3+RED]=src[row*width+col+1];}
573 if (col == WIDTH -1 ) { dst[(row*width+col)*3+RED]=src[row*width+col-1]; }
575 dst[(row*width+col)*3+GREEN]=src[row*width+col];
576 if (row !=0 && row !=HEIGHT-1) {
577 dst[(row*width+col)*3+BLUE]=(src[(row+1)*width+col]+src[(row-1)*width+col])/2;
579 if (row == 0) {dst[(row*width+col)*3+BLUE]=src[(row+1)*width+col];}
580 if (row == WIDTH -1) {dst[(row*width+col)*3+BLUE]=src[(row-1)*width+col];}
583 dst[(row*width+col)*3+RED]=src[row*width+col];
584 if (col != WIDTH -1 && row !=0 ) {
585 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/4;
586 dst[(row*width+col)*3+BLUE]=(src[(row+1)*width+col+1]+src[(row-1)*width+col+1]+src[(row+1)*width+col-1]+src[(row-1)*width+col-1])/4;
588 if (col != WIDTH -1 && row == 0) {
594 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row)*width+col+1]+src[(row)*width+col+1])/3;
595 dst[(row*width+col)*3+BLUE]=(src[(row+1)*width+col+1]+src[(row+1)*width+col-1])/2;
598 if (col == WIDTH -1 && row !=0 ) {
605 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row)*width+col-1])/3;
606 dst[(row*width+col)*3+BLUE]=(src[(row+1)*width+col-1]+src[(row-1)*width+col-1])/2;
609 if (col == WIDTH -1 && row ==0) {
615 dst[(row*width+col)*3+GREEN]=(src[(row-1)*width+col]+src[(row+0)*width+col-1]+src[(row+1)*width+col])/3;
616 dst[(row*width+col)*3+BLUE]=src[(row+1)*width+col-1];
618 if (col == 1 && row !=0) {
626 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/4;
627 dst[(row*width+col)*3+BLUE]=(src[(row+1)*width+col+1]+src[(row-1)*width+col+1]+src[(row+1)*width+col-1]+src[(row-1)*width+col-1])/4;
629 if (row == HEIGHT -1) {
637 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/4;
638 dst[(row*width+col)*3+BLUE]=(src[(row+1)*width+col+1]+src[(row-1)*width+col+1]+src[(row+1)*width+col-1]+src[(row-1)*width+col-1])/4;
646 dst[(row*width+col)*3+BLUE]=src[row*width+col];
647 if ( col != 0 && row != HEIGHT -1) {
652 dst[(row*width+col)*3+RED]=(src[(row+1)*width+col+1]+src[(row-1)*width+col+1]+src[(row+1)*width+col-1]+src[(row-1)*width+col-1])/4;
653 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/4;
655 if (col == 0 && row != HEIGHT -1) {
661 dst[(row*width+col)*3+RED]=(src[(row+1)*width+col+1]+src[(row-1)*width+col+1])/2;
662 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/3;
664 if (row == HEIGHT -1 && col !=0) {
668 dst[(row*width+col)*3+RED]=(src[(row-1)*width+col+1]+src[(row-1)*width+col-1])/2;
669 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/3;
671 if (row == HEIGHT -1 && col ==0) {
675 dst[(row*width+col)*3+RED]=(src[(row-1)*width+col+1]+src[(row-1)*width+col-1])/2;
676 dst[(row*width+col)*3+GREEN]=(src[(row+1)*width+col]+src[(row-1)*width+col]+src[(row+0)*width+col+1]+src[(row+0)*width+col-1])/3;
681 dst[(row*width+col)*3+GREEN]=src[row*width+col];
682 if (col != WIDTH -1 && row != HEIGHT -1) {
688 dst[(row*width+col)*3+RED]=(src[(row+1)*width+col]+src[(row-1)*width+col])/2;
689 dst[(row*width+col)*3+BLUE]=(src[row*width+col+1]+src[row*width+col-1])/2;
691 if (col == WIDTH -1 && row != HEIGHT -1) {
697 dst[(row*width+col)*3+RED]=(src[(row+1)*width+col]+src[(row-1)*width+col])/2;
698 dst[(row*width+col)*3+BLUE]=src[row*width+col-1];
700 if (row == HEIGHT -1 && col != WIDTH -1) {
704 dst[(row*width+col)*3+RED]=src[(row-1)*width+col];
705 dst[(row*width+col)*3+BLUE]=(src[row*width+col+1]+src[row*width+col-1])/2;
707 if (row == HEIGHT -1 && col == WIDTH -1) {
711 dst[(row*width+col)*3+RED]=src[(row-1)*width+col];
712 dst[(row*width+col)*3+BLUE]=src[row*width+col-1];
721 int mjpegtoyuv420p(
unsigned char *map,
unsigned char *cap_map,
int width,
int height,
unsigned int size)
723 unsigned char *yuv[3];
724 unsigned char *y, *u, *v;
727 yuv[0] = malloc(width * height *
sizeof(yuv[0][0]));
728 yuv[1] = malloc(width * height / 4 *
sizeof(yuv[1][0]));
729 yuv[2] = malloc(width * height / 4 *
sizeof(yuv[2][0]));
731 ret =
decode_jpeg_raw(cap_map, size, 0, 420, width, height, yuv[0], yuv[1], yuv[2]);
734 u = y + width * height;
735 v = u + (width * height) / 4;
736 memset(y, 0, width * height);
737 memset(u, 0, width * height / 4);
738 memset(v, 0, width * height / 4);
740 for (loop = 0; loop < width * height; loop++)
741 *map++ = yuv[0][loop];
743 for (loop = 0; loop < width * height / 4; loop++)
744 *map++ = yuv[1][loop];
746 for (loop = 0; loop < width * height / 4; loop++)
747 *map++ = yuv[2][loop];
785 int RGB2YUV(
int x_dim,
int y_dim,
void *bmp,
void *y_out,
void *u_out,
void *v_out,
int flip)
787 static int init_done = 0;
790 unsigned char *r, *g, *b;
791 unsigned char *y, *u, *v;
792 unsigned char *pu1, *pu2, *pv1, *pv2, *psu, *psv;
793 unsigned char *y_buffer, *u_buffer, *v_buffer;
794 unsigned char *sub_u_buf, *sub_v_buf;
803 if ((x_dim % 2) || (y_dim % 2))
805 size = x_dim * y_dim;
808 y_buffer = (
unsigned char *)y_out;
809 sub_u_buf = (
unsigned char *)u_out;
810 sub_v_buf = (
unsigned char *)v_out;
811 u_buffer = (
unsigned char *)malloc(size *
sizeof(
unsigned char));
812 v_buffer = (
unsigned char *)malloc(size *
sizeof(
unsigned char));
813 if (!(u_buffer && v_buffer))
822 b = (
unsigned char *)bmp;
830 for (j = 0; j < y_dim; j++)
832 y = y_buffer + (y_dim - j - 1) * x_dim;
833 u = u_buffer + (y_dim - j - 1) * x_dim;
834 v = v_buffer + (y_dim - j - 1) * x_dim;
836 for (i = 0; i < x_dim; i++)
840 *y = (
unsigned char)(RGBYUV02990[*r] + RGBYUV05870[*g] + RGBYUV01140[*b]);
841 *u = (
unsigned char)(-RGBYUV01684[*r] - RGBYUV03316[*g] + (*b) / 2 + 128);
842 *v = (
unsigned char)((*r) / 2 - RGBYUV04187[*g] - RGBYUV00813[*b] + 128);
852 for (i = 0; i < size; i++)
856 *y = (
unsigned char)(RGBYUV02990[*r] + RGBYUV05870[*g] + RGBYUV01140[*b]);
857 *u = (
unsigned char)(-RGBYUV01684[*r] - RGBYUV03316[*g] + (*b) / 2 + 128);
858 *v = (
unsigned char)((*r) / 2 - RGBYUV04187[*g] - RGBYUV00813[*b] + 128);
867 for (j = 0; j < y_dim / 2; j++)
869 psu = sub_u_buf + j * x_dim / 2;
870 psv = sub_v_buf + j * x_dim / 2;
871 pu1 = u_buffer + 2 * j * x_dim;
872 pu2 = u_buffer + (2 * j + 1) * x_dim;
873 pv1 = v_buffer + 2 * j * x_dim;
874 pv2 = v_buffer + (2 * j + 1) * x_dim;
875 for (i = 0; i < x_dim / 2; i++)
877 *psu = (*pu1 + *(pu1 + 1) + *pu2 + *(pu2 + 1)) / 4;
878 *psv = (*pv1 + *(pv1 + 1) + *pv2 + *(pv2 + 1)) / 4;
894 int BGR2YUV(
int x_dim,
int y_dim,
void *bmp,
void *y_out,
void *u_out,
void *v_out,
int flip)
896 static int init_done = 0;
899 unsigned char *r, *g, *b;
900 unsigned char *y, *u, *v;
901 unsigned char *pu1, *pu2, *pv1, *pv2, *psu, *psv;
902 unsigned char *y_buffer, *u_buffer, *v_buffer;
903 unsigned char *sub_u_buf, *sub_v_buf;
912 if ((x_dim % 2) || (y_dim % 2))
914 size = x_dim * y_dim;
917 y_buffer = (
unsigned char *)y_out;
918 sub_u_buf = (
unsigned char *)u_out;
919 sub_v_buf = (
unsigned char *)v_out;
920 u_buffer = (
unsigned char *)malloc(size *
sizeof(
unsigned char));
921 v_buffer = (
unsigned char *)malloc(size *
sizeof(
unsigned char));
922 if (!(u_buffer && v_buffer))
931 r = (
unsigned char *)bmp;
939 for (j = 0; j < y_dim; j++)
941 y = y_buffer + (y_dim - j - 1) * x_dim;
942 u = u_buffer + (y_dim - j - 1) * x_dim;
943 v = v_buffer + (y_dim - j - 1) * x_dim;
945 for (i = 0; i < x_dim; i++)
949 *y = (
unsigned char)(RGBYUV02990[*r] + RGBYUV05870[*g] + RGBYUV01140[*b]);
950 *u = (
unsigned char)(-RGBYUV01684[*r] - RGBYUV03316[*g] + (*b) / 2 + 128);
951 *v = (
unsigned char)((*r) / 2 - RGBYUV04187[*g] - RGBYUV00813[*b] + 128);
961 for (i = 0; i < size; i++)
965 *y = (
unsigned char)(RGBYUV02990[*r] + RGBYUV05870[*g] + RGBYUV01140[*b]);
966 *u = (
unsigned char)(-RGBYUV01684[*r] - RGBYUV03316[*g] + (*b) / 2 + 128);
967 *v = (
unsigned char)((*r) / 2 - RGBYUV04187[*g] - RGBYUV00813[*b] + 128);
976 for (j = 0; j < y_dim / 2; j++)
978 psu = sub_u_buf + j * x_dim / 2;
979 psv = sub_v_buf + j * x_dim / 2;
980 pu1 = u_buffer + 2 * j * x_dim;
981 pu2 = u_buffer + (2 * j + 1) * x_dim;
982 pv1 = v_buffer + 2 * j * x_dim;
983 pv2 = v_buffer + (2 * j + 1) * x_dim;
984 for (i = 0; i < x_dim / 2; i++)
986 *psu = (*pu1 + *(pu1 + 1) + *pu2 + *(pu2 + 1)) / 4;
987 *psv = (*pv1 + *(pv1 + 1) + *pv2 + *(pv2 + 1)) / 4;
1007 for (i = 0; i < 256; i++)
1008 RGBYUV02990[i] = (
float)0.2990 * i;
1009 for (i = 0; i < 256; i++)
1010 RGBYUV05870[i] = (
float)0.5870 * i;
1011 for (i = 0; i < 256; i++)
1012 RGBYUV01140[i] = (
float)0.1140 * i;
1013 for (i = 0; i < 256; i++)
1014 RGBYUV01684[i] = (
float)0.1684 * i;
1015 for (i = 0; i < 256; i++)
1016 RGBYUV03316[i] = (
float)0.3316 * i;
1017 for (i = 0; i < 256; i++)
1018 RGBYUV04187[i] = (
float)0.4187 * i;
1019 for (i = 0; i < 256; i++)
1020 RGBYUV00813[i] = (
float)0.0813 * i;
1025 #define RGBBGR_BODY24(TIN, TOUT) \
1026 void ccvt_##TIN##_##TOUT(int width, int height, const void *const src, void *dst) \
1028 const PIXTYPE_##TIN *in = src; \
1029 PIXTYPE_##TOUT *out = dst; \
1030 int l, c, stride = 0; \
1033 out += ((height - 1) * width); \
1035 for (l = 0; l < height; l++) \
1037 for (c = 0; c < width; c++) \
1049 #define RGBBGR_BODY32(TIN, TOUT) \
1050 void ccvt_##TIN##_##TOUT(int width, int height, const void *const src, void *dst) \
1052 const PIXTYPE_##TIN *in = src; \
1053 PIXTYPE_##TOUT *out = dst; \
1054 int l, c, stride = 0; \
1057 out += ((height - 1) * width); \
1059 for (l = 0; l < height; l++) \
1061 for (c = 0; c < width; c++) \
int BGR2YUV(int x_dim, int y_dim, void *bmp, void *y_out, void *u_out, void *v_out, int flip)
void InitLookupTable(void)
void bayer16_2_rgb24(unsigned short *dst, unsigned short *src, long int WIDTH, long int HEIGHT)
void ccvt_yuyv_bgr32(int width, int height, const void *src, void *dst)
#define RGBBGR_BODY24(TIN, TOUT)
void bayer2rgb24(unsigned char *dst, unsigned char *src, long int WIDTH, long int HEIGHT)
int mjpegtoyuv420p(unsigned char *map, unsigned char *cap_map, int width, int height, unsigned int size)
mjpegtoyuv420p MPEG to YUV 420 P
void bayer_grbg_to_rgb24(unsigned char *dst, unsigned char *src, long int WIDTH, long int HEIGHT)
void ccvt_yuyv_rgb24(int width, int height, const void *src, void *dst)
void ccvt_yuyv_bgr24(int width, int height, const void *src, void *dst)
#define RGBBGR_BODY32(TIN, TOUT)
void ccvt_yuyv_420p(int width, int height, const void *src, void *dsty, void *dstu, void *dstv)
void bayer_rggb_2rgb24(unsigned char *dst, unsigned char *src, long int WIDTH, long int HEIGHT)
int RGB2YUV(int x_dim, int y_dim, void *bmp, void *y_out, void *u_out, void *v_out, int flip)
int decode_jpeg_raw(unsigned char *jpeg_data, int len, int itype, int ctype, unsigned int width, unsigned int height, unsigned char *raw0, unsigned char *raw1, unsigned char *raw2)
decode JPEG buffer