You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avfilter/af_afir: Avoid allocating AVFilterPad names
If the names are always the same, they need not be duplicated; doing so 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:
@@ -800,11 +800,9 @@ static av_cold void uninit(AVFilterContext *ctx)
|
|||||||
av_frame_free(&s->ir[i]);
|
av_frame_free(&s->ir[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ctx->nb_inputs; i++)
|
for (unsigned i = 1; i < ctx->nb_inputs; i++)
|
||||||
av_freep(&ctx->input_pads[i].name);
|
av_freep(&ctx->input_pads[i].name);
|
||||||
|
|
||||||
for (int i = 0; i < ctx->nb_outputs; i++)
|
|
||||||
av_freep(&ctx->output_pads[i].name);
|
|
||||||
av_frame_free(&s->video);
|
av_frame_free(&s->video);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -842,18 +840,13 @@ static av_cold int init(AVFilterContext *ctx)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pad = (AVFilterPad) {
|
pad = (AVFilterPad) {
|
||||||
.name = av_strdup("main"),
|
.name = "main",
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!pad.name)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ret = ff_insert_inpad(ctx, 0, &pad);
|
ret = ff_insert_inpad(ctx, 0, &pad);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
av_freep(&pad.name);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
for (int n = 0; n < s->nb_irs; n++) {
|
for (int n = 0; n < s->nb_irs; n++) {
|
||||||
pad = (AVFilterPad) {
|
pad = (AVFilterPad) {
|
||||||
@@ -872,35 +865,26 @@ static av_cold int init(AVFilterContext *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pad = (AVFilterPad) {
|
pad = (AVFilterPad) {
|
||||||
.name = av_strdup("default"),
|
.name = "default",
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
.config_props = config_output,
|
.config_props = config_output,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!pad.name)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ret = ff_insert_outpad(ctx, 0, &pad);
|
ret = ff_insert_outpad(ctx, 0, &pad);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
av_freep(&pad.name);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
if (s->response) {
|
if (s->response) {
|
||||||
vpad = (AVFilterPad){
|
vpad = (AVFilterPad){
|
||||||
.name = av_strdup("filter_response"),
|
.name = "filter_response",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.config_props = config_video,
|
.config_props = config_video,
|
||||||
};
|
};
|
||||||
if (!vpad.name)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ret = ff_insert_outpad(ctx, 1, &vpad);
|
ret = ff_insert_outpad(ctx, 1, &vpad);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
av_freep(&vpad.name);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s->fdsp = avpriv_float_dsp_alloc(0);
|
s->fdsp = avpriv_float_dsp_alloc(0);
|
||||||
if (!s->fdsp)
|
if (!s->fdsp)
|
||||||
|
Reference in New Issue
Block a user