From patchwork Fri Dec 23 17:23:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 18054 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 933C4C3200 for ; Fri, 23 Dec 2022 17:23:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1729A623AF; Fri, 23 Dec 2022 18:23:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1671816195; bh=NJdwcD/Nhs6d1VUHMDbiyDP1/ZQ27iEg2jxVjLZO8wk=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=BanDYzFM5ojr2QFMCR3V7S8wJH5OWGkC/YpoKqJ/lwNSOxCQGd33LkfV56V6jn1sV rcGoUITANWuMa8EPFk/IgmdWC4oAVI/2YlHe664/teyB8837/wXLj9sH7FSVLqJmYC XL5KpXzO0C/r7cRsgOLFRpDP1bzzczAY+7KIhMkYPVa7zkGtuw0H/1qmcXM+D5K9LB doUoEi9w58wgE+jFVhtC8EnHhupIiSGm7Rbb2tNc3NO2iviCACes6if0TKPkyN2owt 3NrpkKYuSFGot4LJUGyTfvkgp90md/uVvE66zErY82+wN8j9p5hpJvt5IB6CGlggjL +pDFiAMt1h7Kg== Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA6E462398 for ; Fri, 23 Dec 2022 18:23:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ucw.cz header.i=@ucw.cz header.b="ZbZOGb50"; dkim-atps=neutral Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id EF1ED1C09F5; Fri, 23 Dec 2022 18:23:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1671816192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LqjRmYUIB4BQ9N6tJ+VX0juUoHz/YTQpoG4nzSSwufE=; b=ZbZOGb50Ciinq3/w2CQraqRBaBuCDhe0s85nRFwyMm59GioyQ8OoTP5cy+ptwavnsZbF5T VALe82x01K5lgG5fqTXNUVgiSs7/ecyrsIRy8DymxAl2eaS2F5lVe40YViVPSDWupONlJC jyx4KzpXPhDHGCrLYk7KrfDaZ0Cfr3I= Date: Fri, 23 Dec 2022 18:23:12 +0100 To: Nicolas Dufresne Message-ID: References: <167162721688.3944359.738999548555516756@Monstersaurus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Subject: [libcamera-devel] [PATCHv2] gstreamer: Add bayer8 support to libcamerasrc element X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pavel Machek via libcamera-devel From: Pavel Machek Reply-To: Pavel Machek Cc: Dorota Czaplejewicz , Pavel Machek via libcamera-devel Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Bayer8 support is useful on hardware such as Librem 5, as GStreamer provides easy solution for debayering and display of the camera data. Add neccessary glue to libcamerasrc element. Signed-off-by: Pavel Machek Reviewed-by: Nicolas Dufresne --- Thanks for the review! diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 36b9564c..b2cc7661 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::SGRBG8 }, + { GST_VIDEO_FORMAT_ENCODED, formats::SGBRG8 }, + { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB8 }, + { GST_VIDEO_FORMAT_ENCODED, formats::SBGGR8 }, + /* 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::SGRBG8: + return "grbg"; + case formats::SGBRG8: + return "gbrg"; + case formats::SRGGB8: + return "rggb"; + case formats::SBGGR8: + return "bggr"; + } + return NULL; +} + static GstStructure * bare_structure_from_format(const PixelFormat &format) { @@ -243,6 +265,12 @@ bare_structure_from_format(const PixelFormat &format) switch (format) { case formats::MJPEG: return gst_structure_new_empty("image/jpeg"); + case formats::SGRBG8: + case formats::SGBRG8: + case formats::SRGGB8: + case formats::SBGGR8: + 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..a10cbd4f 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; image/jpeg; video/x-bayer") /* For the simple case, we have a src pad that is always present. */ GstStaticPadTemplate src_template = {