From patchwork Thu Jul 7 09:44:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16569 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 0FEA5BE173 for ; Thu, 7 Jul 2022 09:45:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C207E6330E; Thu, 7 Jul 2022 11:45:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657187116; bh=sJThdyBfxUyE40DY+r1wMy6yCo4WAYqM4FfbhFrsvLg=; 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=iV/TIVJFZaKMWDYNZm2Ot4OLA/r1DN/tP/vzH4OEa1BDkBW+NAc9yoOvu4cH9VHhT EN1kRLjIXRhc7ki0Em4IXrjeaY6sA5gck7S1nMUmKN17Q2X6CKt2xxjwl5EhjsMFqI mthwjQR4f7+UfaTv4ZD9vy47Gco1H8hXsrni2Qk7C2g6tnEsc5krRAeoSUV6WENqRZ mG6YNMHG2prSMhMDSdX2Kan4+U7c4/SnzNUM0yJBRa2+iFBen/hNf/hETJiFTfYmNT bVBQNViGBIgIm0ozsaRuoHMnJXZFdKAz8G6LtRFeFInaJo1PwpVhdlbIzfWG1H5e/i mrwBoRDlna+7Q== Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E126C60401 for ; Thu, 7 Jul 2022 11:45:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eBO7ffzr"; dkim-atps=neutral Received: by mail-pg1-x52d.google.com with SMTP id o18so16312796pgu.9 for ; Thu, 07 Jul 2022 02:45:14 -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=RW2JF1n1924LYd0TU9ejiNK/gAPHiBkN8cF+tJSgJjE=; b=eBO7ffzrRdMDyBft4SqZL2HWHi1LR3GVjgmBMM6vCXg4S9FHeneKbSM7yvAuChHDxc rsCRLPjNhXUJQBrorPSC8nfjT402lertejUjOrB4zWhb6kQL0GllXil4my/aILS8uA0G ZDtx7/OiHT+OltjxNyrHS3+ips83YxZlEtRc/yUJf77MyGCbFQyVtaPCo6v//+HZPsVN R25ifi6uns+GOs52ZYH7hr5HnOpySNGeq1WVmWfbwqt0HjGhDbxaoVhKODK14RyHO4LU HwHXVdIX61DF6PkNGI9ZyrJeZsVd04vEuwaaD9kMhf+VA0kaLz7hIbegQ/nqkAUgPdQC aYzg== 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=RW2JF1n1924LYd0TU9ejiNK/gAPHiBkN8cF+tJSgJjE=; b=wnFvsMYCZTPdFMD8BSwfuiay5gd6u9aHS4YItPZG4DZmGYyOuUhrZFNivDLx25qyA+ LUCqi8nKdrxp9DwFgL9aam2RwtBu6XzMh2KuYQAs+utsGt6JquXNbrUj9dqLZeVl2jox Q41mQw1LtBgYhzpYXtHAs79hCy7jTwyX5/UkDiY6CG7ZAFUMBt0iuezgzaFkz9L7VWuA m0nGXq/UxpvT51Rds1r4nLi8Qe2PZiUf7BwaYWnCFwvTpSFl4zSLx9yRrOeuobp2EVtS LFFTzpcHnkGJlLEPC8qmQZnV8BAfUa+VNItSfA/J8k4/sHuCvJJW9GvhZA7jqYWTChty Ijeg== X-Gm-Message-State: AJIora/siUAdnIRCH51+tJD+U8vaNrb81pswf4d76JrLvZkPFp9DMXYq oTdu2yd3gC5l4RQMnjPFGMLp8YlL32Y= X-Google-Smtp-Source: AGRyM1sl+CYf88sCazUQugDb4K4qJQjBqRPPOPux1eAJZfpzRXZ8F7wvQicezikrs25WxOvk1CERAA== X-Received: by 2002:a17:90a:710a:b0:1ef:991c:dc67 with SMTP id h10-20020a17090a710a00b001ef991cdc67mr4284919pjk.110.1657187114330; Thu, 07 Jul 2022 02:45:14 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30ae:d446:13ee:d079:112a:ac10]) by smtp.googlemail.com with ESMTPSA id p2-20020a1709027ec200b00168f08d0d12sm24530712plb.89.2022.07.07.02.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:45:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 7 Jul 2022 15:14:01 +0530 Message-Id: <20220707094402.28730-4-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> References: <20220707094402.28730-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] gstreamer:Convert between requested colorimetry and libcamera ColorSpace 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" Add map colorimetryToColorSpace and the function colorspace_form_colorimetry() to convert from gstreamer colorimetry to libcamera colorspace. The obtained colorspace form the conversion will be applied to the colorSpace field of the StreamConfiguration. Signed-off-by: Rishikesh Donadkar --- src/gstreamer/gstlibcamera-utils.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index eb9c49da..feefead9 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -51,6 +51,12 @@ static const std::vector> ColorSpaceTocolorim { ColorSpace::Rec2020, GST_VIDEO_COLORIMETRY_BT2020 }, }; +static const std::map colorimetryToColorSpace = { + { GST_VIDEO_COLORIMETRY_SRGB, ColorSpace::Srgb }, + { GST_VIDEO_COLORIMETRY_BT709, ColorSpace::Rec709 }, + { GST_VIDEO_COLORIMETRY_BT2020, ColorSpace::Rec2020 }, +}; + static GstVideoFormat pixel_format_to_gst_format(const PixelFormat &format) { @@ -119,6 +125,15 @@ colorimerty_from_colorspace(std::optional colorSpace) } } +void colorspace_form_colorimetry(std::optional &colorspace, const gchar *colorimetry) +{ + auto iterColorSpace = colorimetryToColorSpace.find(colorimetry); + if (iterColorSpace != colorimetryToColorSpace.end()) { + colorspace = iterColorSpace->second; + return; + } +} + GstCaps * gst_libcamera_stream_formats_to_caps(const StreamFormats &formats) {