Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp820268pxb; Fri, 22 Apr 2022 11:53:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHo434TNCLOcKOLJYVbZKN1TvEXv/KwJ8UNdviKCTIPLg9qF45q1xKfU5C0B0P2Tvs91Wj X-Received: by 2002:a17:903:124a:b0:154:c7a4:9374 with SMTP id u10-20020a170903124a00b00154c7a49374mr5960804plh.68.1650653618681; Fri, 22 Apr 2022 11:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650653618; cv=none; d=google.com; s=arc-20160816; b=ik4moOjlffrnejTwYfJTORS62OtChWN4LRfRBag1L0FdSZtGD9hsBxupMgEUaWKXtl JiTYbu3UB41aVxRa4GKtlk3ITkMVw+CZIVN6MknR8VY4J1xpkzYH87A3DHscC3ZoCYL9 gIi+iT5SnwNbBOQmki2dBvkmS9EKaY3V8PdbDlTdkXNKyzmx2569c9JwrE6Y7uLOLjmp SwpW1xfEmU5blZw0bqU0EVbsFCVz9eGsXp4sODEGjByxmrvB+YxtxG5gk5xNWZtNQ4sX L/7I0trMKYmPRPra7W76F23dxpntyWyF7mUXmZpqbCiyw14YsqgYn9m0L8ly42A3kwle g4Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=R00wOORvoEBOkmuaNq+alfQZnUrmpz8ZW//N44DSsR4=; b=FMdWkwLOCPuNVkDeExx9HjHUNtULdNhY/xNKegB+l2z9RaFf527O9dA1YuLx7DfmM0 Zmg5sR1fpL+wg2eMGgwLAi8slwomDH1K+oqnTsMc5gpykkd6+/oyZ9mCUsPcbKCCGiAO 19OMRWnl2mN2UMNxoRadvG7bFW776kTCHwUqLEDVh0XuvHy+S1f+sbDLq9/5ObFP+4uP crD4OPR/9ea0ABVZ9c1KnyJtRJrRmpW3g407YlU5CoJPTvNlH5+48QyKeiBfUCuLkCyq iwNOAIFkDsnX3HQ1SzXmtM5JP1u6nKUuUBD3yp1aFvBXQ6IDRXQKdK2FBONmuT+HTHu+ gHcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g14-20020a056a001a0e00b004fab5b929fasi8897482pfv.21.2022.04.22.11.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:53:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D20AE17DA09; Fri, 22 Apr 2022 11:17:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444791AbiDVH3e (ORCPT + 99 others); Fri, 22 Apr 2022 03:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241347AbiDVH3b (ORCPT ); Fri, 22 Apr 2022 03:29:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A09F25132C; Fri, 22 Apr 2022 00:26:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 375F161EF0; Fri, 22 Apr 2022 07:26:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 758A4C385A0; Fri, 22 Apr 2022 07:26:36 +0000 (UTC) Message-ID: Date: Fri, 22 Apr 2022 09:26:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 09/24] media: v4l2: Trace calculated p/b0/b1 initial reflist Content-Language: en-US To: Nicolas Dufresne , Mauro Carvalho Chehab Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, Sebastian Fricke , linux-media@vger.kernel.org References: <20220405204426.259074-1-nicolas.dufresne@collabora.com> <20220405204426.259074-10-nicolas.dufresne@collabora.com> From: Hans Verkuil In-Reply-To: <20220405204426.259074-10-nicolas.dufresne@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 On 05/04/2022 22:44, Nicolas Dufresne wrote: > Add debug print statements to print the content of P & B reference > lists, to verify that the ordering of the generated reference lists is > correct. This is especially important for the field decoding mode, > where sorting is more complex. > > Signed-off-by: Nicolas Dufresne > Tested-by: Sebastian Fricke > Reviewed-by: Sebastian Fricke > --- > drivers/media/v4l2-core/v4l2-h264.c | 86 +++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c > index 38d8dbda0045..bcf9b7774560 100644 > --- a/drivers/media/v4l2-core/v4l2-h264.c > +++ b/drivers/media/v4l2-core/v4l2-h264.c > @@ -241,6 +241,87 @@ static int v4l2_h264_b1_ref_list_cmp(const void *ptra, const void *ptrb, > return poca < pocb ? -1 : 1; > } > > +static char ref_type_to_char (u8 ref_type) Spurious space before (. Odd that checkpatch didn't catch that. > +{ > + switch (ref_type) { > + case V4L2_H264_FRAME_REF: > + return 'f'; > + case V4L2_H264_TOP_FIELD_REF: > + return 't'; > + case V4L2_H264_BOTTOM_FIELD_REF: > + return 'b'; > + } > + > + return '?'; > +} > + > +static const char *format_ref_list_p(const struct v4l2_h264_reflist_builder *builder, > + struct v4l2_h264_reference *reflist, > + char *out_str, const int len) > +{ > + int n = 0, i; > + > + n += snprintf(out_str + n, len - n, "|"); > + > + for (i = 0; i < builder->num_valid; i++) { > + /* this is pic_num for frame and frame_num (wrapped) for field, > + * but for frame pic_num is equal to frame_num (wrapped). > + */ > + int frame_num = builder->refs[reflist[i].index].frame_num; > + bool longterm = builder->refs[reflist[i].index].longterm; > + > + n += scnprintf(out_str + n, len - n, "%i%c%c|", > + frame_num, longterm ? 'l' : 's', > + ref_type_to_char (reflist[i].fields)); > + } > + > + return out_str; > +} > + > +static void print_ref_list_p(const struct v4l2_h264_reflist_builder *builder, > + struct v4l2_h264_reference *reflist) > +{ > + char buf[1024]; > + > + pr_debug("ref_pic_list_p (cur_poc %u%c) %s\n", > + builder->cur_pic_order_count, > + ref_type_to_char(builder->cur_pic_fields), > + format_ref_list_p(builder, reflist, buf, sizeof(buf))); > +} > + > +static const char *format_ref_list_b(const struct v4l2_h264_reflist_builder *builder, > + struct v4l2_h264_reference *reflist, > + char *out_str, const int len) > +{ > + int n = 0, i; > + > + n += snprintf(out_str + n, len - n, "|"); > + > + for (i = 0; i < builder->num_valid; i++) { > + int frame_num = builder->refs[reflist[i].index].frame_num; > + u32 poc = v4l2_h264_get_poc(builder, reflist + i); > + bool longterm = builder->refs[reflist[i].index].longterm; > + > + n += scnprintf(out_str + n, len - n, "%i%c%c|", > + longterm ? frame_num : poc, > + longterm ? 'l' : 's', > + ref_type_to_char(reflist[i].fields)); > + } > + > + return out_str; > +} > + > +static void print_ref_list_b(const struct v4l2_h264_reflist_builder *builder, > + struct v4l2_h264_reference *reflist, u8 list_num) > +{ > + char buf[1024]; I really don't like placing 1024 bytes on the stack. Can you find another way of doing this? Perhaps using pr_cont or writing each format_ref_list item on a separate line. Regards, Hans > + > + pr_debug("ref_pic_list_b%u (cur_poc %u%c) %s", > + list_num, builder->cur_pic_order_count, > + ref_type_to_char (builder->cur_pic_fields), > + format_ref_list_b(builder, reflist, buf, sizeof(buf))); > +} > + > /** > * v4l2_h264_build_p_ref_list() - Build the P reference list > * > @@ -261,6 +342,8 @@ v4l2_h264_build_p_ref_list(const struct v4l2_h264_reflist_builder *builder, > sizeof(builder->unordered_reflist[0]) * builder->num_valid); > sort_r(reflist, builder->num_valid, sizeof(*reflist), > v4l2_h264_p_ref_list_cmp, NULL, builder); > + > + print_ref_list_p(builder, reflist); > } > EXPORT_SYMBOL_GPL(v4l2_h264_build_p_ref_list); > > @@ -296,6 +379,9 @@ v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder, > if (builder->num_valid > 1 && > !memcmp(b1_reflist, b0_reflist, builder->num_valid)) > swap(b1_reflist[0], b1_reflist[1]); > + > + print_ref_list_b(builder, b0_reflist, 0); > + print_ref_list_b(builder, b1_reflist, 1); > } > EXPORT_SYMBOL_GPL(v4l2_h264_build_b_ref_lists); >