From patchwork Sat Mar 23 12:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47364 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c889:b0:1a3:b6bb:3029 with SMTP id hb9csp184822pzb; Sat, 23 Mar 2024 05:18:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVef4nDIMJCPr6qc8Gr2EXMqz5Uz6QEYN8qZ0rVzR+2cYrmeZxH/N6T3GvyllgrwDXG5AbnY0Np8kIPmslB0mp0SPW9or1dBN8RNQ== X-Google-Smtp-Source: AGHT+IFx8O2rT3vU2zbLP1icNig4AErho0nDf0Gkm/jlVTuUwLGYix+YM6q8BKRG24R9j1+RkILy X-Received: by 2002:a17:907:7e86:b0:a47:47d2:43ae with SMTP id qb6-20020a1709077e8600b00a4747d243aemr704986ejc.57.1711196300794; Sat, 23 Mar 2024 05:18:20 -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 by5-20020a170906a2c500b00a46e5d13ea1si862511ejb.114.2024.03.23.05.18.20; Sat, 23 Mar 2024 05:18:20 -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=@outlook.com header.s=selector1 header.b=dEOsk0Pb; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6FD3368D41E; Sat, 23 Mar 2024 14:18:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2041.outbound.protection.outlook.com [40.92.75.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD30468D41E for ; Sat, 23 Mar 2024 14:18:09 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yot3eiJlCTO1syfTbnb9mYhvyKG20aY5Ws8b0mtM2YP8q0VFIe3IXStdEL+i4pGfQWB9wnA3vzBSNMWXpa4wk62SrSHXQg/bEvUiPG0NHCJG/2Fd4EYsyj+l78pXbaabJ6s1fubqFNZIUXIOxVMl0VHZw4jDIR9qNacV4T8ud8nAi3f1b3FBa1cXY1BDBJRmOgjSLKxVwGDyjfOTS9/hpFBz2xcIrSxjDPldzkhal18AJwiaCVyRYwODgY/Le7hiLt0NCXYWDDe0VvNofrPq7Pg3HUN5w174Q9IhH7ZSgQ50p/xVl8S3awAWIlZRf10XTwEt/ZoL4kKlTo3/OXDuxA== 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=FgLQVNoeLsQ6Om4xvy87h8MtiPUkVChmNzfmDUk5wiI=; b=Pym0tovi4HLDb+Ws1gQjEb/LAqA9litNNvxp0xdIPYPtyzsmlkbBI2gBA8nP7wrvqLhOUClAwRgXKpt2qMeaJ9MCvr+W0D9C0RW/u9R4yPkmluG+oNrb2XjzSMjUUbN7Epo0JX6OfwibQ/jWvBz6l+fjrpRuJuJ3+GISjWp1rMWF9KT7C8HdKiJS1o+Xbf/Z3QuDojQzOzFZXHJjeJXuy9msowITTLtfF+vEQtnNJOvtiH2RzpjjZ/nX3kAsuh4Nn4T/JSOX0xbPdppLJljQxhE0DpPNhSamw/LDHIE0Es+jKy9CpJ3FkKD66KZTvrkAlH2RwmMOThopJ5mt9p9e7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FgLQVNoeLsQ6Om4xvy87h8MtiPUkVChmNzfmDUk5wiI=; b=dEOsk0Pb71i8WQHG623ZFIk4PHxG63+ztZfmO/EDN6x1rzlGhdXDdyXErXCIIII03bvn1KXEQGl2oHhjlIhX/7g2PdcvCGQSoSQlC/gW8WODPyl3bh8cSPcivZn9EVud6hMT+4mAPuEZGrUyR3dezBRzUjvVEdWT8w2wUxy0IK0q63g/W8HJ5l9NeQlIiZEcX74eXQz3tKqjSEQOKyz5BWWn/Aya/N18QgquBpDkY6KonrtkgZUfiOoSEjqGZ4YtoL+kVvEfn6d2kZakiI0BJ1h/83l2Pyyxz0EX8GtIu4trHhYjoASPHnx7aXpfUpOdZjpLPiZleusWVIwkKSxarw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PAXP250MB0600.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:275::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.15; Sat, 23 Mar 2024 12:18:07 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Sat, 23 Mar 2024 12:18:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Mar 2024 13:17:57 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [VOuWy7T98XRhdYYxiV6gLDnjPD+TLaPW7YYrq57u3l4=] X-ClientProxiedBy: ZR0P278CA0114.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:20::11) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240323121758.1587478-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PAXP250MB0600:EE_ X-MS-Office365-Filtering-Correlation-Id: 0921d30e-94ea-4201-82e0-08dc4b334bf9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CaxnOPc3pmakaBfMIj8+s+F/WjosTxoRj6df7BtfZeyv5WhyGftOaXV38JbJfm1LqyA5Es/S4TxoIh3syrugOX9gTChTSfLhJukT61J4vUKmE0He8XZuLkQQhc0d2wmPbjHHE4lrCT7Vi+84XvCbAibmzdPXMnMpMXKHXdID61cl4aOwXzpXRu9YFYNLWMezXISgOkx0UAFNZNxOggX0mN7VX+XTRM6yF6nq0LUiZVIb6DmoP71fgLmCGVVFXH28PquSs3Y46ZPnrEREtfsBNiw1Bs9P4hmxl/k9Ml30Hb80/C03vA6K5G1yCssPqNX1JO2cvHQdWpOaEv3ksZ3MjTkgRIJo4Y6vV8mmZ7GbTplu59E1uiolRS4AB9cK3Xt1two9xvvx0UOvxV/cmIA5NPoCwM09aBpUeKYAJpqXAhiIElXPicCdeH84o5xBQr/N+mm8+kSx6+/LstJgxnK9pXMHBWb6cGmJdZ9X7wbFwQGRBBRSTKrzf0hGD+ys7+JMEuH/aG9l67yyGCGDW6y1bmk8RDen34knf/Xh+zqmN9gpFBdOPLd82OYmtYLaZbigUXLfx22ATltCJ76DtqXYvGHH7J2pbGpbwPh1dE1u8lPzNqiM2xeLIAD4mUnDvAXQ X-MS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A1s3FqREoZCGhOfucOhLXfuO0tF4Mm6xLAuF+UMFiHSj3F/TeaRNilG50HtpJwoaSghu1HRxo4WqarKAEVqOnsP68AqZyrgI9SSWV+4ifc/n8lh2ggLljmhY1UvqUO3culQ7OILLIrBt2nzhLicNKMBCAshX0OCsa5d5WYInUI6hhoPu+6WGRGZJqQ9Oo+qh7lfIgV9ayNh66Ej5aQES/gFxL1jDXGem395alpmUXqShLXOTuzCMjkMKWaLXAx1GH6Ulcv58gouhMA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0921d30e-94ea-4201-82e0-08dc4b334bf9 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2024 12:18:07.2693 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXP250MB0600 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/mpegutils: Avoid allocations when using AVBPrint 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0XYefyOm0f5W Signed-off-by: Andreas Rheinhardt --- libavcodec/mpegutils.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c index fc3e270631..7f499b3d0f 100644 --- a/libavcodec/mpegutils.c +++ b/libavcodec/mpegutils.c @@ -252,7 +252,6 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, if (avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) { int x,y; AVBPrint buf; - char *str = NULL; int n; int margin_left; int x_step; @@ -278,16 +277,11 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, x_step = (mb_width * 16 > 999) ? 8 : 4; for (x = 0; x < mb_width; x += x_step) av_bprintf(&buf, "%-*d", n * x_step, x << 4); - n = av_bprint_finalize(&buf, &str); - if (n < 0) { - av_log(avctx, AV_LOG_ERROR, "%s failed, %s\n", __func__, av_err2str(n)); - return; - } - av_log(avctx, AV_LOG_DEBUG, "%s\n", str); - av_freep(&str); + + av_log(avctx, AV_LOG_DEBUG, "%s\n", buf.str); for (y = 0; y < mb_height; y++) { - av_bprint_init(&buf, 1, AV_BPRINT_SIZE_UNLIMITED); + av_bprint_clear(&buf); for (x = 0; x < mb_width; x++) { if (x == 0) av_bprintf(&buf, "%*d ", margin_left - 1, y << 4); @@ -310,13 +304,8 @@ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, } } - n = av_bprint_finalize(&buf, &str); - if (n < 0) { - av_log(avctx, AV_LOG_ERROR, "%s failed, %s\n", __func__, av_err2str(n)); - return; - } - av_log(avctx, AV_LOG_DEBUG, "%s\n", str); - av_freep(&str); + av_log(avctx, AV_LOG_DEBUG, "%s\n", buf.str); } + av_bprint_finalize(&buf, NULL); } }