Skip to content

Commit ef080c2

Browse files
committed
samples: drivers: video: tcpserversink: fix buffer allocation for uncompressed formats
1 parent 366a6bd commit ef080c2

File tree

1 file changed

+9
-1
lines changed
  • samples/drivers/video/tcpserversink/src

1 file changed

+9
-1
lines changed

samples/drivers/video/tcpserversink/src/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,17 @@ int main(void)
9595
return 0;
9696
}
9797

98+
/* Alloc Buffers */
99+
size_t buffer_size;
100+
if (video_bits_per_pixel(fmt.pixelformat) > 0) {
101+
buffer_size = fmt.pitch * fmt.height;
102+
} else {
103+
buffer_size = fmt.width * fmt.height / 10;
104+
}
105+
98106
/* Alloc Buffers */
99107
for (i = 0; i < ARRAY_SIZE(buffers); i++) {
100-
buffers[i] = video_buffer_alloc(fmt.pitch * fmt.height, K_FOREVER);
108+
buffers[i] = video_buffer_alloc(buffer_size, K_FOREVER);
101109
if (buffers[i] == NULL) {
102110
LOG_ERR("Unable to alloc video buffer");
103111
return 0;

0 commit comments

Comments
 (0)