Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp372269pxa; Fri, 14 Aug 2020 06:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziduMxIInqtHuX7+VxqEjZ5D28CK440nRlu0urEtDo5Ml6/N9mWk09uZANlRxyWOlZWlp6 X-Received: by 2002:a17:906:1e85:: with SMTP id e5mr2422275ejj.76.1597412588391; Fri, 14 Aug 2020 06:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597412588; cv=none; d=google.com; s=arc-20160816; b=BJesSxmLX+nMwnDW2SQ/IaRd/zyIwJmZXxld6xaAyl7ukiwT2VoXgjvDRHFtEwqYnc W5PeuPdqCQYzaCtYfp3cIgChxElEmzONPekLAAKwlja8qgGEjECZKFF+XWq6Rq9VBr7D 8fCp/7Yk2/pRR6Ji46tBLjHhxH5dtcIqflF1fme30x09dZMSdohSMmZfxRSJl1PQPD7s UTVcnLS5hFPque5Ue+T3S3DKkYyFEQ8oImCbRy2F1Fh22uzSc0jOq6TIk93Nhf4kfc+b Ouy7Rh9h4wzzqVFHzdWX65ZBpUYzkxVCU6CsZ76ep/hFIRvWMAhR0wZB6fKuLYBY4UTR xQdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QNxw/4l7nPyv/w32rVweG/YWELLLcawJc6jaMeRsJi8=; b=dTNZmS8lHra0XLIqaOjW2XhtLe9pqUF1cq9yiedOpPBv0aZUyXmXb/12g2l5JOrw7M mFqe12qCmx/3XF8H7HCYPBCC5A9CoRoH1CBs4ShoU5ePh/r1FKtiyaE34GkJ/YzBpvWD PH0xfVkc1tw5OfFuVoV8o/1OVN8009o0N5iHqaSLrSmTzkuumCze5i8fl6cwTFci2rqn ypRpGubTlPVpZ1PB6eT3nwT4vrtg1QdtcVs7x8J46QL3zo/HEx+GsmFyA4ecS1a4pqYF fXGQO2JHL1uYCa8FceR+piLRqT3BPGxsp6JDuQedxw1Zms7Tb3foVPS9FG+S3XvTiUlV KDQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g13si5250535edu.319.2020.08.14.06.42.45; Fri, 14 Aug 2020 06:43:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728219AbgHNNiV (ORCPT + 99 others); Fri, 14 Aug 2020 09:38:21 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43406 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbgHNNhx (ORCPT ); Fri, 14 Aug 2020 09:37:53 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id F14A429A7D6 From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tomasz Figa , kernel@collabora.com, Jonas Karlman , Hans Verkuil , Alexandre Courbot , Jeffrey Kardatzke , Nicolas Dufresne , Philipp Zabel , Maxime Ripard , Paul Kocialkowski , Jernej Skrabec Subject: [PATCH v3 15/19] media: cedrus: h264: Fix frame list construction Date: Fri, 14 Aug 2020 10:36:30 -0300 Message-Id: <20200814133634.95665-16-ezequiel@collabora.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200814133634.95665-1-ezequiel@collabora.com> References: <20200814133634.95665-1-ezequiel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jernej Skrabec 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 1e89a8438f36..fe041b444385 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h264.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h264.c @@ -101,7 +101,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); @@ -124,6 +124,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; @@ -131,13 +136,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); -- 2.27.0