Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10936972ybi; Thu, 25 Jul 2019 07:19:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0t/DFmth8vgjLDHYsa8aq3HptS0wseMMBWuLrOhlmnM9vU8pxyM38a6uPi5LTkXNOjgiy X-Received: by 2002:a17:902:e65:: with SMTP id 92mr87508877plw.13.1564064362411; Thu, 25 Jul 2019 07:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564064362; cv=none; d=google.com; s=arc-20160816; b=jxDtsqz7mF9AJHmQv12ZWXxeuEEpMinxH6z342CMhTzUCZxCfYtbiTHePlO5TAztgF SDqE9lBOP8bsEP0Hdxa8sXMZYIWnipu5U1Ow+Ii/tqbxg2Dle+XPc2TdFgEoyttItpvM pSMZiB+AJ3DqGpr0h6VRpsj8oEXHTFPB9la+DgKCwuf509XzdcpTuWhbXMzgBXfSBhmZ jSgVWkTPe7qzIT7o2Wu30nyXGgcBl273+QwMaBSBwXHc1oyugAHN7naql3y6Lb6o/Dk9 ZCjzCKtty10NgE9gGi2rcUOaNbDjYsfLxn3cnc1SWgKmDZP+vLF3PQx2zTuk7bgV0pjp 3xIg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=lRofjpGVnPdkvHjT1abpzFvdhqRUdMtCwITS9XC9FqY=; b=m/Ov90LhmfVY0li0KJVYqeCG6rTfalfXj4cnMSaSQWgqVrnoU+FtKGj1H4qGt/nApb CnMH7gljmjTUUXwcIju/XDnyZp8lsIpHDa/0ZhkSkBO4OBsVzbJX14K9v/SsJcjPYKgm o10bpMTTo8FI0ZbEkfTt6gKzJEtf1iK/DPxvlJaE3Gbzj74SClmMbaTXgVNnwJzpq2ml mKUvSxTyToRTgJSPwhJcTGnb5TKgdXagZDFzJIuDGW4iE5qqVZWP8fk+1k2hV8p5GJYs Jc39FO6BF71HsDDrSpl9hPtfRCOcIrKfLv18zdvL7+n9AyCZHRgXh+b7ZbLUXDaYDMrD 74Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=WKwOxX6K; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si17022190pjq.60.2019.07.25.07.19.03; Thu, 25 Jul 2019 07:19:22 -0700 (PDT) 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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=WKwOxX6K; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387769AbfGYNbq (ORCPT + 99 others); Thu, 25 Jul 2019 09:31:46 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:44828 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387665AbfGYNbq (ORCPT ); Thu, 25 Jul 2019 09:31:46 -0400 Received: by mail-lj1-f193.google.com with SMTP id k18so47990371ljc.11 for ; Thu, 25 Jul 2019 06:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lRofjpGVnPdkvHjT1abpzFvdhqRUdMtCwITS9XC9FqY=; b=WKwOxX6KPDQIRmCgJAKTRU8nyTVTibB5C1TnIuihKcSV5lNt9QF4vT4B5iz0FMTva1 X+7McxEoaoHiZtop26NDtdsbRmzb/o4oqU+CfFw5lOJcRcmxL8HDtEfX54kpPakjiubz MUTRw3XXFYfdTUeK+go0VcL/q1AxSnTaPZfY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lRofjpGVnPdkvHjT1abpzFvdhqRUdMtCwITS9XC9FqY=; b=Mbw1AldtUeRx3nZv8yngIDuTR85KPZPhG7VKYJhCL1ybK2t+D7LVAsTk5nB5JTnYDh odLatM82GK8q/5R2Z8V01q/YS85apIKLrg5ZXPymLyIQhT2OVZ5bSzfn9IrHkpc5znDb 78C6EHLM3Y8KpyYnHvcBii+Vl2pbpQO/DZuaWUjD18B8fxEohfJ0Mg95rn7vC9tZoLfA i1i96+toRsH2bpAhpvBAP06tf2iwpWjaKAxblZ5MlbrT36OI7TrRLGIK+2j41eygNuOU pQagbihj2AJD2G73dsHx+CD2C/XC1iUl+Lv021lTdVjWC08F7UxuyYnhDGGjsgGXO9d5 XZZw== X-Gm-Message-State: APjAAAWGD4VX5dPc+0sci/0wA9f6lvMpRViRJZvLcNliSHafQVocCw8w +QKhGvfxTjNBGocY1bG2TbY= X-Received: by 2002:a2e:3013:: with SMTP id w19mr46339678ljw.73.1564061503937; Thu, 25 Jul 2019 06:31:43 -0700 (PDT) Received: from [172.16.11.28] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id l22sm9051754ljc.4.2019.07.25.06.31.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 06:31:43 -0700 (PDT) Subject: Re: [PATCH 7/9] media: hantro: Add core bits to support H264 decoding To: Boris Brezillon , Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Sakari Ailus , linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Tomasz Figa , Nicolas Dufresne , kernel@collabora.com, Paul Kocialkowski , Ezequiel Garcia , Jonas Karlman , linux-rockchip@lists.infradead.org, Heiko Stuebner , Andrew Morton , Philipp Zabel , Hertz Wong References: <20190619121540.29320-1-boris.brezillon@collabora.com> <20190619121540.29320-8-boris.brezillon@collabora.com> From: Rasmus Villemoes Message-ID: <25cc2826-fc8f-570a-07fa-8cbdb11830a7@rasmusvillemoes.dk> Date: Thu, 25 Jul 2019 15:31:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190619121540.29320-8-boris.brezillon@collabora.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/06/2019 14.15, Boris Brezillon wrote: > From: Hertz Wong > > Add helpers and patch hantro_{drv,v4l2}.c to prepare addition of H264 > decoding support. > > Signed-off-by: Hertz Wong > Signed-off-by: Boris Brezillon > --- > + > + /* > + * Short term pics in descending pic num order, long term ones in > + * ascending order. > + */ > + if (!(a->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)) > + return b->frame_num - a->frame_num; > + > + return a->pic_num - b->pic_num; > +} Pet peeve: This works because ->frame_num and ->pic_num are u16, so their difference is guaranteed to fit in an int. > +static int b0_ref_list_cmp(const void *ptra, const void *ptrb, const void *data) > +{ > + const struct hantro_h264_reflist_builder *builder = data; > + const struct v4l2_h264_dpb_entry *a, *b; > + s32 poca, pocb; > + u8 idxa, idxb; > + > + idxa = *((u8 *)ptra); > + idxb = *((u8 *)ptrb); > + a = &builder->dpb[idxa]; > + b = &builder->dpb[idxb]; > + > + if ((a->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) != > + (b->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)) { > + /* Short term pics firt. */ > + if (!(a->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)) > + return -1; > + else > + return 1; > + } > + > + /* Long term pics in ascending pic num order. */ > + if (a->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM) > + return a->pic_num - b->pic_num; > + > + poca = builder->pocs[idxa]; > + pocb = builder->pocs[idxb]; > + > + /* > + * Short term pics with POC < cur POC first in POC descending order > + * followed by short term pics with POC > cur POC in POC ascending > + * order. > + */ > + if ((poca < builder->curpoc) != (pocb < builder->curpoc)) > + return poca - pocb; > + else if (poca < builder->curpoc) > + return pocb - poca; > + > + return poca - pocb; > +} Here, however, poca and pocb are ints. What guarantees that their values are not more than 2^31 apart? I know absolutely nothing about this code or what these numbers represent, so it may be obvious that they are smallish. Rasmus