Commit d9d7c549 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ba8efac9'

* commit 'ba8efac9':
  af_channelmap: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/af_channelmap.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 57148122 ba8efac9
...@@ -1208,7 +1208,7 @@ This filter accepts the following named parameters: ...@@ -1208,7 +1208,7 @@ This filter accepts the following named parameters:
Channel layout of the output stream. Channel layout of the output stream.
@item map @item map
Map channels from input to output. The argument is a comma-separated list of Map channels from input to output. The argument is a '|'-separated list of
mappings, each in the @code{@var{in_channel}-@var{out_channel}} or mappings, each in the @code{@var{in_channel}-@var{out_channel}} or
@var{in_channel} form. @var{in_channel} can be either the name of the input @var{in_channel} form. @var{in_channel} can be either the name of the input
channel (e.g. FL for front left) or its index in the input channel layout. channel (e.g. FL for front left) or its index in the input channel layout.
...@@ -1222,14 +1222,14 @@ output channels preserving index. ...@@ -1222,14 +1222,14 @@ output channels preserving index.
For example, assuming a 5.1+downmix input MOV file For example, assuming a 5.1+downmix input MOV file
@example @example
ffmpeg -i in.mov -filter 'channelmap=map=DL-FL\,DR-FR' out.wav ffmpeg -i in.mov -filter 'channelmap=map=DL-FL|DR-FR' out.wav
@end example @end example
will create an output WAV file tagged as stereo from the downmix channels of will create an output WAV file tagged as stereo from the downmix channels of
the input. the input.
To fix a 5.1 WAV improperly encoded in AAC's native channel order To fix a 5.1 WAV improperly encoded in AAC's native channel order
@example @example
ffmpeg -i in.wav -filter 'channelmap=1\,2\,0\,5\,3\,4:channel_layout=5.1' out.wav ffmpeg -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
@end example @end example
@section join @section join
......
...@@ -123,25 +123,14 @@ static int get_channel(char **map, uint64_t *ch, char delim) ...@@ -123,25 +123,14 @@ static int get_channel(char **map, uint64_t *ch, char delim)
static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
{ {
ChannelMapContext *s = ctx->priv; ChannelMapContext *s = ctx->priv;
int ret; int ret = 0;
char *mapping; char *mapping, separator = '|';
int map_entries = 0; int map_entries = 0;
char buf[256]; char buf[256];
enum MappingMode mode; enum MappingMode mode;
uint64_t out_ch_mask = 0; uint64_t out_ch_mask = 0;
int i; int i;
if (!args) {
av_log(ctx, AV_LOG_ERROR, "No parameters supplied.\n");
return AVERROR(EINVAL);
}
s->class = &channelmap_class;
av_opt_set_defaults(s);
if ((ret = av_set_options_string(s, args, "=", ":")) < 0)
return ret;
mapping = s->mapping_str; mapping = s->mapping_str;
if (!mapping) { if (!mapping) {
...@@ -164,13 +153,20 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -164,13 +153,20 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
else else
mode = MAP_PAIR_STR_STR; mode = MAP_PAIR_STR_STR;
} }
#if FF_API_OLD_FILTER_OPTS
if (strchr(mapping, ',')) {
av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use "
"'|' to separate the mappings.\n");
separator = ',';
}
#endif
} }
if (mode != MAP_NONE) { if (mode != MAP_NONE) {
char *comma = mapping; char *sep = mapping;
map_entries = 1; map_entries = 1;
while ((comma = strchr(comma, ','))) { while ((sep = strchr(sep, separator))) {
if (*++comma) // Allow trailing comma if (*++sep) // Allow trailing comma
map_entries++; map_entries++;
} }
} }
...@@ -187,7 +183,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -187,7 +183,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
static const char err[] = "Failed to parse channel map\n"; static const char err[] = "Failed to parse channel map\n";
switch (mode) { switch (mode) {
case MAP_ONE_INT: case MAP_ONE_INT:
if (get_channel_idx(&mapping, &in_ch_idx, ',', MAX_CH) < 0) { if (get_channel_idx(&mapping, &in_ch_idx, separator, MAX_CH) < 0) {
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
goto fail; goto fail;
...@@ -196,7 +192,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -196,7 +192,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
s->map[i].out_channel_idx = i; s->map[i].out_channel_idx = i;
break; break;
case MAP_ONE_STR: case MAP_ONE_STR:
if (!get_channel(&mapping, &in_ch, ',')) { if (!get_channel(&mapping, &in_ch, separator)) {
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto fail; goto fail;
...@@ -206,7 +202,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -206,7 +202,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
break; break;
case MAP_PAIR_INT_INT: case MAP_PAIR_INT_INT:
if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 || if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||
get_channel_idx(&mapping, &out_ch_idx, ',', MAX_CH) < 0) { get_channel_idx(&mapping, &out_ch_idx, separator, MAX_CH) < 0) {
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto fail; goto fail;
...@@ -216,7 +212,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -216,7 +212,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
break; break;
case MAP_PAIR_INT_STR: case MAP_PAIR_INT_STR:
if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 || if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||
get_channel(&mapping, &out_ch, ',') < 0 || get_channel(&mapping, &out_ch, separator) < 0 ||
out_ch & out_ch_mask) { out_ch & out_ch_mask) {
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
...@@ -228,7 +224,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -228,7 +224,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
break; break;
case MAP_PAIR_STR_INT: case MAP_PAIR_STR_INT:
if (get_channel(&mapping, &in_ch, '-') < 0 || if (get_channel(&mapping, &in_ch, '-') < 0 ||
get_channel_idx(&mapping, &out_ch_idx, ',', MAX_CH) < 0) { get_channel_idx(&mapping, &out_ch_idx, separator, MAX_CH) < 0) {
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
goto fail; goto fail;
...@@ -238,7 +234,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args) ...@@ -238,7 +234,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
break; break;
case MAP_PAIR_STR_STR: case MAP_PAIR_STR_STR:
if (get_channel(&mapping, &in_ch, '-') < 0 || if (get_channel(&mapping, &in_ch, '-') < 0 ||
get_channel(&mapping, &out_ch, ',') < 0 || get_channel(&mapping, &out_ch, separator) < 0 ||
out_ch & out_ch_mask) { out_ch & out_ch_mask) {
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
ret = AVERROR(EINVAL); ret = AVERROR(EINVAL);
...@@ -409,8 +405,8 @@ AVFilter avfilter_af_channelmap = { ...@@ -409,8 +405,8 @@ AVFilter avfilter_af_channelmap = {
.init = channelmap_init, .init = channelmap_init,
.query_formats = channelmap_query_formats, .query_formats = channelmap_query_formats,
.priv_size = sizeof(ChannelMapContext), .priv_size = sizeof(ChannelMapContext),
.priv_class = &channelmap_class,
.inputs = avfilter_af_channelmap_inputs, .inputs = avfilter_af_channelmap_inputs,
.outputs = avfilter_af_channelmap_outputs, .outputs = avfilter_af_channelmap_outputs,
.priv_class = &channelmap_class,
}; };
...@@ -667,6 +667,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ...@@ -667,6 +667,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "blend" ) || !strcmp(filter->filter->name, "blend" ) ||
!strcmp(filter->filter->name, "boxblur" ) || !strcmp(filter->filter->name, "boxblur" ) ||
!strcmp(filter->filter->name, "cellauto") || !strcmp(filter->filter->name, "cellauto") ||
!strcmp(filter->filter->name, "channelmap") ||
!strcmp(filter->filter->name, "colormatrix") || !strcmp(filter->filter->name, "colormatrix") ||
!strcmp(filter->filter->name, "crop" ) || !strcmp(filter->filter->name, "crop" ) ||
!strcmp(filter->filter->name, "cropdetect") || !strcmp(filter->filter->name, "cropdetect") ||
......
channelmap=map=1\,2\,0\,5\,3\,4:channel_layout=5.1 channelmap=map=1|2|0|5|3|4:channel_layout=5.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment