src_buffer: move code to avoid forward declarations.
authorNicolas George <nicolas.george@normalesup.org>
Sun, 6 May 2012 19:30:49 +0000 (21:30 +0200)
committerNicolas George <nicolas.george@normalesup.org>
Tue, 8 May 2012 17:38:18 +0000 (19:38 +0200)
libavfilter/src_buffer.c

index a64a6e2..4a28061 100644 (file)
@@ -69,11 +69,75 @@ typedef struct {
         return AVERROR(EINVAL);\
     }
 
+static void buf_free(AVFilterBuffer *ptr)
+{
+    av_free(ptr);
+    return;
+}
+
+static void set_link_source(AVFilterContext *src, AVFilterLink *link)
+{
+    link->src       = src;
+    link->srcpad    = &(src->output_pads[0]);
+    src->outputs[0] = link;
+}
+
+static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *filt_ctx)
+{
+    int ret;
+    AVFilterLink * const inlink  = filt_ctx->inputs[0];
+    AVFilterLink * const outlink = filt_ctx->outputs[0];
+
+    inlink->format         = abuffer->sample_format;
+    inlink->channel_layout = abuffer->channel_layout;
+    inlink->planar         = abuffer->packing_format;
+    inlink->sample_rate    = abuffer->sample_rate;
+
+    filt_ctx->filter->uninit(filt_ctx);
+    memset(filt_ctx->priv, 0, filt_ctx->filter->priv_size);
+    if ((ret = filt_ctx->filter->init(filt_ctx, NULL , NULL)) < 0)
+        return ret;
+    if ((ret = inlink->srcpad->config_props(inlink)) < 0)
+        return ret;
+    return outlink->srcpad->config_props(outlink);
+}
+
 static int insert_filter(BufferSourceContext *abuffer,
                          AVFilterLink *link, AVFilterContext **filt_ctx,
-                         const char *filt_name);
-static void remove_filter(AVFilterContext **filt_ctx);
-static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *filt_ctx);
+                         const char *filt_name)
+{
+    int ret;
+
+    if ((ret = avfilter_open(filt_ctx, avfilter_get_by_name(filt_name), NULL)) < 0)
+        return ret;
+
+    link->src->outputs[0] = NULL;
+    if ((ret = avfilter_link(link->src, 0, *filt_ctx, 0)) < 0) {
+        link->src->outputs[0] = link;
+        return ret;
+    }
+
+    set_link_source(*filt_ctx, link);
+
+    if ((ret = reconfigure_filter(abuffer, *filt_ctx)) < 0) {
+        avfilter_free(*filt_ctx);
+        return ret;
+    }
+
+    return 0;
+}
+
+static void remove_filter(AVFilterContext **filt_ctx)
+{
+    AVFilterLink *outlink = (*filt_ctx)->outputs[0];
+    AVFilterContext *src  = (*filt_ctx)->inputs[0]->src;
+
+    (*filt_ctx)->outputs[0] = NULL;
+    avfilter_free(*filt_ctx);
+    *filt_ctx = NULL;
+
+    set_link_source(src, outlink);
+}
 
 static inline void log_input_change(void *ctx, AVFilterLink *link, AVFilterBufferRef *ref)
 {
@@ -516,76 +580,6 @@ static int poll_frame(AVFilterLink *link)
     return size/sizeof(AVFilterBufferRef*);
 }
 
-static void buf_free(AVFilterBuffer *ptr)
-{
-    av_free(ptr);
-    return;
-}
-
-static void set_link_source(AVFilterContext *src, AVFilterLink *link)
-{
-    link->src       = src;
-    link->srcpad    = &(src->output_pads[0]);
-    src->outputs[0] = link;
-}
-
-static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *filt_ctx)
-{
-    int ret;
-    AVFilterLink * const inlink  = filt_ctx->inputs[0];
-    AVFilterLink * const outlink = filt_ctx->outputs[0];
-
-    inlink->format         = abuffer->sample_format;
-    inlink->channel_layout = abuffer->channel_layout;
-    inlink->planar         = abuffer->packing_format;
-    inlink->sample_rate    = abuffer->sample_rate;
-
-    filt_ctx->filter->uninit(filt_ctx);
-    memset(filt_ctx->priv, 0, filt_ctx->filter->priv_size);
-    if ((ret = filt_ctx->filter->init(filt_ctx, NULL , NULL)) < 0)
-        return ret;
-    if ((ret = inlink->srcpad->config_props(inlink)) < 0)
-        return ret;
-    return outlink->srcpad->config_props(outlink);
-}
-
-static int insert_filter(BufferSourceContext *abuffer,
-                         AVFilterLink *link, AVFilterContext **filt_ctx,
-                         const char *filt_name)
-{
-    int ret;
-
-    if ((ret = avfilter_open(filt_ctx, avfilter_get_by_name(filt_name), NULL)) < 0)
-        return ret;
-
-    link->src->outputs[0] = NULL;
-    if ((ret = avfilter_link(link->src, 0, *filt_ctx, 0)) < 0) {
-        link->src->outputs[0] = link;
-        return ret;
-    }
-
-    set_link_source(*filt_ctx, link);
-
-    if ((ret = reconfigure_filter(abuffer, *filt_ctx)) < 0) {
-        avfilter_free(*filt_ctx);
-        return ret;
-    }
-
-    return 0;
-}
-
-static void remove_filter(AVFilterContext **filt_ctx)
-{
-    AVFilterLink *outlink = (*filt_ctx)->outputs[0];
-    AVFilterContext *src  = (*filt_ctx)->inputs[0]->src;
-
-    (*filt_ctx)->outputs[0] = NULL;
-    avfilter_free(*filt_ctx);
-    *filt_ctx = NULL;
-
-    set_link_source(src, outlink);
-}
-
 int av_asrc_buffer_add_audio_buffer_ref(AVFilterContext *ctx,
                                         AVFilterBufferRef *samplesref,
                                         int av_unused flags)