Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1621904pxb; Wed, 30 Mar 2022 07:14:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRar9YFHpcrInwlRTwFVj/j+X6kyGflzi0IVvalv7K1lD6pavi2sA3M2uLJimWp7tfhJeS X-Received: by 2002:a17:907:1c0c:b0:6e0:9b15:29d5 with SMTP id nc12-20020a1709071c0c00b006e09b1529d5mr32966014ejc.416.1648649643009; Wed, 30 Mar 2022 07:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648649643; cv=none; d=google.com; s=arc-20160816; b=Wr9Hw0VuYcNMudAX9OjlaMCrqMj1JmrGZO4o9WHL7r/F3ExjVoxydfGj/BKlUlNnwj GQgC6gX1zoM+xjr43Ig0G5isLXhov1oMQOHvJ3TX5uQH40nc2aweh52GFwynFermUITe duOQi6nAmOyiNQ25XzbHRz8AC2037KxAAJintf64YqlZh16swIQSK8PkEnv25GKc9EpE QRkhjv2jCoBQDJTVVLjaAzesjQNwZm46TKZxT1ZLB0VsdVY+uDSYeEKwWPxft3rJf3pY 8n6ZYMeJL5b84s/FoMkatxkLTJJ5DIcdIq8n2jR4tOhNCx0Ndd+G0lq4L4O/xPUFCWki ItLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HHO69iPHA6PNfgqwMj8ruMCXHWVVFh+ogWNB1+O2+Cg=; b=TRu0QMAoT2HOVbNPGqho0okQb1UDShxZB1xF8S1qEKNxlV3sxvl0dYgSkycnxIrWFx kYRdXjHOH4KaQm66+Ycs3KHUIZtBuHFLxwxhOZcaR/oac/EHsf0YNDUkq551oltY3g3z GKh4UCvhjVACFiz/OkaAZzAfJs0OY2jIWjS7ys4IdX94ghTvbJKE4ldhhfmhBmfEcru/ W72gy8aQN7mGZGAV6QAHq9oNZ0f6JPZIsxWbC7SQSwfOFk/A2GG8yosaiQnAKyabd9MG uZhBHCz3HtpxKbqXIbeQRBwrtzcuSMOrOvjSNoxxtjtwc0yKbJYfKX8uEzt8AXna/Z9o HMVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Cjo6B7GB; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a1709066d5a00b006df9363ea5asi20590010ejt.483.2022.03.30.07.13.36; Wed, 30 Mar 2022 07:14:02 -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=@collabora.com header.s=mail header.b=Cjo6B7GB; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237583AbiC2Nz6 (ORCPT + 99 others); Tue, 29 Mar 2022 09:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237561AbiC2Nzx (ORCPT ); Tue, 29 Mar 2022 09:55:53 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C74BF1C7C3B; Tue, 29 Mar 2022 06:54:08 -0700 (PDT) Received: from localhost (unknown [IPv6:2a02:3030:a:f397:f6bc:b726:2678:839f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sebastianfricke) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 244CD1F43F35; Tue, 29 Mar 2022 14:54:07 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648562047; bh=8B1qrSJI0pwevUCYKVB5QvEM9Cz4zIGrfiS9YCQ8xWM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Cjo6B7GBuagdrECvYXJwN4E9sG+lit31ck1eIlwF6q7cHMEtMXpmAIjQ4l7cTHAIW hNnpYA2UimzcJtad2wFPaNAU7lP6BehiEuQ4rXVLVGSbJ7Lp1cZJNlLC7Scq7z2SvE 6vAsgz3twqcVWyI3QEWw0lFuoa0TSZ5cH+t146TedABssSbsUcOqLhXYl2uDUEYuJ1 UFAaIt8TKHh4+YzbK09VT2yk5MhgVvI5XFNuS/epQuAsJKtnAH/w1WDUA95xyEwmkL i6Iaz01DtPOQm0OIEStaWw7JvMwmwaHXgj8shvu3wPHe/dr5+bVV3jmt9OwDVGq1Xv pqTOsw8zpHbMg== Date: Tue, 29 Mar 2022 15:54:03 +0200 From: Sebastian Fricke To: Nicolas Dufresne Cc: Mauro Carvalho Chehab , kernel@collabora.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 08/24] media: v4l2: Reorder field reflist Message-ID: <20220329135403.37dqfaw5ctxoj3wx@basti-XPS-13-9310> References: <20220328195936.82552-1-nicolas.dufresne@collabora.com> <20220328195936.82552-9-nicolas.dufresne@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <20220328195936.82552-9-nicolas.dufresne@collabora.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 Hey Nicolas, On 28.03.2022 15:59, Nicolas Dufresne wrote: >As per spec, the field refslist requires interleaving top and bottom In other patches you call it always field reflist, so I'd say let's stick to that: s/field refslist/field reflist/ >field in a specific way that does not fit inside the sort operation. >Reorder in-place the references so that their parity sart with the same >parity as the current picture and do that for both short and longterm >references separately. I find that sentence hard to understand, is this maybe better: """ Rearrange the references in place so that their parity matches that of the current image, and do this separately for both short- and long-term references. """ > >Signed-off-by: Nicolas Dufresne Reviewed-by: Sebastian Fricke >--- > drivers/media/v4l2-core/v4l2-h264.c | 45 +++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > >diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c >index c3fad382882d..2f7ee8d5479f 100644 >--- a/drivers/media/v4l2-core/v4l2-h264.c >+++ b/drivers/media/v4l2-core/v4l2-h264.c >@@ -243,6 +243,43 @@ static int v4l2_h264_b1_ref_list_cmp(const void *ptra, const void *ptrb, > return poca < pocb ? -1 : 1; > } > >+/* >+ * The references need to be reorder so that reference are alternating between s/to be reorder/to be reordered/ s/ so that reference/, so that references/ >+ * top and bottom ref starting with the current picture parity. This have to be s/bottom ref/bottom field references/ s/This have to be/This has to be/ >+ * done for short term and long term references separately. >+ */ >+static void reorder_field_reflist(const struct v4l2_h264_reflist_builder *b, >+ struct v4l2_h264_reference *reflist) >+{ >+ struct v4l2_h264_reference tmplist[V4L2_H264_REF_LIST_LEN]; >+ u8 lt, i = 0, j = 0, k = 0; >+ >+ memcpy(tmplist, reflist, sizeof(tmplist[0]) * b->num_valid); >+ >+ for (lt = 0; lt <= 1; lt++) { >+ do { >+ for (; i < b->num_valid && b->refs[tmplist[i].index].longterm == lt; i++) { >+ if (tmplist[i].fields == b->cur_pic_fields) { >+ reflist[k] = tmplist[i]; >+ k++; >+ i++; You can just say: `reflist[k++] = tmplist[i++];` >+ break; >+ } >+ } >+ >+ for (; j < b->num_valid && b->refs[tmplist[j].index].longterm == lt; j++) { >+ if (tmplist[j].fields != b->cur_pic_fields) { >+ reflist[k] = tmplist[j]; >+ k++; >+ j++; Same here: `reflist[k++] = tmplist[j++];` Greetings, Sebastian >+ break; >+ } >+ } >+ } while ((i < b->num_valid && b->refs[tmplist[i].index].longterm == lt) || >+ (j < b->num_valid && b->refs[tmplist[j].index].longterm == lt)); >+ } >+} >+ > static char ref_type_to_char (u8 ref_type) > { > switch (ref_type) { >@@ -345,6 +382,9 @@ v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder, > sort_r(reflist, builder->num_valid, sizeof(*reflist), > v4l2_h264_p_ref_list_cmp, NULL, builder); > >+ if (builder->cur_pic_fields != V4L2_H264_FRAME_REF) >+ reorder_field_reflist(builder, reflist); >+ > print_ref_list_p(builder, reflist); > } > EXPORT_SYMBOL_GPL(v4l2_h264_build_p_ref_list); >@@ -378,6 +418,11 @@ v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder, > sort_r(b1_reflist, builder->num_valid, sizeof(*b1_reflist), > v4l2_h264_b1_ref_list_cmp, NULL, builder); > >+ if (builder->cur_pic_fields != V4L2_H264_FRAME_REF) { >+ reorder_field_reflist(builder, b0_reflist); >+ reorder_field_reflist(builder, b1_reflist); >+ } >+ > if (builder->num_valid > 1 && > !memcmp(b1_reflist, b0_reflist, builder->num_valid)) > swap(b1_reflist[0], b1_reflist[1]); >-- >2.34.1 >