1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

avfilter/vf_fieldmatch: Don't allocate inpad names

These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt
2020-08-22 03:57:55 +02:00
parent 7e736cd38a
commit 2d349631b1

View File

@@ -964,28 +964,20 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx)
{ {
const FieldMatchContext *fm = ctx->priv; const FieldMatchContext *fm = ctx->priv;
AVFilterPad pad = { AVFilterPad pad = {
.name = av_strdup("main"), .name = "main",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.config_props = config_input, .config_props = config_input,
}; };
int ret; int ret;
if (!pad.name) if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) {
av_freep(&pad.name);
return ret; return ret;
}
if (fm->ppsrc) { if (fm->ppsrc) {
pad.name = av_strdup("clean_src"); pad.name = "clean_src";
pad.config_props = NULL; pad.config_props = NULL;
if (!pad.name) if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0)
return AVERROR(ENOMEM);
if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) {
av_freep(&pad.name);
return ret; return ret;
}
} }
if ((fm->blockx & (fm->blockx - 1)) || if ((fm->blockx & (fm->blockx - 1)) ||
@@ -1004,7 +996,6 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx)
static av_cold void fieldmatch_uninit(AVFilterContext *ctx) static av_cold void fieldmatch_uninit(AVFilterContext *ctx)
{ {
int i;
FieldMatchContext *fm = ctx->priv; FieldMatchContext *fm = ctx->priv;
if (fm->prv != fm->src) if (fm->prv != fm->src)
@@ -1021,8 +1012,6 @@ static av_cold void fieldmatch_uninit(AVFilterContext *ctx)
av_freep(&fm->cmask_data[0]); av_freep(&fm->cmask_data[0]);
av_freep(&fm->tbuffer); av_freep(&fm->tbuffer);
av_freep(&fm->c_array); av_freep(&fm->c_array);
for (i = 0; i < ctx->nb_inputs; i++)
av_freep(&ctx->input_pads[i].name);
} }
static int config_output(AVFilterLink *outlink) static int config_output(AVFilterLink *outlink)