From patchwork Fri Dec 3 18:28:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31922 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1032272iog; Fri, 3 Dec 2021 10:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUho96XyCpVpofow073gqQXtlZH5X4R5RTZqf0SNiRePYmpFTsf6iz7PJBsrpFVJeD4kBO X-Received: by 2002:a17:907:75f0:: with SMTP id jz16mr26009449ejc.77.1638556153681; Fri, 03 Dec 2021 10:29:13 -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 q19si5191879edr.184.2021.12.03.10.29.13; Fri, 03 Dec 2021 10:29:13 -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=dfAp3L3D; 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 F077B68AE7A; Fri, 3 Dec 2021 20:29:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.92.90.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F01A668ADF7 for ; Fri, 3 Dec 2021 20:29:03 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=De+uMnSoVQTqSMhNY3fjNW0hDYo6N+ZsF8vszSk9KizKHfBUMix5d/QLB7DK52RMYUiDmafE1PUpxdDXDxHYIehzs3N6LuW879N/We/UJN3YJLPD4Pd1besvkFfcY0yc5X1gP2YnmKcQo7J0CwL/U6YHRMPNFHGz8jAL50Lb2bBRJbKume4OtdU6G6eVWaETs9EPHIlGdIChaES6lXCtK+/3iDculgREugWDfVYgTsCaIXaF/WJvO9RXcI8evWfgq6TY9F0sdiouHwfzkMLVv5p3eRDQaY2pdRh4WJPTCsXvJut/w3pH4raTm9KZhBcHq+MM4aZFvXV0G9Cx2+X+Ew== 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=AQYbJMcbltOLIuMTtk8AXvraaeFYz4mhko+PAyYEvFk=; b=NY9FxLFZmQopvlTouyK/VPucfCCLiBXBOwR1kpNBtDy2TMW6RipZfJA11Rxgw+5Tad+vmlo5Zxp8z1zUS1kxRiJ+3O5bD3G0w9en4c4u8GOcCinav3Jtdj4mVySc0gBJ4O0a90rxGJnxriDQM5oKfaWiHtUAOmX8MvLXIApslnKbDEdq4DP8HSMPYv+2okw2SOUMOIS2PEJEyebY3Yre/R3rm1yT2LjN8xBGk5KBc99grjcGVwK8CqjMqi2j4kwxqfnQoh1VQPiq90IPN7SkNHrGqt9UBQvp5FULLg2GLv6CXKjYMx+nLsW+rgAl3oQKnsJbyTwsGkBGaFipXpWSsg== 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=AQYbJMcbltOLIuMTtk8AXvraaeFYz4mhko+PAyYEvFk=; b=dfAp3L3D+27ls2O8exYjjOrzyBTZSui3JmcOWGnVn4hJb8OVITixwwuv6ab42+EU+JER2ASyqoMgeVyxuyfuQ0GAH6+zRTLxsYdFanapFD4EXeioNtoOtZST1HowwYSC3VjEcizEynwnlgFoHDchACHymFY4Uuw0zxWqLm8dQr0TD0EVoWIZVggj5+sDp5dpm74uMKG8U36K0XOZXK9UqunRbOf/76Zvimdmo6UK5xBFa3AOLXCj2Rzss8wLYDRtlEXuSrtPhVDxWh7Yge2kRWieV4ZUK8BDkLFCjCI2GKgltrVUrNftyTOPnTxUf4YtmdjCEoFdcpskxubHQvVuvw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB3605.eurprd03.prod.outlook.com (2603:10a6:209:2f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Fri, 3 Dec 2021 18:29:03 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca%4]) with mapi id 15.20.4755.016; Fri, 3 Dec 2021 18:29:03 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Dec 2021 19:28:54 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [fqtuPbSgc565FLk8LJWqBTj9rLtGol39] X-ClientProxiedBy: AS9PR0301CA0058.eurprd03.prod.outlook.com (2603:10a6:20b:469::17) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211203182855.1688900-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.248.74) by AS9PR0301CA0058.eurprd03.prod.outlook.com (2603:10a6:20b:469::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Fri, 3 Dec 2021 18:29:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d33af617-2801-4b67-2a61-08d9b68ac823 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQtx8w+3h2yNNoYV95SbXd9n8o+rrc61BJvrr666Ep80Wkd/L67UTNAsPvvE/Fc9mJpTUaK4FEol9fDgvOQKrtiXSanVdG6hodZVXOek7a65SYLpkGvLq9JMqWTotodU4QwNqiWmxF3ECQWPxZ5zPqwGHgf9diAR6D3Yhffp09z/2mOHERYP+XJoBMtnOw/vWP9HstJgljvrfnhmvTlJ+bnRYa+2nPXp8EplSnLaE50wABsIxOpdHG9BTjqumD3Rpka0TRoDIamkfcGgsMvqSYZhDhgGG3Nr2KGiXdQ5qrQHDmMh3IQ9ADvr6jfKnHbAsP5nVUuRig1HH3Qj3ezK2a00/lj+4XXzw3H+OWXYtXxtbasTuujKz6w60hgda0WsucWk7lJbSERBU3mUSvGcAz2ILB0X3iLgTQPYzoiyYJw4eG/s2dZEymUpI8pWUxfecEE9fUcL7/Rl0VvxXe+NPasAgVYt2t8zMykhk38AA2Qc+9fkcDW/fC8IfJOVBjWp4SKApQoVPROfIv3G+V+qm+Z8+T9ddEb/nu1T1PGQBJcS+59swkInlmmPgmNOROnmdFttVRSCHrR6gD3DNayA5uR5LvlzBeCy3nscsVoxKjwQx678vg/LvbmC1vpQMexORJuspegkFoPJ7FenwDnPCTU/8yVrdrPm8bEDoD1F+qK9xbMF48bREiavAiOFdXHQO87SjiwjmOo/YC5+RkmRzAFPgfudkZFSuZNblOUzB4Qf0ZoemJ7j4CymDTSu/74GNE= X-MS-TrafficTypeDiagnostic: AM6PR03MB3605: X-Microsoft-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fepuD1dg6Hr3CPrtqNV7LBVzrq6CNNrE6R1H+uNWsuwWLoG5fd8rviEe8zNBZ6GgP23v+NSfqfF43I3sG8qVtWiyJaohO/azv+finhSymYApIxnM6WSsIBBQd/YsPEu8HW7B2btPIhEss64EpkKxIm2mYqFF/CxF58tJhPBMsW+WvUyjGLDerpo8pjTu7vL9f4s1t73cmN8Rxs8FF/E/cE778dmnYDDBtWr0eE2sY4l42RAuzxo5qVvt4x/7zEm9P+wm3qPjz/kZP4E8PA3TJSyuqDnPS1tF2ByxSwKIUPskTkO1Kypw4tToavbgJzMuGLalf96XXM00aPJT6nFY+MroFS41t+9rxgzA4QGgvOOz384IKaPkNCG5f99v9z6/agBYArJR2Yp1wtuD6TURFa9fieGdDK3Q9poVTuC84f3DSEgllZ5B2Dr9mlfaZKv8tzzW+HMOnVZrYVCIIIfzA+8vmt/cTyNUY8dMSVtIS24b+IO68P8HcAFqVunj1fV3PmF5X0cPyb94DnHgW2rXGYoIy9HeZ7omODY/m8In2q3YzQCSI2E2OvllfGTnZF1k271wvtQx04+DL/VVJu/7fkKsCn1qptWZOx1A4NQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d33af617-2801-4b67-2a61-08d9b68ac823 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 18:29:03.0700 (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: AM6PR03MB3605 Subject: [FFmpeg-devel] [PATCH 3/4] fftools/cmdutils: Make allocate_array_elem() return ptr to new 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: cyIrlCSjxZUG Signed-off-by: Andreas Rheinhardt --- fftools/cmdutils.c | 6 ++++-- fftools/cmdutils.h | 4 ++-- fftools/ffmpeg_filter.c | 13 ++++--------- fftools/ffmpeg_opt.c | 9 +++------ 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 1464b122df..0b57552e5c 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2216,8 +2216,9 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems) { - void *new_elem, **array = (void**)ptr; + void *new_elem, **array; + memcpy(&array, ptr, sizeof(array)); if (*nb_elems == INT_MAX) { av_log(NULL, AV_LOG_ERROR, "Array too big.\n"); exit_program(1); @@ -2226,8 +2227,9 @@ void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems) if (!new_elem) exit_program(1); GROW_ARRAY(array, *nb_elems); + memcpy(ptr, &array, sizeof(array)); array[*nb_elems - 1] = new_elem; - return array; + return new_elem; } double get_rotation(int32_t *displaymatrix) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index ae78e60f4c..82cda208be 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -638,7 +638,7 @@ void *grow_array(void *array, int elem_size, int *size, int new_size); * @param elem_size size of the new element to allocate * @param nb_elems pointer to the number of elements of the array array; * *nb_elems will be incremented by one by this function. - * @return reallocated array + * @return pointer to the newly allocated entry */ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); @@ -648,7 +648,7 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1) #define ALLOC_ARRAY_ELEM(array, nb_elems)\ - array = allocate_array_elem(array, sizeof(*array[0]), &nb_elems) + allocate_array_elem(&array, sizeof(*array[0]), &nb_elems) #define GET_PIX_FMT_NAME(pix_fmt)\ const char *name = av_get_pix_fmt_name(pix_fmt); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 04253a9b21..bd48098bff 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -166,16 +166,14 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) exit_program(1); fg->index = nb_filtergraphs; - ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); - ofilter = fg->outputs[0]; + ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); ofilter->ost = ost; ofilter->graph = fg; ofilter->format = -1; ost->filter = ofilter; - ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs); - ifilter = fg->inputs[0]; + ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs); ifilter->ist = ist; ifilter->graph = fg; ifilter->format = -1; @@ -281,8 +279,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) ist->decoding_needed |= DECODING_FOR_FILTER; ist->st->discard = AVDISCARD_NONE; - ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs); - ifilter = fg->inputs[fg->nb_inputs - 1]; + ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs); ifilter->ist = ist; ifilter->graph = fg; ifilter->format = -1; @@ -318,9 +315,7 @@ int init_complex_filtergraph(FilterGraph *fg) init_input_filter(fg, cur); for (cur = outputs; cur;) { - OutputFilter *ofilter; - ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); - ofilter = fg->outputs[fg->nb_outputs - 1]; + OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); ofilter->graph = fg; ofilter->out_tmp = cur; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 6f971bc922..17e4cdd2d6 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1265,8 +1265,7 @@ static int open_input_file(OptionsContext *o, const char *filename) /* dump the file content */ av_dump_format(ic, nb_input_files, filename, 0); - ALLOC_ARRAY_ELEM(input_files, nb_input_files); - f = input_files[nb_input_files - 1]; + f = ALLOC_ARRAY_ELEM(input_files, nb_input_files); f->ctx = ic; f->ist_index = nb_input_streams - ic->nb_streams; @@ -2258,8 +2257,7 @@ static int open_output_file(OptionsContext *o, const char *filename) } } - ALLOC_ARRAY_ELEM(output_files, nb_output_files); - of = output_files[nb_output_files - 1]; + of = ALLOC_ARRAY_ELEM(output_files, nb_output_files); of->ost_index = nb_output_streams; of->recording_time = o->recording_time; @@ -3276,8 +3274,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * if (!graph_desc) return AVERROR(EINVAL); - ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); - fg = filtergraphs[nb_filtergraphs - 1]; + fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs); fg->index = nb_filtergraphs - 1; fg->graph_desc = graph_desc;