From patchwork Sun Jul 3 07:33:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishikesh Donadkar X-Patchwork-Id: 16527 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 2920ABE173 for ; Sun, 3 Jul 2022 07:34:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E90AA6564A; Sun, 3 Jul 2022 09:34:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656833676; bh=od/F7mDvbjsOqucnf4PTHvCW287++kgVDi9oiaJXcfc=; 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=p6+RzO54htspqhEcsBE7rXuTClTd5fmXes2EliVKdOQTIiC8vsWLUmVoM22pXsxUt fmfQu0b3Fl6OwcffHoGk+I9qaoQz9NnwW8MP8dskczpHqHJHDQ2OujjtrF5VQw7Lkc 4Y025ib++ljeGW1QbIsbCP/ehCC5aHMTupSxCJvp3hu5zVegOo4cTIlXbmQakE27uQ FpQLxyzRHrCP3yluAjcNC/yxykoOmnCmYJo0ET0OCnP+TuWMwl9fqaFFSO8VzjrXgo DNP9COGqEwyilVEpVsrk/tAJ/weicrMd+e5DGK63r8pQtiL8kqq/7Tpge4hXe/WqzC 32kFM7JpdWSng== Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2566E6564A for ; Sun, 3 Jul 2022 09:34:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ig09jwFq"; dkim-atps=neutral Received: by mail-pg1-x532.google.com with SMTP id q140so6196970pgq.6 for ; Sun, 03 Jul 2022 00:34:35 -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=uKye1mYdGvCKbcR65Kghc9l6W+ZDxjv5P//wb8fqUks=; b=ig09jwFqUB5PJzDSShXhn5tqQfrDQyS9Zo+pVk8kE+VFKxh5YYMd9SqyEH0dz8ctl1 kliBvLNVbrxBW7WMNpt58oT0P7gSUPaThSALHXe5Lk1Oh/qSCf1DwwNcOin/Mkln4Ljr Oxw+Y5RBDtiY0eK2OctfxXALGy2QF940BALwiRcWkkVOVgxcbbCpyqI9bdJIJw0JIzvP v4n/96CsRoCJra13NV4idaM45PdXsSlw+wpLorxDo7cJ/2Dk0MUNLMBh1V999gj/oho2 CcfgQv2shFmFzBdhAyS4axYFuI9rMyZfkT1YPV8rqYxLa2uS+Waorh73OTuWyNuKzHod y/cA== 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=uKye1mYdGvCKbcR65Kghc9l6W+ZDxjv5P//wb8fqUks=; b=BogF5sufkbW9iFKkOb7G7pdLQK8uiX9xPKPOW6GSYxQYnep3nlvGTdtcbFrevvwf/N AHnNrzAj35djTAGjDVvUCShC8t2UfDx/oY3rR8D1w0B3ZmSyYmQ7hgckxn6Bvv6aMIeH /w/gCGoAsVq2pRqh66oteksarmHUB+djDGh27oguno25BTcHfNS8bu2x/HRGCdZ5IefB IKHXOYxYRQcc4FxhynViPepEOvESwSaSlxjmErToDfegg7Q1haGJW0VtP4KsKqYZP9Wv bKZmyac4ycKsRh1MOSeJzx1/5BrcficaTAmkZ5VEs8z5lpaG/NY27L//6KQzjNm6JIKo FDYw== X-Gm-Message-State: AJIora/LssWIoCSmrC1aEW4XVuNLT6dEc1DKNM8NlJ2T4qanRio87tTY QvkIze3g1g061vCzmTYyeEG6aAeLrHeY+g82 X-Google-Smtp-Source: AGRyM1sIwMe+mpuT6nIuCybHgovxEoissNSPhL0UaFJpV9e3st1CRxODg/rpb1hwEMA5UtKwxj60Zw== X-Received: by 2002:a05:6a00:b94:b0:525:930f:57ff with SMTP id g20-20020a056a000b9400b00525930f57ffmr30161252pfj.72.1656833673521; Sun, 03 Jul 2022 00:34:33 -0700 (PDT) Received: from localhost.localdomain ([2402:8100:30af:f358:3ebf:ad3f:f834:3344]) by smtp.googlemail.com with ESMTPSA id l11-20020a170903120b00b0016b953872a7sm10300285plh.201.2022.07.03.00.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 00:34:33 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Sun, 3 Jul 2022 13:03:57 +0530 Message-Id: <20220703073358.76643-4-rishikeshdonadkar@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> References: <20220703073358.76643-1-rishikeshdonadkar@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/5] 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 +++++++++++++++ src/gstreamer/gstlibcamera-utils.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-utils.cpp index 690a9f43..221100e9 100644 --- a/src/gstreamer/gstlibcamera-utils.cpp +++ b/src/gstreamer/gstlibcamera-utils.cpp @@ -73,6 +73,12 @@ static const std::map ToGstVideoColorRang { ColorSpace::Range::Limited, GST_VIDEO_COLOR_RANGE_16_235 }, }; +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) { @@ -158,6 +164,15 @@ colorimerty_from_colorspace(std::optional colorSpace) return colorimetry_str; } +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) { diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h index d54f1588..6aff6be0 100644 --- a/src/gstreamer/gstlibcamera-utils.h +++ b/src/gstreamer/gstlibcamera-utils.h @@ -20,6 +20,7 @@ void gst_libcamera_configure_stream_from_caps(libcamera::StreamConfiguration &st GstCaps *caps); void gst_libcamera_resume_task(GstTask *task); std::shared_ptr gst_libcamera_get_camera_manager(int &ret); +void colorspace_form_colorimetry(std::optional &colorspace, const gchar *colorimetry); /** * \class GLibLocker