From patchwork Mon Jun 20 17:55:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 12888010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99687C433EF for ; Mon, 20 Jun 2022 17:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uXeNLuMWCRbhF8rVlt8mpYlrurXoOlRnCFt+3Uzk6gk=; b=5FDNIdKvuEX9QR NI/snG2pXKM7hvu9vXLTP22vgjdOSwCMmFG2SggfKt6kXM/joolv6K0LBaa/XAjTN9VstqeS7K7U8 fZB202QcIvfsCvNbshsherFOt3rIC9pPY5PA+ChIqc9NbrNuocpKaLwbl4ftK1RNuBZfIXiO9wr/v v5nSEXsFVmkXWe7Kidd4CYqYCeaZrgq6OAUaB7FrGx5CV8atFVL99bJLOzj/qpk+s0SXlyxd/I19o g/WPUj9PDBLMsNokVMm71L4VTxevxZdcjBfqVtzJb4YIB35zVKHPMW+RBEHmurL/7FPXnF3xBXmdu +iZL8mu6I/YZVY7nvS8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3LdO-001hjO-42; Mon, 20 Jun 2022 17:56:22 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Lcc-001hPu-Rf for linux-arm-kernel@lists.infradead.org; Mon, 20 Jun 2022 17:55:36 +0000 Received: by mail-wr1-x432.google.com with SMTP id k22so9252593wrd.6 for ; Mon, 20 Jun 2022 10:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+lhmhRazPbCiO0ZinItgn/yvpq/qsLzRHWrKJfMBAU=; b=ij7bpM7fYgafh4dGUzxUNkZ8mBe+1r3nO44hxCPnlMgcixxMJdfdSiXAdXE15WMCLM AyrqEh6M+p4d899WbwMSR4K1RQjNL5aRVO7l3tv9cR9JLGot1WiSXOLEbiRltLC+RO2+ PjAB3k7Kmhb4cHJueB/5F93qKDW8F4c03ykyisyEAs0apL6U6sI8E697cwDod0mwN3OB iRbkQyuE5SLRr75UEpV1KHoFr/k0KJfHAUBxKLMz0XPxkZG6MRWzsCvWcR+/uX+N8LLy qmR7mEMzZ6RcUeYBNDp1NSaL/BxEowh8eAc0djSZXcY/U+/uqkn9eEPONFRPL2r8jtTR L0bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c+lhmhRazPbCiO0ZinItgn/yvpq/qsLzRHWrKJfMBAU=; b=W3biVvY9qRmxWKPnx70N7H+gA9gksQjdaR8Z+qhUB3irO74YXae5whbZgXYiGNCNBF gxZ27gjIH+py6s8MS+QwgXjqA6yS65ERVzl8G18QLZSX/CSaPP6owgM9o2JXwLuKlBva 1CJOxUAcgeIk+hpd1TBI/G9FaBM8IRv6gNg0nh++i989fjyAfE4zdXIskb34D3mx+4Hk rTpmCnLfm+26I586Uf99BNEqQTyK/jU13RME5pUrILCZ+SZr1U4dF/crHUrZb2VfmsDc Qf7qkAkYEaSO24p8MG4yfJmfQDZUP12qtgGXyIP+Fm41OCG9+BqMJCRZsdwjLsOGrRFg l+ZA== X-Gm-Message-State: AJIora/WQc55D87PEjHmqlQD3oZlykDOfEfSBqBHj7UASF8dlDdnampG 5VCYu5DS2iLZc22U9LX7Ec0= X-Google-Smtp-Source: AGRyM1ugVC+G+EV+zF7RaG1caUz4KMQyumBWu+cN6/oYPJe14QiJ+H9HFyA6JwaBXtZLXPwI5NYlbw== X-Received: by 2002:adf:f84b:0:b0:21b:8e43:b8ba with SMTP id d11-20020adff84b000000b0021b8e43b8bamr7141670wrq.155.1655747732210; Mon, 20 Jun 2022 10:55:32 -0700 (PDT) Received: from kista.localdomain (213-161-3-76.dynamic.telemach.net. [213.161.3.76]) by smtp.gmail.com with ESMTPSA id 184-20020a1c02c1000000b0039db31f6372sm19620752wmc.2.2022.06.20.10.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 10:55:31 -0700 (PDT) From: Jernej Skrabec To: mripard@kernel.org, paul.kocialkowski@bootlin.com, wens@csie.org, samuel@sholland.org Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 2/7] media: cedrus: h265: Fix logic for not low delay flag Date: Mon, 20 Jun 2022 19:55:12 +0200 Message-Id: <20220620175517.648767-3-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620175517.648767-1-jernej.skrabec@gmail.com> References: <20220620175517.648767-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220620_105534_913461_E45926A6 X-CRM114-Status: GOOD ( 14.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- .../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 9ee6f0f111e5..46119912c387 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) { @@ -588,7 +613,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);