From patchwork Thu Jun 4 18:57:45 2020 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: 11588253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78121912 for ; Thu, 4 Jun 2020 18:55:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66C942063A for ; Thu, 4 Jun 2020 18:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729178AbgFDSzY (ORCPT ); Thu, 4 Jun 2020 14:55:24 -0400 Received: from mailoutvs56.siol.net ([185.57.226.247]:52722 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729141AbgFDSzX (ORCPT ); Thu, 4 Jun 2020 14:55:23 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id 77EC0521370; Thu, 4 Jun 2020 20:55:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta10.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta10.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 22HNnnPf64Hw; Thu, 4 Jun 2020 20:55:20 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 2AD98521295; Thu, 4 Jun 2020 20:55:20 +0200 (CEST) Received: from kista.localdomain (cpe-194-152-20-232.static.triera.net [194.152.20.232]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id D2A915211F9; Thu, 4 Jun 2020 20:55:17 +0200 (CEST) From: Jernej Skrabec To: paul.kocialkowski@bootlin.com, mripard@kernel.org Cc: mchehab@kernel.org, wens@csie.org, hverkuil-cisco@xs4all.nl, gregkh@linuxfoundation.org, jonas@kwiboo.se, nicolas@ndufresne.ca, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] media: cedrus: h264: Fix frame list construction Date: Thu, 4 Jun 2020 20:57:45 +0200 Message-Id: <20200604185745.23568-4-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200604185745.23568-1-jernej.skrabec@siol.net> References: <20200604185745.23568-1-jernej.skrabec@siol.net> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Current frame list construction algorithm assumes that decoded image will be output into its own buffer. That is true for progressive content but not for interlaced where each field is decoded separately into same buffer. Fix that by checking if capture buffer is listed in DPB. If it is, reuse it. Signed-off-by: Jernej Skrabec --- drivers/staging/media/sunxi/cedrus/cedrus_h264.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c index c87717d17ec5..4f79386315ae 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -102,7 +102,7 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx, struct cedrus_dev *dev = ctx->dev; unsigned long used_dpbs = 0; unsigned int position; - unsigned int output = 0; + int output = -1; unsigned int i; cap_q = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE); @@ -125,6 +125,11 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx, position = cedrus_buf->codec.h264.position; used_dpbs |= BIT(position); + if (run->dst->vb2_buf.timestamp == dpb->reference_ts) { + output = position; + continue; + } + if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) continue; @@ -132,13 +137,11 @@ static void cedrus_write_frame_list(struct cedrus_ctx *ctx, dpb->top_field_order_cnt, dpb->bottom_field_order_cnt, &pic_list[position]); - - output = max(position, output); } - position = find_next_zero_bit(&used_dpbs, CEDRUS_H264_FRAME_NUM, - output); - if (position >= CEDRUS_H264_FRAME_NUM) + if (output >= 0) + position = output; + else position = find_first_zero_bit(&used_dpbs, CEDRUS_H264_FRAME_NUM); output_buf = vb2_to_cedrus_buffer(&run->dst->vb2_buf);