diff options
Diffstat (limited to 'libavfilter/af_channelmap.c')
-rw-r--r-- | libavfilter/af_channelmap.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c index 3035405..c3454c5 100644 --- a/libavfilter/af_channelmap.c +++ b/libavfilter/af_channelmap.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2012 Google, Inc. * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -68,20 +68,16 @@ typedef struct ChannelMapContext { #define OFFSET(x) offsetof(ChannelMapContext, x) #define A AV_OPT_FLAG_AUDIO_PARAM -static const AVOption options[] = { +#define F AV_OPT_FLAG_FILTERING_PARAM +static const AVOption channelmap_options[] = { { "map", "A comma-separated list of input channel numbers in output order.", - OFFSET(mapping_str), AV_OPT_TYPE_STRING, .flags = A }, + OFFSET(mapping_str), AV_OPT_TYPE_STRING, .flags = A|F }, { "channel_layout", "Output channel layout.", - OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A }, - { NULL }, + OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A|F }, + { NULL } }; -static const AVClass channelmap_class = { - .class_name = "channel map filter", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; +AVFILTER_DEFINE_CLASS(channelmap); static char* split(char *message, char delim) { char *next = strchr(message, delim); @@ -291,10 +287,16 @@ static av_cold int channelmap_init(AVFilterContext *ctx) static int channelmap_query_formats(AVFilterContext *ctx) { ChannelMapContext *s = ctx->priv; + AVFilterChannelLayouts *layouts; ff_set_common_formats(ctx, ff_planar_sample_fmts()); ff_set_common_samplerates(ctx, ff_all_samplerates()); - ff_channel_layouts_ref(ff_all_channel_layouts(), &ctx->inputs[0]->out_channel_layouts); + + layouts = ff_all_channel_layouts(); + if (!layouts) + return AVERROR(ENOMEM); + + ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts); ff_channel_layouts_ref(s->channel_layouts, &ctx->outputs[0]->in_channel_layouts); return 0; @@ -316,7 +318,7 @@ static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf) if (nch_out > nch_in) { if (nch_out > FF_ARRAY_ELEMS(buf->data)) { uint8_t **new_extended_data = - av_mallocz(nch_out * sizeof(*buf->extended_data)); + av_mallocz_array(nch_out, sizeof(*buf->extended_data)); if (!new_extended_data) { av_frame_free(&buf); return AVERROR(ENOMEM); @@ -389,7 +391,8 @@ static const AVFilterPad avfilter_af_channelmap_inputs[] = { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .filter_frame = channelmap_filter_frame, - .config_props = channelmap_config_input + .config_props = channelmap_config_input, + .needs_writable = 1, }, { NULL } }; @@ -409,7 +412,6 @@ AVFilter ff_af_channelmap = { .query_formats = channelmap_query_formats, .priv_size = sizeof(ChannelMapContext), .priv_class = &channelmap_class, - .inputs = avfilter_af_channelmap_inputs, .outputs = avfilter_af_channelmap_outputs, }; |