Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1012504pxb; Wed, 6 Apr 2022 06:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSyksGS8AntpWKoTGrxreKpa2dRRHihtqSnnEAX4g0Ta84LzRILUdIEz8XavF73i/aF2Le X-Received: by 2002:a17:902:aa46:b0:156:5651:1d55 with SMTP id c6-20020a170902aa4600b0015656511d55mr8974483plr.66.1649252556492; Wed, 06 Apr 2022 06:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252556; cv=none; d=google.com; s=arc-20160816; b=TeXxW/f6p9lGmQBkbGRRhvSQCJqiZXt2HbuqmkbT1+kmTlga3F6HBJKLYQa+BuGZ6F kg4wv2jLUlyXH1nnVA/hS+9j2YWd72kgy59ZWTtBwK55D3hgIY2tRBg2LyQ0KfAsTKBT I9RfTtOmXRaF2LqGDQJL+wN+eFdY9yt3VKnAwT1mKsNmwLGo6TuIOUqaYlSocqkEgIJO Vqbdp5GXlgsw68qzlWu6J309VqW875kJoqSr6RgCoQuVC260cH9Zam7AkU2/+ZTOrm25 nYUC8YE+Q8q5GY3SXdflYm5b+FKNajwuSnDmD5wPSTXHDUf5Qf5YuOXKoCpBk/LSp4CV bHxA== 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=JnChPp9DfOqXBFGceCUojHUe4sbmTb/yutF2aJ+S/M2cThmSKWAfliX3hk8TN23jia vkWEY3hlFsld7OuL2dgcTmYc2gL55O8JErhwkhpLMwxgTiZ0uhU62+5werQsmiByZpxM h5M5kGDFpaJMuFnYwO2x5uzMvnOri9bAoqfTBpmwpYIuDc/FsJ2q9fgH3zuZFeUn0TAh yoM1DHdJuYXGb1WAVwhQbgYvExfEE5i6EG+BYox3gt8WbXs5eUDS09m8QrcaIAzBYfYB tmkPR6zZ8Rm8TXjf9FhQOAfk0lJqc+ogsEzwvzppF9whokS4kA57Hq7KZZauDGyndeC/ 9Iaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=K00DBOR7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b22-20020a63d316000000b00399599c54ffsi6094764pgg.252.2022.04.06.06.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=K00DBOR7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 79A5D55050D; Wed, 6 Apr 2022 04:30:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1849234AbiDFCeL (ORCPT + 99 others); Tue, 5 Apr 2022 22:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444275AbiDEWVC (ORCPT ); Tue, 5 Apr 2022 18:21:02 -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 A138BD4CA1; Tue, 5 Apr 2022 13:45:20 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: nicolas) with ESMTPSA id 564691F448BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649191519; bh=XEgENTYjCMT2Anghn2qsNUIMLssrmzXSWUAtGOk2EIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K00DBOR7Hvo/9zOUg7lYZRuUhYH5gu6hpMp8+CwehK8Ew1thRyoPeXAzuCfW48OG6 ERjNW2T+FmscAkYBw4+LBX0ucFvMjMrALKymQ+f7r+zk/D+OzGNZSv8rEr1LZ1+PVS nXnhCh/EpGCqxJFtGFDm7J26poJEv2y0YMfFzr8NYw7McU3FOqMJzAl+rXkpYzgBjg xkVrnWorKFnYYHovlQlgUosTLSYopg3Nk/CQUFqQF2V0/PAMww4HO9rvzBdFnjyLUt E3yfI0Y53pG3khoL8RIpZULurg+lLoYACu1ExDNT4rllT7Y0tSS+gYUlVbXq9lzWr9 io3mWn9lF1Krg== From: Nicolas Dufresne To: Ezequiel Garcia , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, Jonas Karlman , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-staging@lists.linux.dev Subject: [PATCH v3 22/24] media: hantro: h264: Make dpb entry management more robust Date: Tue, 5 Apr 2022 16:44:23 -0400 Message-Id: <20220405204426.259074-23-nicolas.dufresne@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220405204426.259074-1-nicolas.dufresne@collabora.com> References: <20220405204426.259074-1-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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 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