Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2226762pxb; Wed, 30 Mar 2022 19:58:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHtQu67RlPGU9X6iig9Y+Vp9TB3gvxgV8U+RziaEWulL1Qzm/Uj2m309OBnXnpkp3aRMu2 X-Received: by 2002:a17:90b:1b03:b0:1c7:778b:d4ce with SMTP id nu3-20020a17090b1b0300b001c7778bd4cemr3582485pjb.128.1648695533532; Wed, 30 Mar 2022 19:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648695533; cv=none; d=google.com; s=arc-20160816; b=eRi1EeHAtKUaSsOPOp5wGsf7rKDiiBWKlYoXPnycamwzXTBj47U2NpXGWZyD0ksKm5 w41PsUdD6iDxs1N6xHB7z/3NkjNO3ot2kRDZDVfJOpgapkLAm4wwGEr0Qlcj+wg3murz zV22+HOV7gSnrItEMHCz3QR1x7lKuEZ9VZEtaYplGitevw71PNZK10p8e7jKXQr5OUEG Z6UyK+0a0vGtpz6XSrYue+jphONCaII7ZIeV03PsI2vICDhmwXaUTr7uJq3sjBgogIWE LWgLutrPvQswfVFGwd9DQYpd8dPRQqX2ta/CDWRhuCYEUi8WZqIUGaRYN5rAEB77DsOr p40g== 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=iREdRJSlGkex49OSzIjV0KsFYd3jZkgqeIW8XLnqJVg=; b=cF2dt7KkHs0gPGWveqaklCKOq8ckTDs8HOZE5oCa5Nr7cP4SDvIZzPTcELOMVDE0KH 6HSwHuUDqkPbTE37uAkRJ65xco1gGotMv0r24VLcY0S38zf7FAt8+jXugtEpmb+7073E XdInQlUYGT1sYXDlIMZXTxoUWDVJzOP13eu+qdAEfA6Xtz0NJ0CntlTllOLQeBXJMzJ+ VKEfc50NaPnNKV+rg2EGePYqGfi51tY7ULnaJpehiT0VHktaV2M37QipeSRri6wA+5r0 ivSkp6VFORZIWiJua01ixu5veEPcOmsFtJJnLADY8Zz8ooFE8Q6XYuSoDGK743hHAOQ1 djOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20210112.gappssmtp.com header.s=20210112 header.b=v3+DvT6M; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id mw18-20020a17090b4d1200b001bd14e01fa6si2144405pjb.148.2022.03.30.19.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 19:58:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20210112.gappssmtp.com header.s=20210112 header.b=v3+DvT6M; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 324E7E09AD; Wed, 30 Mar 2022 19:42:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351836AbiC3XpM (ORCPT + 99 others); Wed, 30 Mar 2022 19:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351835AbiC3XpK (ORCPT ); Wed, 30 Mar 2022 19:45:10 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41B3C10C6 for ; Wed, 30 Mar 2022 16:43:22 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id yy13so44628930ejb.2 for ; Wed, 30 Mar 2022 16:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=iREdRJSlGkex49OSzIjV0KsFYd3jZkgqeIW8XLnqJVg=; b=v3+DvT6MCRwfRE2AsrD6YG1zSiTxbEnxL6aEqZFU/4zqeuCy5A6lE4iTeY+xbiG8I5 x5sI51qPvKIaTNBzbsgmeiUriNZA6Kn1CbUpdVh6K0ARyes4hEwCSxnpaTpGQo8CsY8I 68ayLJPCkYZ1TBvBlm8Jy3i/0yq4T7lOHGm4oaGQB57zlbrm14e6zjQ30W4QWlJ1na8B yluIPxS3F2ANatES130GX7cIUfWGFbkaMSpvwt/xt4mBXmWxaWn0vCtU6Y9ontlzRgGK MnvGuNkZ8A4FkSalHvCMKXkPXM6NSnLvgCAUZybrfmU2m0axLV54Da5AyNWnee/FFq0D RkmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iREdRJSlGkex49OSzIjV0KsFYd3jZkgqeIW8XLnqJVg=; b=WxrPOT+yisPQIHbqIennF33RK0Febys6sDUp8rQDtGMiFQNfsSWL6j9FSAsQQ9JWcK l7Uuo8qVVztiuxxVWvuy79cYOJOFizzBZUaYfhoXdF6CEamppCRs2NArBAvYpH7OfyuK x/NMbaMpFEA+TILJjyZPgif9km3X7x9nZZoagRB2a5slR5rmFuldgH9PTzYAlijdfJSU D0e/dXObJtUt6fW1mqJxdJZfysUhD+7Q36AnbX1h0pRb2LlCn8jw05BWazLPhdMq35+E 1e+WbLiw5EAjfrSUj/eP57uLhny6ha99gr2DSUKZtNnCL+RGrlNx0P1cwReMXJoysjie ljoQ== X-Gm-Message-State: AOAM532kefKYhFoNEmh5inYhD4cSoJ59MT+jrO4nX9DhpzK4BR2P0q7o b2nmDEp1/atFwuZoAJ832ni0iUvtZsIJFwxo/SowvA== X-Received: by 2002:a17:907:168a:b0:6da:9177:9fdd with SMTP id hc10-20020a170907168a00b006da91779fddmr2232289ejc.757.1648683800778; Wed, 30 Mar 2022 16:43:20 -0700 (PDT) MIME-Version: 1.0 References: <20220328195936.82552-1-nicolas.dufresne@collabora.com> <20220328195936.82552-23-nicolas.dufresne@collabora.com> <20220330075913.wfl3prsyw5fvsv4t@basti-XPS-13-9310> <4740735d92c0dac3708aa922b3d73db7a61fbdda.camel@collabora.com> In-Reply-To: <4740735d92c0dac3708aa922b3d73db7a61fbdda.camel@collabora.com> From: Ezequiel Garcia Date: Wed, 30 Mar 2022 20:43:08 -0300 Message-ID: Subject: Re: [PATCH v1 22/24] media: hantro: h264: Make dpb entry management more robust To: Nicolas Dufresne Cc: Sebastian Fricke , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Collabora Kernel ML , Jonas Karlman , linux-media , "open list:ARM/Rockchip SoC..." , "open list:STAGING SUBSYSTEM" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 30, 2022 at 12:16 PM Nicolas Dufresne wrote: > > Le mercredi 30 mars 2022 =C3=A0 09:59 +0200, Sebastian Fricke a =C3=A9cri= t : > > Hey Nicolas, > > > > On 28.03.2022 15:59, Nicolas Dufresne wrote: > > > From: Jonas Karlman > > > > > > The driver maintains stable slot location for reference pictures. Thi= s > > > > s/slot location/slot locations/ > > > > > change makes the code more robust by using the reference_ts as key an= d > > > by marking all entries invalid right from the start. > > > > > > Signed-off-by: Jonas Karlman > > > Signed-off-by: Nicolas Dufresne > > > --- > > > drivers/staging/media/hantro/hantro_h264.c | 10 ++++------ > > > 1 file changed, 4 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/staging/media/hantro/hantro_h264.c b/drivers/sta= ging/media/hantro/hantro_h264.c > > > index 228629fb3cdf..7377fc26f780 100644 > > > --- a/drivers/staging/media/hantro/hantro_h264.c > > > +++ b/drivers/staging/media/hantro/hantro_h264.c > > > @@ -258,8 +258,7 @@ static void prepare_table(struct hantro_ctx *ctx) > > > static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a, > > > const struct v4l2_h264_dpb_entry *b) > > > { > > > - return a->top_field_order_cnt =3D=3D b->top_field_order_cnt && > > > - a->bottom_field_order_cnt =3D=3D b->bottom_field_order_cnt= ; > > > + return a->reference_ts =3D=3D b->reference_ts; > > > } > > > > > > static void update_dpb(struct hantro_ctx *ctx) > > > @@ -273,13 +272,13 @@ static void update_dpb(struct hantro_ctx *ctx) > > > > > > /* Disable all entries by default. */ > > > for (i =3D 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++) > > > - ctx->h264_dec.dpb[i].flags &=3D ~V4L2_H264_DPB_ENTRY_FLAG= _ACTIVE; > > > + ctx->h264_dec.dpb[i].flags =3D 0; > > > > Ehm ... we just remove all flags? Can't this have any unwanted side > > effects like removing a flag that we actually wanted to keep? > > (Like long term or the field flags?) > > This is a local copy of the dpb, the DPB is fully passed for every decode= . So > these flags will be fully restored lower when we copy the found entry. In= fact, > holding a state here would not represent well the userland intention and = can > have negative side effect on the decoding. Flags are not immutable betwee= n > decode and can change. This simplify the code, and make things less error= prone. > This part of the code is already a bit complex, no need for an extra laye= r. > > > If we just want to set the DPB entry inactive, then removing the ACTIVE > > flag seems like the correct approach to me. > > If we want to get rid of the VALID flag as well, then we could just do: > > ctx->h264_dec.dpb[i].flags &=3D > > ~(V4L2_H264_DPB_ENTRY_FLAG_ACTIVE | V4L2_H264_DPB_ENTRY_FLAG_VAL= ID); > > > > In case we really want to reset all flags, I'd say adjust the comment > > above it: > > ``` > > - /* Disable all entries by default. */ > > + /* Reset the flags for all entries by default. */ > > ``` > > This reads the same to me, but I can do that yes. understand that VALID m= eans > the reference exist and the TS should point to some existing past referen= ce > (unless there was some decode error, which the userland may not be aware = yet as > this is asynchronous). While ACTIVE means that it is used as a reference.= FFMPEG > is known not to filter inactive references. ACTIVE is just a flag without= bunch > of other flags that can change for every decode. So none of this make sen= se > between 2 decodes. > Please leave the comment as-is, 'Disable all entries' is readable. As much as I'd love to have very clear comments everywhere, we have to accept that only people with insight on codec details are expected to make sense of driver details :-) Thanks, Ezequiel