Commit 949c603e authored by Anton Khirnov's avatar Anton Khirnov

af_channelmap: remove now unnecessary goto

Options are freed from the generic code now, there is no need to call
av_opt_free() from the filter.
parent 10121557
...@@ -122,7 +122,6 @@ static int get_channel(char **map, uint64_t *ch, char delim) ...@@ -122,7 +122,6 @@ static int get_channel(char **map, uint64_t *ch, char delim)
static av_cold int channelmap_init(AVFilterContext *ctx) static av_cold int channelmap_init(AVFilterContext *ctx)
{ {
ChannelMapContext *s = ctx->priv; ChannelMapContext *s = ctx->priv;
int ret = 0;
char *mapping, separator = '|'; char *mapping, separator = '|';
int map_entries = 0; int map_entries = 0;
char buf[256]; char buf[256];
...@@ -172,8 +171,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -172,8 +171,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
if (map_entries > MAX_CH) { if (map_entries > MAX_CH) {
av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", map_entries); av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", map_entries);
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} }
for (i = 0; i < map_entries; i++) { for (i = 0; i < map_entries; i++) {
...@@ -183,9 +181,8 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -183,9 +181,8 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
switch (mode) { switch (mode) {
case MAP_ONE_INT: case MAP_ONE_INT:
if (get_channel_idx(&mapping, &in_ch_idx, separator, 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); av_log(ctx, AV_LOG_ERROR, err);
goto fail; return AVERROR(EINVAL);
} }
s->map[i].in_channel_idx = in_ch_idx; s->map[i].in_channel_idx = in_ch_idx;
s->map[i].out_channel_idx = i; s->map[i].out_channel_idx = i;
...@@ -193,8 +190,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -193,8 +190,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
case MAP_ONE_STR: case MAP_ONE_STR:
if (!get_channel(&mapping, &in_ch, separator)) { if (!get_channel(&mapping, &in_ch, separator)) {
av_log(ctx, AV_LOG_ERROR, err); av_log(ctx, AV_LOG_ERROR, err);
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} }
s->map[i].in_channel = in_ch; s->map[i].in_channel = in_ch;
s->map[i].out_channel_idx = i; s->map[i].out_channel_idx = i;
...@@ -203,8 +199,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -203,8 +199,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
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, separator, 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); return AVERROR(EINVAL);
goto fail;
} }
s->map[i].in_channel_idx = in_ch_idx; s->map[i].in_channel_idx = in_ch_idx;
s->map[i].out_channel_idx = out_ch_idx; s->map[i].out_channel_idx = out_ch_idx;
...@@ -214,8 +209,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -214,8 +209,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
get_channel(&mapping, &out_ch, separator) < 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); return AVERROR(EINVAL);
goto fail;
} }
s->map[i].in_channel_idx = in_ch_idx; s->map[i].in_channel_idx = in_ch_idx;
s->map[i].out_channel = out_ch; s->map[i].out_channel = out_ch;
...@@ -225,8 +219,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -225,8 +219,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
if (get_channel(&mapping, &in_ch, '-') < 0 || if (get_channel(&mapping, &in_ch, '-') < 0 ||
get_channel_idx(&mapping, &out_ch_idx, separator, 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); return AVERROR(EINVAL);
goto fail;
} }
s->map[i].in_channel = in_ch; s->map[i].in_channel = in_ch;
s->map[i].out_channel_idx = out_ch_idx; s->map[i].out_channel_idx = out_ch_idx;
...@@ -236,8 +229,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -236,8 +229,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
get_channel(&mapping, &out_ch, separator) < 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); return AVERROR(EINVAL);
goto fail;
} }
s->map[i].in_channel = in_ch; s->map[i].in_channel = in_ch;
s->map[i].out_channel = out_ch; s->map[i].out_channel = out_ch;
...@@ -255,8 +247,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -255,8 +247,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) { if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) {
av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n", av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n",
s->channel_layout_str); s->channel_layout_str);
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} }
if (mode == MAP_NONE) { if (mode == MAP_NONE) {
int i; int i;
...@@ -270,14 +261,12 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -270,14 +261,12 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
av_log(ctx, AV_LOG_ERROR, av_log(ctx, AV_LOG_ERROR,
"Output channel layout '%s' does not match the list of channel mapped: '%s'.\n", "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
s->channel_layout_str, buf); s->channel_layout_str, buf);
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} else if (s->nch != av_get_channel_layout_nb_channels(fmt)) { } else if (s->nch != av_get_channel_layout_nb_channels(fmt)) {
av_log(ctx, AV_LOG_ERROR, av_log(ctx, AV_LOG_ERROR,
"Output channel layout %s does not match the number of channels mapped %d.\n", "Output channel layout %s does not match the number of channels mapped %d.\n",
s->channel_layout_str, s->nch); s->channel_layout_str, s->nch);
ret = AVERROR(EINVAL); return AVERROR(EINVAL);
goto fail;
} }
s->output_layout = fmt; s->output_layout = fmt;
} }
...@@ -290,9 +279,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx) ...@@ -290,9 +279,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
} }
} }
fail: return 0;
av_opt_free(s);
return ret;
} }
static int channelmap_query_formats(AVFilterContext *ctx) static int channelmap_query_formats(AVFilterContext *ctx)
......
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