From patchwork Tue Jan 26 18:48:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 11027 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 82FEBC0F2B for ; Tue, 26 Jan 2021 18:49:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2E67F68331; Tue, 26 Jan 2021 19:49:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=posteo.net header.i=@posteo.net header.b="SjgioRzT"; dkim-atps=neutral Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EB7B86831D for ; Tue, 26 Jan 2021 19:49:13 +0100 (CET) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 8C7F62400FF for ; Tue, 26 Jan 2021 19:49:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1611686953; bh=FNWKW/f0pRuFSFWTBHX5dD9QOT5+GCUXbyd0LRC3eyI=; h=From:To:Cc:Subject:Date:From; b=SjgioRzTEklb4SJD+zDN8OnKREJQ8uNhTgHmoSUbf7chfQ5TaPHS5s0dwrPTy5Ujo +Z8ZYjWL29yZDcCaP1vXmBEmjT5QXN5KWts4k8PsR4N/xr39VcWZw9iV9Ue4f/RPPJ eEt9H3TQxnWaZdtVk9HD07+EDgHHcX8CVPv8jcf7G1g8Rshz+OxemHT5rI9vFtkdBn s9omU0Co42+0OM0qBjMDCPsptSlOenAmQ1aR+1PYeTojmgO0C/FLEWU7JPTCUljdhd 3uYUigPTwkHlLG/Bkc9MObZmpL3EFcrwJKd+iFroBCa1PqlCcwWoft9S/An5+VaFNT NYXcc4jPuxifQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DQG3r6Z6dz6tm8; Tue, 26 Jan 2021 19:49:12 +0100 (CET) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 19:48:53 +0100 Message-Id: <20210126184854.46156-5-sebastian.fricke@posteo.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210126184854.46156-1-sebastian.fricke@posteo.net> References: <20210126184854.46156-1-sebastian.fricke@posteo.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/5] libcamera: Add the transpose transformation 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To transpose a BayerFormat means to flip it over its main-diagonal. For example: G B G R -> R G B G The main-diagonal goes from the top left to the bottom right. This means, that the only two orders affected by a transpose are GBRG & GRBG. When a transpose is used in combination with horizontal and/or vertical flips it is performed with the lowest priority. Therefore add the functionality by switching GBRG (index 1) with GRBG (index 2), after the flips have been applied. Signed-off-by: Sebastian Fricke Reviewed-by: Laurent Pinchart Reviewed-by: David Plowman --- src/libcamera/bayer_format.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index d4e7f142..e06cd6e8 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -272,10 +272,6 @@ BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) * The transformed image would have a GRBG order. The bit depth and modifiers * are not affected. * - * Note that transpositions are ignored as the order of a transpose with - * respect to the flips would have to be defined, and sensors are not expected - * to support transposition. - * * \return The transformed Bayer format */ BayerFormat BayerFormat::transform(Transform t) const @@ -292,6 +288,11 @@ BayerFormat BayerFormat::transform(Transform t) const if (!!(t & Transform::VFlip)) result.order = static_cast(result.order ^ 2); + if (!!(t & Transform::Transpose) && result.order == 1) + result.order = static_cast(2); + else if (!!(t & Transform::Transpose) && result.order == 2) + result.order = static_cast(1); + return result; }