UVC视频格式细节详解及分类大全
UVC支持各类的视频格式,如I420,YUY2,MJPG,H264等格式,但这些格式有的是归为统一一类的,如YUY2和NV12就归为无压缩的格式。
对于UVC视频流格式,其统一的视频流格式描述符如下:
typedef struct _VIDEO_FORMAT_DESCRIPTOR
UINT8 bLength;
UINT8 bDescriptorType;
UINT8 bDescriptorSubtype;
}VIDEO_FORMAT_DESCRIPTOR;
其中bDescriptorType为0x24(视频特定类描述符类型)时,代表的是Video Streaming Interface。
而bDescriptorSubtype的值可取: https://www.usbzh.com/article/detail-91.html 中的一些值。但这些值其实具有逻辑上的层次结构。虽然数字值是累计的。
VS_FORMAT_UNCOMPRESSED
VS_FORMAT_UNCOMPRESSED值为0x05,表示无压缩的视频格式。常见的格式有:YUY2,NV12,M420,I420等。以上的子分类通过其GUID来区分标识。
Format | GUID |
---|---|
YUY2 | 32595559-0000-0010-8000-00AA00389B71 |
NV12 | 3231564E-0000-0010-8000-00AA00389B71 |
M420 | 3032344D-0000-0010-8000-00AA00389B71 |
I420 | 30323449-0000-0010-8000-00AA00389B71 |
具体详见:UVC YUV2、NV12、M420、I420无压缩视频帧描述符GUID https://www.usbzh.com/article/detail-119.html
VS_FORMAT_FRAME_BASED
VS_FORMAT_FRAME_BASED的值为0x10,其下一般包括H264、H265压缩的视频格式。其通过GUID来区分具体的格式。
- UVC H264视频帧描述符 https://www.usbzh.com/article/detail-660.html
- UVC H265视频帧描述符 https://www.usbzh.com/article/detail-661.html
对于VS_FORMAT_FRAME_BASED和VS_FORMAT_UNCOMPRESSED格式,其结构体一是一致的。
typedef struct _H265_H264_VIDEO_FORMAT_DESCRIPTOR
{
UINT8 bLength;
UINT8 bDescriptorType;
UINT8 bDescriptorSubtype;
UINT8 bFormatIndex;
UINT8 bNumberFrameDescriptor;
GUID guidFormat; //UINT[16]
UINT8 bBitsPerPixel;
UINT8 bDefaultFrameIndex;
UINT8 bAspectRatioX;
UINT8 bAspectRatioY;
UINT8 bmInterlaceFlags;
UINT8 bCopyProtect;
UINT8 bVariableSize;
}H265_VIDEO_FORMAT_DESCRIPTOR;
typedef struct _UNCOMPRESSED_VIDEO_FORMAT_DESCRIPTOR
{
UINT8 bLength;
UINT8 bDescriptorType;
UINT8 bDescriptorSubtype;
UINT8 bFormatIndex;
UINT8 bNumberFrameDescriptor;
GUID guidFormat:指定了; //UINT[16]
UINT8 bBitsPerPixel;
UINT8 bDefaultFrameIndex;
UINT8 bAspectRatioX;
UINT8 bAspectRatioY;
UINT8 bmInterlaceFlags;
UINT8 bCopyProtect;
}UNCOMPRESSED_VIDEO_FORMAT_DESCRIPTOR
VS_FORMAT_MJPEG
VS_FORMAT_MJPEG值为0x06,其下一般只有一种视频帧格式,VS_FRAME_MJPEG.
VS_FRAME_MJPEG的值为0x07
- UVC MJPEG视频帧描述符 https://www.usbzh.com/article/detail-169.html
VS_FORMAT_DV/UVC_VS_FORMAT_DV
UVC_VS_FORMAT_DV值为0x0C,该格式下没有帧格式描述符。
该格式下buffer[8]的代7位代表着具体的子格式,最高为为1时为60HZ,为0时为50HZ.
switch (buffer[8] & 0x7f) {
case 0:
strscpy(format->name, "SD-DV", sizeof(format->name));
break;
case 1:
strscpy(format->name, "SDL-DV", sizeof(format->name));
break;
case 2:
strscpy(format->name, "HD-DV", sizeof(format->name));
break;
deafult:
break;
}
strlcat(format->name, buffer[8] & (1 << 7) ? " 60Hz" : " 50Hz", sizeof(format->name));