From patchwork Fri Jun 28 21:35:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20486 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 A7CE9BD87C for ; Fri, 28 Jun 2024 21:36:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C1FBB62C9F; Fri, 28 Jun 2024 23:36:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="G9zpe3dR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0055662C95 for ; Fri, 28 Jun 2024 23:35:58 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 10A862C5 for ; Fri, 28 Jun 2024 23:35:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719610533; bh=j7YXVIhlBpY9+vSh/yt9XreDl5UBpm+4n4rSTlqjKsw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G9zpe3dRHR3v6IuVu7nRo5fLOE3n/WRuk1XfEIAMqBrM6hOKJNRq1/h2gPuVcjrrk leVStOiI8YTeFUwC3DL3g2O+bLQyDYGwuMDt8jzxt0DFWDVeSWlxnmAq1EI0OK2bYM i1DdFNy0quu4nLafbzygq17YNYHO0ifRU23AL0BI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 1/2] apps: common: dng_writer: Fix thumbnail generation on BE machines Date: Sat, 29 Jun 2024 00:35:34 +0300 Message-ID: <20240628213535.6906-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240628213535.6906-1-laurent.pinchart@ideasonboard.com> References: <20240628213535.6906-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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" The 16-bit padded raw 10 and raw 12 formats are stored in memory in little endian order, regardless of the machine's endianness. Swap the 16-bit values on big-endian machines when reading pixels from memory to generate thumbnails. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Signed-off-by: Stefan Klug Reviewed-by: Stefan Klug --- src/apps/common/dng_writer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp index 9241f23fb806..50db5eb33c83 100644 --- a/src/apps/common/dng_writer.cpp +++ b/src/apps/common/dng_writer.cpp @@ -8,6 +8,7 @@ #include "dng_writer.h" #include +#include #include #include @@ -185,7 +186,8 @@ void thumbScanlineRaw(const FormatInfo &info, void *output, const void *input, /* Simple averaging that produces greyscale RGB values. */ for (unsigned int x = 0; x < width; x++) { - uint16_t value = (in[0] + in[1] + in2[0] + in2[1]) >> 2; + uint16_t value = (le16toh(in[0]) + le16toh(in[1]) + + le16toh(in2[0]) + le16toh(in2[1])) >> 2; value = value >> shift; *out++ = value; *out++ = value;