Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1232396pxb; Fri, 1 Apr 2022 08:02:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziVMOCOD3wLPmgHTo/o/UjK8xuqeAGJDQdvgDwiAqohQROZkFuJumfZPCLs4sdHmXKo/X3 X-Received: by 2002:a17:907:9811:b0:6df:f50e:47a0 with SMTP id ji17-20020a170907981100b006dff50e47a0mr235036ejc.124.1648825352242; Fri, 01 Apr 2022 08:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648825352; cv=none; d=google.com; s=arc-20160816; b=uBdCVSypdGNwVkKSGmyu59YOsfHlbi2teoqaP5uD67Zpb7PwMnnxvtFMEeRq8mYIJh 9mDEVXT/WwcMrYGWVrazbL2zXdcS2kB1pQTZjbGgokhMYatWQiK/sVbrEzxYjfjkSgt4 9qwSILO/fivcRRhFw9e+RJk6YogumKjBTqp8g8K6QK48KyLhaxuJuFuTV89cKSSEE48V zkiLdaX0oEEnykmsha27EuubLMd2YXzLFvzhTHcRPfLEs7V/FOUm96sRYj4cqtyd31F+ zOjVGC1J8w6qhcFZK1orGubMlSyMiiYnQGlY7hcrsvEQ2/wzKPwqf2TilW4/6Mp+BvL3 iLag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R6FaE7qZsNiMmCPa+kv9ghDx9FLWWjpS2nGg14cqaYs=; b=bOEUy9dxedADju+/+bdX+We8au8OjgN0jC/gJksvgmsFeMH3Waz1TYG0oX6vpp4sqY Bt8+vpbyBc/3mA9AU8Cr3zyEFuBxhXGOSsK2TpJTMihXcARmgki0dNa2Ram96vZ5q47Q CeXix2jU0cAMT2PkpwSlPPcrSq+fYUwU5wATRYstApHvvus6Ds5UYd2bEu4FTI2VNuB6 DsmZTkteHfpUj/I6BN0b+aAFsGpe8z3T4xkMp9yVdpZ+9T5pwvA9znxTqhXlkZUXyRV4 Emwty8NMrzbEir1bJQE96yP/4yTvThsm/kfEYLqt+424BwMAsX5xnlq8dPyH8mXki8h4 HpOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=E2gxoqJY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a056402510a00b00418d6c3d730si2112993edd.253.2022.04.01.08.01.58; Fri, 01 Apr 2022 08:02:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=E2gxoqJY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241063AbiCaTlM (ORCPT + 99 others); Thu, 31 Mar 2022 15:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241060AbiCaTkP (ORCPT ); Thu, 31 Mar 2022 15:40:15 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413492414D1; Thu, 31 Mar 2022 12:38:12 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id C572A1F47264 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648755491; bh=XEgENTYjCMT2Anghn2qsNUIMLssrmzXSWUAtGOk2EIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E2gxoqJYVViah1bnCh0Ns/I6N5AWWkUGJ5pwWF1M2iGOkatQdu7HYSfXKLCPR6Vjs CIOdDSZTD8YGL/O0L0HIIUraQV/W+PS2aZqG0ebyX3gYmT0hnDmMfbqpGI4DIX6HgC +CXc0sS+dZYb/4sDd8TzDpDaTyiBaREh+L3XbxjKYDjZTHJGx8q+UWB290VIDhPwvO bqKYSgcQr5KZ7ycx3sB7ZR4Cp+0a9HHvql1YJ7trdLRBLGv6ZvzHqSXVGH3FI4qSNC kq2I4PWNBc6HPvyPsvZvKya5e2900uSShQ/0cLwh2RVgLekIsUANMF8sKfvUT1yfBK HeSQf8SQMqmMg== From: Nicolas Dufresne To: Ezequiel Garcia , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman Cc: kernel@collabora.com, Jonas Karlman , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 22/23] media: hantro: h264: Make dpb entry management more robust Date: Thu, 31 Mar 2022 15:37:24 -0400 Message-Id: <20220331193726.289559-23-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220331193726.289559-1-nicolas.dufresne@collabora.com> References: <20220331193726.289559-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham 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 From: Jonas Karlman The driver maintains stable slot locations for reference pictures. This change makes the code more robust by using the reference_ts as key and 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/staging/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 == b->top_field_order_cnt && - a->bottom_field_order_cnt == b->bottom_field_order_cnt; + return a->reference_ts == 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 = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++) - ctx->h264_dec.dpb[i].flags &= ~V4L2_H264_DPB_ENTRY_FLAG_ACTIVE; + ctx->h264_dec.dpb[i].flags = 0; /* Try to match new DPB entries with existing ones by their POCs. */ for (i = 0; i < ARRAY_SIZE(dec_param->dpb); i++) { const struct v4l2_h264_dpb_entry *ndpb = &dec_param->dpb[i]; - if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) + if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID)) continue; /* @@ -290,8 +289,7 @@ static void update_dpb(struct hantro_ctx *ctx) struct v4l2_h264_dpb_entry *cdpb; cdpb = &ctx->h264_dec.dpb[j]; - if (cdpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE || - !dpb_entry_match(cdpb, ndpb)) + if (!dpb_entry_match(cdpb, ndpb)) continue; *cdpb = *ndpb; -- 2.34.1