本帖最后由 zengweitotty 于 2015-12-16 10:19 编辑
新手入门的系列文档【原创】
本贴讲解了UVC example 中如何实现一个frame size支持多个帧率,英文写的,就不翻译了。有空的时候给翻译成中文。
1. Your UVC frame descriptor need support multi frameintervals. Like following settings
/* Class specific Uncompressed VSFrame Descriptor 1 - 640x480@60fps, or 30fps*/
0x22, // Descriptor size
0x24, // Descriptor type
0x05, // Subtype:uncompressed frame I/F
0x01, // Frame DescriptorIndex = 1
0x00, // Still image capturemethod not supported, not fixed frame rate
0x80,0x02, // Width in pixel: 640 =0x280
0xE0,0x01, //Height in pixel 480 =0x1E0
0x00,0x00,0x94,0x11, // Min bit ratebits/s. 640 pixels x 480 pixels x 2 bpp x 8 bits x 60 fps = 294912000 bits/s =0x11940000
0x00,0x00,0xCA,0x08, // Max bit ratebits/s. 640 pixels x 480 pixels x 2 bpp x 8 bits x 30 fps = 147456000 bits/s =0x8CA0000
0x00,0x60,0x09,0x00, // Maximumvideo or still frame size in bytes(Deprecated) 640 pixels x 480 pixels x 2 bpp= 614400 bytes = 0x96000
0x0A,0x8B,0x02,0x00, //0x28B0A =166816 (unit 100 ns) = 1 / (166816 * 100 ns) = 59.94fps
0x02, //Frame interval(FrameRate) types: Only Two frame interval supported
0x0A,0x8B,0x02,0x00, //0x28B0A =166816 (unit 100 ns) = 1 / (166816 * 100 ns) = 59.94fps
0x15,0x16,0x05,0x00 //0x51615= 333333 (unit 100 ns) = 1 / (333333 * 100 ns) = 29.97fps
2. Probe commit stage whenchange your frame rate.
Probe Stage:
GET_CUR class request:
Return the relavent current probe data base on your frame index. As followingVGA frame size probe structure data.
uint8_tglProbeCtrl1[CX3_UVC_MAX_PROBE_SETTING] = {
0x00,0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0x0A,0x8B,0x02,0x00, /* Desiredframe interval in 100ns */
0x00,0x00, /* Key frame rate in key frame/video frame units */
0x00,0x00, /* PFrame rate in PFrame / key frame units */
0x00,0x00, /* Compression quality control */
0x00,0x00, /* Window size for average bit rate */
0x00,0x00, /* Internal video streaming i/flatency in ms */
0x00,0x60,0x09,0x00, /* Max video frame size in bytes */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x40, 0x00,0x00 /* No. of bytes device can rx in single payload: 32KB */
#else
/* UVC 1.1 Probe Control hasadditional fields from UVC 1.0 */
0x00, 0x90, 0x00,0x00, /* No. of bytes device can rx in single payload: 32KB */
0x00, 0x60, 0xE3,0x16, /*Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
SET_CUR class request:
Change your frame intervals from set_cur class request based on the selectprobe structure from host side.
status = CyU3PUsbGetEP0Data(CX3_UVC_MAX_PROBE_SETTING_ALIGNED, glCommitCtrl,&readCount);// get set_cur class request data from host
glCurrentFrameIndex = glCommitCtrl[3];//frame index
switch(glCurrentFrameIndex){
// change your probe
case 0x1:
glProbeCtrl1[2] = glCommitCtrl[2]; //change probe structure frame intervalsvalues.
glProbeCtrl1[3] = glCommitCtrl[3];
glProbeCtrl1[4] = glCommitCtrl[4];
glProbeCtrl1[5] = glCommitCtrl[5];
glProbeCtrl1[6] = glCommitCtrl[6];
glProbeCtrl1[7] = glCommitCtrl[7];
break;
Commit Stage:
GET_CUR class request:
Return the relavent current commit data base on your frame index. As followingVGA frame size probe structure data.
uint8_t glProbeCtrl1[CX3_UVC_MAX_PROBE_SETTING]= {
0x00,0x00, /* bmHint : No fixed parameters */
0x01, /* Use 1st Video format index */
0x01, /* Use 1st Video frame index */
0xx,0xx,0xx,0xx /* Desired frameinterval in 100ns */ Need to be changed from your probe set_cur class request
0x00,0x00, /* Key frame rate in key frame/video frame units */
0x00,0x00, /* PFrame rate in PFrame / key frame units */
0x00,0x00, /* Compression quality control */
0x00,0x00, /* Window size for average bit rate */
0x00,0x00, /* Internal video streaming i/flatency in ms */
0x00,0x60,0x09,0x00, /* Max video frame size in bytes */
#ifdef CX3_UVC_1_0_SUPPORT
0x00, 0x40, 0x00,0x00 /* No. of bytes device can rx in single payload: 32KB */
#else
/* UVC 1.1 Probe Control hasadditional fields from UVC 1.0 */
0x00, 0x90, 0x00, 0x00, /* No. of bytes device can rx in single payload: 32KB */
0x00, 0x60, 0xE3,0x16, /* Device Clock */
0x00, /* Framing Information - Ignored for uncompressed format*/
0x00, /* Preferred payload format version */
0x00, /* Minimum payload format version */
0x00 /* Maximum payload format version */
#endif
};
SET_CUR class request:
Change your image sensor configuration as your expect frame rate and streamingthe video data as following code.
CyCx3UvcAppImageSensorSetVideoResolution (glCommitCtrl[3]);//your frame indexand frame interval
if (glIsApplnActive)
{
#ifdef CX3_DEBUG_ENABLED
CyU3PDebugPrint (4, "\n\rUSB Setup CB:Call AppSTOP1");
#endif
CyCx3UvcAppStop();
}
CyCx3UvcAppStart();
|
|