summaryrefslogtreecommitdiff
path: root/examples/device/video_capture_2ch/src/main.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-05 16:12:31 +0700
committerhathach <[email protected]>2024-04-05 16:12:31 +0700
commit5b2441d8a3cae01de522d28cbac378464d3df678 (patch)
treebb77781b440d88c8cda7000f6b4159604448d6e8 /examples/device/video_capture_2ch/src/main.c
parentdf1f84adad8090066ccb7393791c70f752c9af4e (diff)
support CFG_EXAMPLE_VIDEO_READONLY for stream0 for small mcu
Diffstat (limited to 'examples/device/video_capture_2ch/src/main.c')
-rw-r--r--examples/device/video_capture_2ch/src/main.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/device/video_capture_2ch/src/main.c b/examples/device/video_capture_2ch/src/main.c
index a373c2472..82bc7d6ca 100644
--- a/examples/device/video_capture_2ch/src/main.c
+++ b/examples/device/video_capture_2ch/src/main.c
@@ -112,6 +112,8 @@ void tud_resume_cb(void) {
//--------------------------------------------------------------------+
// USB Video
//--------------------------------------------------------------------+
+#define FRAMEBUF_SIZE (FRAME_WIDTH * FRAME_HEIGHT * 16 / 8)
+
static unsigned frame_num[CFG_TUD_VIDEO_STREAMING] = {1};
static unsigned tx_busy = 0;
static unsigned interval_ms[CFG_TUD_VIDEO_STREAMING] = {1000 / FRAME_RATE};
@@ -134,8 +136,8 @@ static struct {
{sizeof(color_bar_7_jpg), color_bar_7_jpg},
};
+#if !defined(CFG_EXAMPLE_VIDEO_READONLY)
// YUY2 frame buffer
-#define FRAMEBUF_SIZE (FRAME_WIDTH * FRAME_HEIGHT * 16 / 8)
static uint8_t framebuf_yuy2[FRAMEBUF_SIZE];
static void fill_color_bar(uint8_t* buffer, unsigned start_position) {
@@ -174,14 +176,20 @@ static void fill_color_bar(uint8_t* buffer, unsigned start_position) {
p += FRAME_WIDTH * 2;
}
}
+#endif
size_t get_framebuf(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, size_t fnum, void **fb) {
uint32_t idx = ctl_idx + stm_idx;
if (idx == 0) {
// stream 0 use uncompressed YUY2 frame
+ #if defined(CFG_EXAMPLE_VIDEO_READONLY)
+ *fb = (void*)(uintptr_t ) framebuf_yuy2_readonly[(fnum % (FRAME_WIDTH / 2)) * 4];
+ #else
fill_color_bar(framebuf_yuy2, frame_num[idx]);
*fb = framebuf_yuy2;
+ #endif
+
return FRAMEBUF_SIZE;
}else {
// stream 1 use MJPEG frame