diff options
author | Andrew Wason <rectalogic@rectalogic.com> | 2012-06-05 11:02:43 -0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-06-05 18:15:29 +0200 |
commit | c527027c27d58e1f885e3a2649477bed89f830f6 (patch) | |
tree | b9d8d09b691fca82212b8620e234301dacd3756c /libavfilter | |
parent | 787c395a30ecc87bd6dadf2ec1ccab8648653880 (diff) | |
download | ffmpeg-streaming-c527027c27d58e1f885e3a2649477bed89f830f6.zip ffmpeg-streaming-c527027c27d58e1f885e3a2649477bed89f830f6.tar.gz |
aconvert filter needs to configure samplerates
I changed the *_set_common_* functions to only set unset formats, then
added a wrapper that calls them after the filters query_formats.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/avfiltergraph.c | 36 | ||||
-rw-r--r-- | libavfilter/formats.c | 4 |
2 files changed, 35 insertions, 5 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 1ab9879..80715ee 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -173,6 +173,36 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name) return NULL; } +static int filter_query_formats(AVFilterContext *ctx) +{ + int ret; + AVFilterFormats *formats; + AVFilterChannelLayouts *chlayouts; + AVFilterFormats *samplerates; + enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type : + ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : + AVMEDIA_TYPE_VIDEO; + + if ((ret = ctx->filter->query_formats(ctx)) < 0) + return ret; + + formats = avfilter_make_all_formats(type); + if (!formats) + return AVERROR(ENOMEM); + avfilter_set_common_formats(ctx, formats); + if (type == AVMEDIA_TYPE_AUDIO) { + samplerates = ff_all_samplerates(); + if (!samplerates) + return AVERROR(ENOMEM); + ff_set_common_samplerates(ctx, samplerates); + chlayouts = ff_all_channel_layouts(); + if (!chlayouts) + return AVERROR(ENOMEM); + ff_set_common_channel_layouts(ctx, chlayouts); + } + return 0; +} + static int insert_conv_filter(AVFilterGraph *graph, AVFilterLink *link, const char *filt_name, const char *filt_args) { @@ -198,7 +228,7 @@ static int insert_conv_filter(AVFilterGraph *graph, AVFilterLink *link, if ((ret = avfilter_insert_filter(link, filt_ctx, 0, 0)) < 0) return ret; - filt_ctx->filter->query_formats(filt_ctx); + filter_query_formats(filt_ctx); if ( ((link = filt_ctx-> inputs[0]) && !avfilter_merge_formats(link->in_formats, link->out_formats)) || @@ -244,7 +274,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) if (!graph->filters[i]->input_count == j) continue; if (graph->filters[i]->filter->query_formats) - ret = graph->filters[i]->filter->query_formats(graph->filters[i]); + ret = filter_query_formats(graph->filters[i]); else ret = ff_default_query_formats(graph->filters[i]); if (ret < 0) @@ -348,7 +378,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) if ((ret = avfilter_insert_filter(link, convert, 0, 0)) < 0) return ret; - convert->filter->query_formats(convert); + filter_query_formats(convert); inlink = convert->inputs[0]; outlink = convert->outputs[0]; if (!avfilter_merge_formats( inlink->in_formats, inlink->out_formats) || diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 9e15024..1fd95eb 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -405,13 +405,13 @@ void avfilter_formats_changeref(AVFilterFormats **oldref, int count = 0, i; \ \ for (i = 0; i < ctx->input_count; i++) { \ - if (ctx->inputs[i]) { \ + if (ctx->inputs[i] && !ctx->inputs[i]->out_fmts) { \ ref(fmts, &ctx->inputs[i]->out_fmts); \ count++; \ } \ } \ for (i = 0; i < ctx->output_count; i++) { \ - if (ctx->outputs[i]) { \ + if (ctx->outputs[i] && !ctx->outputs[i]->in_fmts) { \ ref(fmts, &ctx->outputs[i]->in_fmts); \ count++; \ } \ |