@@ -191,7 +191,7 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR(ENOMEM);
pad.name = name;
- if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -836,7 +836,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_AUDIO,
};
- ret = ff_insert_inpad(ctx, 0, &pad);
+ ret = ff_insert_inpad(ctx, &pad);
if (ret < 0)
return ret;
@@ -849,7 +849,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- ret = ff_insert_inpad(ctx, n + 1, &pad);
+ ret = ff_insert_inpad(ctx, &pad);
if (ret < 0) {
av_freep(&pad.name);
return ret;
@@ -862,7 +862,7 @@ static av_cold int init(AVFilterContext *ctx)
.config_props = config_output,
};
- ret = ff_insert_outpad(ctx, 0, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
@@ -873,7 +873,7 @@ static av_cold int init(AVFilterContext *ctx)
.config_props = config_video,
};
- ret = ff_insert_outpad(ctx, 1, &vpad);
+ ret = ff_insert_outpad(ctx, &vpad);
if (ret < 0)
return ret;
}
@@ -1473,7 +1473,7 @@ static av_cold int init(AVFilterContext *ctx)
.config_props = config_output,
};
- ret = ff_insert_outpad(ctx, 0, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
@@ -1484,7 +1484,7 @@ static av_cold int init(AVFilterContext *ctx)
.config_props = config_video,
};
- ret = ff_insert_outpad(ctx, 1, &vpad);
+ ret = ff_insert_outpad(ctx, &vpad);
if (ret < 0)
return ret;
}
@@ -328,7 +328,7 @@ static av_cold int init(AVFilterContext *ctx)
};
if (!name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -553,7 +553,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -196,7 +196,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_AUDIO,
};
- ret = ff_insert_outpad(ctx, 0, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
@@ -206,7 +206,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_video,
};
- ret = ff_insert_outpad(ctx, 1, &vpad);
+ ret = ff_insert_outpad(ctx, &vpad);
if (ret < 0)
return ret;
}
@@ -97,9 +97,8 @@ static av_cold int init(AVFilterContext *ctx)
s->map[i] = ret;
}
- if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0)
return ret;
- }
}
fail:
@@ -652,7 +652,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_AUDIO,
.config_props = config_input,
};
- if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
if (!s->map) {
@@ -670,7 +670,7 @@ static av_cold int init(AVFilterContext *ctx)
};
if (!name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i + 1, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -194,7 +194,7 @@ static av_cold int join_init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -639,7 +639,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.filter_frame = filter_frame;
pad.config_props = config_input;
- if (ff_insert_inpad(ctx, ctx->nb_inputs, &pad) < 0) {
+ if (ff_insert_inpad(ctx, &pad) < 0) {
av_freep(&pad.name);
return AVERROR(ENOMEM);
}
@@ -464,7 +464,7 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR(ENOMEM);
pad.filter_frame = filter_frame;
- if (ff_insert_inpad(ctx, ctx->nb_inputs, &pad) < 0) {
+ if (ff_insert_inpad(ctx, &pad) < 0) {
av_freep(&pad.name);
return AVERROR(ENOMEM);
}
@@ -355,7 +355,7 @@ static av_cold int init(AVFilterContext *ctx)
.name = "out0",
.type = AVMEDIA_TYPE_AUDIO,
};
- ret = ff_insert_outpad(ctx, 0, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
@@ -365,7 +365,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_video_output,
};
- ret = ff_insert_outpad(ctx, 1, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
}
@@ -317,7 +317,7 @@ static av_cold int init(AVFilterContext *ctx)
.get_audio_buffer = get_audio_buffer,
};
pad.name = av_asprintf("in%d:%c%d", seg, "va"[type], str);
- if ((ret = ff_insert_inpad(ctx, ctx->nb_inputs, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -332,7 +332,7 @@ static av_cold int init(AVFilterContext *ctx)
.config_props = config_output,
};
pad.name = av_asprintf("out:%c%d", "va"[type], str);
- if ((ret = ff_insert_outpad(ctx, ctx->nb_outputs, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -101,18 +101,16 @@ void ff_command_queue_pop(AVFilterContext *filter)
av_free(c);
}
-int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
+int ff_insert_pad(unsigned *count,
AVFilterPad **pads, AVFilterLink ***links,
AVFilterPad *newpad)
{
AVFilterLink **newlinks;
AVFilterPad *newpads;
- unsigned i;
-
- idx = FFMIN(idx, *count);
+ unsigned idx = *count;
- newpads = av_realloc_array(*pads, *count + 1, sizeof(AVFilterPad));
- newlinks = av_realloc_array(*links, *count + 1, sizeof(AVFilterLink*));
+ newpads = av_realloc_array(*pads, idx + 1, sizeof(*newpads));
+ newlinks = av_realloc_array(*links, idx + 1, sizeof(*newlinks));
if (newpads)
*pads = newpads;
if (newlinks)
@@ -120,15 +118,10 @@ int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
if (!newpads || !newlinks)
return AVERROR(ENOMEM);
- memmove(*pads + idx + 1, *pads + idx, sizeof(AVFilterPad) * (*count - idx));
- memmove(*links + idx + 1, *links + idx, sizeof(AVFilterLink*) * (*count - idx));
memcpy(*pads + idx, newpad, sizeof(AVFilterPad));
(*links)[idx] = NULL;
(*count)++;
- for (i = idx + 1; i < *count; i++)
- if ((*links)[i])
- (*(unsigned *)((uint8_t *) (*links)[i] + padidx_off))++;
return 0;
}
@@ -552,7 +552,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_video_output,
};
- ret = ff_insert_outpad(ctx, 0, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
}
@@ -561,7 +561,7 @@ static av_cold int init(AVFilterContext *ctx)
.type = AVMEDIA_TYPE_AUDIO,
.config_props = config_audio_output,
};
- ret = ff_insert_outpad(ctx, ebur128->do_video, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
if (ret < 0)
return ret;
@@ -173,7 +173,7 @@ static av_cold int init(AVFilterContext *ctx)
default:
av_assert0(0);
}
- if ((ret = ff_insert_inpad(ctx, i, &inpad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &inpad)) < 0) {
av_freep(&inpad.name);
return ret;
}
@@ -137,7 +137,7 @@ static av_cold int init(AVFilterContext *ctx, enum AVMediaType type)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -192,7 +192,7 @@ static av_cold int init(AVFilterContext *ctx)
return AVERROR(ENOMEM);
pad.type = ctx->filter->inputs[0].type;
pad.request_frame = request_frame;
- if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -167,10 +167,10 @@ static int parse_definition(AVFilterContext *ctx, int nb_pads, int is_input, int
av_log(ctx, AV_LOG_DEBUG, "Add %s pad %s\n", padtype, pad.name);
if (is_input) {
- ret = ff_insert_inpad(ctx, i, &pad);
+ ret = ff_insert_inpad(ctx, &pad);
} else {
pad.config_props = config_output;
- ret = ff_insert_outpad(ctx, i, &pad);
+ ret = ff_insert_outpad(ctx, &pad);
}
if (ret < 0) {
@@ -228,34 +228,29 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end);
/**
* Insert a new pad.
*
- * @param idx Insertion point. Pad is inserted at the end if this point
- * is beyond the end of the list of pads.
* @param count Pointer to the number of pads in the list
- * @param padidx_off Offset within an AVFilterLink structure to the element
- * to increment when inserting a new pad causes link
- * numbering to change
* @param pads Pointer to the pointer to the beginning of the list of pads
* @param links Pointer to the pointer to the beginning of the list of links
* @param newpad The new pad to add. A copy is made when adding.
* @return >= 0 in case of success, a negative AVERROR code on error
*/
-int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
+int ff_insert_pad(unsigned *count,
AVFilterPad **pads, AVFilterLink ***links,
AVFilterPad *newpad);
/** Insert a new input pad for the filter. */
-static inline int ff_insert_inpad(AVFilterContext *f, unsigned index,
+static inline int ff_insert_inpad(AVFilterContext *f,
AVFilterPad *p)
{
- return ff_insert_pad(index, &f->nb_inputs, offsetof(AVFilterLink, dstpad),
+ return ff_insert_pad(&f->nb_inputs,
&f->input_pads, &f->inputs, p);
}
/** Insert a new output pad for the filter. */
-static inline int ff_insert_outpad(AVFilterContext *f, unsigned index,
+static inline int ff_insert_outpad(AVFilterContext *f,
AVFilterPad *p)
{
- return ff_insert_pad(index, &f->nb_outputs, offsetof(AVFilterLink, srcpad),
+ return ff_insert_pad(&f->nb_outputs,
&f->output_pads, &f->outputs, p);
}
@@ -56,7 +56,7 @@ static av_cold int split_init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -306,7 +306,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx)
return AVERROR(ENOMEM);
pad.config_props = movie_config_output_props;
pad.request_frame = movie_request_frame;
- if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -941,7 +941,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.name = "source";
pad.config_props = config_input;
- if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
if (s->ref) {
@@ -949,7 +949,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.name = "reference";
pad.config_props = NULL;
- if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
}
@@ -310,13 +310,13 @@ static av_cold int decimate_init(AVFilterContext *ctx)
};
int ret;
- if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
if (dm->ppsrc) {
pad.name = "clean_src";
pad.config_props = NULL;
- if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
}
@@ -352,7 +352,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.type = AVMEDIA_TYPE_VIDEO;
pad.config_props = config_output;
- if ((ret = ff_insert_outpad(ctx, ctx->nb_outputs, &pad)) < 0) {
+ if ((ret = ff_insert_outpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -970,13 +970,13 @@ static av_cold int fieldmatch_init(AVFilterContext *ctx)
};
int ret;
- if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
if (fm->ppsrc) {
pad.name = "clean_src";
pad.config_props = NULL;
- if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
}
@@ -442,7 +442,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.name = "source";
pad.config_props = config_input;
- if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
if (s->guidance == ON) {
@@ -450,7 +450,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.name = "guidance";
pad.config_props = NULL;
- if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
}
@@ -96,7 +96,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0){
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0){
av_freep(&pad.name);
return ret;
}
@@ -125,7 +125,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -790,7 +790,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.name = "main";
pad.config_props = config_input;
- if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
if (!s->inplace) {
@@ -798,7 +798,7 @@ static av_cold int init(AVFilterContext *ctx)
pad.name = "alpha";
pad.config_props = NULL;
- if ((ret = ff_insert_inpad(ctx, 1, &pad)) < 0)
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0)
return ret;
}
@@ -287,7 +287,7 @@ static av_cold int program_opencl_init(AVFilterContext *avctx)
input.config_props = &ff_opencl_filter_config_input;
- err = ff_insert_inpad(avctx, i, &input);
+ err = ff_insert_inpad(avctx, &input);
if (err < 0) {
av_freep(&input.name);
return err;
@@ -664,7 +664,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -123,7 +123,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
@@ -118,7 +118,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!pad.name)
return AVERROR(ENOMEM);
- if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
+ if ((ret = ff_insert_inpad(ctx, &pad)) < 0) {
av_freep(&pad.name);
return ret;
}
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavfilter/af_acrossover.c | 2 +- libavfilter/af_afir.c | 8 ++++---- libavfilter/af_aiir.c | 4 ++-- libavfilter/af_amerge.c | 2 +- libavfilter/af_amix.c | 2 +- libavfilter/af_anequalizer.c | 4 ++-- libavfilter/af_channelsplit.c | 3 +-- libavfilter/af_headphone.c | 4 ++-- libavfilter/af_join.c | 2 +- libavfilter/af_ladspa.c | 2 +- libavfilter/af_lv2.c | 2 +- libavfilter/avf_aphasemeter.c | 4 ++-- libavfilter/avf_concat.c | 4 ++-- libavfilter/avfilter.c | 15 ++++----------- libavfilter/f_ebur128.c | 4 ++-- libavfilter/f_interleave.c | 2 +- libavfilter/f_segment.c | 2 +- libavfilter/f_select.c | 2 +- libavfilter/f_streamselect.c | 4 ++-- libavfilter/internal.h | 15 +++++---------- libavfilter/split.c | 2 +- libavfilter/src_movie.c | 2 +- libavfilter/vf_bm3d.c | 4 ++-- libavfilter/vf_decimate.c | 4 ++-- libavfilter/vf_extractplanes.c | 2 +- libavfilter/vf_fieldmatch.c | 4 ++-- libavfilter/vf_guided.c | 4 ++-- libavfilter/vf_mergeplanes.c | 2 +- libavfilter/vf_mix.c | 2 +- libavfilter/vf_premultiply.c | 4 ++-- libavfilter/vf_program_opencl.c | 2 +- libavfilter/vf_signature.c | 2 +- libavfilter/vf_stack.c | 2 +- libavfilter/vf_xmedian.c | 2 +- 34 files changed, 56 insertions(+), 69 deletions(-)