From patchwork Fri Nov 26 19:24:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31753 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp2669340iob; Fri, 26 Nov 2021 11:24:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBF61/1iw48m1XIi+YmQ1cwkH3s+265BYKfYmRwZ8CrMHtB1D8MMN7Z6rkx+E2mjuSPH1h X-Received: by 2002:a17:906:d193:: with SMTP id c19mr39982342ejz.471.1637954667289; Fri, 26 Nov 2021 11:24:27 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lf8si10033932ejb.635.2021.11.26.11.24.26; Fri, 26 Nov 2021 11:24:27 -0800 (PST) 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=a6AsOhDh; 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 71C7968A703; Fri, 26 Nov 2021 21:24:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2018.outbound.protection.outlook.com [40.92.89.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D4496818DB for ; Fri, 26 Nov 2021 21:24:17 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AImrQFNPZSFgNCAvo8TSkZUAxIkYJwxCU1edDdji1UJk5/QWFrOqvmhcJ324oRSVWL9a9bn+p7RAhZmpnEXM9x+uAm7mKKxfmx93TjAn9jB9YCpmi/p70poxEh3TuPAjIpwApdiIaaookVvr0eHAkWz3PE8mubfzBqvmWsCj1AwuhJwpiQEiawbiHLh+ZWGkNA1C5H28BCxu614BLseSAEZ8rIYIndv1w1Qf+dUkkyjINHzXAo7ksKD5Zs9Hv+9wzhQ8AUFe767D32YhDix0VLe3Nsl7i9BP/j5m6DvbheLdh84XdgmfBRuXHgYP20Db0SEFA5oCyL/XMB+sv9fDpA== 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=RLPkjWMeIOFuZi/QeoBHZ9C/DbgYt3PzzcvUvGgdsN0=; b=lObJo8k7hTrOCNpP5FNYTXpljbF5n1mqRU9TCv5kwpaG39V2nijXINAzEvE1Ki8Kiwq22aACI2AMO76/W8TGYM9Kk7Vn3xKtVw9yB1HUk5BU2xK2UQ7KKvAyMF3oOlV2c3llP/ASppVu8WavKChjEXpFOEkpNqb5El25E8nUml1sBb7OBuxhJg3mEIATXeS7PIvkshxnsBJwx9+DWtlc5Gvbr57vSyqiBhP2fyPx4hhuFPPId27ySBkXrwkPDt0L1hug6P9ncZDlZT5icE6oinYrT9eqgfBzA1Ll31F1jB3lQij3PLwWTcBwya9f+zZ3u1JfPgdKOxFSjGY4UObW6A== 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=RLPkjWMeIOFuZi/QeoBHZ9C/DbgYt3PzzcvUvGgdsN0=; b=a6AsOhDhZoK6bNToAxVYE6ZEIElpo62J/zcbCZlNgRM2axZRbFr/xWDmwFvWsCIF5vfmJAfK1Iva2Wtai4WjhewQxuEbnXvPOUfEjdC7j4QCtPdBSugsgFaGXsXkFGb1SFGIrPdhmoJwjQIX5c+UmU88783vNEMJWmo6oLLfhq1PbJn8z8k+i49lQzfBuGp3Bol8Azj2n1PjF7GLk3CScBREoOihESOarI0PyPVrZcIcWIWMHF/cqgOz8DWbMBrai5puLad+ZQa1wULJeCjVLTv4+oavocl2OXrq+mRhjpglm58utoyTFeEtXjDD/oMfFpP1OUOHcbckVsqd3MJvdQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB5543.eurprd03.prod.outlook.com (2603:10a6:20b:f7::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.24; Fri, 26 Nov 2021 19:24:16 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%9]) with mapi id 15.20.4734.023; Fri, 26 Nov 2021 19:24:16 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Nov 2021 20:24:05 +0100 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [CcCs7braDNK1Ob8VWahlvAvG/NVcDUkD] X-ClientProxiedBy: AM6PR04CA0057.eurprd04.prod.outlook.com (2603:10a6:20b:f0::34) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211126192405.276713-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.248.74) by AM6PR04CA0057.eurprd04.prod.outlook.com (2603:10a6:20b:f0::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.21 via Frontend Transport; Fri, 26 Nov 2021 19:24:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3bf4fb42-f8f3-4fa8-7551-08d9b1125609 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTC4ziyQch4o21Y9d141MBfmoTxl9Pc3A8Br6gOQGLxudCYcyvb5/YDwjEGykRWdP/oq1lExzSXazLB1G54Eu8H273nAoMq1ZXk6I7jEkV8RkVbBQDikQuUotJ4XSnyC/c+5tCDpVNz7B/Bmyce5etXv2ZfkH4j2RiQgqnN99iAUKHqf1WUbXT1LuILI7gtuWlu5xnz+60u7leQQE5r+9NLBddvDcnBIrAE0LOeYb1S76X+b7O5uaWKz0DQRd0Un3epfUQWepm3wqyaiQ+y7t1oKDAgrFVcvIpXF4XsV02cKKk8TvICzqmaBAmm++03owX/c2W1/y6TA4WwtHtkxkmViClhl1/fUiMZ7YJmknLYgdpIKxulngFqwI013TWAAvMyxbpr2yygiammHmNmnSQ2I/AD/DiqESS/aNMPC4prWSS/zhEsu254HT2f5tty9CgmGPKe2nwsmfTBHo7T/q7nPIqbTT8NqbQvDwXQR5OQ58HvkvvFSDI+f2PQwejIfAcn9ljue7jxJjohepWRU1nQgT0d/f6pdyXBwRsa+IK/0NhyhwSbukbOCVXkRYBqTuB9Hsr2HQjvqb65diJyPXsTkfxqhG6wvMiDTkEAy0QMOaevsoZ7tkSx7Z7zRIkW6OUCfNj2fcwog8bJ1rnEpQEnLQu5bsAVknyPP8OwjT5ZT8MEk90DDTvWqUaQFj6MBbFEAUp2cGYb+80pMJch+E4tuPJg0QXNlPbI1JXyb/avNljW/stZbpGTtGbvty7eNO4= X-MS-TrafficTypeDiagnostic: AM6PR03MB5543: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ea+DJr02KBJqnBPIJefV6hWojk9kkOopnRt103LH/MudgzJB5grdeFMfWTA6ngTMhN2KN86xxvN1K3pxPqzBzbUHdY/Iswcjw4gUU41oqbu8xwZlCF34Fpb2yEmHyRx0SdOv4Nakqc1zYKeK+b6eXDRDe/c/EjwEa1RxJ5Daun4Cqd26jMqAHVcD5Tx1zVxtoyH1uMHjeH86T/iIvzCDXj/KrhoWCxelBEsQGuFNaP1quG8tOj1dHqqlzFP7Y4A4voQIdr0SF5IxTCzCL2WpC5Kg7FYuq1rr7A2yTKJyPuxf/bQYbjGtPNCmVZGnCNuthirVZ8A1z+mLCZLzJkohbRHO9nrWPYOKfprSCFhAvPJQuIaIQb4n1J1gK0hkuqbcPhfPP1AiG2KYlFoWt9067uuqUmzckwDpFrplcffYNbOeA15FkthwMFAt9VwVIv8Dfwu+Ij0lww7xC+v1BP9tpA9HoAoP0zvquMNShwIGn5apRKdos8RFej+RecpPYj7g19bSug0Kbc0S9kNg9EYutwom4crdlvsQMOTunFwHz3S/vI/U6yU0QgYuGLvND2cNrWVg/XewjN/Mnc9JOrjnfQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cd8eiFdiYGNWbiSGvqCBd/Fs9kbHIDrLc32p+r+mBMjD7407h2y510BPMh1UqGGhT3RXiCFOWIGNpu4TjgmXPCq1h7nG18k7QTAeK9X+0giXpCSY2efJMYgHtHMMVZzX1+dlNy2z2x3oKCwfGo1B9OiVRb2FPCNZRDPlTwN7CgOH/itm7I5O/dz6xglOEVzSl3e32c2VvnDySf+XxWR9i5R+77KEtwjJOJmblZp/LzjqyKWGRraSd9ab9qbr5OzAvAJs9j3hQk4kFjo0KwXJWM63uwZ0HWBHpBGjfQLY3qdVGmWxOdv8C5GmDVjEcNLvsKSyIi/Q7dHFMxC3QzWsqI/PmsVgCDqF63cQpCW06e7ssBv6up8laGsQmiREhDuoEyvU/qgqcVoeGNSTvpdkKdQKN8SfP4hCT5rIXTblc6124gh62vm7rQe+Nl5Z4d57bxaeew3xiTa7kUnuEEBvd0dOYrg0jCwhOVAMgUoSiKqrIdbtiwDyJO4FJ5dSLP03Qby9SGmdFcBffxscq3P1O8iPnvsFnGyIu6N9E74X3my6TexPG6Y0CgGEl/zCNREPyfZuQoXvbKEwQkqowevsNOA6eRo5+hPARx6lQikVSnJOQ5reKDn0lZvWoYx05KVje5YUaPqUrsIIHNeRR8OxxLe42tN6eKB4DHIsvRcEDeADF6hz0VXlmt/303k84e2LBGs0kip9+CPFFXy4uy0lCw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bf4fb42-f8f3-4fa8-7551-08d9b1125609 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2021 19:24:16.2704 (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: AM6PR03MB5543 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_opt: Don't duplicate array unnecessarily 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: QwzRYHXKVDg1 Signed-off-by: Andreas Rheinhardt --- fftools/ffmpeg.c | 3 --- fftools/ffmpeg.h | 7 ++++--- fftools/ffmpeg_opt.c | 43 ++++++++----------------------------------- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index c838e2604c..0bc11949f2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -555,9 +555,6 @@ static void ffmpeg_cleanup(int ret) avfilter_inout_free(&ofilter->out_tmp); av_freep(&ofilter->name); - av_freep(&ofilter->formats); - av_freep(&ofilter->channel_layouts); - av_freep(&ofilter->sample_rates); av_freep(&fg->outputs[j]); } av_freep(&fg->outputs); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1728010f56..f10b63c21f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -281,9 +281,10 @@ typedef struct OutputFilter { uint64_t channel_layout; // those are only set if no format is specified and the encoder gives us multiple options - int *formats; - uint64_t *channel_layouts; - int *sample_rates; + // They point directly to the relevant lists of the encoder. + const int *formats; + const uint64_t *channel_layouts; + const int *sample_rates; } OutputFilter; typedef struct FilterGraph { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index feed772452..8a0cad3f62 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2631,7 +2631,6 @@ loop_end: /* set the filter output constraints */ if (ost->filter) { OutputFilter *f = ost->filter; - int count; switch (ost->enc_ctx->codec_type) { case AVMEDIA_TYPE_VIDEO: f->frame_rate = ost->frame_rate; @@ -2639,51 +2638,25 @@ loop_end: f->height = ost->enc_ctx->height; if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { f->format = ost->enc_ctx->pix_fmt; - } else if (ost->enc->pix_fmts) { - count = 0; - while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE) - count++; - f->formats = av_calloc(count + 1, sizeof(*f->formats)); - if (!f->formats) - exit_program(1); - memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats)); + } else { + f->formats = ost->enc->pix_fmts; } break; case AVMEDIA_TYPE_AUDIO: if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) { f->format = ost->enc_ctx->sample_fmt; - } else if (ost->enc->sample_fmts) { - count = 0; - while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE) - count++; - f->formats = av_calloc(count + 1, sizeof(*f->formats)); - if (!f->formats) - exit_program(1); - memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats)); + } else { + f->formats = ost->enc->sample_fmts; } if (ost->enc_ctx->sample_rate) { f->sample_rate = ost->enc_ctx->sample_rate; - } else if (ost->enc->supported_samplerates) { - count = 0; - while (ost->enc->supported_samplerates[count]) - count++; - f->sample_rates = av_calloc(count + 1, sizeof(*f->sample_rates)); - if (!f->sample_rates) - exit_program(1); - memcpy(f->sample_rates, ost->enc->supported_samplerates, - (count + 1) * sizeof(*f->sample_rates)); + } else { + f->sample_rates = ost->enc->supported_samplerates; } if (ost->enc_ctx->channels) { f->channel_layout = av_get_default_channel_layout(ost->enc_ctx->channels); - } else if (ost->enc->channel_layouts) { - count = 0; - while (ost->enc->channel_layouts[count]) - count++; - f->channel_layouts = av_calloc(count + 1, sizeof(*f->channel_layouts)); - if (!f->channel_layouts) - exit_program(1); - memcpy(f->channel_layouts, ost->enc->channel_layouts, - (count + 1) * sizeof(*f->channel_layouts)); + } else { + f->channel_layouts = ost->enc->channel_layouts; } break; }