YUV2摄像头相关数据大小计算
2021-05-22
1360
0
视备支持的分辨率格式如下:
当我们使用YUV2 1280x720x10格式打开摄像头,通过BUSHOUND抓包如下:
Length Phase Data Description
-------- ----- ----------------------------------------------------------------------------------- ------
CTL 21 01 00 05 00 02 01 00 SET CUR
1 OUT 02 .
CTL a1 81 00 01 01 00 1a 00 GET CUR
CTL 21 01 00 01 01 00 1a 00 SET CUR
26 OUT 00 00 02 01 40 42 0f 00 00 00 00 00 00 00 1e 00 00 00 00 00 00 00 00 00 00 00
CTL a1 81 00 01 01 00 1a 00 GET CUR
CTL a1 83 00 01 01 00 1a 00 GET MAX
CTL a1 82 00 01 01 00 1a 00 GET MIN
CTL 21 01 00 01 01 00 1a 00 SET CUR
26 OUT 00 00 02 01 40 42 0f 00 00 00 00 00 00 00 1e 00 00 00 00 20 1c 00 00 00 00 00
CTL a1 81 00 01 01 00 1a 00 GET CUR
CTL 21 01 00 02 01 00 1a 00 SET CUR
26 OUT 00 00 02 01 40 42 0f 00 00 00 00 00 00 00 1e 00 00 00 00 20 1c 00 00 0c 00 00
CTL 01 0b 06 00 01 00 00 00 SET INTERFACE
CTL a1 83 00 14 00 01 0a 00 GET MAX
CTL 21 01 00 14 00 01 0a 00 SET CUR
10 OUT a3 01 5d 02 9a 02 53 03 1d 00
CTL a1 81 00 14 00 01 0a 00 GET CUR
CTL a1 83 00 14 00 01 0a 00 GET MAX
CTL a1 87 00 14 00 01 0a 00 GET DEF
CTL 21 01 00 14 00 01 0a 00 SET CUR
10 OUT 00 00 00 00 00 00 00 00 10 00
CTL a1 81 00 14 00 01 0a 00 GET CUR
CTL a1 83 00 14 00 01 0a 00 GET MAX
CTL 21 01 00 14 00 01 0a 00 SET CUR
10 OUT 9d 01 2d 02 98 02 27 03 1d 00
CTL a1 81 00 14 00 01 0a 00 GET CUR
`
通过SET_CUR提交到视频流接口的数据长度为26可知,此UVC摄像头使用的UVC版本为1.0。
- wPFrameRate:
- bmHint = 00 00
- bFormatIndex = 02
- bFrameIndex = 01
- dwFrameInterval = 40 42 0f 00 = 0x000f4240 = 1,000,000 ns = 100ms即每秒10帧
- wKeyFrameRate = 00 00
- wPFrameRate = 00 00
- wCompQuality = 00 00
- wCompWindowSize = 1e 00 = 30
- wDelay = 00 00
- dwMaxVideoFrameSize =00 20 1c 00 = 0x001C2000==1,843,200
- dwMaxPayloadTransferSize = 00 0c 00 00 = 0x00000c00=3072,即一个USBD_ISO_PACKET_DESCRIPTOR的最大数据长度。
其对应的描述符如下:
---> This is the Default (optimum) Frame index
bLength : 0x1E (30 bytes)
bDescriptorType : 0x24 (Video Streaming Interface)
bDescriptorSubtype : 0x05 (Uncompressed Frame Type)
bFrameIndex : 0x01
bmCapabilities : 0x00
wWidth : 0x0500 (1280)
wHeight : 0x02D0 (720)
dwMinBitRate : 0x08CA0000 (147456000 bps -> 18.432 MB/s) = 1280*720*2*8*10=147,456,000
dwMaxBitRate : 0x08CA0000 (147456000 bps -> 18.432 MB/s)
dwMaxVideoFrameBufferSize: 0x001C2000 (1843200 bytes) = 1280*720*2=1,843,200
dwDefaultFrameInterval : 0x000F4240 (100.0000 ms -> 10.000 fps)
bFrameIntervalType : 0x01 (1 discrete frame interval supported)
adwFrameInterval[1] : 0x000F4240 (100.0000 ms -> 10.000 fps)
Data (HexDump) : 1E 24 05 01 00 00 05 D0 02 00 00 CA 08 00 00 CA .$..............
08 00 20 1C 00 40 42 0F 00 01 40 42 0F 00 .. ..@B...@B..
dwMaxVideoFrameSize(0x18):00 20 1c 00 即0x001c2000=1843200=1280*720*2,由于这里为YUV2格式,所以2个Y对应一个UV,所以数据帧的总大小为1280*720*2,具体可参见 YUV数据格式 一节。
打开摄像头时,选择接口的内容如下:
CTL 01 0b 06 00 01 00 00 00 SET INTERFACE
可见选择接口ID=1,转换接口为6的接口内的端点,其描述符如下:
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x01
bAlternateSetting : 0x06
bNumEndpoints : 0x01 (1 Endpoint)
bInterfaceClass : 0x0E (Video)
bInterfaceSubClass : 0x02 (Video Streaming)
bInterfaceProtocol : 0x00
iInterface : 0x00 (No String Descriptor)
Data (HexDump) : 09 04 01 06 01 0E 02 00 00 .........
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x05 (TransferType=Isochronous SyncType=Asynchronous EndpointType=Data)
wMaxPacketSize : 0x1400
Bits 15..13 : 0x00 (reserved, must be zero)
Bits 12..11 : 0x02 (2 additional transactions per microframe -> allows 683..1024 bytes per packet)
Bits 10..0 : 0x400 (1024 bytes per packet)
bInterval : 0x01 (1 ms)
Data (HexDump) : 07 05 81 05 00 14 01 .......
可以看到,该USB使用的是同步/等时传输,端点最大包为1024字节,可额外传输2次,所以最大传输的字节数为1024*(2+1)=0xc00
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936