Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2940074rwb; Mon, 15 Aug 2022 14:29:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR7pFeN/ilhYsq/gGO1QENKQ8xXahmcb0RjpbEKaOzGrwsxhG1YDCgK9wQgL8kIp+PefYQE/ X-Received: by 2002:a63:1ce:0:b0:41c:6c25:5ae with SMTP id 197-20020a6301ce000000b0041c6c2505aemr15372578pgb.155.1660598954556; Mon, 15 Aug 2022 14:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598954; cv=none; d=google.com; s=arc-20160816; b=tmGQJcrN9PG5ZnCZL4V99IzAVRU1ouc8/tR4a/zIcEtvyrCxhakVT/xxCTYw/7qdDr gn9izQsKgIjzDGw0J5xpcVQdpMRoOnFal+sIeAvLJKRcQ1nTSUsbERAxraOja4/8KSNu U1q3sJ8rLAzX2Nm9YGJlrfQAqYRPvYpPIGj3nc/iriLOz4gMm4Y0mmd/QFPSfc4I/egw HhUvf3V/buwxNFhnm7yrw6a3p3KS8419eMmeY6RDRTxFi2wFVCfPrM7fm7jpAp/9mh9/ HkRm/k2++10akqTlme4+55QF6sH2vXb2FOZeJeqnjQoCSQwxDNJOEt2sd87UqLWJsTey SiCQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FaGl0IN25mGlc/ltq3bHyhY0f4PlOt7n5rpFjbqborM=; b=q8UOTn9/3aVQbFGy1JgoPAuWPyaEnN6toqLZ6DLsjSU0a+IvCuKzUS6hicFR7Q7z99 DdhnVQFuQMCJm5OyFxCtgEi2tQN+txSpFdysHRt7AwDmp9fZ0wKq8GK68yEvmyDEmH+7 3DA08ZLb6zX9D6SgLnhcBlsBFMusSzWCfL1SoWnQS26ayRNP/dV9cSVBzzsW3fjmLn1o 7Ja9LlhLgSqau6NF+thJPd/jvLLRBf8y84B6Isa7UH+dypdSmLKcBnm7A39N+J77zw68 TPUhDYzCzo5AHmdlYr/Ma9jfo9VO5rvpm3S557/uon+kRmrYr738lPXiOa6d0cg8Y9Wi R4BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sxmx7lL7; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a635406000000b0041bd09a9c1dsi11585045pgb.536.2022.08.15.14.29.02; Mon, 15 Aug 2022 14:29:14 -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=@linuxfoundation.org header.s=korg header.b=sxmx7lL7; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345108AbiHOVZc (ORCPT + 99 others); Mon, 15 Aug 2022 17:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241696AbiHOVNs (ORCPT ); Mon, 15 Aug 2022 17:13:48 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36AF15722E; Mon, 15 Aug 2022 12:19:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 22873CE1087; Mon, 15 Aug 2022 19:19:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CF6CC433C1; Mon, 15 Aug 2022 19:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591183; bh=TMDXt7jtDWdicJEzEyNkxrX+6SxG2YI30o1x7P3pwRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sxmx7lL7I8vAFJ4dKQpqzq1bmOIQUSyho5MWMXU2CHkbWHUICTPBMA6nzAX6RSVT6 YG7eWiJY+hEMEWUHUmeBm2gBWrbHgou8aDbONGMNIjFGM3talGuu36l+c1yqRdRI1Y FJi1h/vPACKBuRHi01gAN5P9AaL22edTn9opLdk0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jernej Skrabec , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.18 0466/1095] media: cedrus: h265: Fix logic for not low delay flag Date: Mon, 15 Aug 2022 19:57:45 +0200 Message-Id: <20220815180448.886955062@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: Jernej Skrabec [ Upstream commit f1a413902aa71044b6ec41265e5e28ebaf29a9ce ] Now that we know real purpose of "not low delay" flag, logic for applying this flag should be fixed too. According to vendor and reference implementation, low delay is signaled when POC of current frame is lower than POC of at least one reference of a slice. Implement mentioned logic and invert it to conform to flag meaning. Also don't apply flag for I frames. They don't have any reference. This fixes decoding of 3 reference bitstreams. Fixes: 86caab29da78 ("media: cedrus: Add HEVC/H.265 decoding support") Signed-off-by: Jernej Skrabec Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- .../staging/media/sunxi/cedrus/cedrus_h265.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index c26e515d64c9..2f6404fccd5a 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -301,6 +301,31 @@ static void cedrus_h265_write_scaling_list(struct cedrus_ctx *ctx, } } +static int cedrus_h265_is_low_delay(struct cedrus_run *run) +{ + const struct v4l2_ctrl_hevc_slice_params *slice_params; + const struct v4l2_hevc_dpb_entry *dpb; + s32 poc; + int i; + + slice_params = run->h265.slice_params; + poc = run->h265.decode_params->pic_order_cnt_val; + dpb = run->h265.decode_params->dpb; + + for (i = 0; i < slice_params->num_ref_idx_l0_active_minus1 + 1; i++) + if (dpb[slice_params->ref_idx_l0[i]].pic_order_cnt_val > poc) + return 1; + + if (slice_params->slice_type != V4L2_HEVC_SLICE_TYPE_B) + return 0; + + for (i = 0; i < slice_params->num_ref_idx_l1_active_minus1 + 1; i++) + if (dpb[slice_params->ref_idx_l1[i]].pic_order_cnt_val > poc) + return 1; + + return 0; +} + static void cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run) { @@ -571,7 +596,7 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx, V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED, slice_params->flags); - if (decode_params->num_poc_st_curr_after == 0) + if (slice_params->slice_type != V4L2_HEVC_SLICE_TYPE_I && !cedrus_h265_is_low_delay(run)) reg |= VE_DEC_H265_DEC_SLICE_HDR_INFO1_FLAG_SLICE_NOT_LOW_DELAY; cedrus_write(dev, VE_DEC_H265_DEC_SLICE_HDR_INFO1, reg); -- 2.35.1