|
28 | 28 |
|
29 | 29 | static const char *TAG = "AV_STREAM_HAL"; |
30 | 30 |
|
31 | | -const av_resolution_info_t av_resolution[AV_FRAMESIZE_INVALID] = { |
32 | | - { 96, 96 }, /* 96x96 */ |
33 | | - { 160, 120 }, /* QQVGA */ |
34 | | - { 176, 144 }, /* QCIF */ |
35 | | - { 240, 176 }, /* HQVGA */ |
36 | | - { 240, 240 }, /* 240x240 */ |
37 | | - { 320, 240 }, /* QVGA */ |
38 | | - { 400, 296 }, /* CIF */ |
39 | | - { 480, 320 }, /* HVGA */ |
40 | | - { 640, 480 }, /* VGA */ |
41 | | - { 800, 600 }, /* SVGA */ |
42 | | - { 1024, 768 }, /* XGA */ |
43 | | - { 1280, 720 }, /* HD */ |
44 | | - { 1280, 1024 }, /* SXGA */ |
45 | | - { 1600, 1200 }, /* UXGA */ |
46 | | - // 3MP Sensors |
47 | | - { 1920, 1080 }, /* FHD */ |
48 | | - { 720, 1280 }, /* Portrait HD */ |
49 | | - { 864, 1536 }, /* Portrait 3MP */ |
50 | | - { 2048, 1536 }, /* QXGA */ |
51 | | - // 5MP Sensors |
52 | | - { 2560, 1440 }, /* QHD */ |
53 | | - { 2560, 1600 }, /* WQXGA */ |
54 | | - { 1088, 1920 }, /* Portrait FHD */ |
55 | | - { 2560, 1920 }, /* QSXGA */ |
56 | | -}; |
| 31 | +void av_stream_get_video_framesize(framesize_t framesize, uint16_t *width, uint16_t *height) |
| 32 | +{ |
| 33 | + switch (framesize) { |
| 34 | + case FRAMESIZE_96X96: |
| 35 | + *width = 96; |
| 36 | + *height = 96; |
| 37 | + break; |
| 38 | + case FRAMESIZE_QQVGA: |
| 39 | + *width = 160; |
| 40 | + *height = 120; |
| 41 | + break; |
| 42 | + case FRAMESIZE_128X128: |
| 43 | + *width = 128; |
| 44 | + *height = 128; |
| 45 | + break; |
| 46 | + case FRAMESIZE_QCIF: |
| 47 | + *width = 176; |
| 48 | + *height = 144; |
| 49 | + break; |
| 50 | + case FRAMESIZE_HQVGA: |
| 51 | + *width = 240; |
| 52 | + *height = 176; |
| 53 | + break; |
| 54 | + case FRAMESIZE_240X240: |
| 55 | + *width = 240; |
| 56 | + *height = 240; |
| 57 | + break; |
| 58 | + case FRAMESIZE_QVGA: |
| 59 | + default: |
| 60 | + *width = 320; |
| 61 | + *height = 240; |
| 62 | + break; |
| 63 | + case FRAMESIZE_320X320: |
| 64 | + *width = 320; |
| 65 | + *height = 320; |
| 66 | + break; |
| 67 | + case FRAMESIZE_CIF: |
| 68 | + *width = 400; |
| 69 | + *height = 296; |
| 70 | + break; |
| 71 | + case FRAMESIZE_HVGA: |
| 72 | + *width = 480; |
| 73 | + *height = 320; |
| 74 | + break; |
| 75 | + case FRAMESIZE_VGA: |
| 76 | + *width = 640; |
| 77 | + *height = 480; |
| 78 | + break; |
| 79 | + case FRAMESIZE_SVGA: |
| 80 | + *width = 800; |
| 81 | + *height = 600; |
| 82 | + break; |
| 83 | + case FRAMESIZE_XGA: |
| 84 | + *width = 1024; |
| 85 | + *height = 768; |
| 86 | + break; |
| 87 | + case FRAMESIZE_HD: |
| 88 | + *width = 1280; |
| 89 | + *height = 720; |
| 90 | + break; |
| 91 | + case FRAMESIZE_SXGA: |
| 92 | + *width = 1280; |
| 93 | + *height = 1024; |
| 94 | + break; |
| 95 | + case FRAMESIZE_UXGA: |
| 96 | + *width = 1600; |
| 97 | + *height = 1200; |
| 98 | + break; |
| 99 | + case FRAMESIZE_FHD: |
| 100 | + *width = 1920; |
| 101 | + *height = 1080; |
| 102 | + break; |
| 103 | + case FRAMESIZE_P_HD: |
| 104 | + *width = 720; |
| 105 | + *height = 1280; |
| 106 | + break; |
| 107 | + case FRAMESIZE_P_3MP: |
| 108 | + *width = 864; |
| 109 | + *height = 1536; |
| 110 | + break; |
| 111 | + case FRAMESIZE_QXGA: |
| 112 | + *width = 2048; |
| 113 | + *height = 1536; |
| 114 | + break; |
| 115 | + case FRAMESIZE_QHD: |
| 116 | + *width = 2560; |
| 117 | + *height = 1440; |
| 118 | + break; |
| 119 | + case FRAMESIZE_WQXGA: |
| 120 | + *width = 2560; |
| 121 | + *height = 1600; |
| 122 | + break; |
| 123 | + case FRAMESIZE_P_FHD: |
| 124 | + *width = 1080; |
| 125 | + *height = 1920; |
| 126 | + break; |
| 127 | + case FRAMESIZE_QSXGA: |
| 128 | + *width = 2560; |
| 129 | + *height = 1920; |
| 130 | + break; |
| 131 | + case FRAMESIZE_5MP: |
| 132 | + *width = 2592; |
| 133 | + *height = 1944; |
| 134 | + break; |
| 135 | + } |
| 136 | +} |
57 | 137 |
|
58 | 138 | #if CONFIG_IDF_TARGET_ESP32 |
59 | 139 | int av_stream_camera_init(av_stream_hal_config_t *config, void *cb, void *arg) |
@@ -92,9 +172,12 @@ static esp_err_t usb_camera_init(av_stream_hal_config_t *config, void *camera_cb |
92 | 172 |
|
93 | 173 | /* the quick demo skip the standred get descriptors process, |
94 | 174 | users need to get params from camera descriptors from demo print */ |
| 175 | + uint16_t width = 0, height = 0; |
| 176 | + av_stream_get_video_framesize(config->video_framesize, &width, &height); |
| 177 | + ESP_LOGI(TAG, "camera frame size: %dx%d", width, height); |
95 | 178 | uvc_config_t uvc_config = { |
96 | | - .frame_width = av_resolution[config->video_framesize].width, |
97 | | - .frame_height = av_resolution[config->video_framesize].height, |
| 179 | + .frame_width = width, |
| 180 | + .frame_height = height, |
98 | 181 | .frame_interval = USB_CAMERA_FRAME_INTERVAL(VIDEO_FPS), |
99 | 182 | .xfer_buffer_size = VIDEO_MAX_SIZE, |
100 | 183 | .xfer_buffer_a = xfer_buffer_a, |
|
0 commit comments