mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-06-19 19:03:00 +02:00
Merge commit 'ba8efac977f4276f05274947b2b67d144cbc965a'
* commit 'ba8efac977f4276f05274947b2b67d144cbc965a': af_channelmap: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/af_channelmap.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
+19
-23
@@ -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)
|
||||
{
|
||||
ChannelMapContext *s = ctx->priv;
|
||||
int ret;
|
||||
char *mapping;
|
||||
int ret = 0;
|
||||
char *mapping, separator = '|';
|
||||
int map_entries = 0;
|
||||
char buf[256];
|
||||
enum MappingMode mode;
|
||||
uint64_t out_ch_mask = 0;
|
||||
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;
|
||||
|
||||
if (!mapping) {
|
||||
@@ -164,13 +153,20 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
|
||||
else
|
||||
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) {
|
||||
char *comma = mapping;
|
||||
char *sep = mapping;
|
||||
map_entries = 1;
|
||||
while ((comma = strchr(comma, ','))) {
|
||||
if (*++comma) // Allow trailing comma
|
||||
while ((sep = strchr(sep, separator))) {
|
||||
if (*++sep) // Allow trailing comma
|
||||
map_entries++;
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
switch (mode) {
|
||||
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);
|
||||
av_log(ctx, AV_LOG_ERROR, err);
|
||||
goto fail;
|
||||
@@ -196,7 +192,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
|
||||
s->map[i].out_channel_idx = i;
|
||||
break;
|
||||
case MAP_ONE_STR:
|
||||
if (!get_channel(&mapping, &in_ch, ',')) {
|
||||
if (!get_channel(&mapping, &in_ch, separator)) {
|
||||
av_log(ctx, AV_LOG_ERROR, err);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
@@ -206,7 +202,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
|
||||
break;
|
||||
case MAP_PAIR_INT_INT:
|
||||
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);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
@@ -216,7 +212,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
|
||||
break;
|
||||
case MAP_PAIR_INT_STR:
|
||||
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) {
|
||||
av_log(ctx, AV_LOG_ERROR, err);
|
||||
ret = AVERROR(EINVAL);
|
||||
@@ -228,7 +224,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
|
||||
break;
|
||||
case MAP_PAIR_STR_INT:
|
||||
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);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
@@ -238,7 +234,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx, const char *args)
|
||||
break;
|
||||
case MAP_PAIR_STR_STR:
|
||||
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) {
|
||||
av_log(ctx, AV_LOG_ERROR, err);
|
||||
ret = AVERROR(EINVAL);
|
||||
@@ -409,8 +405,8 @@ AVFilter avfilter_af_channelmap = {
|
||||
.init = channelmap_init,
|
||||
.query_formats = channelmap_query_formats,
|
||||
.priv_size = sizeof(ChannelMapContext),
|
||||
.priv_class = &channelmap_class,
|
||||
|
||||
.inputs = avfilter_af_channelmap_inputs,
|
||||
.outputs = avfilter_af_channelmap_outputs,
|
||||
.priv_class = &channelmap_class,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user