Web lists-archives.com

[Spca50x-devs] luvcview half working bayer decode support




This is required to be able to test the pixart v4l2 port. Right now it
display bayer to 422 "properly" (colors and image quality) but scaled
half size (if you know how to fix it please help I am new to bayer->422
decoding).

Regards
Alban
diff -uNr luvcview-20070512.orig/luvcview.c luvcview-20070512.new/luvcview.c
--- luvcview-20070512.orig/luvcview.c	2007-08-01 17:43:34.000000000 +0200
+++ luvcview-20070512.new/luvcview.c	2007-08-01 17:27:30.000000000 +0200
@@ -53,7 +53,7 @@
 #define TO_FIXED(X) (((Sint32)(X))<<(FIXED_BITS))
 #define FROM_FIXED(X) (((Sint32)(X))>>(FIXED_BITS))
 
-#define INCPANTILT 64 // 1�
+#define INCPANTILT 64 // 1°
 
 typedef enum action_gui {
 /* 0..7..15 action top */
@@ -269,6 +269,9 @@
 	    if (strncmp(mode, "yuv", 3) == 0) {
 		format = V4L2_PIX_FMT_YUYV;
 
+	    } else if (strncmp(mode, "bay", 3) == 0) {
+		format = V4L2_PIX_FMT_SBGGR8;
+
 	    } else if (strncmp(mode, "jpg", 3) == 0) {
 		format = V4L2_PIX_FMT_MJPEG;
 
@@ -345,7 +348,7 @@
 	    printf("-d	/dev/videoX       use videoX device\n");
 	    printf("-g	use read method for grab instead mmap \n");
 	    printf("-w	disable SDL hardware accel. \n");
-	    printf("-f	video format  default jpg  others options are yuv jpg \n");
+	    printf("-f	video format  default jpg  others options are bay yuv jpg \n");
 	    printf("-i	fps           use specified frame interval \n");
 	    printf("-s	widthxheight      use specified input size \n");
 	    printf("-c	enable raw frame capturing for the first frame\n");
@@ -491,13 +494,13 @@
 	    break;
 	}
 
-    /* if we're grabbing video, show the frame rate */
-    if (videoIn->toggleAvi)
-        printf("\rframe rate: %d     ",frmrate);
+	/* if we're grabbing video, show the frame rate */
+	if (videoIn->toggleAvi)
+	    printf("\rframe rate: %d     ",frmrate);
 
 	SDL_LockYUVOverlay(overlay);
 	memcpy(p, videoIn->framebuffer,
-	       videoIn->width * (videoIn->height) * 2);
+	       videoIn->width * (videoIn->height) * 2 );
 	SDL_UnlockYUVOverlay(overlay);
 	SDL_DisplayYUVOverlay(overlay, &drect);
 
@@ -506,6 +509,9 @@
 		case V4L2_PIX_FMT_MJPEG:
 			get_picture(videoIn->tmpbuffer,videoIn->buf.bytesused);
 			break;
+		case V4L2_PIX_FMT_SBGGR8:
+			get_pictureSBGGR8(videoIn->framebuffer,videoIn->width,videoIn->height);
+			break;
 		case V4L2_PIX_FMT_YUYV:
 			get_pictureYV2(videoIn->framebuffer,videoIn->width,videoIn->height);
 			break;
Les fichiers binaires luvcview-20070512.orig/.luvcview.c.swp et luvcview-20070512.new/.luvcview.c.swp sont différents.
diff -uNr luvcview-20070512.orig/Makefile luvcview-20070512.new/Makefile
--- luvcview-20070512.orig/Makefile	2007-08-01 17:43:34.000000000 +0200
+++ luvcview-20070512.new/Makefile	2007-07-31 16:05:37.000000000 +0200
@@ -22,7 +22,7 @@
 #           -Wno-unused
 #           -Wunused
 
-CFLAGS += -DUSE_SDL -O2 -DLINUX -DVERSION=\"$(VERSION)\" -I$(SDLFLAGS) $(WARNINGS)
+CFLAGS += -DUSE_SDL -g -DLINUX -DVERSION=\"$(VERSION)\" -I$(SDLFLAGS) $(WARNINGS)
 CPPFLAGS = $(CFLAGS)
 
 OBJECTS= luvcview.o color.o utils.o v4l2uvc.o gui.o avilib.o
Les fichiers binaires luvcview-20070512.orig/.Makefile.swp et luvcview-20070512.new/.Makefile.swp sont différents.
diff -uNr luvcview-20070512.orig/spcagamma.h luvcview-20070512.new/spcagamma.h
--- luvcview-20070512.orig/spcagamma.h	1970-01-01 01:00:00.000000000 +0100
+++ luvcview-20070512.new/spcagamma.h	2007-07-31 16:52:23.000000000 +0200
@@ -0,0 +1,231 @@
+#ifndef GAMMA_TABLES_H
+#define GAMMA_TABLES_H
+/* Gamma tables for the spca5xx camera (25/12/2003) by mxhaard@xxxxxxxx
+* Original work from
+* Adam M. Costello <amc @ cs.berkeley.edu>
+* Gamma_tables_h is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Gamma_tables_h is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+*/
+/*	Gtable[0][n] -> 2.2
+*	Gtable[1][n] -> 1.7
+*	Gtable[2][n] -> 1.45
+*	Gtable[3][n] -> 1
+*	Gtable[4][n] -> 0.6896
+*	Gtable[5][n] -> 0.5882
+*	Gtable[6][n] -> 0.4545
+*	
+*/
+static unsigned char GTable[7][256] = {
+// gamma-coeff = 2.2000
+    {
+     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
+     1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
+     3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6,
+     6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12,
+     12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19,
+     20, 20, 21, 22, 22, 23, 23, 24, 25, 25, 26, 26, 27, 28, 28, 29,
+     30, 30, 31, 32, 33, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41,
+     42, 43, 43, 44, 45, 46, 47, 48, 49, 49, 50, 51, 52, 53, 54, 55,
+     56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
+     73, 74, 75, 76, 77, 78, 79, 81, 82, 83, 84, 85, 87, 88, 89, 90,
+     91, 93, 94, 95, 97, 98, 99, 100, 102, 103, 105, 106, 107, 109, 110,
+     111,
+     113, 114, 116, 117, 119, 120, 121, 123, 124, 126, 127, 129, 130, 132,
+     133, 135,
+     137, 138, 140, 141, 143, 145, 146, 148, 149, 151, 153, 154, 156, 158,
+     159, 161,
+     163, 165, 166, 168, 170, 172, 173, 175, 177, 179, 181, 182, 184, 186,
+     188, 190,
+     192, 194, 196, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217,
+     219, 221,
+     223, 225, 227, 229, 231, 234, 236, 238, 240, 242, 244, 246, 248, 251,
+     253, 255,
+     },
+// gamma-coeff = 1.7000
+    {
+     0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2,
+     2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7,
+     7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
+     15, 15, 16, 17, 17, 18, 18, 19, 19, 20, 21, 21, 22, 22, 23, 24,
+     24, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 33, 33, 34, 35,
+     36, 36, 37, 38, 39, 39, 40, 41, 42, 43, 43, 44, 45, 46, 47, 48,
+     48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62,
+     63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+     79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+     97, 98, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 111, 112,
+     113, 114,
+     115, 117, 118, 119, 120, 122, 123, 124, 125, 127, 128, 129, 131, 132,
+     133, 134,
+     136, 137, 138, 140, 141, 142, 144, 145, 146, 148, 149, 151, 152, 153,
+     155, 156,
+     157, 159, 160, 162, 163, 164, 166, 167, 169, 170, 172, 173, 175, 176,
+     177, 179,
+     180, 182, 183, 185, 186, 188, 189, 191, 192, 194, 195, 197, 198, 200,
+     202, 203,
+     205, 206, 208, 209, 211, 212, 214, 216, 217, 219, 220, 222, 224, 225,
+     227, 228,
+     230, 232, 233, 235, 237, 238, 240, 242, 243, 245, 247, 248, 250, 252,
+     253, 255,
+     },
+// gamma-coeff = 1.4500
+    {
+     0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4,
+     5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12,
+     13, 13, 14, 14, 15, 16, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22,
+     23, 23, 24, 25, 25, 26, 27, 28, 28, 29, 30, 31, 31, 32, 33, 34,
+     34, 35, 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47,
+     47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61,
+     62, 63, 64, 65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 74, 75, 76,
+     77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93,
+     94, 95, 96, 97, 98, 99, 100, 101, 103, 104, 105, 106, 107, 108, 109,
+     110,
+     111, 112, 114, 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126,
+     127, 129,
+     130, 131, 132, 133, 134, 136, 137, 138, 139, 140, 142, 143, 144, 145,
+     147, 148,
+     149, 150, 151, 153, 154, 155, 156, 158, 159, 160, 161, 163, 164, 165,
+     166, 168,
+     169, 170, 172, 173, 174, 175, 177, 178, 179, 181, 182, 183, 185, 186,
+     187, 188,
+     190, 191, 192, 194, 195, 196, 198, 199, 200, 202, 203, 205, 206, 207,
+     209, 210,
+     211, 213, 214, 215, 217, 218, 220, 221, 222, 224, 225, 227, 228, 229,
+     231, 232,
+     234, 235, 236, 238, 239, 241, 242, 243, 245, 246, 248, 249, 251, 252,
+     254, 255,
+     },
+// gamma-coeff = 1.0000
+    {
+     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+     96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
+     111,
+     112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
+     126, 127,
+     128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
+     142, 143,
+     144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157,
+     158, 159,
+     160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
+     174, 175,
+     176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
+     190, 191,
+     192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
+     206, 207,
+     208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
+     222, 223,
+     224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
+     238, 239,
+     240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253,
+     254, 255,
+     },
+// gamma-coeff = 0.6896
+    {
+     0, 6, 9, 12, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 34, 36,
+     38, 39, 41, 43, 44, 46, 47, 49, 50, 51, 53, 54, 56, 57, 58, 60,
+     61, 62, 64, 65, 66, 67, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79,
+     81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+     98, 99, 100, 101, 102, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+     113, 114,
+     115, 116, 117, 118, 119, 120, 121, 121, 122, 123, 124, 125, 126, 127,
+     128, 129,
+     130, 131, 132, 133, 134, 135, 136, 136, 137, 138, 139, 140, 141, 142,
+     143, 144,
+     145, 145, 146, 147, 148, 149, 150, 151, 152, 153, 153, 154, 155, 156,
+     157, 158,
+     159, 159, 160, 161, 162, 163, 164, 164, 165, 166, 167, 168, 169, 169,
+     170, 171,
+     172, 173, 174, 174, 175, 176, 177, 178, 178, 179, 180, 181, 182, 183,
+     183, 184,
+     185, 186, 187, 187, 188, 189, 190, 190, 191, 192, 193, 194, 194, 195,
+     196, 197,
+     197, 198, 199, 200, 201, 201, 202, 203, 204, 204, 205, 206, 207, 207,
+     208, 209,
+     210, 210, 211, 212, 213, 213, 214, 215, 216, 216, 217, 218, 219, 219,
+     220, 221,
+     222, 222, 223, 224, 225, 225, 226, 227, 227, 228, 229, 230, 230, 231,
+     232, 232,
+     233, 234, 235, 235, 236, 237, 237, 238, 239, 240, 240, 241, 242, 242,
+     243, 244,
+     245, 245, 246, 247, 247, 248, 249, 249, 250, 251, 252, 252, 253, 254,
+     254, 255,
+     },
+// gamma-coeff = 0.5882
+    {
+     0, 10, 15, 19, 22, 25, 28, 31, 33, 36, 38, 40, 42, 44, 46, 48,
+     50, 52, 54, 55, 57, 59, 60, 62, 64, 65, 67, 68, 70, 71, 72, 74,
+     75, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 94,
+     95, 97, 98, 99, 100, 101, 102, 103, 105, 106, 107, 108, 109, 110, 111,
+     112,
+     113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
+     127, 128,
+     129, 130, 131, 132, 133, 134, 135, 135, 136, 137, 138, 139, 140, 141,
+     142, 143,
+     144, 144, 145, 146, 147, 148, 149, 150, 150, 151, 152, 153, 154, 155,
+     156, 156,
+     157, 158, 159, 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 168,
+     168, 169,
+     170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 178, 178, 179, 180,
+     181, 181,
+     182, 183, 184, 184, 185, 186, 187, 187, 188, 189, 190, 190, 191, 192,
+     192, 193,
+     194, 195, 195, 196, 197, 197, 198, 199, 200, 200, 201, 202, 202, 203,
+     204, 204,
+     205, 206, 206, 207, 208, 208, 209, 210, 210, 211, 212, 212, 213, 214,
+     214, 215,
+     216, 216, 217, 218, 218, 219, 220, 220, 221, 222, 222, 223, 224, 224,
+     225, 226,
+     226, 227, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 234,
+     235, 236,
+     236, 237, 238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 244, 244,
+     245, 245,
+     246, 247, 247, 248, 248, 249, 250, 250, 251, 251, 252, 253, 253, 254,
+     254, 255,
+     },
+// gamma-coeff = 0.4545
+    {
+     0, 21, 28, 34, 39, 43, 46, 50, 53, 56, 59, 61, 64, 66, 68, 70,
+     72, 74, 76, 78, 80, 82, 84, 85, 87, 89, 90, 92, 93, 95, 96, 98,
+     99, 101, 102, 103, 105, 106, 107, 109, 110, 111, 112, 114, 115, 116,
+     117, 118,
+     119, 120, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133,
+     134, 135,
+     136, 137, 138, 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148,
+     149, 150,
+     151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 160, 160, 161,
+     162, 163,
+     164, 164, 165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 173, 173,
+     174, 175,
+     175, 176, 177, 178, 178, 179, 180, 180, 181, 182, 182, 183, 184, 184,
+     185, 186,
+     186, 187, 188, 188, 189, 190, 190, 191, 192, 192, 193, 194, 194, 195,
+     195, 196,
+     197, 197, 198, 199, 199, 200, 200, 201, 202, 202, 203, 203, 204, 205,
+     205, 206,
+     206, 207, 207, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,
+     214, 215,
+     215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 223,
+     223, 224,
+     224, 225, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231,
+     231, 232,
+     232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
+     239, 240,
+     240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247,
+     247, 248,
+     248, 249, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254,
+     255, 255,
+     },
+};
+#endif				/* GAMMA_TABLES_H */
diff -uNr luvcview-20070512.orig/utils.c luvcview-20070512.new/utils.c
--- luvcview-20070512.orig/utils.c	2007-08-01 17:43:34.000000000 +0200
+++ luvcview-20070512.new/utils.c	2007-08-01 17:41:45.000000000 +0200
@@ -33,6 +33,7 @@
 #include <time.h>
 #include <limits.h>
 #include "huffman.h"
+#include "spcagamma.h"
 
 #define ISHIFT 11
 
@@ -474,57 +475,57 @@
 		    err = ERR_WRONG_MARKER;
 		    goto error;
 		}
-	switch (mb){
-	    case 6: {
-		decode_mcus(&in, decdata->dcts, mb, dscans, max);
-		idct(decdata->dcts, decdata->out, decdata->dquant[0],
-		     IFIX(128.5), max[0]);
-		idct(decdata->dcts + 64, decdata->out + 64,
-		     decdata->dquant[0], IFIX(128.5), max[1]);
-		idct(decdata->dcts + 128, decdata->out + 128,
-		     decdata->dquant[0], IFIX(128.5), max[2]);
-		idct(decdata->dcts + 192, decdata->out + 192,
-		     decdata->dquant[0], IFIX(128.5), max[3]);
-		idct(decdata->dcts + 256, decdata->out + 256,
-		     decdata->dquant[1], IFIX(0.5), max[4]);
-		idct(decdata->dcts + 320, decdata->out + 320,
-		     decdata->dquant[2], IFIX(0.5), max[5]);
-	  
-	    } break;
-	    case 4:
-	    {
-		decode_mcus(&in, decdata->dcts, mb, dscans, max);
-		idct(decdata->dcts, decdata->out, decdata->dquant[0],
-		     IFIX(128.5), max[0]);
-		idct(decdata->dcts + 64, decdata->out + 64,
-		     decdata->dquant[0], IFIX(128.5), max[1]);
-		idct(decdata->dcts + 128, decdata->out + 256,
-		     decdata->dquant[1], IFIX(0.5), max[4]);
-		idct(decdata->dcts + 192, decdata->out + 320,
-		     decdata->dquant[2], IFIX(0.5), max[5]);
-	   	   
-	    }
-	    break;
-	    case 3:
-	    	 decode_mcus(&in, decdata->dcts, mb, dscans, max);
-		idct(decdata->dcts, decdata->out, decdata->dquant[0],
-		     IFIX(128.5), max[0]);		     
-		idct(decdata->dcts + 64, decdata->out + 256,
-		     decdata->dquant[1], IFIX(0.5), max[4]);
-		idct(decdata->dcts + 128, decdata->out + 320,
-		     decdata->dquant[2], IFIX(0.5), max[5]);
-	    
-		         
-	    break;
-	    case 1:
-	    	 decode_mcus(&in, decdata->dcts, mb, dscans, max);
-		idct(decdata->dcts, decdata->out, decdata->dquant[0],
-		     IFIX(128.5), max[0]);
+	    switch (mb){
+		case 6: {
+		    decode_mcus(&in, decdata->dcts, mb, dscans, max);
+		    idct(decdata->dcts, decdata->out, decdata->dquant[0],
+			 IFIX(128.5), max[0]);
+		    idct(decdata->dcts + 64, decdata->out + 64,
+			 decdata->dquant[0], IFIX(128.5), max[1]);
+		    idct(decdata->dcts + 128, decdata->out + 128,
+			 decdata->dquant[0], IFIX(128.5), max[2]);
+		    idct(decdata->dcts + 192, decdata->out + 192,
+			 decdata->dquant[0], IFIX(128.5), max[3]);
+		    idct(decdata->dcts + 256, decdata->out + 256,
+			 decdata->dquant[1], IFIX(0.5), max[4]);
+		    idct(decdata->dcts + 320, decdata->out + 320,
+			 decdata->dquant[2], IFIX(0.5), max[5]);
+	      
+		} break;
+		case 4:
+		{
+		    decode_mcus(&in, decdata->dcts, mb, dscans, max);
+		    idct(decdata->dcts, decdata->out, decdata->dquant[0],
+			 IFIX(128.5), max[0]);
+		    idct(decdata->dcts + 64, decdata->out + 64,
+			 decdata->dquant[0], IFIX(128.5), max[1]);
+		    idct(decdata->dcts + 128, decdata->out + 256,
+			 decdata->dquant[1], IFIX(0.5), max[4]);
+		    idct(decdata->dcts + 192, decdata->out + 320,
+			 decdata->dquant[2], IFIX(0.5), max[5]);
+		       
+		}
+		break;
+		case 3:
+		     decode_mcus(&in, decdata->dcts, mb, dscans, max);
+		    idct(decdata->dcts, decdata->out, decdata->dquant[0],
+			 IFIX(128.5), max[0]);		     
+		    idct(decdata->dcts + 64, decdata->out + 256,
+			 decdata->dquant[1], IFIX(0.5), max[4]);
+		    idct(decdata->dcts + 128, decdata->out + 320,
+			 decdata->dquant[2], IFIX(0.5), max[5]);
+		
+			     
+		break;
+		case 1:
+		     decode_mcus(&in, decdata->dcts, mb, dscans, max);
+		    idct(decdata->dcts, decdata->out, decdata->dquant[0],
+			 IFIX(128.5), max[0]);
+		      
+		  break;
 		  
-	    break;
-	    
-	} // switch enc411
-	convert(decdata->out,*pic+y+x,pitch); 
+	      } // switch enc411
+	      convert(decdata->out,*pic+y+x,pitch); 
 	}
     }
 
@@ -542,6 +543,153 @@
     return err;
 }
 
+
+
+
+// y=0.656g+0.125b+0.226r
+
+#define RGB24_TO_Y(r,g,b) (CLIP(\
+        (((g) <<9)+((g)<<7)+((g)<<5)+((b)<<7)+((r)<<8)-((r)<<4)-((r)<<3))>>10))
+
+// v=(r-y)0.656
+#define YR_TO_V(r,y) (128 + \
+        (((((r)-(y)) << 9 )+(((r)-(y)) << 7 )+(((r)-(y)) << 5 )) >> 10))
+
+// u=(b-y)0.5   
+#define YB_TO_U(b,y) (128 + \
+        (((b)-(y)) >> 1))
+
+#define PACKRGB16(r,g,b) (__u16) ((((b) & 0xF8) << 8 ) | (((g) & 0xFC) << 3 ) | (((r) & 0xF8) >> 3 ))
+
+
+int bayer_decode(unsigned char **pic, unsigned char *buf, int *width,
+		int *height)
+{
+    int my, mx;                 /* scan input surface */
+    int err = 0;
+    unsigned char *pic0;        /* output surface */
+    __u16 *pix1, *pix2;         /* same for 16 bits output */
+    unsigned char Y, Y1, U, V, Yp, Up, Vp;       /* chroma  */
+    unsigned char inr, ing1, ing2, inb, ing;    /* srgb input */
+    int inl, inl1;              /* offset line input */
+    int nextinline, nextoutline;
+    unsigned char r, b, y1, y2, y3, y4;
+    /*kernel matrix 4x4 */
+    unsigned char G00, R10, G20, R30, B01, G02, B03, G31, R32, G13,
+        B23, G33;
+    unsigned char r1, g1, b1, r2, g2, b2, r3, g3, b3, r4, g4, b4;
+    int bpp;
+
+    int framesize, frameUsize;
+
+    unsigned char red[256];
+    unsigned char green[256];
+    unsigned char blue[256];
+
+    /* Gamma setting change compute all case */
+    memcpy(red, &GTable[3], 256);
+    memcpy(green, &GTable[3], 256);
+    memcpy(blue, &GTable[3], 256);
+
+
+    pic0 = *pic;
+    if (buf == NULL) {
+        err = -1;
+        goto error;
+    }
+    datap = buf;
+
+    inr = ing1 = ing2 = ing = inb = r = b = 0;  //compiler maybe happy !!
+
+    framesize = (*width) * (*height);
+    frameUsize = framesize >> 2;
+
+    /* initialize input pointer */
+    inl = 0;
+    inl1 = *width;
+    nextinline = *width << 1;
+
+    nextoutline = *width;
+    for (my = 0; my < *height ; my += 2) {
+	for (mx = 0; mx < *width ; mx += 2) {
+	    g1 = green[buf[inl + mx]];
+	    b2 = blue[buf[inl + 1 + mx]];
+	    r3 = red[buf[inl1 + mx]];
+	    g4 = green[buf[inl1 + 1 + mx]];
+
+	    if ((mx == 0) || (my == 0)
+		|| (mx == (*width - 2))
+		|| (my == (*height - 2))) {
+		ing = (g1 + g4) >> 1;
+		y1 = RGB24_TO_Y(r3, g1, b2);
+		y2 = RGB24_TO_Y(r3, ing, b2);
+		y3 = RGB24_TO_Y(r3, ing, b2);
+		y4 = RGB24_TO_Y(r3, g4, b2);
+		Y = (y1+y2+y3+y4) >>2 ;
+		U = YB_TO_U(b2, ((y1 + y4)
+				    >> 1));
+		V = YR_TO_V(r3, ((y1 + y4)
+				    >> 1));
+	    } else {
+		G00 = buf[inl + mx - *width - 1];
+		R10 = buf[inl + mx - *width];
+		G20 = buf[inl + mx - *width + 1];
+		R30 = buf[inl + mx - *width + 2];
+		B01 = buf[inl + mx - 1];
+		G31 = buf[inl + mx + 2];
+		G02 = buf[inl1 + mx - 1];
+		R32 = buf[inl1 + mx + 2];
+		B03 = buf[inl1 + mx + *width - 1];
+		G13 = buf[inl1 + mx + *width];
+		B23 = buf[inl1 + mx + *width + 1];
+		G33 = buf[inl1 + mx + *width + 2];
+		b1 = blue[((B01 + b2) >> 1)];
+		r1 = red[((R10 + r3) >> 1)];
+		r4 = red[((r3 + R32) >> 1)];
+		b4 = blue[((b2 + B23) >> 1)];
+		g2 = green[((g1 + g4 + G31 + G20)
+			    >> 2)];
+		r2 = red[((R10 + R30 + r3 + R32) >> 2)];
+		g3 = green[((g1 + g4 + G13 + G02)
+			    >> 2)];
+		b3 = blue[((B01 + b2 + B23 + B03) >> 2)];
+		y1 = RGB24_TO_Y(r1, g1, b1);
+		y2 = RGB24_TO_Y(r2, g2, b2);
+		y3 = RGB24_TO_Y(r3, g3, b3);
+		y4 = RGB24_TO_Y(r4, g4, b4);
+		Y = (y1+y2+y3+y4) >>2;
+		U = YB_TO_U(((b1 + b2 + b3 + b4)
+				>> 2), ((y1 + y2 + y3 + y4)
+					>> 2));
+		V = YR_TO_V(((r1 + r2 + r3 + r4)
+				>> 2), ((y1 + y2 + y3 + y4)
+					>> 2));
+	      }
+
+	      if(mx %4 == 0) {
+		      Yp = Y;
+		      Up = U;
+		      Vp = V;
+	      } else {
+		      *pic0++ = Yp;
+		      *pic0++ = Up;
+		      *pic0++ = Y;
+		      *pic0++ = Vp;
+	      }
+
+	}               // end mx loop
+	inl += nextinline;
+	inl1 += nextinline;
+	pic0 += nextoutline;
+    }                   // end my loop
+
+
+   return 0; 
+   
+error:
+  return err;
+}
+
 /****************************************************************/
 /**************       huffman decoder             ***************/
 /****************************************************************/
@@ -988,6 +1136,34 @@
 #define  FOUR_TWO_TWO 2		//Y00 Cb Y01 Cr
 
 
+
+unsigned int
+Pgrbgtorgb24(unsigned char * input_ptr, unsigned char * output_ptr, unsigned int image_width, unsigned int image_height)
+{
+	unsigned int i, size;
+	unsigned char Y, Y1, U, V;
+	unsigned char *buff = input_ptr;
+	unsigned char *output_pt = output_ptr;
+	size = image_width * image_height /2;
+	for (i = size; i > 0; i--) {
+		/* bgr instead rgb ?? */
+		Y = buff[0] ;
+		U = buff[1] ;
+		Y1 = buff[2];
+		V = buff[3];
+		buff += 4;
+		*output_pt++ = R_FROMYV(Y,V);
+		*output_pt++ = G_FROMYUV(Y,U,V); //b
+		*output_pt++ = B_FROMYU(Y,U); //v
+			
+		*output_pt++ = R_FROMYV(Y1,V);
+		*output_pt++ = G_FROMYUV(Y1,U,V); //b
+		*output_pt++ = B_FROMYU(Y1,U); //v
+	}
+	
+	return FOUR_TWO_TWO;
+} 
+
 /* translate YUV422Packed to rgb24 */
 
 unsigned int
@@ -1030,34 +1206,35 @@
     pic1 = pic + width;
     outy = out;
     outu = out + 64 * 4;
-    outv = out + 64 * 5;    
-	for (j = 0; j < 8; j++) {
-	    for (k = 0; k < 8; k++) {
-	    if( k == 4) { 
-	    	outy1 += 56;
-	    	outy2 += 56;
-	    }
-	    *pic0++ = CLIP(outy[outy1]);
-	    *pic0++ = CLIP(128 + *outu);
-	    *pic0++ = CLIP(outy[outy1+1]);
-	    *pic0++ = CLIP(128 + *outv);
-	    *pic1++ = CLIP(outy[outy2]);
-	    *pic1++ = CLIP(128 + *outu);
-	    *pic1++ = CLIP(outy[outy2+1]);
-	    *pic1++ = CLIP(128 + *outv);
-	   outy1 +=2; outy2 += 2; outu++; outv++;
-	  }
-	  if(j==3) {
-	  outy = out + 128;
-	  } else {
-	  outy += 16;
+    outv = out + 64 * 5;   
+ 
+    for (j = 0; j < 8; j++) {
+	for (k = 0; k < 8; k++) {
+	  if( k == 4) { 
+	      outy1 += 56;
+	      outy2 += 56;
 	  }
-	    outy1 = 0;
-	    outy2 = 8;
-	    pic0 += 2 * (width -16);
-	    pic1 += 2 * (width -16);
-	    
+	  *pic0++ = CLIP(outy[outy1]);
+	  *pic0++ = CLIP(128 + *outu);
+	  *pic0++ = CLIP(outy[outy1+1]);
+	  *pic0++ = CLIP(128 + *outv);
+	  *pic1++ = CLIP(outy[outy2]);
+	  *pic1++ = CLIP(128 + *outu);
+	  *pic1++ = CLIP(outy[outy2+1]);
+	  *pic1++ = CLIP(128 + *outv);
+	  outy1 +=2; outy2 += 2; outu++; outv++;
 	}
+	if(j==3) {
+		outy = out + 128;
+	} else {
+		outy += 16;
+	}
+	outy1 = 0;
+	outy2 = 8;
+	pic0 += 2 * (width -16);
+	pic1 += 2 * (width -16);
+	
+    }
     
 }
 static void yuv422pto422(int * out,unsigned char *pic,int width)
@@ -1264,3 +1441,30 @@
 picture = NULL;
 return 0;
 }
+
+int
+get_pictureSBGGR8(unsigned char *buf,int width,int height)
+{
+FILE *foutpict;
+unsigned char *picture = NULL;
+char *name = NULL;
+name = calloc(80,1);
+getPictureName (name, 0);
+picture = (unsigned char *)malloc(width*height*3*sizeof(char));
+if(picture){
+	Pgrbgtorgb24(buf, picture, width, height);
+}else{
+	printf(" no room to take a picture \n");
+	return 0;
+}
+if(name){
+	foutpict = fopen (name, "wb");
+	fprintf (foutpict, "P6\n%d %d\n255\n", width, height);
+	fwrite (picture, sizeof (char), width * height * 3, foutpict);
+	fclose (foutpict);
+	free(name);
+}
+free(picture);
+picture = NULL;
+return 0;
+}
Les fichiers binaires luvcview-20070512.orig/.utils.c.swp et luvcview-20070512.new/.utils.c.swp sont différents.
diff -uNr luvcview-20070512.orig/utils.h luvcview-20070512.new/utils.h
--- luvcview-20070512.orig/utils.h	2007-08-01 17:43:34.000000000 +0200
+++ luvcview-20070512.new/utils.h	2007-07-30 16:01:43.000000000 +0200
@@ -42,4 +42,6 @@
 int 
 get_picture(unsigned char *buf,int size);
 int
+get_pictureSBGGR8(unsigned char *buf,int width,int height);
+int
 get_pictureYV2(unsigned char *buf,int width,int height);
Les fichiers binaires luvcview-20070512.orig/.utils.h.swp et luvcview-20070512.new/.utils.h.swp sont différents.
diff -uNr luvcview-20070512.orig/v4l2uvc.c luvcview-20070512.new/v4l2uvc.c
--- luvcview-20070512.orig/v4l2uvc.c	2007-08-01 17:43:34.000000000 +0200
+++ luvcview-20070512.new/v4l2uvc.c	2007-08-01 17:28:05.000000000 +0200
@@ -124,6 +124,16 @@
 				     (size_t) vd->width * (vd->height +
 							   8) * 2);
 	break;
+    case V4L2_PIX_FMT_SBGGR8:
+	vd->tmpbuffer =
+	    (unsigned char *) calloc(1, (size_t) vd->framesizeIn);
+	if (!vd->tmpbuffer)
+	    goto error;
+	vd->framebuffer =
+	    (unsigned char *) calloc(1,
+				     (size_t) vd->width * (vd->height +
+							   8) * 2);
+	break;
     case V4L2_PIX_FMT_YUYV:
 	vd->framebuffer =
 	    (unsigned char *) calloc(1, (size_t) vd->framesizeIn);
@@ -352,8 +362,8 @@
     vd->fmt.fmt.pix.pixelformat = vd->formatIn;
     vd->fmt.fmt.pix.field = V4L2_FIELD_ANY;
     ret = ioctl(vd->fd, VIDIOC_S_FMT, &vd->fmt);
-    if (ret < 0) {
-	printf("Unable to set format: %d.\n", errno);
+    if (ret < 0 || vd->formatIn != vd->fmt.fmt.pix.pixelformat) {
+	printf("Unable to set format: %d.\n", vd->formatIn);
 	goto fatal;
     }
     if ((vd->fmt.fmt.pix.width != vd->width) ||
@@ -474,63 +484,63 @@
 	goto err;
     }
 
-	/* Capture a single raw frame */
-	if (vd->rawFrameCapture && vd->buf.bytesused > 0) {
-		FILE *frame = NULL;
-		char filename[13];
-		int ret;
-
-		/* Disable frame capturing unless we're in frame stream mode */
-		if(vd->rawFrameCapture == 1)
-			vd->rawFrameCapture = 0;
-
-		/* Create a file name and open the file */
-		sprintf(filename, "frame%03u.raw", vd->fileCounter++ % 1000);
-		frame = fopen(filename, "wb");
-		if(frame == NULL) {
-			perror("Unable to open file for raw frame capturing");
-			goto end_capture;
-		}
-		
-		/* Write the raw data to the file */
-		ret = fwrite(vd->mem[vd->buf.index], vd->buf.bytesused, 1, frame);
-		if(ret < 1) {
-			perror("Unable to write to file");
-			goto end_capture;
-		}
-		printf("Saved raw frame to %s (%u bytes)\n", filename, vd->buf.bytesused);
-		if(vd->rawFrameCapture == 2) {
-			vd->rfsBytesWritten += vd->buf.bytesused;
-			vd->rfsFramesWritten++;
-		}
+    /* Capture a single raw frame */
+    if (vd->rawFrameCapture && vd->buf.bytesused > 0) {
+	    FILE *frame = NULL;
+	    char filename[13];
+	    int ret;
+
+	    /* Disable frame capturing unless we're in frame stream mode */
+	    if(vd->rawFrameCapture == 1)
+		    vd->rawFrameCapture = 0;
+
+	    /* Create a file name and open the file */
+	    sprintf(filename, "frame%03u.raw", vd->fileCounter++ % 1000);
+	    frame = fopen(filename, "wb");
+	    if(frame == NULL) {
+		    perror("Unable to open file for raw frame capturing");
+		    goto end_capture;
+	    }
+	    
+	    /* Write the raw data to the file */
+	    ret = fwrite(vd->mem[vd->buf.index], vd->buf.bytesused, 1, frame);
+	    if(ret < 1) {
+		    perror("Unable to write to file");
+		    goto end_capture;
+	    }
+	    printf("Saved raw frame to %s (%u bytes)\n", filename, vd->buf.bytesused);
+	    if(vd->rawFrameCapture == 2) {
+		    vd->rfsBytesWritten += vd->buf.bytesused;
+		    vd->rfsFramesWritten++;
+	    }
 
 
 		/* Clean up */
 end_capture:
-		if(frame)
-			fclose(frame);
-	}
+	    if(frame)
+		fclose(frame);
+    }
 
    
 
-	/* Capture raw stream data */
-	if (vd->captureFile && vd->buf.bytesused > 0) {
-		int ret;
-		ret = fwrite(vd->mem[vd->buf.index], vd->buf.bytesused, 1, vd->captureFile);
-		if (ret < 1) {
-			perror("Unable to write raw stream to file");
-			fprintf(stderr, "Stream capturing terminated.\n");
-			fclose(vd->captureFile);
-			vd->captureFile = NULL;
-			vd->framesWritten = 0;
-			vd->bytesWritten = 0;
-		} else {
-			vd->framesWritten++;
-			vd->bytesWritten += vd->buf.bytesused;
-			if (debug)
-				printf("Appended raw frame to stream file (%u bytes)\n", vd->buf.bytesused);
-		}
-	}
+    /* Capture raw stream data */
+    if (vd->captureFile && vd->buf.bytesused > 0) {
+	    int ret;
+	    ret = fwrite(vd->mem[vd->buf.index], vd->buf.bytesused, 1, vd->captureFile);
+	    if (ret < 1) {
+		    perror("Unable to write raw stream to file");
+		    fprintf(stderr, "Stream capturing terminated.\n");
+		    fclose(vd->captureFile);
+		    vd->captureFile = NULL;
+		    vd->framesWritten = 0;
+		    vd->bytesWritten = 0;
+	    } else {
+		    vd->framesWritten++;
+		    vd->bytesWritten += vd->buf.bytesused;
+		    if (debug)
+			    printf("Appended raw frame to stream file (%u bytes)\n", vd->buf.bytesused);
+	    }
+    }
 
     switch (vd->formatIn) {
     case V4L2_PIX_FMT_MJPEG:
@@ -541,28 +551,28 @@
         }
 	memcpy(vd->tmpbuffer, vd->mem[vd->buf.index],vd->buf.bytesused);
 	 /* avi recording is toggled on */
-    if (vd->toggleAvi) {
-        /* if vd->avifile is NULL, then we need to initialize it */
-        if (vd->avifile == NULL) {
-            vd->avifile = AVI_open_output_file(vd->avifilename);
-
-            /* if avifile is NULL, there was an error */
-            if (vd->avifile == NULL ) {
-                fprintf(stderr,"Error opening avifile %s\n",vd->avifilename);
-            }
-            else {
-                /* we default the fps to 15, we'll reset it on close */
-                AVI_set_video(vd->avifile, vd->width, vd->height,
-                    15, "MJPG");
-                printf("recording to %s\n",vd->avifilename);
-            }
-        } else {
-        /* if we have a valid avifile, record the frame to it */
-            AVI_write_frame(vd->avifile, vd->tmpbuffer,
-                vd->buf.bytesused, vd->framecount);
-            vd->framecount++;
-        }
-    }
+	if (vd->toggleAvi) {
+	    /* if vd->avifile is NULL, then we need to initialize it */
+	    if (vd->avifile == NULL) {
+		vd->avifile = AVI_open_output_file(vd->avifilename);
+
+		/* if avifile is NULL, there was an error */
+		if (vd->avifile == NULL ) {
+		    fprintf(stderr,"Error opening avifile %s\n",vd->avifilename);
+		}
+		else {
+		    /* we default the fps to 15, we'll reset it on close */
+		    AVI_set_video(vd->avifile, vd->width, vd->height,
+			15, "MJPG");
+		    printf("recording to %s\n",vd->avifilename);
+		}
+	    } else {
+	    /* if we have a valid avifile, record the frame to it */
+		AVI_write_frame(vd->avifile, vd->tmpbuffer,
+		    vd->buf.bytesused, vd->framecount);
+		vd->framecount++;
+	    }
+	}
 	if (jpeg_decode(&vd->framebuffer, vd->tmpbuffer, &vd->width,
 	     &vd->height) < 0) {
 	    printf("jpeg decode errors\n");
@@ -571,6 +581,22 @@
 	if (debug)
 	    printf("bytes in used %d \n", vd->buf.bytesused);
 	break;
+    case V4L2_PIX_FMT_SBGGR8:
+        if(vd->buf.bytesused <= HEADERFRAME1) {	/* Prevent crash on empty image */
+/*	    if(debug)*/
+	        printf("Ignoring empty buffer ...\n");
+	    return 0;
+        }
+	memcpy(vd->tmpbuffer, vd->mem[vd->buf.index],vd->buf.bytesused);
+
+	if (bayer_decode(&vd->framebuffer, vd->tmpbuffer, &vd->width,
+	     &vd->height) < 0) {
+	    printf("bayer decode errors\n");
+	    goto err;
+	}
+	if (debug)
+	    printf("bytes in used %d \n", vd->buf.bytesused);
+	break;
     case V4L2_PIX_FMT_YUYV:
 	if (vd->buf.bytesused > vd->framesizeIn)
 	    memcpy(vd->framebuffer, vd->mem[vd->buf.index],
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Spca50x-devs mailing list
Spca50x-devs@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/spca50x-devs