Skip to content

Commit 5b2441d

Browse files
committed
support CFG_EXAMPLE_VIDEO_READONLY for stream0 for small mcu
1 parent df1f84a commit 5b2441d

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

examples/device/video_capture_2ch/src/images.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#if defined(CFG_EXAMPLE_VIDEO_DISABLE_MJPEG)
2-
// uncopmressed frame
3-
static const unsigned char frame_buffer[128 * (96 + 1) * 2] = {
1+
#if defined(CFG_EXAMPLE_VIDEO_READONLY)
2+
//--------------------------------------------------------------------+
3+
// YUY2 Uncompressed Frame (fixed)
4+
//--------------------------------------------------------------------+
5+
static const unsigned char framebuf_yuy2_readonly[128 * (96 + 1) * 2] = {
46
/* 0 */
57
0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80,
68
0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80, 0xeb, 0x80,
@@ -1654,9 +1656,10 @@ static const unsigned char frame_buffer[128 * (96 + 1) * 2] = {
16541656

16551657
#endif
16561658

1657-
#if 1
1659+
//--------------------------------------------------------------------+
1660+
// MPEG Compressed Frame (fixed)
1661+
//--------------------------------------------------------------------+
16581662

1659-
// mpeg compressed data (not CFG_EXAMPLE_VIDEO_DISABLE_MJPEG)
16601663
unsigned char color_bar_0_jpg[] = {
16611664
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
16621665
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -1929,7 +1932,3 @@ unsigned char color_bar_7_jpg[] = {
19291932
0x42, 0x51, 0x59, 0x8c, 0xb1, 0x45, 0x00, 0x25, 0x15, 0x98, 0xc4, 0xa2, 0xb5, 0x32, 0x12, 0x8a,
19301933
0xcc, 0x63, 0x68, 0xad, 0x8d, 0x84, 0xa2, 0xb3, 0x18, 0x94, 0x56, 0xa6, 0x47, 0xff, 0xd9
19311934
};
1932-
1933-
1934-
1935-
#endif

examples/device/video_capture_2ch/src/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void tud_resume_cb(void) {
112112
//--------------------------------------------------------------------+
113113
// USB Video
114114
//--------------------------------------------------------------------+
115+
#define FRAMEBUF_SIZE (FRAME_WIDTH * FRAME_HEIGHT * 16 / 8)
116+
115117
static unsigned frame_num[CFG_TUD_VIDEO_STREAMING] = {1};
116118
static unsigned tx_busy = 0;
117119
static unsigned interval_ms[CFG_TUD_VIDEO_STREAMING] = {1000 / FRAME_RATE};
@@ -134,8 +136,8 @@ static struct {
134136
{sizeof(color_bar_7_jpg), color_bar_7_jpg},
135137
};
136138

139+
#if !defined(CFG_EXAMPLE_VIDEO_READONLY)
137140
// YUY2 frame buffer
138-
#define FRAMEBUF_SIZE (FRAME_WIDTH * FRAME_HEIGHT * 16 / 8)
139141
static uint8_t framebuf_yuy2[FRAMEBUF_SIZE];
140142

141143
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) {
174176
p += FRAME_WIDTH * 2;
175177
}
176178
}
179+
#endif
177180

178181
size_t get_framebuf(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, size_t fnum, void **fb) {
179182
uint32_t idx = ctl_idx + stm_idx;
180183

181184
if (idx == 0) {
182185
// stream 0 use uncompressed YUY2 frame
186+
#if defined(CFG_EXAMPLE_VIDEO_READONLY)
187+
*fb = (void*)(uintptr_t ) framebuf_yuy2_readonly[(fnum % (FRAME_WIDTH / 2)) * 4];
188+
#else
183189
fill_color_bar(framebuf_yuy2, frame_num[idx]);
184190
*fb = framebuf_yuy2;
191+
#endif
192+
185193
return FRAMEBUF_SIZE;
186194
}else {
187195
// stream 1 use MJPEG frame

0 commit comments

Comments
 (0)