[FFmpeg-soc] [soc]: r620 - in libavfilter: avfilter.c avfilter.h
koorogi
subversion at mplayerhq.hu
Wed Aug 8 00:31:57 CEST 2007
Author: koorogi
Date: Wed Aug 8 00:31:56 2007
New Revision: 620
Log:
Helper functions for adding new pads to filters at runtime
Modified:
libavfilter/avfilter.c
libavfilter/avfilter.h
Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c (original)
+++ libavfilter/avfilter.c Wed Aug 8 00:31:56 2007
@@ -47,6 +47,27 @@ void avfilter_unref_pic(AVFilterPicRef *
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)
{
Modified: libavfilter/avfilter.h
==============================================================================
--- libavfilter/avfilter.h (original)
+++ libavfilter/avfilter.h Wed Aug 8 00:31:56 2007
@@ -22,6 +22,7 @@
#ifndef FFMPEG_AVFILTER_H
#define FFMPEG_AVFILTER_H
+#include <stddef.h>
#include "avcodec.h"
typedef struct AVFilterContext AVFilterContext;
@@ -240,4 +241,36 @@ void avfilter_destroy(AVFilterContext *f
int *avfilter_make_format_list(int len, ...);
+/**
+ * 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.
+ */
+void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
+ AVFilterPad **pads, AVFilterLink ***links,
+ AVFilterPad *newpad);
+
+/** insert a new input pad for the filter */
+static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
+ AVFilterPad *p)
+{
+ avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
+ &f->input_pads, &f->inputs, p);
+}
+
+/** insert a new output pad for the filter */
+static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
+ AVFilterPad *p)
+{
+ avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
+ &f->output_pads, &f->outputs, p);
+}
+
#endif /* FFMPEG_AVFILTER_H */
More information about the FFmpeg-soc
mailing list