summaryrefslogtreecommitdiff
path: root/video-buffers.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-06-09 12:11:25 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-06-09 12:20:02 +0300
commitdf651c5b397a4b6648695cdf725a8243ff512dcd (patch)
treea8f88286cedafe8c8d35cbaa38698063a2e64961 /video-buffers.c
parent6dc91f22f9bb2aafeee2f7c5df53a02a37acc3a0 (diff)
v4l2: Extract video buffer structure to separate file
The v4l2_video_buffer structure describes a video buffer. It is used by the v4l2_device class only, but isn't otherwise tied to V4L2. To prepare for non-V4L2 video sources, extract it to a separate file and rename it to video_buffer. At the same time, add a new video_buffer_set structure to represent as set of video buffers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'video-buffers.c')
-rw-r--r--video-buffers.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/video-buffers.c b/video-buffers.c
new file mode 100644
index 0000000..f5dc6ec
--- /dev/null
+++ b/video-buffers.c
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Video buffers
+ *
+ * Copyright (C) 2018 Laurent Pinchart
+ *
+ * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ */
+
+#include "video-buffers.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+struct video_buffer_set *video_buffer_set_new(unsigned int nbufs)
+{
+ struct video_buffer_set *buffers;
+
+ buffers = malloc(sizeof *buffers);
+ if (!buffers)
+ return NULL;
+
+ buffers->nbufs = nbufs;
+ buffers->buffers = calloc(nbufs, sizeof *buffers->buffers);
+ if (!buffers->buffers) {
+ free(buffers);
+ return NULL;
+ }
+
+ return buffers;
+}
+
+void video_buffer_set_delete(struct video_buffer_set *buffers)
+{
+ if (!buffers)
+ return;
+
+ free(buffers->buffers);
+ free(buffers);
+}