static av_cold int channelmap_init(AVFilterContext *ctx)

{

    ChannelMapContext *s = ctx->priv;

    int ret;

    char *mapping, separator = '|';

    int map_entries = 0;

    char buf[256];

    enum MappingMode mode;

    uint64_t out_ch_mask = 0;

    int i;



    mapping = s->mapping_str;



    if (!mapping) {

        mode = MAP_NONE;

    } else {

        char *dash = strchr(mapping, '-');

        if (!dash) {  // short mapping

            if (av_isdigit(*mapping))

                mode = MAP_ONE_INT;

            else

                mode = MAP_ONE_STR;

        } else if (av_isdigit(*mapping)) {

            if (av_isdigit(*(dash+1)))

                mode = MAP_PAIR_INT_INT;

            else

                mode = MAP_PAIR_INT_STR;

        } else {

            if (av_isdigit(*(dash+1)))

                mode = MAP_PAIR_STR_INT;

            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 *sep = mapping;

        map_entries = 1;

        while ((sep = strchr(sep, separator))) {

            if (*++sep)  // Allow trailing comma

                map_entries++;

        }

    }



    if (map_entries > MAX_CH) {

        av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", map_entries);

        ret = AVERROR(EINVAL);

        goto fail;

    }



    for (i = 0; i < map_entries; i++) {

        int in_ch_idx = -1, out_ch_idx = -1;

        uint64_t in_ch = 0, out_ch = 0;

        static const char err[] = "Failed to parse channel map\n";

        switch (mode) {

        case MAP_ONE_INT:

            if (get_channel_idx(&mapping, &in_ch_idx, separator, MAX_CH) < 0) {

                ret = AVERROR(EINVAL);

                av_log(ctx, AV_LOG_ERROR, err);

                goto fail;

            }

            s->map[i].in_channel_idx  = in_ch_idx;

            s->map[i].out_channel_idx = i;

            break;

        case MAP_ONE_STR:

            if (!get_channel(&mapping, &in_ch, separator)) {

                av_log(ctx, AV_LOG_ERROR, err);

                ret = AVERROR(EINVAL);

                goto fail;

            }

            s->map[i].in_channel      = in_ch;

            s->map[i].out_channel_idx = i;

            break;

        case MAP_PAIR_INT_INT:

            if (get_channel_idx(&mapping, &in_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;

            }

            s->map[i].in_channel_idx  = in_ch_idx;

            s->map[i].out_channel_idx = out_ch_idx;

            break;

        case MAP_PAIR_INT_STR:

            if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||

                get_channel(&mapping, &out_ch, separator) < 0 ||

                out_ch & out_ch_mask) {

                av_log(ctx, AV_LOG_ERROR, err);

                ret = AVERROR(EINVAL);

                goto fail;

            }

            s->map[i].in_channel_idx  = in_ch_idx;

            s->map[i].out_channel     = out_ch;

            out_ch_mask |= out_ch;

            break;

        case MAP_PAIR_STR_INT:

            if (get_channel(&mapping, &in_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;

            }

            s->map[i].in_channel      = in_ch;

            s->map[i].out_channel_idx = out_ch_idx;

            break;

        case MAP_PAIR_STR_STR:

            if (get_channel(&mapping, &in_ch, '-') < 0 ||

                get_channel(&mapping, &out_ch, separator) < 0 ||

                out_ch & out_ch_mask) {

                av_log(ctx, AV_LOG_ERROR, err);

                ret = AVERROR(EINVAL);

                goto fail;

            }

            s->map[i].in_channel = in_ch;

            s->map[i].out_channel = out_ch;

            out_ch_mask |= out_ch;

            break;

        }

    }

    s->mode          = mode;

    s->nch           = map_entries;

    s->output_layout = out_ch_mask ? out_ch_mask :

                       av_get_default_channel_layout(map_entries);



    if (s->channel_layout_str) {

        uint64_t fmt;

        if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) {

            av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n",

                   s->channel_layout_str);

            ret = AVERROR(EINVAL);

            goto fail;

        }

        if (mode == MAP_NONE) {

            int i;

            s->nch = av_get_channel_layout_nb_channels(fmt);

            for (i = 0; i < s->nch; i++) {

                s->map[i].in_channel_idx  = i;

                s->map[i].out_channel_idx = i;

            }

        } else if (out_ch_mask && out_ch_mask != fmt) {

            av_get_channel_layout_string(buf, sizeof(buf), 0, out_ch_mask);

            av_log(ctx, AV_LOG_ERROR,

                   "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",

                   s->channel_layout_str, buf);

            ret = AVERROR(EINVAL);

            goto fail;

        } else if (s->nch != av_get_channel_layout_nb_channels(fmt)) {

            av_log(ctx, AV_LOG_ERROR,

                   "Output channel layout %s does not match the number of channels mapped %d.\n",

                   s->channel_layout_str, s->nch);

            ret = AVERROR(EINVAL);

            goto fail;

        }

        s->output_layout = fmt;

    }

    ff_add_channel_layout(&s->channel_layouts, s->output_layout);



    if (mode == MAP_PAIR_INT_STR || mode == MAP_PAIR_STR_STR) {

        for (i = 0; i < s->nch; i++) {

            s->map[i].out_channel_idx = av_get_channel_layout_channel_index(

                s->output_layout, s->map[i].out_channel);

        }

    }



fail:

    av_opt_free(s);

    return ret;

}

static av_cold int channelmap_init(AVFilterContext *ctx)

{

    ChannelMapContext *s = ctx->priv;

    int ret;

    char *mapping, separator = '|';

    int map_entries = 0;

    char buf[256];

    enum MappingMode mode;

    uint64_t out_ch_mask = 0;

    int i;



    mapping = s->mapping_str;



    if (!mapping) {

        mode = MAP_NONE;

    } else {

        char *dash = strchr(mapping, '-');

        if (!dash) {  

            if (av_isdigit(*mapping))

                mode = MAP_ONE_INT;

            else

                mode = MAP_ONE_STR;

        } else if (av_isdigit(*mapping)) {

            if (av_isdigit(*(dash+1)))

                mode = MAP_PAIR_INT_INT;

            else

                mode = MAP_PAIR_INT_STR;

        } else {

            if (av_isdigit(*(dash+1)))

                mode = MAP_PAIR_STR_INT;

            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 *sep = mapping;

        map_entries = 1;

        while ((sep = strchr(sep, separator))) {

            if (*++sep)  

                map_entries++;

        }

    }



    if (map_entries > MAX_CH) {

        av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", map_entries);

        ret = AVERROR(EINVAL);

        goto fail;

    }



    for (i = 0; i < map_entries; i++) {

        int in_ch_idx = -1, out_ch_idx = -1;

        uint64_t in_ch = 0, out_ch = 0;

        static const char err[] = "Failed to parse channel map\n";

        switch (mode) {

        case MAP_ONE_INT:

            if (get_channel_idx(&mapping, &in_ch_idx, separator, MAX_CH) < 0) {

                ret = AVERROR(EINVAL);

                av_log(ctx, AV_LOG_ERROR, err);

                goto fail;

            }

            s->map[i].in_channel_idx  = in_ch_idx;

            s->map[i].out_channel_idx = i;

            break;

        case MAP_ONE_STR:

            if (!get_channel(&mapping, &in_ch, separator)) {

                av_log(ctx, AV_LOG_ERROR, err);

                ret = AVERROR(EINVAL);

                goto fail;

            }

            s->map[i].in_channel      = in_ch;

            s->map[i].out_channel_idx = i;

            break;

        case MAP_PAIR_INT_INT:

            if (get_channel_idx(&mapping, &in_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;

            }

            s->map[i].in_channel_idx  = in_ch_idx;

            s->map[i].out_channel_idx = out_ch_idx;

            break;

        case MAP_PAIR_INT_STR:

            if (get_channel_idx(&mapping, &in_ch_idx, '-', MAX_CH) < 0 ||

                get_channel(&mapping, &out_ch, separator) < 0 ||

                out_ch & out_ch_mask) {

                av_log(ctx, AV_LOG_ERROR, err);

                ret = AVERROR(EINVAL);

                goto fail;

            }

            s->map[i].in_channel_idx  = in_ch_idx;

            s->map[i].out_channel     = out_ch;

            out_ch_mask |= out_ch;

            break;

        case MAP_PAIR_STR_INT:

            if (get_channel(&mapping, &in_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;

            }

            s->map[i].in_channel      = in_ch;

            s->map[i].out_channel_idx = out_ch_idx;

            break;

        case MAP_PAIR_STR_STR:

            if (get_channel(&mapping, &in_ch, '-') < 0 ||

                get_channel(&mapping, &out_ch, separator) < 0 ||

                out_ch & out_ch_mask) {

                av_log(ctx, AV_LOG_ERROR, err);

                ret = AVERROR(EINVAL);

                goto fail;

            }

            s->map[i].in_channel = in_ch;

            s->map[i].out_channel = out_ch;

            out_ch_mask |= out_ch;

            break;

        }

    }

    s->mode          = mode;

    s->nch           = map_entries;

    s->output_layout = out_ch_mask ? out_ch_mask :

                       av_get_default_channel_layout(map_entries);



    if (s->channel_layout_str) {

        uint64_t fmt;

        if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) {

            av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n",

                   s->channel_layout_str);

            ret = AVERROR(EINVAL);

            goto fail;

        }

        if (mode == MAP_NONE) {

            int i;

            s->nch = av_get_channel_layout_nb_channels(fmt);

            for (i = 0; i < s->nch; i++) {

                s->map[i].in_channel_idx  = i;

                s->map[i].out_channel_idx = i;

            }

        } else if (out_ch_mask && out_ch_mask != fmt) {

            av_get_channel_layout_string(buf, sizeof(buf), 0, out_ch_mask);

            av_log(ctx, AV_LOG_ERROR,

                   "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",

                   s->channel_layout_str, buf);

            ret = AVERROR(EINVAL);

            goto fail;

        } else if (s->nch != av_get_channel_layout_nb_channels(fmt)) {

            av_log(ctx, AV_LOG_ERROR,

                   "Output channel layout %s does not match the number of channels mapped %d.\n",

                   s->channel_layout_str, s->nch);

            ret = AVERROR(EINVAL);

            goto fail;

        }

        s->output_layout = fmt;

    }

    ff_add_channel_layout(&s->channel_layouts, s->output_layout);



    if (mode == MAP_PAIR_INT_STR || mode == MAP_PAIR_STR_STR) {

        for (i = 0; i < s->nch; i++) {

            s->map[i].out_channel_idx = av_get_channel_layout_channel_index(

                s->output_layout, s->map[i].out_channel);

        }

    }



fail:

    av_opt_free(s);

    return ret;

}

    int ret;
static av_cold int FUNC_0(AVFilterContext *ctx)

{

    ChannelMapContext *s = ctx->priv;

    int VAR_0;

    char *VAR_1, VAR_2 = '|';

    int VAR_3 = 0;

    char VAR_4[256];

    enum MappingMode VAR_5;

    uint64_t out_ch_mask = 0;

    int VAR_12;



    VAR_1 = s->mapping_str;



    if (!VAR_1) {

        VAR_5 = MAP_NONE;

    } else {

        char *VAR_7 = strchr(VAR_1, '-');

        if (!VAR_7) {  

            if (av_isdigit(*VAR_1))

                VAR_5 = MAP_ONE_INT;

            else

                VAR_5 = MAP_ONE_STR;

        } else if (av_isdigit(*VAR_1)) {

            if (av_isdigit(*(VAR_7+1)))

                VAR_5 = MAP_PAIR_INT_INT;

            else

                VAR_5 = MAP_PAIR_INT_STR;

        } else {

            if (av_isdigit(*(VAR_7+1)))

                VAR_5 = MAP_PAIR_STR_INT;

            else

                VAR_5 = MAP_PAIR_STR_STR;

        }

#if FF_API_OLD_FILTER_OPTS

        if (strchr(VAR_1, ',')) {

            av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use "

                   "'|' to separate the mappings.\n");

            VAR_2 = ',';

        }

#endif

    }



    if (VAR_5 != MAP_NONE) {

        char *VAR_8 = VAR_1;

        VAR_3 = 1;

        while ((VAR_8 = strchr(VAR_8, VAR_2))) {

            if (*++VAR_8)  

                VAR_3++;

        }

    }



    if (VAR_3 > MAX_CH) {

        av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", VAR_3);

        VAR_0 = AVERROR(EINVAL);

        goto fail;

    }



    for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++) {

        int VAR_9 = -1, VAR_10 = -1;

        uint64_t in_ch = 0, out_ch = 0;

        static const char VAR_11[] = "Failed to parse channel map\n";

        switch (VAR_5) {

        case MAP_ONE_INT:

            if (get_channel_idx(&VAR_1, &VAR_9, VAR_2, MAX_CH) < 0) {

                VAR_0 = AVERROR(EINVAL);

                av_log(ctx, AV_LOG_ERROR, VAR_11);

                goto fail;

            }

            s->map[VAR_12].in_channel_idx  = VAR_9;

            s->map[VAR_12].out_channel_idx = VAR_12;

            break;

        case MAP_ONE_STR:

            if (!get_channel(&VAR_1, &in_ch, VAR_2)) {

                av_log(ctx, AV_LOG_ERROR, VAR_11);

                VAR_0 = AVERROR(EINVAL);

                goto fail;

            }

            s->map[VAR_12].in_channel      = in_ch;

            s->map[VAR_12].out_channel_idx = VAR_12;

            break;

        case MAP_PAIR_INT_INT:

            if (get_channel_idx(&VAR_1, &VAR_9, '-', MAX_CH) < 0 ||

                get_channel_idx(&VAR_1, &VAR_10, VAR_2, MAX_CH) < 0) {

                av_log(ctx, AV_LOG_ERROR, VAR_11);

                VAR_0 = AVERROR(EINVAL);

                goto fail;

            }

            s->map[VAR_12].in_channel_idx  = VAR_9;

            s->map[VAR_12].out_channel_idx = VAR_10;

            break;

        case MAP_PAIR_INT_STR:

            if (get_channel_idx(&VAR_1, &VAR_9, '-', MAX_CH) < 0 ||

                get_channel(&VAR_1, &out_ch, VAR_2) < 0 ||

                out_ch & out_ch_mask) {

                av_log(ctx, AV_LOG_ERROR, VAR_11);

                VAR_0 = AVERROR(EINVAL);

                goto fail;

            }

            s->map[VAR_12].in_channel_idx  = VAR_9;

            s->map[VAR_12].out_channel     = out_ch;

            out_ch_mask |= out_ch;

            break;

        case MAP_PAIR_STR_INT:

            if (get_channel(&VAR_1, &in_ch, '-') < 0 ||

                get_channel_idx(&VAR_1, &VAR_10, VAR_2, MAX_CH) < 0) {

                av_log(ctx, AV_LOG_ERROR, VAR_11);

                VAR_0 = AVERROR(EINVAL);

                goto fail;

            }

            s->map[VAR_12].in_channel      = in_ch;

            s->map[VAR_12].out_channel_idx = VAR_10;

            break;

        case MAP_PAIR_STR_STR:

            if (get_channel(&VAR_1, &in_ch, '-') < 0 ||

                get_channel(&VAR_1, &out_ch, VAR_2) < 0 ||

                out_ch & out_ch_mask) {

                av_log(ctx, AV_LOG_ERROR, VAR_11);

                VAR_0 = AVERROR(EINVAL);

                goto fail;

            }

            s->map[VAR_12].in_channel = in_ch;

            s->map[VAR_12].out_channel = out_ch;

            out_ch_mask |= out_ch;

            break;

        }

    }

    s->VAR_5          = VAR_5;

    s->nch           = VAR_3;

    s->output_layout = out_ch_mask ? out_ch_mask :

                       av_get_default_channel_layout(VAR_3);



    if (s->channel_layout_str) {

        uint64_t fmt;

        if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) {

            av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n",

                   s->channel_layout_str);

            VAR_0 = AVERROR(EINVAL);

            goto fail;

        }

        if (VAR_5 == MAP_NONE) {

            int VAR_12;

            s->nch = av_get_channel_layout_nb_channels(fmt);

            for (VAR_12 = 0; VAR_12 < s->nch; VAR_12++) {

                s->map[VAR_12].in_channel_idx  = VAR_12;

                s->map[VAR_12].out_channel_idx = VAR_12;

            }

        } else if (out_ch_mask && out_ch_mask != fmt) {

            av_get_channel_layout_string(VAR_4, sizeof(VAR_4), 0, out_ch_mask);

            av_log(ctx, AV_LOG_ERROR,

                   "Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",

                   s->channel_layout_str, VAR_4);

            VAR_0 = AVERROR(EINVAL);

            goto fail;

        } else if (s->nch != av_get_channel_layout_nb_channels(fmt)) {

            av_log(ctx, AV_LOG_ERROR,

                   "Output channel layout %s does not match the number of channels mapped %d.\n",

                   s->channel_layout_str, s->nch);

            VAR_0 = AVERROR(EINVAL);

            goto fail;

        }

        s->output_layout = fmt;

    }

    ff_add_channel_layout(&s->channel_layouts, s->output_layout);



    if (VAR_5 == MAP_PAIR_INT_STR || VAR_5 == MAP_PAIR_STR_STR) {

        for (VAR_12 = 0; VAR_12 < s->nch; VAR_12++) {

            s->map[VAR_12].out_channel_idx = av_get_channel_layout_channel_index(

                s->output_layout, s->map[VAR_12].out_channel);

        }

    }



fail:

    av_opt_free(s);

    return VAR_0;

}

static av_cold int FUNC_0(AVFilterContext *ctx)
{ ChannelMapContext *s = ctx->priv; int VAR_0; char *VAR_1, VAR_2 = '|'; int VAR_3 = 0; char VAR_4[256]; enum MappingMode VAR_5; uint64_t out_ch_mask = 0; int VAR_12; VAR_1 = s->mapping_str; if (!VAR_1) { VAR_5 = MAP_NONE; } else { char *VAR_7 = strchr(VAR_1, '-'); if (!VAR_7) { if (av_isdigit(*VAR_1))
VAR_5 = MAP_ONE_INT; else
VAR_5 = MAP_ONE_STR; } else if (av_isdigit(*VAR_1)) { if (av_isdigit(*(VAR_7+1)))
VAR_5 = MAP_PAIR_INT_INT; else
VAR_5 = MAP_PAIR_INT_STR; } else { if (av_isdigit(*(VAR_7+1)))
VAR_5 = MAP_PAIR_STR_INT; else
VAR_5 = MAP_PAIR_STR_STR; } #if FF_API_OLD_FILTER_OPTS
if (strchr(VAR_1, ',')) { av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use "
"'|' to separate the mappings.\n"); VAR_2 = ','; } #endif
} if (VAR_5 != MAP_NONE) { char *VAR_8 = VAR_1; VAR_3 = 1; while ((VAR_8 = strchr(VAR_8, VAR_2))) { if (*++VAR_8)
VAR_3++; } } if (VAR_3 > MAX_CH) { av_log(ctx, AV_LOG_ERROR, "Too many channels mapped: '%d'.\n", VAR_3); VAR_0 = AVERROR(EINVAL); goto fail; } for (VAR_12 = 0; VAR_12 < VAR_3; VAR_12++) { int VAR_9 = -1, VAR_10 = -1; uint64_t in_ch = 0, out_ch = 0; static const char VAR_11[] = "Failed to parse channel map\n"; switch (VAR_5) { case MAP_ONE_INT:
if (get_channel_idx(&VAR_1, &VAR_9, VAR_2, MAX_CH) < 0) { VAR_0 = AVERROR(EINVAL); av_log(ctx, AV_LOG_ERROR, VAR_11); goto fail; } s->map[VAR_12].in_channel_idx  = VAR_9; s->map[VAR_12].out_channel_idx = VAR_12; break; case MAP_ONE_STR:
if (!get_channel(&VAR_1, &in_ch, VAR_2)) { av_log(ctx, AV_LOG_ERROR, VAR_11); VAR_0 = AVERROR(EINVAL); goto fail; } s->map[VAR_12].in_channel      = in_ch; s->map[VAR_12].out_channel_idx = VAR_12; break; case MAP_PAIR_INT_INT:
if (get_channel_idx(&VAR_1, &VAR_9, '-', MAX_CH) < 0 ||
get_channel_idx(&VAR_1, &VAR_10, VAR_2, MAX_CH) < 0) { av_log(ctx, AV_LOG_ERROR, VAR_11); VAR_0 = AVERROR(EINVAL); goto fail; } s->map[VAR_12].in_channel_idx  = VAR_9; s->map[VAR_12].out_channel_idx = VAR_10; break; case MAP_PAIR_INT_STR:
if (get_channel_idx(&VAR_1, &VAR_9, '-', MAX_CH) < 0 ||
get_channel(&VAR_1, &out_ch, VAR_2) < 0 ||
out_ch & out_ch_mask) { av_log(ctx, AV_LOG_ERROR, VAR_11); VAR_0 = AVERROR(EINVAL); goto fail; } s->map[VAR_12].in_channel_idx  = VAR_9; s->map[VAR_12].out_channel     = out_ch; out_ch_mask |= out_ch; break; case MAP_PAIR_STR_INT:
if (get_channel(&VAR_1, &in_ch, '-') < 0 ||
get_channel_idx(&VAR_1, &VAR_10, VAR_2, MAX_CH) < 0) { av_log(ctx, AV_LOG_ERROR, VAR_11); VAR_0 = AVERROR(EINVAL); goto fail; } s->map[VAR_12].in_channel      = in_ch; s->map[VAR_12].out_channel_idx = VAR_10; break; case MAP_PAIR_STR_STR:
if (get_channel(&VAR_1, &in_ch, '-') < 0 ||
get_channel(&VAR_1, &out_ch, VAR_2) < 0 ||
out_ch & out_ch_mask) { av_log(ctx, AV_LOG_ERROR, VAR_11); VAR_0 = AVERROR(EINVAL); goto fail; } s->map[VAR_12].in_channel = in_ch; s->map[VAR_12].out_channel = out_ch; out_ch_mask |= out_ch; break; } } s->VAR_5          = VAR_5; s->nch           = VAR_3; s->output_layout = out_ch_mask ? out_ch_mask :
av_get_default_channel_layout(VAR_3); if (s->channel_layout_str) { uint64_t fmt; if ((fmt = av_get_channel_layout(s->channel_layout_str)) == 0) { av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: '%s'.\n",
s->channel_layout_str); VAR_0 = AVERROR(EINVAL); goto fail; } if (VAR_5 == MAP_NONE) { int VAR_12; s->nch = av_get_channel_layout_nb_channels(fmt); for (VAR_12 = 0; VAR_12 < s->nch; VAR_12++) { s->map[VAR_12].in_channel_idx  = VAR_12; s->map[VAR_12].out_channel_idx = VAR_12; } } else if (out_ch_mask && out_ch_mask != fmt) { av_get_channel_layout_string(VAR_4, sizeof(VAR_4), 0, out_ch_mask); av_log(ctx, AV_LOG_ERROR,
"Output channel layout '%s' does not match the list of channel mapped: '%s'.\n",
s->channel_layout_str, VAR_4); VAR_0 = AVERROR(EINVAL); goto fail; } else if (s->nch != av_get_channel_layout_nb_channels(fmt)) { av_log(ctx, AV_LOG_ERROR,
"Output channel layout %s does not match the number of channels mapped %d.\n",
s->channel_layout_str, s->nch); VAR_0 = AVERROR(EINVAL); goto fail; } s->output_layout = fmt; } ff_add_channel_layout(&s->channel_layouts, s->output_layout); if (VAR_5 == MAP_PAIR_INT_STR || VAR_5 == MAP_PAIR_STR_STR) { for (VAR_12 = 0; VAR_12 < s->nch; VAR_12++) { s->map[VAR_12].out_channel_idx = av_get_channel_layout_channel_index(
s->output_layout, s->map[VAR_12].out_channel); } } fail:
av_opt_free(s); return VAR_0; }