[libcamera-devel] libcamerasrc on librem 5: bayer support missing
Pavel Machek
pavel at ucw.cz
Tue Dec 20 23:13:26 CET 2022
Hi!
> > This gets me going. I don't know how to pass details of bayer format,
> > so help would be welcome there.
>
>
> video/x-bayer
> format: { (string)bggr, (string)grbg, (string)gbrg, (string)rggb }
>
>
> So in you case, create caps that looks like video/x-bayer, format=grbg, width=X,
> height=Y. Stride must match the Width * 4, cause there is no custom stride
> support yet.
Thanks for the hints. Should I add support for other bayer8 formats
and submit it for merge?
Best regards,
Pavel
diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp
index 36b9564c..7f45f4e7 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -55,6 +55,10 @@ static struct {
{ GST_VIDEO_FORMAT_YUY2, formats::YUYV },
{ GST_VIDEO_FORMAT_YVYU, formats::YVYU },
+ /* Lie about bayer */
+ { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 },
+
+
/* \todo NV42 is used in libcamera but is not mapped in GStreamer yet. */
};
@@ -228,11 +232,23 @@ gst_format_to_pixel_format(GstVideoFormat gst_format)
return PixelFormat{};
}
+static const gchar *
+bayer_format_to_string(int format)
+{
+ switch (format) {
+ case formats::SGRBG8:
+ return "grbg";
+ }
+ return NULL;
+}
+
static GstStructure *
bare_structure_from_format(const PixelFormat &format)
{
GstVideoFormat gst_format = pixel_format_to_gst_format(format);
+ printf("bare_structure_from_format: XXX\n");
+
if (gst_format == GST_VIDEO_FORMAT_UNKNOWN)
return nullptr;
@@ -243,6 +259,9 @@ bare_structure_from_format(const PixelFormat &format)
switch (format) {
case formats::MJPEG:
return gst_structure_new_empty("image/jpeg");
+ case formats::SGRBG8:
+ return gst_structure_new("video/x-bayer", "format", G_TYPE_STRING,
+ bayer_format_to_string(format), nullptr);
default:
return nullptr;
}
diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 8d97d7c2..2ceeeb99 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -161,7 +161,7 @@ G_DEFINE_TYPE_WITH_CODE(GstLibcameraSrc, gst_libcamera_src, GST_TYPE_ELEMENT,
GST_DEBUG_CATEGORY_INIT(source_debug, "libcamerasrc", 0,
"libcamera Source"))
-#define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; image/jpeg")
+#define TEMPLATE_CAPS GST_STATIC_CAPS("video/x-raw; video/x-bayer; image/jpeg")
/* For the simple case, we have a src pad that is always present. */
GstStaticPadTemplate src_template = {
--
People of Russia, stop Putin before his war on Ukraine escalates.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20221220/41e224ce/attachment.sig>
More information about the libcamera-devel
mailing list