Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4253243
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: 嵌入式

2011-05-01 13:26:44

v4l2_format 解析,在内核中这么定义的

  1. 1598   struct v4l2_format {
  2. 1599    enum v4l2_buf_type type;
  3. 1600    union {
  4. 1601    struct v4l2_pix_format pix; /* V4L2_BUF_TYPE_VIDEO_CAPTURE */
  5. 1602    struct v4l2_window win; /* V4L2_BUF_TYPE_VIDEO_OVERLAY */
  6. 1603    struct v4l2_vbi_format vbi; /* V4L2_BUF_TYPE_VBI_CAPTURE */
  7. 1604    struct v4l2_sliced_vbi_format sliced; /* V4L2_BUF_TYPE_SLICED_VBI_CAPTURE */
  8. 1605    __u8 raw_data[200]; /* user-defined */
  9. 1606    } fmt;
  10. 1607   };
  11. 1608
struct v4l2_pix_format 定义:
  1. 270    struct v4l2_pix_format {
  2.  271      __u32 width;
  3.  272      __u32 height;
  4.  273      __u32 pixelformat;
  5.  274      enum v4l2_field field;
  6.  275      __u32 bytesperline; /* for padding, zero if unused */
  7.  276      __u32 sizeimage;
  8.  277      enum v4l2_colorspace colorspace;
  9.  278      __u32 priv; /* private data, depends on pixelformat */
  10.  279   };

在程序中,这么写的:
  1. CLEAR (fmt);
  2. fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
  3. fmt.fmt.pix.width = 320;
  4. fmt.fmt.pix.height = 240;
  5. fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
  6. fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
  7. ioctl (fd, VIDIOC_S_FMT, &fmt); //设置图像格式

  8. printf("v4l2_buf_type(CAPTURE=1)    :%d\n",fmt.type); /* CAPTURE=1*/
  9. printf("width              :%d\n",fmt.fmt.pix.width);
  10. printf("height             :%d\n",fmt.fmt.pix.height);
  11. printf("pixel'yuyv'             :%d\n",('Y'|'U'<<8|'Y'<<16|'V'<<24));
  12. printf("pixel'jpeg'         :%d\n",('J'|'P'<<8|'E'<<16|'G'<<24));
  13. printf("pixelformat              :%d\n",fmt.fmt.pix.pixelformat);
  14. printf("v4l1_filed(FIELD_INTERCACED=4) :%d\n",fmt.fmt.pix.field);
  15. printf("bytesperline         :%d\n",fmt.fmt.pix.bytesperline);
  16. printf("sizeimage         :%d\n",fmt.fmt.pix.sizeimage);
  17. printf("colorspace(COLOSPACE_JPEG=7)    :%d\n",fmt.fmt.pix.colorspace);
  18. printf("priv             :%d\n",fmt.fmt.pix.priv);

  1. v4l2_buf_type(CAPTURE=1)        :1
  2. width                           :320
  3. height                          :240
  4. pixel'yuyv'                     :1448695129
  5. pixel'jpeg'                     :1195724874  ##得出 zc3xx 的输出是 JPEG格式,这里自动修改的格式
  6. pixelformat                     :1195724874
  7. v4l1_filed(FIELD_INTERCACED=4)  :1          ###
  8. bytesperline                    :320
  9. sizeimage                       :29390        图像大小????
  10. colorspace(COLOSPACE_JPEG=7)    :7
  11. priv                            :1

  1. pixel'jpeg' :1195724874
  2. pixelformat :1195724874

  我们原先设置的是 V4L2_PIX_FMT_YUYV,但是这里和我们设置的不一样, 这里设备自动修改为 JPEG格式,说明,zc3xx输出的JPEG格式

  1. v4l1_filed(FIELD_INTERCACED=4) :1
this device has no fields :说明这个设备没有 场设置
 filed 定义如下
  1. 106   enum v4l2_field {
  2.  107        V4L2_FIELD_ANY = 0, /* driver can choose from none,
  3.  108                               top, bottom, interlaced
  4.   109                              depending on whatever it thinks
  5.  110                               is approximate ... */
  6.  111        V4L2_FIELD_NONE = 1, /* this device has no fields ... */
  7.  112        V4L2_FIELD_TOP = 2, /* top field only */
  8.  113        V4L2_FIELD_BOTTOM = 3, /* bottom field only */
  9.  114        V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */
  10.  115        V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one
  11.  116                                    buffer, top-bottom order */
  12.  117        V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */
  13.  118        V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into
  14.  119                                      separate buffers */
  15.  120        V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field
  16.  121                                         first and the top field is
  17.  122                                         transmitted first */
  18.  123        V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field
  19.  124                                          first and the bottom field is
  20.  125                                              transmitted first */
  21.  126     };

  1. bytesperline :320

bytesPerLine 表明缓冲区中有多少字节用于表示图像中一行像素的所有

像素值。由于一个像素可能有多个字节表示,所以 bytesPerLine 可能是

字段 width 值的若干倍


表示 一行像素点,有320个字节表示

  1. sizeimage :       29390   ?????

  1. colorspace(COLOSPACE_JPEG=7) :7

  1.        /* I know there will be cameras that send this. So, this is
  2.  204    * unspecified chromaticities and full 0-255 on each of the
  3.  205    * Y'CbCr components  
  4.  206    */
  5.        未指定色度,充分0-255每个* Y'CbCr组件
  6.  207 V4L2_COLORSPACE_JPEG = 7,





注意:如果该视频设备驱动不支持你所设定的图像格式,视频驱动会重新修改struct v4l2_format结构体变量的值为该视频设备所支持的图像格式,所以在程序设计中,设定完所有的视频格式后,要获取实际的视频格式,要重新读取struct v4l2_format结构体变量。





阅读(14055) | 评论(0) | 转发(4) |
给主人留下些什么吧!~~