mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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>
This commit is contained in:
parent
787c395a30
commit
c527027c27
@ -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) ||
|
||||
|
@ -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++; \
|
||||
} \
|
||||
|
Loading…
Reference in New Issue
Block a user