From patchwork Fri May 8 19:19:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Tia X-Patchwork-Id: 26702 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 74718C32F6 for ; Fri, 8 May 2026 19:19:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4199163025; Fri, 8 May 2026 21:19:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=jetm.me header.i=@jetm.me header.b="WtCjh+X/"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="DvLtISIn"; dkim-atps=neutral Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 74BED62FEA for ; Fri, 8 May 2026 21:19:42 +0200 (CEST) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id BC4D414000E1; Fri, 8 May 2026 15:19:41 -0400 (EDT) Received: from phl-imap-07 ([10.202.2.97]) by phl-compute-02.internal (MEProxy); Fri, 08 May 2026 15:19:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jetm.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1778267981; x=1778354381; bh=lgsJYtARUo3uiB8kvm5L7vqQwr7PVbssQxgHzP8KrxM=; b= WtCjh+X/roVhluKhD+BVqWAS5XaWI4O7tf23vqI6fHvhtG1HTn8ZH3SQ9cZaRnYj IwPoliAOc30QlxzM5Xgxrex5wmx1i9w/BWvGp5SNdoN0wt93SphXwCptxo4Hj5RR xqNFwoPB50Pg6/KU6EI4KDLa70DfxJ1E8tRchqT4/0HD5Cx4teIWKjbjWXxYr6K9 OflVpAOjRSKaMOM1rvxsnV5MBD5JoaIF0OEgJhdlkkpf+OImwG7fca8GzaS+CYMI P18RwEAl6aoUSsStLUWw9XGGrDABefa7NJyC+YKw/AQO4b2CzGzaFsdGpZKBxSu7 dMk3Kns7HE2IwHN5+KkOUw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1778267981; x= 1778354381; bh=lgsJYtARUo3uiB8kvm5L7vqQwr7PVbssQxgHzP8KrxM=; b=D vLtISInPNxkAQG1brnSywS8kLpL4/wse7YWcVdzxhQalfI7QbIIxOw3KvwExpFRp y4DNoIEeU67PWnklSDrJ1TZbkzUqwGUT/JoeR6JXoeyZsx88ZYUMO+8HFFMYLFql zStbOQzsraZUhnkUdBBxUPdJLXGo2D2bsId6/b8EVlczWuB77wkXZef1wKTWz4Dm CnjvJCITQs9aLt4g6t1Y+fRjdq1c+f4HEhxdbHYlqmLAQ4SuyL8ZglUIHZyVmFld 4rp++D4G4qcgUxaLWmdsiEC9/xCpnSsIaoexEFMdP2JPJSs/Od6PDV6PqOKAYXzi N4SvyNFtojS1UBL3ObIJw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduudduudekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgopfhokfffucdluddtmdenucfjughrpefotggggffhvf ffufevjghfsehtkedttdertdejnecuhfhrohhmpeflrghvihgvrhcuvfhirgcuoehflhho shhssehjvghtmhdrmhgvqeenucggtffrrghtthgvrhhnpedtudejffejkeekteelueefvd ejvdeuhfefteehkeevtddvleduteekleetvdelhfenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehflhhoshhssehjvghtmhdrmhgvpdhnsggprh gtphhtthhopeejpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehrohgsvghrthdr mhgruggvrhestgholhhlrggsohhrrgdrtghomhdprhgtphhtthhopegsrghrnhgrsggrsh drphhotgiivgesihguvggrshhonhgsohgrrhgurdgtohhmpdhrtghpthhtohepkhhivghr rghnrdgsihhnghhhrghmsehiuggvrghsohhnsghorghrugdrtghomhdprhgtphhtthhope hlrghurhgvnhhtrdhpihhntghhrghrthesihguvggrshhonhgsohgrrhgurdgtohhmpdhr tghpthhtohepfhhlohhsshesjhgvthhmrdhmvgdprhgtphhtthhopehlihgstggrmhgvrh grqdguvghvvghlsehlihhsthhsrdhlihgstggrmhgvrhgrrdhorhhgpdhrtghpthhtohep mhiirghmrgiirghlsehrvgguhhgrthdrtghomh X-ME-Proxy: Feedback-ID: i9dde48b3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 9DB451EA006C; Fri, 8 May 2026 15:19:41 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 From: Javier Tia To: libcamera-devel@lists.libcamera.org Date: Fri, 08 May 2026 13:19:25 -0600 Subject: [PATCH 1/2] libcamera: libipa: Add right-shift operators to Vector Cc: mzamazal@redhat.com, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, barnabas.pocze@ideasonboard.com, robert.mader@collabora.com In-Reply-To: <177826797798.345005.11618565886801750854@jetm.me> References: <177826797798.345005.11618565886801750854@jetm.me> Message-Id: <20260508191941.9DB451EA006C@mailuser.phl.internal> 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" Add operator>> and operator>>= for right-shifting all elements by a scalar shift amount. Both operate element-wise: operator>> returns a new Vector with each element shifted, operator>>= shifts in place and returns a reference to *this. The motivating use case is SwStatsCpu::finishFrame(), which right-shifts three individual components of the RGB sum by the same sumShift_ value. With these operators that becomes a single sum_ >>= sumShift_ expression. Suggested-by: Barnabás Pőcze Suggested-by: Laurent Pinchart Signed-off-by: Javier Tia --- include/libcamera/internal/vector.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/libcamera/internal/vector.h b/include/libcamera/internal/vector.h index ed7490e1..475bc522 100644 --- a/include/libcamera/internal/vector.h +++ b/include/libcamera/internal/vector.h @@ -111,6 +111,14 @@ public: return apply(*this, scalar, std::divides<>{}); } + constexpr Vector operator>>(unsigned int shift) const + { + Vector result; + std::transform(data_.begin(), data_.end(), result.data_.begin(), + [shift](T v) { return v >> shift; }); + return result; + } + Vector &operator+=(const Vector &other) { return apply(other, [](T a, T b) { return a + b; }); @@ -151,6 +159,13 @@ public: return apply(scalar, [](T a, T b) { return a / b; }); } + Vector &operator>>=(unsigned int shift) + { + std::for_each(data_.begin(), data_.end(), + [shift](T &v) { v >>= shift; }); + return *this; + } + constexpr Vector min(const Vector &other) const { return apply(*this, other, [](T a, T b) { return std::min(a, b); });