Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1565264pxb; Fri, 27 Aug 2021 11:49:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzauydkTLoy2nkwlzYF0i7Cq0wO8LKiiuyTDTuXWeVBDnutE6YobuGsM9mKhlVBhG/bAigg X-Received: by 2002:a02:90d0:: with SMTP id c16mr9305123jag.106.1630090168493; Fri, 27 Aug 2021 11:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630090168; cv=none; d=google.com; s=arc-20160816; b=FBbmOr26HpJAlLmLEdbl9SURvPRKvWnFt8k9QZQMnlzUrXA6eMP4OiTZEQ2h5OkiH2 +6g6j2xUj+eSem/N75V4A3++NECsgjwYfhHokixvwANjDD5DCxFtBY3gWbE9xOgCFhB6 vuL3QEeZYn4Z/6jWifO7rRBRjQ9bhgLQRTAddxCCoSGMS5Kxbou0Kt1WfwwoWfUW4GSA F6dKrUzz8SQzw7GZ9XSkcb6AgSiWU3NnWdTFj+4HmJxR6oou1mDUX4OSPkpDkc1s+EZ9 zedVDrcJLgha+Hd0RnlSbCyAnat4RMYDJ3e9ixLjVFndzHMovEkYkArbikjA0ykzZYJx ikUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KeZQzHpEFEr9FV0/AKy8TSifxmzkQIz3WN598+K3z5s=; b=H283RET/XZ6TG0ptxboVoN25+FcVw4JrKzZ/S96Aqs1buP5p3nBGxHr0zYvO1zWauV igEFwn0sgBH44zDaMlYvNq0JJgXOPgJnaTHXmy/MqLy1v2oeHAqD3FonY1Hgs6ppwVor XTrLB0cl9Tp1z4LfICJ1JUJKBElha/wx5FeBjmG+5DtXVhdJKXe8gUQjfEuT1qS/umst xpaEVKEzj9ickYML/dbUQmwMy59zGiEYbRg0uITddvML2wMlos++Xa91krh7+GcmnZ03 aZ5VlmNPqNwZbx0mM4HgN1cHfq7wFfCuiSJiJHgrJl8SLEgIx/yeNhSTZRXkHSqJL8+6 +IvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b="EwOw/8qG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si7956648ill.124.2021.08.27.11.49.16; Fri, 27 Aug 2021 11:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b="EwOw/8qG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbhH0SsD (ORCPT + 99 others); Fri, 27 Aug 2021 14:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbhH0Sr7 (ORCPT ); Fri, 27 Aug 2021 14:47:59 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F57CC0613CF for ; Fri, 27 Aug 2021 11:47:09 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id t19so15813961ejr.8 for ; Fri, 27 Aug 2021 11:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=KeZQzHpEFEr9FV0/AKy8TSifxmzkQIz3WN598+K3z5s=; b=EwOw/8qGsz5LfJ7BC7neHVTtAykNj5pjJn1xJiY3JCFODNr/26l443lJfxC1RzAfpD xrp0bVmtffTVkaBqm7Yaj97uM1vuin3IyCmvDi2ea9tcG2Vs3du/WryXAbtLNA+QtPcT t3zono2PtDiKO44ezoJQHKhHm0hAeDBRKdcKdyar+9n2JlMBoLgD5Y1WMVfw6yRRY0nx 7d9j4v2hbKZWVq3Ou6rIwzJ76cZfC22NeR6Gzulw1hnwfxwVomWLI+ezqf2csVnMc/kK 9eRfxfPxDY6k6ig88DbFSp9mecIxVqlVhmDIa9Bq70jb2yW/Uqm/+5RkX8zh2ycHgm2c 4SFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KeZQzHpEFEr9FV0/AKy8TSifxmzkQIz3WN598+K3z5s=; b=n1OPc/Nd8wIMk8E1aRjRZzbCzTId4Zsv+WuCy96XlRQuIgfvoWtZUaVUVunH/zI7ep 2sblH5u3moKbIHligmkMXbJepVkuvpaHqabE8WNbvtsKjkQJvV/Ii2ehmBHF0tyItCNR peoBF3ZuMcX/WfT5XonGmiD5cPvlPTCsqdvDaasYYE0v0l6Aw1q5wmfedJ21UZLIEJI1 Td4XXAJFILJ2mAVw1ioOhgXzUjM7NrcwXwMnbQSBSEMVQO9V74uPL4HBUBwtNuVLIxnX bbgAXd93lbVvvsX1kPQffjGDtr9IC/a8vOm9EDxzV7evbnnwEv4oXe5tC0XH3j92njfx tf2g== X-Gm-Message-State: AOAM5338AEwfP04qYMAhZR5evdaNU9xIVZ1vL8gtJBmeHJNJ1mbd9RDh u44LB2rsqoiRaUvkI17kvQydaQPpbyb3YBtovvre7w== X-Received: by 2002:a17:906:a0c9:: with SMTP id bh9mr11275816ejb.51.1630090028030; Fri, 27 Aug 2021 11:47:08 -0700 (PDT) MIME-Version: 1.0 References: <20210823082949.237716-1-benjamin.gaignard@collabora.com> <02r6ig176o0lqc52nm8rhta7cn5bfn04in@4ax.com> <9d6336fff6f122a9a4510a111387a000c65f797b.camel@ndufresne.ca> In-Reply-To: From: Ezequiel Garcia Date: Fri, 27 Aug 2021 15:46:56 -0300 Message-ID: Subject: Re: [PATCH] media: hevc: fix pictures lists type To: Benjamin Gaignard Cc: John Cox , Nicolas Dufresne , Mauro Carvalho Chehab , Hans Verkuil , linux-media , Linux Kernel Mailing List , Collabora Kernel ML , Daniel Almeida Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 27 Aug 2021 at 12:26, Benjamin Gaignard wrote: > > > Le 27/08/2021 =C3=A0 14:40, Ezequiel Garcia a =C3=A9crit : > > On Fri, 27 Aug 2021 at 09:36, John Cox wrote: > >>> Le 27/08/2021 =C3=A0 12:10, John Cox a =C3=A9crit : > >>>>> Le 26/08/2021 =C3=A0 18:09, Nicolas Dufresne a =C3=A9crit : > >>>>>> Le lundi 23 ao=C3=BBt 2021 =C3=A0 12:35 +0100, John Cox a =C3=A9cr= it : > >>>>>>> Hi > >>>>>>> > >>>>>>>> Le 23/08/2021 =C3=A0 11:50, John Cox a =C3=A9crit : > >>>>>>>>>> The lists embedded Picture Order Count values which are s32 so= their type > >>>>>>>>>> most be s32 and not u8. > >>>>>>>>> I'm not convinced that you can't calculate all of those lists f= rom the > >>>>>>>>> info already contained in the DPB array so this is probably red= undant > >>>>>>>>> info though I grant that having the list pre-calced might make = your life > >>>>>>>>> easier, and the userland side will have calculated the lists to > >>>>>>>>> calculate other required things so it isn't much extra work for= it. > >>>>>>>> Yes the userland have already compute these lists and the number= of items > >>>>>>>> in each of them. > >>>>>>>> Build them in the kernel would means to also compute the values = of NumPocStCurrBefore, > >>>>>>>> NumPocStCurrAfter, NumPocLtCurr, NumPocStCurrAfter, NumPocStCurr= Before and NumPocLtCurr > >>>>>>>> and that requires information (NumNegativePics, NumPositivePics.= ..) not provided to the kernel. > >>>>>>>> Since it have to be done in userland anyway, I'm reluctant to mo= dify the API to redo in the kernel. > >>>>>>> Well, fair enough, I'm not going to argue > >>>>>>> > >>>>>>>>> Even if you do need the lists wouldn't it be a better idea to h= ave them > >>>>>>>>> as indices into the DPB (you can't have a frame in any of those= lists > >>>>>>>>> that isn't in the DPB) which already contains POCs then it will= still > >>>>>>>>> fit into u8 and be smaller? > >>>>>>>> Hantro HW works with indexes but I think it is more simple to se= nd PoC rather than indexes. > >>>>>>> I'd disagree but as I don't use the info I'm not concerned. Thoug= h I > >>>>>>> think I should point out that when Hantro converts the POCs to in= dicies > >>>>>>> it compares the now s32 POC in these lists with the u16 POC in th= e DPB > >>>>>>> so you might need to fix that too; by std (8.3.1) no POC diff can= be > >>>>>>> outside s16 so you can mask & compare or use u16 POCs in the list= s or > >>>>>>> s32 in the DPB. > >>>>>> Fun fact, my interpretation with the API when I drafted GStreamer = support was > >>>>>> that it was DPB indexes: > >>>>>> > >>>>>> https://gitlab.freedesktop.org/ndufresne/gst-plugins-bad/-/blob/he= vc_wip/sys/v4l2codecs/gstv4l2codech265dec.c#L850 > >>>>>> > >>>>>> It felt quite natural to be, since this is also how we pass refere= nces for l0/l1 > >>>>>> (unused by hantro I guess). > >>>>>> > >>>>>> Looking at old rkvdec code as a refresher: > >>>>>> > >>>>>> for (j =3D 0; j < run->num_slices; j++) { > >>>>>> sl_params =3D &run->slices_params[j]; > >>>>>> dpb =3D sl_params->dpb; > >>>>>> > >>>>>> hw_ps =3D &priv_tbl->rps[j]; > >>>>>> memset(hw_ps, 0, sizeof(*hw_ps)); > >>>>>> > >>>>>> for (i =3D 0; i <=3D sl_params->num_ref_idx_l0_= active_minus1; i++) { > >>>>>> WRITE_RPS(!!(dpb[sl_params->ref_idx_l0[= i]].rps =3D=3D V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR), > >>>>>> REF_PIC_LONG_TERM_L0(i)); > >>>>>> WRITE_RPS(sl_params->ref_idx_l0[i], REF= _PIC_IDX_L0(i)); > >>>>>> } > >>>>>> > >>>>>> for (i =3D 0; i <=3D sl_params->num_ref_idx_l1_= active_minus1; i++) { > >>>>>> WRITE_RPS(!!(dpb[sl_params->ref_idx_l1[= i]].rps =3D=3D V4L2_HEVC_DPB_ENTRY_RPS_LT_CURR), > >>>>>> REF_PIC_LONG_TERM_L1(i)); > >>>>>> WRITE_RPS(sl_params->ref_idx_l1[i], REF= _PIC_IDX_L1(i)); > >>>>>> } > >>>>>> > >>>>>> > >>>>>> This is code is clearly unsafe, but now I remember that dpb_entry = has a flag > >>>>>> "rps". So we know from the DPB in which of the list the reference = lives, if any. > >>>>>> In the case of RKVDEC the HW only cares to know if this is long te= rm or not. > >>>>>> > >>>>>> So without looking at the spec, is that dpb represention enough to= reconstruct > >>>>>> these array ? If we pass these array, shall we keep the rps flag ?= I think a > >>>>>> little step back and cleanup will be needed. I doubt there is a si= ngle answer, > >>>>>> perhaps list what others do (VA, DXVA, NVDEC, Khronos, etc) and we= can > >>>>>> collectively decide were we want V4L2 to sit ? > >>>>> I have done some tests with Hantro driver and look at the spec, the= order of the PoC > >>>>> in the reference lists matters. You can deducted the order for DPB = rps flags. > >>>>> I would suggest to remove rps flags to avoid information duplicatio= n. > >>>> I want the DPB rps member for long term reference marking. I don't = care > >>>> about before / after, but LTR can't be deduced from PoC and if you a= re > >>>> going to keep the member you might as well keep before / after. > >>> Ok so keep like it is. > >>> In this case my patch is enough, right ? > > The problem with the patch is that it breaks existing userspace. > > Currently, there's no upstreamed userspace so this is not a huge > > deal. > > > > However, it's definitely not a good practice. Even if these are > > staging controls, I think a proper action item is to start discussing > > what's missing on the HEVC interface as a whole, so it can be > > moved to stable. > > I do agree I think it could the time to talk about moving the API to stab= le. > My plan is to get this patch merge before sending a RFC to move the API. > I'd rather not merge this patch, and instead merge all the changes in one g= o, so we avoid making further changes to the API. The patch iself might look good, but I'd rather have the discussion on the big picture, and make sure we can all review the interface against the spec. BTW, this should probably mean we have a plan to extend APIs if we need to. Daniel Almeida (Cc) has the details for my proposal on that front, if you w= ant to push it forward. Thanks, Ezequiel