From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 011CAC624D7 for ; Thu, 3 Sep 2026 06:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Er0+jf5qJ7+MA51OSpnVT+FMczAyphggtDBLkpQXO4c=; b=OQ/RfrP4nFqlxHIJrEDc2TgUKr gI/LZcVGYxbDfXY30z7aQt95zINgFTEik0MA3PtSBWBfJc9gYuVP0LEViFFIcAbu/P4nuiQHI2dn/ ufKxWrYE1UhcpynmL8aYPzibbnubrI6+JXUJQyOsQRClIEBvE4xvLKjm5t8LIjoRaZzyrdsGmq63B 08WD6fCIKMGnq/dg45gO8e+PHiyi8lOxIApDcnAt/+AKgAfhxE9Z2L82MbJmhfK2/5dxC4pAIh7ov 7weltJL4v/exJx/h5iurnyHxeAVImFGXPe6Oal/3uJTsL0UdEI3GaPOgdM7RWb4dj8e4RldT9JPDi 5jBatygg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x21II-0000000GVrB-2mmP; Thu, 03 Sep 2026 06:51:30 +0000 Received: from sender4-op-o11.zoho.com ([136.143.188.11]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x21IG-0000000GVqc-1AS5; Thu, 03 Sep 2026 06:51:29 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1788418279; cv=none; d=zohomail.com; s=zohoarc; b=mI5TxV9T26KLVPzQLeqcFHoC/lN6cuL/O/xDyuorrq9EqGlnIZcIt2cPuBy+XF9eDOwL9a/EkL5qR+DzwMwNMnGUQOTSAn9JXJKncxfC4ZrI8M+MTuIY6vh/JUK8u7suFAl4remvr/R0k8/dVMeStdbOFiTEZB5vJInr82EPJu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788418279; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=Er0+jf5qJ7+MA51OSpnVT+FMczAyphggtDBLkpQXO4c=; b=lkaUMpL0cElA3/wMMziec7VPPkdPTAK2scVBRXvPvLIR8f5WUPXYNjYSNafh7Uq9orHIMwvo2tPJ1xRKdbGhujIig25r5ju72CelsK7qoEgcdkzDrGSC3pbUfLmBW/440KYPKRn8ocz0iWlkWyvZkH1BbzBTjaO7YWVkuYQLQqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=benjamin.gaignard@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1788418279; s=zohomail; d=collabora.com; i=benjamin.gaignard@collabora.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=Er0+jf5qJ7+MA51OSpnVT+FMczAyphggtDBLkpQXO4c=; b=cIX6bqhC/3XCAkCL6Tc6nvhZtYeuTxGDr1kaobPawvv7CvvYybPZSJn3ZTsT31C+ /37n9RTnycYHAneXf+msH150uvy1Wv2ccEkigPVUzeyq0wTSRyMQqYAKVn1XcB8IaSY iFfqs5XvYWUkV2skmAZE8QPuilEnt4eNCzmIp6rU= Received: by mx.zohomail.com with SMTPS id 178841827811934.23632285902954; Wed, 2 Sep 2026 23:51:18 -0700 (PDT) Message-ID: <92f2fa35-aff2-4c14-b617-0884f90af44f@collabora.com> Date: Thu, 3 Sep 2026 08:51:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/9] media: hevc: add bounded tile-count helpers To: Michael Bommarito , Hans Verkuil , Mauro Carvalho Chehab , Sakari Ailus , Nicolas Dufresne Cc: Laurent Pinchart , Detlev Casanova , Ezequiel Garcia , Yunfei Dong , Jonas Karlman , Heiko Stuebner , Kees Cook , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260617021906.2746743-1-michael.bommarito@gmail.com> <20260617021906.2746743-4-michael.bommarito@gmail.com> Content-Language: en-US From: Benjamin Gaignard In-Reply-To: <20260617021906.2746743-4-michael.bommarito@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260902_235128_366400_7650EF30 X-CRM114-Status: GOOD ( 17.46 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Le 17/06/2026 à 04:19, Michael Bommarito a écrit : > The stateless HEVC decoders compute the number of tile columns and rows > from num_tile_columns_minus1 / num_tile_rows_minus1 and clamp it to the > column_width_minus1[] / row_height_minus1[] capacity before using it as a > loop bound. Add shared helpers in a new so the rkvdec > and hantro drivers do not each open-code the min_t() clamp. > > Assisted-by: Claude:claude-opus-4-8 > Signed-off-by: Michael Bommarito Reviewed-by: Benjamin Gaignard > --- > include/media/v4l2-hevc.h | 41 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > create mode 100644 include/media/v4l2-hevc.h > > diff --git a/include/media/v4l2-hevc.h b/include/media/v4l2-hevc.h > new file mode 100644 > index 0000000000000..973c96be16be4 > --- /dev/null > +++ b/include/media/v4l2-hevc.h > @@ -0,0 +1,41 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Helper functions for HEVC stateless codecs. > + */ > + > +#ifndef _MEDIA_V4L2_HEVC_H > +#define _MEDIA_V4L2_HEVC_H > + > +#include > +#include > + > +/** > + * v4l2_hevc_pps_num_tile_columns - number of HEVC tile columns, bounded > + * @pps: the V4L2 HEVC PPS control > + * > + * Return the number of tile columns (num_tile_columns_minus1 + 1) clamped to > + * the capacity of column_width_minus1[]. The control validation already > + * rejects out-of-range counts; this keeps the consuming drivers bounded too. > + */ > +static inline unsigned int > +v4l2_hevc_pps_num_tile_columns(const struct v4l2_ctrl_hevc_pps *pps) > +{ > + return min_t(unsigned int, pps->num_tile_columns_minus1 + 1, > + ARRAY_SIZE(pps->column_width_minus1)); > +} > + > +/** > + * v4l2_hevc_pps_num_tile_rows - number of HEVC tile rows, bounded > + * @pps: the V4L2 HEVC PPS control > + * > + * Return the number of tile rows (num_tile_rows_minus1 + 1) clamped to the > + * capacity of row_height_minus1[]. > + */ > +static inline unsigned int > +v4l2_hevc_pps_num_tile_rows(const struct v4l2_ctrl_hevc_pps *pps) > +{ > + return min_t(unsigned int, pps->num_tile_rows_minus1 + 1, > + ARRAY_SIZE(pps->row_height_minus1)); > +} > + > +#endif /* _MEDIA_V4L2_HEVC_H */