aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/avfilter.c
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2008-02-15 21:37:22 +0000
committerVitor Sessak <vitor1001@gmail.com>2008-02-15 21:37:22 +0000
commit246184413a2b9fbd8575461be7eb9a3a49d2c9bf (patch)
treee3e38a426af8cdfd8bc87dc29ec7421fb3ee306f /libavfilter/avfilter.c
parent01942f1d9095abacad4581ceac63864903b715e1 (diff)
downloadffmpeg-246184413a2b9fbd8575461be7eb9a3a49d2c9bf.tar.gz
Helper functions for adding new pads to filters at runtime
Commited in SoC by Bobby Bingham on 2007-08-07 22:31:56 Originally committed as revision 11999 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r--libavfilter/avfilter.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 32e0944102..6157521ab3 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -47,6 +47,27 @@ void avfilter_unref_pic(AVFilterPicRef *ref)
av_free(ref);
}
+void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
+ AVFilterPad **pads, AVFilterLink ***links,
+ AVFilterPad *newpad)
+{
+ unsigned i;
+
+ idx = FFMIN(idx, *count);
+
+ *pads = av_realloc(*pads, sizeof(AVFilterPad) * (*count + 1));
+ *links = av_realloc(*links, sizeof(AVFilterLink*) * (*count + 1));
+ 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)) ++;
+}
+
int avfilter_link(AVFilterContext *src, unsigned srcpad,
AVFilterContext *dst, unsigned dstpad)
{