Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1442 → Rev 1443

/demos/trunk/bttvdemo/bttv.c
45,6 → 45,8
#define HEIGHT 480
#define BYTES_PP 2
 
//#define COLOR
 
#define FG_PERIOD 40000
#define FG_WCET 30000
#define FG_W 320
65,6 → 67,7
struct video_buffer fbuf[2];
struct video_window win;
struct video_channel chan;
struct video_tuner tuner;
int on,display,temp,save;
 
task_nopreempt();
72,36 → 75,70
/* Init videodev driver */
VIDEODEV26_open(0);
 
VIDEODEV26_ioctl(0,VIDIOCGCHAN,(unsigned long)&chan);
 
chan.channel = (int)(arg);
chan.type = VIDEO_VC_TUNER;
chan.norm = VIDEO_TYPE_CAMERA;
VIDEODEV26_ioctl(0,VIDIOCSCHAN,(unsigned long)&chan);
 
VIDEODEV26_ioctl(0,VIDIOCGTUNER,(unsigned long)&tuner);
 
tuner.mode = VIDEO_MODE_PAL;
 
VIDEODEV26_ioctl(0,VIDIOCSTUNER,(unsigned long)&tuner);
 
/* Select palette and depth */
VIDEODEV26_ioctl(0,VIDIOCGPICT,(unsigned long)&vpic);
vpic.palette = VIDEO_PALETTE_GREY;
vpic.depth = 8;
#ifdef COLOR
vpic.palette = VIDEO_PALETTE_RGB24;
vpic.depth = 24;
#else
vpic.palette = VIDEO_PALETTE_GREY;
vpic.depth = 8;
#endif
 
vpic.brightness = 35000;
vpic.hue = 32000;
vpic.contrast = 32000;
vpic.colour = 32000;
VIDEODEV26_ioctl(0,VIDIOCSPICT,(unsigned long)&vpic);
 
/* Double Buffering Strategy */
 
fbuf[0].base = malloc(FG_W*FG_H);
fbuf[0].height = FG_H;
fbuf[0].width = FG_W;
fbuf[0].bytesperline = FG_W;
fbuf[0].depth = 8;
#ifdef COLOR
 
fbuf[0].base = malloc(FG_W*FG_H*3);
fbuf[0].height = FG_H;
fbuf[0].width = FG_W;
fbuf[0].bytesperline = FG_W*3;
fbuf[0].depth = 24;
fbuf[1].base = malloc(FG_W*FG_H);
fbuf[1].height = FG_H;
fbuf[1].width = FG_W;
fbuf[1].bytesperline = FG_W;
fbuf[1].depth = 8;
fbuf[1].base = malloc(FG_W*FG_H*3);
fbuf[1].height = FG_H;
fbuf[1].width = FG_W;
fbuf[1].bytesperline = FG_W*3;
fbuf[1].depth = 24;
 
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&(fbuf[0]));
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&(fbuf[1]));
#else
 
fbuf[0].base = malloc(FG_W*FG_H);
fbuf[0].height = FG_H;
fbuf[0].width = FG_W;
fbuf[0].bytesperline = FG_W;
fbuf[0].depth = 8;
fbuf[1].base = malloc(FG_W*FG_H);
fbuf[1].height = FG_H;
fbuf[1].width = FG_W;
fbuf[1].bytesperline = FG_W;
fbuf[1].depth = 8;
 
#endif
 
/* Set grabbing window */
VIDEODEV26_ioctl(0,VIDIOCGWIN,(unsigned long)&win);
120,19 → 157,18
while(1) {
task_nopreempt();
 
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&(fbuf[save]));
/* Set the current buffer */
VIDEODEV26_ioctl(0,VIDIOCSFBUF,(unsigned long)&(fbuf[save]));
 
/* Start grabbing */
on = 1;
VIDEODEV26_ioctl(0,VIDIOCCAPTURE,(unsigned long)&on);
task_preempt();
 
/*
printf_xy(1,20,WHITE,"%08x%08x",
*(unsigned int *)(fbuf[display].base+50*320+50),
*(unsigned int *)(fbuf[display].base+50*320+54));
printf_xy(1,20,WHITE,"%08x",
*(unsigned int *)(fbuf[display].base+50*320*3+50*3));
*/
elaborate_image(fbuf[display].base);
159,14 → 195,28
WORD x,y;
BYTE *col;
 
#ifdef COLOR
 
for(y = 0; y < FG_H; y++)
for(x = 0; x < FG_W; x++) {
 
col = (BYTE *)(imageptr + y * FG_W + x);
*(WORD *)(video_memory + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col),*(BYTE *)(col));
col = (BYTE *)(imageptr + y * FG_W * 3 + x * 3);
*(WORD *)(video_memory + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col+2),*(BYTE *)(col+1),*(BYTE *)(col+0));
 
}
 
#else
 
for(y = 0; y < FG_H; y++)
for(x = 0; x < FG_W; x++) {
col = (BYTE *)(imageptr + y * FG_W + x);
*(WORD *)(video_memory + y*(WIDTH*2) + (x*2)) = (WORD)rgb16(*(BYTE *)(col),*(BYTE *)(col),*(BYTE *)(col));
}
 
#endif
 
}
 
int main(int argc, char **argv)