From patchwork Tue Oct 10 02:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dai, Jianhui J" X-Patchwork-Id: 44219 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4e24:b0:15d:8365:d4b8 with SMTP id gk36csp1795494pzb; Mon, 9 Oct 2023 19:57:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF36xIOisJtbblh/WlCSRMZspCWeVaS73ZVor9QgOMKTvFJGhgkkBh/9ujICewGrqozNJRP X-Received: by 2002:a17:906:2d2:b0:9b9:ed52:8230 with SMTP id 18-20020a17090602d200b009b9ed528230mr11626709ejk.62.1696906621962; Mon, 09 Oct 2023 19:57:01 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id qk11-20020a1709077f8b00b009b9ee6b6b59si5032465ejc.978.2023.10.09.19.57.01; Mon, 09 Oct 2023 19:57:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=LKP57j9+; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73DCA68CA6D; Tue, 10 Oct 2023 05:56:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 95E0268C8E9 for ; Tue, 10 Oct 2023 05:56:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696906615; x=1728442615; h=from:to:subject:date:message-id: content-transfer-encoding:mime-version; bh=cJ4Xf3UIg/+N/Dcgj6llkUr74y4vEVOnLB8Ij4MAkTc=; b=LKP57j9+sRS3AtIeqNgzHUA8si8pxxSHxL+2r8OkbA5K1Xp8QWOkPnCf q8vDE71w6Z7F0o5+wd2e57iWj5dm4orqlRf6TTHC2EkSUXo9fKFbUQy0j gnNEwGu3wwBWYak2Si7CPGdp5v6ookuCVxXXXEbAkhcRh6EIJKy/tr6LD L+mCkHNhvjCfXcYJrjZKQxyYTbI0XoN67nbn/ymEFfa104KvIayF8cZe8 6jC6hJoDxKvwpoePkszGJft3GeVDUgGGPZNnAb+Ay1w7eUnouTsIONfIj 2Wj/ddb70clkYkIIgeFOzGDYKGgZEsbo64oVVpzAwt3wxW0SFSJdIJwLr g==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="374640719" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="374640719" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 19:56:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="753233762" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="753233762" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 09 Oct 2023 19:56:46 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Mon, 9 Oct 2023 19:56:46 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Mon, 9 Oct 2023 19:56:46 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Mon, 9 Oct 2023 19:56:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QT+Fw/teYTbl5rQvrUbWWVepLulk85/bJiFj93hvZ6vY4kZGzEy/P9hDZL/XyFyWAtAEthw6QEHzz80GuODzUFeL32696fMKsjMZLY+sahgtuToU3UCyggJ6I0gY8bjAfXTsXuDDAbL3UzvNj6r+fZm2rHEioBj7557ZKPmvxOGfT+xaImOABJOjTN+zEaBaXWeLNIyQt73kEwpjXMqTXcg7BhoOXj29+pP9/IHswSj0zsALoB8WU4oC+Elexwk1NIbhl6VJ0VtvQnN3DG+aafCT0dbKgOFw0WWrmVnW9qLZAi9DR93Cuz5IKwfHifsxxofZQncBylwcXoCfQIVEbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=C+OtazFxpi3k7Xis3IFT+gQ2+RbMjZmyZMRfo55Q3YU=; b=Lr7l1siHxqtHcgjN92d7lNnQR9GSvgnU7uOcNXVZiSfJl8U6Mgy2GF8hDbnlaFwMtJ8WrTZTCv3upAywMeYyP/3HN7JNxiJlvln8sb+r1nRARuWtBgBJ8Tue5cNeOsptSAuoIAlol8K5NOZ++H881pJ6Xlyx0met+4A91HfLrISKzzBLf6an5mS6VdepERuKJfI5wgRtvmgv4Dk7rBPmBrxq5mbxF01jpwYKc3aBODXBp1jWaI2jfToi62OAaWVZt5+Puv7U8+S+mQ+lJK1LFSFw2a7+QfomplBcpQ8pl+erNcww08Dh1hVqAXfLskzjduM4buBinIlpUi/82evF+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB2681.namprd11.prod.outlook.com (2603:10b6:5:bd::33) by DM4PR11MB6066.namprd11.prod.outlook.com (2603:10b6:8:62::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.37; Tue, 10 Oct 2023 02:56:45 +0000 Received: from DM6PR11MB2681.namprd11.prod.outlook.com ([fe80::8f95:f5b:207f:4a1e]) by DM6PR11MB2681.namprd11.prod.outlook.com ([fe80::8f95:f5b:207f:4a1e%3]) with mapi id 15.20.6863.032; Tue, 10 Oct 2023 02:56:44 +0000 From: "Dai, Jianhui J" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v1] avcodec/cbs: Keep ff_cbs_trace_syntax_element Thread-Index: Adn6remfkCjk64uBRNWNs04RIhyP1Q== Date: Tue, 10 Oct 2023 02:56:44 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM6PR11MB2681:EE_|DM4PR11MB6066:EE_ x-ms-office365-filtering-correlation-id: 1ff41879-7093-45c0-d887-08dbc93c899c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LoHP9wDanyC6LgDAMc8JoGm7MH0PsgvQYDTaBJQ2VgYg9JQpURw0773cTXfKyozOG5LjQxjhPSOrR1PzKk2Qf28mr7YJUKOK/AzFtLzQppg3vxM2QrIlb8+knwYv7LfxoHcT+XWqOqUz9+KBlF62QWubzEovIc0Y6zDs520aLfZhKcLFP7lWkeax/oLd9ycyV9TGltFALTVmnRtKeJ2f65iyCUcjs/oE87/cVOIq6Ue0BjyJAXEBjLFSJDVANeAQ+0JSIDDYQjI7XBn2SRNMXkzMyaJfffDT1mcCPs+XDcSDEz/o0mgAn1fV8VSRv6GqwBGjCD2jFQKq3UuyZrSeCA1IxR2aEBc/o/LdN+cFRsFt9O7xSCO9dZc3ILquJ/tErnkIrpc5aq54apGwyKPQPDIHHhdRdKOIi3KdaBmJjyLdfa8hZgTnjS7KG16ML2Q9qkWhif+VOkTngDl+/+qf6nT97GZFJU+18yIT1dEFk8dNfHyrwXDiEsfpqLgrU3IUCrZZr1rxlG0MijdkfOU/kFCm2apGjOG+Eq7t+2nR6ulitPEOKtHgr3sVRzzPhazXvxDjIkUHYkX/ha6sPYo+lu3BVbG/MauYD4eLvEfOw2vf++tveOONGKCxvi7WRJ9j x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB2681.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(136003)(366004)(376002)(39860400002)(396003)(230922051799003)(64100799003)(1800799009)(186009)(451199024)(76116006)(8936002)(8676002)(5660300002)(41300700001)(316002)(66946007)(66556008)(6916009)(64756008)(66446008)(66476007)(52536014)(2906002)(38070700005)(38100700002)(83380400001)(82960400001)(122000001)(55016003)(86362001)(9686003)(26005)(33656002)(71200400001)(6506007)(478600001)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: 5e7ICP5OaG93iuY/9Fw6AVfOY8nCtnkfa+vWpkvfIhUMwpAM6p2e8No+pra/uhYnn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v9FsEJLDVrU2rIwi2Q7OFA6t2U5K34jIlWTnxG1yOkWi03uvqCDSu3mRiCF2/3qWRCsOB/9GgfvOv0rfdRPmwrgJImsMY4ov8VCKfj1ZzJqt5uytBu+jNCeCLiJgce1F8vF3m0BYsZniQwVRnxkz/orzXUSw/x0LpZwJ29Lu/UgTd8fn9rfI/1RBySCXIwOcSXHMNGvV4r5iTZVhDqA6xQ8RWj8a53HulFW7xcnx0s6i3xQE8/JRiWzQo+PKUBZbkhIfcZ7Eej3P1lMasNz0hfJiCIhBnmldJA0lsqRuWzYXlZp8akGSQag/3ZFGyTIJVdPyIqOf679HmB97O1dPRpSy0hJUPsu7+xAzAHN9oaNFSAxXLVfI005t+IeVBKwQPOJ2h8mc88nCqBuzEKmjxgykNirtO9Zops2A248N7teOyaBIj4hQ09ONm2s0NDfPQajZEzelR5y67Q1/Ta01jK MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB2681.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ff41879-7093-45c0-d887-08dbc93c899c X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Oct 2023 02:56:44.6716 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: E1yRJ/xjIl2JY8DZcLXpultp0ikeSwGTLNuveTofOcXPl/vz5rLugcaFJQ1gNRtKZwTxXB5g5jkUMTi8a+uWhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6066 X-OriginatorOrg: intel.com Subject: [FFmpeg-devel] [PATCH v1] avcodec/cbs: Keep ff_cbs_trace_syntax_element X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: l8LevJCc5cut Split ff_cbs_trace_syntax_element from ff_cbs_trace_read_log to decouple the tracing from GetBitContext. This allows CBS implementations that do not have a GetBitContext to directly use ff_cbs_trace_syntax_element to trace syntax elements. Signed-off-by: Jianhui Dai --- libavcodec/cbs.c | 41 +++++++++++++++++++++++++-------------- libavcodec/cbs_internal.h | 4 ++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index cdd7adebeb..2f2cfcfb31 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -498,26 +498,18 @@ void ff_cbs_trace_header(CodedBitstreamContext *ctx, av_log(ctx->log_ctx, ctx->trace_level, "%s\n", name); } -void ff_cbs_trace_read_log(void *trace_context, - GetBitContext *gbc, int length, - const char *str, const int *subscripts, - int64_t value) +void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, + const char *str, const int *subscripts, + const char *bits, int64_t value) { - CodedBitstreamContext *ctx = trace_context; char name[256]; - char bits[256]; size_t name_len, bits_len; int pad, subs, i, j, k, n; - int position; - - av_assert0(value >= INT_MIN && value <= UINT32_MAX); - position = get_bits_count(gbc); + if (!ctx->trace_enable) + return; - av_assert0(length < 256); - for (i = 0; i < length; i++) - bits[i] = get_bits1(gbc) ? '1' : '0'; - bits[length] = 0; + av_assert0(value >= INT_MIN && value <= UINT32_MAX); subs = subscripts ? subscripts[0] : 0; n = 0; @@ -545,7 +537,7 @@ void ff_cbs_trace_read_log(void *trace_context, av_assert0(n == subs); name_len = strlen(name); - bits_len = length; + bits_len = strlen(bits); if (name_len + bits_len > 60) pad = bits_len + 2; @@ -556,6 +548,25 @@ void ff_cbs_trace_read_log(void *trace_context, position, name, pad, bits, value); } +void ff_cbs_trace_read_log(void *trace_context, + GetBitContext *gbc, int length, + const char *str, const int *subscripts, + int64_t value) +{ + CodedBitstreamContext *ctx = trace_context; + char bits[256]; + int position; + + position = get_bits_count(gbc); + + av_assert0(length < 256); + for (int i = 0; i < length; i++) + bits[i] = get_bits1(gbc) ? '1' : '0'; + bits[length] = 0; + + ff_cbs_trace_syntax_element(ctx, position, str, subscripts, bits, value); +} + void ff_cbs_trace_write_log(void *trace_context, PutBitContext *pbc, int length, const char *str, const int *subscripts, diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 07220f1f3e..ff90ce467d 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -158,6 +158,10 @@ typedef struct CodedBitstreamType { void ff_cbs_trace_header(CodedBitstreamContext *ctx, const char *name); +void ff_cbs_trace_syntax_element(CodedBitstreamContext *ctx, int position, + const char *name, const int *subscripts, + const char *bitstring, int64_t value); + // Helper functions for read/write of common bitstream elements, including // generation of trace output. The simple functions are equivalent to