Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2328392ybf; Mon, 2 Mar 2020 06:32:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxt1zSjlK1QNz1PQB10ztDbeAb9RkF3sTGLCZ5pl+G8hSI1Onsg3txXCnekHHzYHRSxfbB7 X-Received: by 2002:aca:33d5:: with SMTP id z204mr10991378oiz.120.1583159532449; Mon, 02 Mar 2020 06:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583159532; cv=none; d=google.com; s=arc-20160816; b=cw7AlXRezTuiPKMqBOguleEm0+dVeUi7z40NQbfBYOJfV5nzN78SBPcHfxCl2aoq42 QDEeA11gnSD9G8dw0eqRKGmpu6pa/Pb4lcyOSBwmy6iLA6KZlT0w4KAIG6L5h7HfyL0x zg601aNw3T3fR1DQrN5WtB2qWUsXp7FRM/dYx1z3euWi5oghgA0Y5e84kHFKy3Zc0W9R yAVP73+CGw1RDMW+04mPzvFzYG9d+dFSh7d/xKmOSOwvYlgLewPGVEpVw12KqXP6ei9g e5zC6SkJ7qMkn4RVKf1nba/If6h/58j8MXlrlcWtp/INg92PZeegyT6mZKrJOLnT0QSx 0wOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=1sGl06N+Rl7O37u2OorYyBoyo/el8MUoGWWYcoaMZMc=; b=E+vA160qFDYhjQKVINXD3UEjDWB8obqDoG+2P0zuA8OM1PDaY00BsNK3XstA96E8mL ilgHYB8P+20m/LA9Sh+SgfjFenYPCrdT3mlJIVQN23ZVWKxv1qUPM+phUkKw51sY/T0s 8o7/iMWFzSt8p+/l+SMSbmiQ5uxXzmc6sWeCZ4Sllm5Xb+maHudREvJqjarYU6nEie4g 3eKk8UmOWGfSFDj7gG3OOgfb79X2Ksclgk89PNGsaD7UqiBcoo0M4KrE44vKTVMgrTKt HONqVhDfwDjgTyQ6W0SAssFkG+12Z02xYkE0hYNBvYMXWD5HdLIXFJJgENgYvu+8px3a nL5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si5981064otp.189.2020.03.02.06.31.59; Mon, 02 Mar 2020 06:32:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727250AbgCBOao convert rfc822-to-8bit (ORCPT + 99 others); Mon, 2 Mar 2020 09:30:44 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46468 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbgCBOao (ORCPT ); Mon, 2 Mar 2020 09:30:44 -0500 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id C7561294B57; Mon, 2 Mar 2020 14:30:41 +0000 (GMT) Date: Mon, 2 Mar 2020 15:30:39 +0100 From: Boris Brezillon To: Mauro Carvalho Chehab Cc: Ezequiel Garcia , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Laurent Pinchart , Rob Herring , Tomasz Figa , Nicolas Dufresne , kernel@collabora.com, Paul Kocialkowski , Jonas Karlman , Heiko Stuebner , Sakari Ailus , Hans Verkuil Subject: Re: [PATCH v6 5/6] media: rkvdec: Add the rkvdec driver Message-ID: <20200302153039.0c4ff54f@collabora.com> In-Reply-To: <20200302145746.3e94c1d1@coco.lan> References: <20200220163016.21708-1-ezequiel@collabora.com> <20200220163016.21708-6-ezequiel@collabora.com> <20200302145746.3e94c1d1@coco.lan> Organization: Collabora X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 Mar 2020 14:57:46 +0100 Mauro Carvalho Chehab wrote: > > +#define M_N(ctxidx, idc0_m, idc0_n, idc1_m, idc1_n, \ > > + idc2_m, idc2_n, intra_m, intra_n) \ > > + [0][(ctxidx)] = {idc0_m, idc0_n}, \ > > + [1][(ctxidx)] = {idc1_m, idc1_n}, \ > > + [2][(ctxidx)] = {idc2_m, idc2_n}, \ > > + [3][(ctxidx)] = {intra_m, intra_n} > > Hmm... I can't even imagine what a macro named "M_N" would do. > Please use a better name for it. Well, the meaning of those fields is explained in the spec, and the name itself has been chosen so it's short enough to not have lines exceeding 80 chars while still keeping the number of lines used for the cabac_table[] definition acceptable. But, I'm open to any other suggestion. > > - > > With regards to the macro itself, at least for my eyes, it looked bad, > from long-term maintenance PoV, to have a first argument (ctxidx) whose > value is just a monotonic linearly-incremented counter. It's not, we have holes in the middle, hence the explicit indexing. I also tried to have something as close as possible to the spec, so people can easily see where it comes from. > > I mean, the way it is, it sounds risky, as one might miss a number > and one entire line of the array would be filled with zeros. That's exactly why I used explicit indexing: I want specific portions of the table to be 0-filled :-). > > > + > > +/* > > + * Constant CABAC table. > > + * Built from the tables described in section '9.3.1.1 Initialisation process > > + * for context variables' of the H264 spec. > > + */ > > +static const s8 rkvdec_h264_cabac_table[4][464][2] = { > > + /* Table 9-12 – Values of variables m and n for ctxIdx from 0 to 10 */ > > + M_N(0, 20, -15, 20, -15, 20, -15, 20, -15), > > So, (maybe except if the ctxidx value has some real meaning), > perhaps you could, instead, switch the array order at the tables, > and get rid of ctxidx parameter for good, so the above code would > be like: I can't switch the array order since the HW expects things to be organized this way (that table is directly copied to a memory region that's passed to the HW). > > #define INIT_MN_PAIRS(idc0_m, idc0_n, idc1_m, idc1_n, \ > idc2_m, idc2_n, intra_m, intra_n) \ > { \ > [0] = {idc0_m, idc0_n}, \ > [1] = {idc1_m, idc1_n}, \ > [2] = {idc2_m, idc2_n}, \ > [3] = {intra_m, intra_n} \ > }, > > static const s8 rkvdec_h264_cabac_table[464][4][2] = { > /* Table 9-12 – Values of variables m and n for ctxIdx from 0 to 10 */ > INIT_MN_PAIRS(20, -15, 20, -15, 20, -15, 20, -15), > ...