Skip to content

Commit

Permalink
Frame descriptors, use frame size macro
Browse files Browse the repository at this point in the history
  • Loading branch information
xerpi committed Jan 6, 2019
1 parent b012e4c commit 1a1a35e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#define UVC_DRIVER_NAME "VITAUVC00"
#define UVC_USB_PID 0x1337

#define VIDEO_FRAME_SIZE_NV12(w, h) (((w) * (h) * 3) / 2)
#define MAX_UVC_VIDEO_FRAME_SIZE VIDEO_FRAME_SIZE_NV12(960, 544)

#define UVC_PAYLOAD_HEADER_SIZE 16
Expand Down
10 changes: 6 additions & 4 deletions usb_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* Helper macros
*/

#define VIDEO_FRAME_SIZE_NV12(w, h) (((w) * (h) * 3) / 2)

#define FRAME_BITRATE(w, h, bpp, interval) (((w) * (h) * (bpp)) / ((interval) * 100 * 1E-9))
#define FPS_TO_INTERVAL(fps) ((1E9 / 100) / (fps))

Expand Down Expand Up @@ -138,7 +140,7 @@ static struct __attribute__((packed)) {
.wHeight = 544,
.dwMinBitRate = FRAME_BITRATE(960, 544, 12, FPS_TO_INTERVAL(30)),
.dwMaxBitRate = FRAME_BITRATE(960, 544, 12, FPS_TO_INTERVAL(60)),
.dwMaxVideoFrameBufferSize = (960 * 544 * 3) / 2,
.dwMaxVideoFrameBufferSize = VIDEO_FRAME_SIZE_NV12(960, 544),
.dwDefaultFrameInterval = FPS_TO_INTERVAL(60),
.bFrameIntervalType = 2,
.dwFrameInterval = {FPS_TO_INTERVAL(60), FPS_TO_INTERVAL(30)},
Expand All @@ -153,7 +155,7 @@ static struct __attribute__((packed)) {
.wHeight = 504,
.dwMinBitRate = FRAME_BITRATE(896, 504, 12, FPS_TO_INTERVAL(30)),
.dwMaxBitRate = FRAME_BITRATE(896, 504, 12, FPS_TO_INTERVAL(60)),
.dwMaxVideoFrameBufferSize = (896 * 504 * 3) / 2,
.dwMaxVideoFrameBufferSize = VIDEO_FRAME_SIZE_NV12(896, 504),
.dwDefaultFrameInterval = FPS_TO_INTERVAL(60),
.bFrameIntervalType = 2,
.dwFrameInterval = {FPS_TO_INTERVAL(60), FPS_TO_INTERVAL(30)},
Expand All @@ -168,7 +170,7 @@ static struct __attribute__((packed)) {
.wHeight = 488,
.dwMinBitRate = FRAME_BITRATE(864, 488, 12, FPS_TO_INTERVAL(30)),
.dwMaxBitRate = FRAME_BITRATE(864, 488, 12, FPS_TO_INTERVAL(60)),
.dwMaxVideoFrameBufferSize = (864 * 488 * 3) / 2,
.dwMaxVideoFrameBufferSize = VIDEO_FRAME_SIZE_NV12(864, 488),
.dwDefaultFrameInterval = FPS_TO_INTERVAL(60),
.bFrameIntervalType = 2,
.dwFrameInterval = {FPS_TO_INTERVAL(60), FPS_TO_INTERVAL(30)},
Expand All @@ -183,7 +185,7 @@ static struct __attribute__((packed)) {
.wHeight = 272,
.dwMinBitRate = FRAME_BITRATE(480, 272, 12, FPS_TO_INTERVAL(30)),
.dwMaxBitRate = FRAME_BITRATE(480, 272, 12, FPS_TO_INTERVAL(60)),
.dwMaxVideoFrameBufferSize = (480 * 272 * 3) / 2,
.dwMaxVideoFrameBufferSize = VIDEO_FRAME_SIZE_NV12(480, 272),
.dwDefaultFrameInterval = FPS_TO_INTERVAL(60),
.bFrameIntervalType = 2,
.dwFrameInterval = {FPS_TO_INTERVAL(60), FPS_TO_INTERVAL(30)},
Expand Down

0 comments on commit 1a1a35e

Please sign in to comment.