From patchwork Tue Aug 2 18:57:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16918 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 17AEBC3275 for ; Tue, 2 Aug 2022 18:57:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AEA2E63317; Tue, 2 Aug 2022 20:57:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659466652; bh=mFbQuwMkfn3ZjgGgGsMXPZqDOEOCiI4vwkTD+aI3SYs=; 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=teO4VnZTJABLtHgL8BkrcTGn8vtEF0tHkTMAuN8RL7Xv+KtpREJBx0GolLCLhmcqT 2dV7otYGOedx/k/rvuNrOBfitPdBfNaNC82fD776PmVQJ6QitnFfX4ATD8ASXnO3nx VsH6MMoPwGBTeHCiyXfwQgMGH+CE7Bv07tvlz66pv7QHk0y0vGfkEqrOa8QUI6BqZT 4L4UInVCU5QlxgORZB3KjqqxSrXrv2FhQVY2gEXsRlY482Tmg/dDTfatywvH/S2Y8D SoHE6bVvSZfkQIHkh/2akclHBq42HkjAS7w1NYh7LTYUhO0rj3MKcE4FtdGRZ/L0S8 Gn2j/w+s4Q8nw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 44FD1603E7 for ; Tue, 2 Aug 2022 20:57:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ds1bVcF/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:85c2:5ee8:5bb8:aca7:5517]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C886025B; Tue, 2 Aug 2022 20:57:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659466650; bh=mFbQuwMkfn3ZjgGgGsMXPZqDOEOCiI4vwkTD+aI3SYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ds1bVcF/uzH1/1wGyk6adEYhLhcSS7oqK48JyM2pP5dFS4WmUkQH/wsf20/tiDdfv h7HQs4Ef15TRFrInto8XPXCohwvJ9pMyzwWBY2hDoX3lcc0gpZNIEOM5zUcQyntMy3 q7W8RSVs1dSkAoHFDp+Izq0R8/sSA5Gquc6m8XYk= To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 00:27:16 +0530 Message-Id: <20220802185719.380855-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220802185719.380855-1-umang.jain@ideasonboard.com> References: <20220802185719.380855-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/4] libcamera: colorspace: Rectify ColorSpace::Srgb preset 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Cc: rishikeshdonadkar@gmail.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Rectify the ColorSpace::Srgb to denote that it does not use any Y'Cbcr encoding and uses full range. The kernel on the other hand, recommends to use Rec601 as the encoding for V4L2_COLORSPACE_SRGB. It is not very explicit but it can be inferred that the kernel assumes V4L2_COLORSPACE_SRGB is a YUV-encoded one. However, when the data is in RGB, no encoding is required (and this is denoted by YcbcrEncoding::None in libcamera). Hence, to be clear on the libcamera colorspace API, rectify the ColorSpace::Srgb preset to use YcbcrEncoding::None. Signed-off-by: Umang Jain --- src/libcamera/color_space.cpp | 9 +++------ src/libcamera/v4l2_device.cpp | 2 -- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp index caf39760..73148228 100644 --- a/src/libcamera/color_space.cpp +++ b/src/libcamera/color_space.cpp @@ -254,16 +254,13 @@ const ColorSpace ColorSpace::Jpeg = { }; /** - * \brief A constant representing the sRGB color space - * - * This is identical to the JPEG color space except that the Y'CbCr - * range is limited rather than full. + * \brief A constant representing the sRGB color space (non-YUV format) */ const ColorSpace ColorSpace::Srgb = { Primaries::Rec709, TransferFunction::Srgb, - YcbcrEncoding::Rec601, - Range::Limited + YcbcrEncoding::None, + Range::Full }; /** diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 3fc8438f..a4446fbf 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -746,7 +746,6 @@ void V4L2Device::eventAvailable() static const std::map v4l2ToColorSpace = { { V4L2_COLORSPACE_RAW, ColorSpace::Raw }, { V4L2_COLORSPACE_JPEG, ColorSpace::Jpeg }, - { V4L2_COLORSPACE_SRGB, ColorSpace::Srgb }, { V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m }, { V4L2_COLORSPACE_REC709, ColorSpace::Rec709 }, { V4L2_COLORSPACE_BT2020, ColorSpace::Rec2020 }, @@ -772,7 +771,6 @@ static const std::map v4l2ToRange = { static const std::vector> colorSpaceToV4l2 = { { ColorSpace::Raw, V4L2_COLORSPACE_RAW }, { ColorSpace::Jpeg, V4L2_COLORSPACE_JPEG }, - { ColorSpace::Srgb, V4L2_COLORSPACE_SRGB }, { ColorSpace::Smpte170m, V4L2_COLORSPACE_SMPTE170M }, { ColorSpace::Rec709, V4L2_COLORSPACE_REC709 }, { ColorSpace::Rec2020, V4L2_COLORSPACE_BT2020 },