From patchwork Mon Jul 11 15:37:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16589 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 292E3BE173 for ; Mon, 11 Jul 2022 15:38:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E1CC963317; Mon, 11 Jul 2022 17:38:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657553898; bh=S+pMnG9qArCipiVzmsCS00FAuvLtVCHo8cfZuFnUdyM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=brGjidRmZB0qpZWaflSPrK9opGYaRe3vJ93dtxDQUsnzb+xQD0700gfh8n8BgnhVj 7Up9T9cWSYmJEm3NA+QLQpHnzVaYnBwxf6wCHRbiFOnAVMFj7S0R/YTZgFEACov7Qc D4YefBkBMaljYQ5QCdV29/fq/WsA+fgRXOWcgMw3RWG54oIxthFGEJPJ9M2uNWOp1t UK0bi3PiGvJI9GI48u7J41QgZbhjony8JT/OVBkrV3axZ7qDXGVOwpqbTQHkFIMQ6w PHP6/vZS/ukjwfVgh0GaFv90WTjkQNHLZWDGPZ8/9MIz9YFQzRYTrxGKHZPGkMK/5p 2sHujNZu/LnHw== Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDACE62752 for ; Mon, 11 Jul 2022 17:38:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="L1hxUZhf"; dkim-atps=neutral Received: by mail-pf1-x42d.google.com with SMTP id l124so5078270pfl.8 for ; Mon, 11 Jul 2022 08:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T7FcClSDovKV4o5TX4pXqGgDSXUR6G3jMCCkLVzbUmA=; b=L1hxUZhfPy+xVk3duC1bwnV/8nCYaf4b5clx/0LQiYi2aJwkCRYFb7LySsVOJcmfIX 64kCMfECmNvk/uB6L+n/TSHOZYdfuwFd2Vl05r8QQRD1HvXdCOGAeklKsz2LWvNs0Otk Gxp8/OyUHDJUGSc12nlo6PFerdZOBNNyusZ5pM1yqDGna8fpsMXxdtMU3UsrR3OZCKKW NyO69loBFkMoLXNGs2B78fZXWBVWT77+gCcQ1lfr9VZFpX0AtngzU1MMkryCmsGj1UdC LX5+A4xWnCeFHE3szA5qLgPj/JpGx4gL685248MagijeN6iXi2aXjimpExLuEuTK98Ga bKlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T7FcClSDovKV4o5TX4pXqGgDSXUR6G3jMCCkLVzbUmA=; b=xVSVJ3tGn8YIajvyTcr3uU/NA2JB4lomy68PMup4Y6ihrRquTRnQhu1+IixRVbfcg5 MA8lV9L7k2G9VtDT/rfS3RwWxqP+Mhd68pErEcBTPUsBRr/bk5WrPGFr3pB2BnVyUZP9 aixCp/54sAlZ1Hzf5z5Q3ZT9nDGB/Hk1X/VSbj4nBhbPgPE7PAS7HSewqfr8e7ghD6Pl vasXqBH4ZEEPLlBnIESlJGQtfZI7ehXf2aBX+l8pdDDgfdi5QgdSvlGNpnFYAz54Sb7h b4QPeCbV2fn61ITdhCbUX3OZRE9IVu0mREGQPFfwGFS1PRoN1rGdumeZCUiyDk+v4a42 +p+Q== X-Gm-Message-State: AJIora+sInSpC8MSHzUCSMu7U1MXy/qDEqwwPYcIAcjcaeMJxw9qV0Yk 6TwI6YztQw7CL+XKmRHdE2QgalgYL6Q= X-Google-Smtp-Source: AGRyM1uAJq2JW8o5SFvVhNFjj0Fl3viJchCyhsLuGjZOpq5y8whYXZb4vaSC9kHrYp2Qd5lvvD3oWA== X-Received: by 2002:a63:385d:0:b0:415:df85:4b73 with SMTP id h29-20020a63385d000000b00415df854b73mr10049165pgn.179.1657553896258; Mon, 11 Jul 2022 08:38:16 -0700 (PDT) Received: from localhost.localdomain ([103.124.170.70]) by smtp.googlemail.com with ESMTPSA id u18-20020a17090a891200b001ef87123615sm4891268pjn.37.2022.07.11.08.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:38:16 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 11 Jul 2022 21:07:08 +0530 Message-Id: <20220711153711.36679-3-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711153711.36679-1-rishikeshdonadkar@gmail.com> References: <20220711153711.36679-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/5] gstreamer: Update the obtained colorimetry in caps. 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: Rishikesh Donadkar via libcamera-devel From: Rishikesh Donadkar Reply-To: Rishikesh Donadkar Cc: Rishikesh Donadkar , nicolas.dufresne@collabora.com, vedantparanjape160201@gmail.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the colorspace is set in the StreamConfiguration, convert the libcamera colorspace to GStreamer colorimetry using the function colorimetry_from_colorspace() which will take in the ColorSpace value and return the gst string representation of the colorimetry. If the colorimetry corresponding to the colorspace set in the StreamConfiguration is not available in GStreamer remove the field colorimetry from the caps structure if present. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 43837602..a2d9b64d 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -164,11 +164,24 @@ gst_libcamera_stream_configuration_to_caps(const StreamConfiguration &stream_cfg { GstCaps *caps = gst_caps_new_empty(); GstStructure *s = bare_structure_from_format(stream_cfg.pixelFormat); + gchar *colorimetry = nullptr; + std::optional colorspace = stream_cfg.colorSpace; gst_structure_set(s, "width", G_TYPE_INT, stream_cfg.size.width, "height", G_TYPE_INT, stream_cfg.size.height, nullptr); + + if (colorspace) { + ColorSpace colorspaceValue = colorspace.value(); + colorimetry = colorimetry_from_colorspace(colorspaceValue); + if (colorimetry) + gst_structure_set(s, "colorimetry", G_TYPE_STRING, colorimetry, nullptr); + else + gst_structure_remove_fields(s, "colorimetry", nullptr); + + } + gst_caps_append_structure(caps, s); return caps;