diff --git a/libavfilter/af_acrossover.c b/libavfilter/af_acrossover.c
index e8dcc48e6a..1ad7ebad01 100644
--- a/libavfilter/af_acrossover.c
+++ b/libavfilter/af_acrossover.c
@@ -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;
         }
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 8cbdf81df4..670a8c837b 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -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;
     }
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 55d5ac7f14..5f954dcf73 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -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;
     }
diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c
index 7749495970..ef84f4d264 100644
--- a/libavfilter/af_amerge.c
+++ b/libavfilter/af_amerge.c
@@ -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;
         }
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c
index 003c1717cd..c0c909fb0c 100644
--- a/libavfilter/af_amix.c
+++ b/libavfilter/af_amix.c
@@ -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;
         }
diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c
index b9d02e28ff..48d6b8848b 100644
--- a/libavfilter/af_anequalizer.c
+++ b/libavfilter/af_anequalizer.c
@@ -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;
     }
diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c
index d6f1438b86..07f131eae9 100644
--- a/libavfilter/af_channelsplit.c
+++ b/libavfilter/af_channelsplit.c
@@ -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:
diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
index f3543fafb6..44a7cdfe74 100644
--- a/libavfilter/af_headphone.c
+++ b/libavfilter/af_headphone.c
@@ -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;
         }
diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c
index 10bd3c1c01..6534b619ca 100644
--- a/libavfilter/af_join.c
+++ b/libavfilter/af_join.c
@@ -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;
         }
diff --git a/libavfilter/af_ladspa.c b/libavfilter/af_ladspa.c
index 0c2bd5a54e..e21a874dda 100644
--- a/libavfilter/af_ladspa.c
+++ b/libavfilter/af_ladspa.c
@@ -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);
         }
diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c
index 83ff5e7861..179ef6e24e 100644
--- a/libavfilter/af_lv2.c
+++ b/libavfilter/af_lv2.c
@@ -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);
         }
diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c
index a31805f204..b4d6909063 100644
--- a/libavfilter/avf_aphasemeter.c
+++ b/libavfilter/avf_aphasemeter.c
@@ -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;
     }
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 333a0b090c..2ad092466f 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -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;
             }
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 24184ed1ed..af371e4fb9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -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;
 }
diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index 47ea9b59d7..a058ee8884 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -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;
 
diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c
index 259952b591..a58892862b 100644
--- a/libavfilter/f_interleave.c
+++ b/libavfilter/f_interleave.c
@@ -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;
         }
diff --git a/libavfilter/f_segment.c b/libavfilter/f_segment.c
index f060794cfe..7a76550411 100644
--- a/libavfilter/f_segment.c
+++ b/libavfilter/f_segment.c
@@ -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;
         }
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 4a131f01c8..43aab5e549 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -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;
         }
diff --git a/libavfilter/f_streamselect.c b/libavfilter/f_streamselect.c
index 05a8d5f49a..732b253b0b 100644
--- a/libavfilter/f_streamselect.c
+++ b/libavfilter/f_streamselect.c
@@ -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) {
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index e7a9275114..13d0e2b457 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -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);
 }
 
diff --git a/libavfilter/split.c b/libavfilter/split.c
index da5f681af8..81a3a58dda 100644
--- a/libavfilter/split.c
+++ b/libavfilter/split.c
@@ -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;
         }
diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c
index 7d97295dd0..3050d33e58 100644
--- a/libavfilter/src_movie.c
+++ b/libavfilter/src_movie.c
@@ -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;
         }
diff --git a/libavfilter/vf_bm3d.c b/libavfilter/vf_bm3d.c
index 49a52ecc18..47c2fef0ba 100644
--- a/libavfilter/vf_bm3d.c
+++ b/libavfilter/vf_bm3d.c
@@ -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;
     }
 
diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index 9ef03ff1a3..2c2b443bae 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -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;
     }
 
diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c
index cede3d669e..2d26369c2d 100644
--- a/libavfilter/vf_extractplanes.c
+++ b/libavfilter/vf_extractplanes.c
@@ -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;
         }
diff --git a/libavfilter/vf_fieldmatch.c b/libavfilter/vf_fieldmatch.c
index 9626737b40..eb7e0c9ebb 100644
--- a/libavfilter/vf_fieldmatch.c
+++ b/libavfilter/vf_fieldmatch.c
@@ -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;
     }
 
diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c
index 4003b9578f..17e94764f1 100644
--- a/libavfilter/vf_guided.c
+++ b/libavfilter/vf_guided.c
@@ -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;
     }
 
diff --git a/libavfilter/vf_mergeplanes.c b/libavfilter/vf_mergeplanes.c
index 30888f62af..e8112abba8 100644
--- a/libavfilter/vf_mergeplanes.c
+++ b/libavfilter/vf_mergeplanes.c
@@ -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;
         }
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 5bd056759e..e8db74c7cf 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -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;
             }
diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
index bc8e080e4c..d6fbf499c9 100644
--- a/libavfilter/vf_premultiply.c
+++ b/libavfilter/vf_premultiply.c
@@ -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;
     }
 
diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c
index 5f455e9afa..1682a5d7c8 100644
--- a/libavfilter/vf_program_opencl.c
+++ b/libavfilter/vf_program_opencl.c
@@ -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;
diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index 69930e9f02..52bd515446 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -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;
         }
diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c
index 38e5aa098b..5b0203fbcb 100644
--- a/libavfilter/vf_stack.c
+++ b/libavfilter/vf_stack.c
@@ -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;
         }
diff --git a/libavfilter/vf_xmedian.c b/libavfilter/vf_xmedian.c
index fa131a7259..462e0b82e7 100644
--- a/libavfilter/vf_xmedian.c
+++ b/libavfilter/vf_xmedian.c
@@ -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;
         }
