aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-05-06 21:30:49 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-05-08 19:38:18 +0200
commit75e0324eabfbdefd63f21d8a9796073433bbf259 (patch)
treedd9133b0540404840a84038703e4bdb3361b2386
parentf7f6aaf988c224a10ad9ad67d7f7864746880c76 (diff)
downloadffmpeg-75e0324eabfbdefd63f21d8a9796073433bbf259.tar.gz
src_buffer: move code to avoid forward declarations.
-rw-r--r--libavfilter/src_buffer.c140
1 files changed, 67 insertions, 73 deletions
diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
index a64a6e2f6c..4a280613a4 100644
--- a/libavfilter/src_buffer.c
+++ b/libavfilter/src_buffer.c
@@ -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)