summaryrefslogtreecommitdiff
path: root/src/gstreamer/gstlibcamera-utils.cpp
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2022-12-23 18:23:12 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-12-24 17:47:19 +0200
commite83d94915df9cc279161adc9c1b32a09580111e1 (patch)
tree160da659a84f66d34ffd6ca0c25a3f9e8f432daf /src/gstreamer/gstlibcamera-utils.cpp
parent21a82ed8a5153e11a0f6eab724c8819599b4e758 (diff)
gstreamer: Add bayer8 support to libcamerasrc element
Bayer8 support is useful on hardware such as Librem 5, as GStreamer provides easy solution for debayering and display of the camera data. Add necessary glue to libcamerasrc element. Signed-off-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/gstreamer/gstlibcamera-utils.cpp')
-rw-r--r--src/gstreamer/gstlibcamera-utils.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 36b9564c..16aac441 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -20,6 +20,12 @@ static struct {
/* Compressed */
{ GST_VIDEO_FORMAT_ENCODED, formats::MJPEG },
+ /* Bayer formats, gstreamer only supports 8-bit */
+ { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR8 },
+ { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG8 },
+ { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 },
+ { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB8 },
+
/* RGB16 */
{ GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
@@ -228,6 +234,22 @@ gst_format_to_pixel_format(GstVideoFormat gst_format)
return PixelFormat{};
}
+static const gchar *
+bayer_format_to_string(int format)
+{
+ switch (format) {
+ case formats::SBGGR8:
+ return "bggr";
+ case formats::SGBRG8:
+ return "gbrg";
+ case formats::SGRBG8:
+ return "grbg";
+ case formats::SRGGB8:
+ return "rggb";
+ }
+ return NULL;
+}
+
static GstStructure *
bare_structure_from_format(const PixelFormat &format)
{
@@ -243,6 +265,14 @@ bare_structure_from_format(const PixelFormat &format)
switch (format) {
case formats::MJPEG:
return gst_structure_new_empty("image/jpeg");
+
+ case formats::SBGGR8:
+ case formats::SGBRG8:
+ case formats::SGRBG8:
+ case formats::SRGGB8:
+ return gst_structure_new("video/x-bayer", "format", G_TYPE_STRING,
+ bayer_format_to_string(format), nullptr);
+
default:
return nullptr;
}