|
楼主 |
发表于 2004-6-30 13:24:33
|
显示全部楼层
再补发一下我写的framebuffer下,overlay显示的v4l2程序。
- #include <stdio.h>
- #include <errno.h>
- #include <sys/ioctl.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <linux/types.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <sys/mman.h>
- #include <sys/poll.h>
- #include <linux/videodev.h>
- #define FILENAME "/dev/video"
- #define IOCTL(fd, req, addr ) ((-1==ioctl(fd,req,addr))?(perror(#req),exit(EXI
- T_FAILURE)):0)
- int main(void)
- {
- int fd;
- struct v4l2_input input;
- struct v4l2_standard standard;
- struct v4l2_format format;
- struct v4l2_framebuffer fb;
- v4l2_std_id std;
- int index;
- int one=1,zero=0;
- fd=open(FILENAME,O_RDWR);
- //set the input to Composite1
- index = 1;
- IOCTL(fd,VIDIOC_S_INPUT,&index);
- //query video standard
- IOCTL(fd,VIDIOC_G_STD,&std);
- standard.index = 0;
- while (0 == ioctl(fd,VIDIOC_ENUMSTD,&standard))
- { if (standard.id & std)
- printf("the current video standard :%s\n",standard.name);
- standard.index++;
- }
- //set up overlay param and start overlay
- format.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
- IOCTL(fd,VIDIOC_G_FMT,&format);
- format.fmt.win.w.width = 768 ;
- format.fmt.win.w.height = 576 ;
- format.fmt.win.w.top = 70;
- format.fmt.win.w.left = 50;
- format.fmt.win.field = V4L2_FIELD_INTERLACED;
- IOCTL(fd,VIDIOC_S_FMT,&format);
- IOCTL(fd,VIDIOC_G_FBUF,&fb);
- printf("before set the fb, the pixelformat is 0x%x\n ",fb.fmt.pixelformat
- );
- fb.flags = V4L2_FBUF_FLAG_PRIMARY;
- fb.fmt.width = 1024;
- fb.fmt.height = 768;
- fb.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
- fb.fmt.bytesperline = 4096;
- fb.fmt.sizeimage = 768*4096;
- fb.fmt.field = V4L2_FIELD_INTERLACED;
- fb.fmt.colorspace = V4L2_COLORSPACE_SRGB;
- IOCTL(fd,VIDIOC_S_FBUF,&fb);
- IOCTL(fd,VIDIOC_OVERLAY,&one);
- while(getchar()=='q') {
- IOCTL(fd,VIDIOC_OVERLAY,&zero);
- close(fd);
- }
- return(0);
- }
复制代码
请热爱linux下多媒体编程的朋友多提建议。 |
|