static int parse_channel_name(char **arg, int *rchannel, int *rnamed)

{

    char buf[8];

    int len, i, channel_id = 0;

    int64_t layout, layout0;



    /* try to parse a channel name, e.g. "FL" */

    if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {

        layout0 = layout = av_get_channel_layout(buf);

        /* channel_id <- first set bit in layout */

        for (i = 32; i > 0; i >>= 1) {

            if (layout >= (int64_t)1 << i) {

                channel_id += i;

                layout >>= i;

            }

        }

        /* reject layouts that are not a single channel */

        if (channel_id >= MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)

            return AVERROR(EINVAL);

        *rchannel = channel_id;

        *rnamed = 1;

        *arg += len;

        return 0;

    }

    /* try to parse a channel number, e.g. "c2" */

    if (sscanf(*arg, " c%d %n", &channel_id, &len) &&

        channel_id >= 0 && channel_id < MAX_CHANNELS) {

        *rchannel = channel_id;

        *rnamed = 0;

        *arg += len;

        return 0;

    }

    return AVERROR(EINVAL);

}

static int parse_channel_name(char **arg, int *rchannel, int *rnamed)

{

    char buf[8];

    int len, i, channel_id = 0;

    int64_t layout, layout0;



    

    if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {

        layout0 = layout = av_get_channel_layout(buf);

        

        for (i = 32; i > 0; i >>= 1) {

            if (layout >= (int64_t)1 << i) {

                channel_id += i;

                layout >>= i;

            }

        }

        

        if (channel_id >= MAX_CHANNELS || layout0 != (int64_t)1 << channel_id)

            return AVERROR(EINVAL);

        *rchannel = channel_id;

        *rnamed = 1;

        *arg += len;

        return 0;

    }

    

    if (sscanf(*arg, " c%d %n", &channel_id, &len) &&

        channel_id >= 0 && channel_id < MAX_CHANNELS) {

        *rchannel = channel_id;

        *rnamed = 0;

        *arg += len;

        return 0;

    }

    return AVERROR(EINVAL);

}

    if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {     if (sscanf(*arg, " c%d %n", &channel_id, &len) &&
static int FUNC_0(char **VAR_0, int *VAR_1, int *VAR_2)

{

    char VAR_3[8];

    int VAR_4, VAR_5, VAR_6 = 0;

    int64_t layout, layout0;



    

    if (sscanf(*VAR_0, " %7[A-Z] %n", VAR_3, &VAR_4)) {

        layout0 = layout = av_get_channel_layout(VAR_3);

        

        for (VAR_5 = 32; VAR_5 > 0; VAR_5 >>= 1) {

            if (layout >= (int64_t)1 << VAR_5) {

                VAR_6 += VAR_5;

                layout >>= VAR_5;

            }

        }

        

        if (VAR_6 >= MAX_CHANNELS || layout0 != (int64_t)1 << VAR_6)

            return AVERROR(EINVAL);

        *VAR_1 = VAR_6;

        *VAR_2 = 1;

        *VAR_0 += VAR_4;

        return 0;

    }

    

    if (sscanf(*VAR_0, " c%d %n", &VAR_6, &VAR_4) &&

        VAR_6 >= 0 && VAR_6 < MAX_CHANNELS) {

        *VAR_1 = VAR_6;

        *VAR_2 = 0;

        *VAR_0 += VAR_4;

        return 0;

    }

    return AVERROR(EINVAL);

}

static int FUNC_0(char **VAR_0, int *VAR_1, int *VAR_2)
{ char VAR_3[8]; int VAR_4, VAR_5, VAR_6 = 0; int64_t layout, layout0; if (sscanf(*VAR_0, " %7[A-Z] %n", VAR_3, &VAR_4)) { layout0 = layout = av_get_channel_layout(VAR_3); for (VAR_5 = 32; VAR_5 > 0; VAR_5 >>= 1) { if (layout >= (int64_t)1 << VAR_5) { VAR_6 += VAR_5; layout >>= VAR_5; } } if (VAR_6 >= MAX_CHANNELS || layout0 != (int64_t)1 << VAR_6)
return AVERROR(EINVAL); *VAR_1 = VAR_6; *VAR_2 = 1; *VAR_0 += VAR_4; return 0; } if (sscanf(*VAR_0, " c%d %n", &VAR_6, &VAR_4) &&
VAR_6 >= 0 && VAR_6 < MAX_CHANNELS) { *VAR_1 = VAR_6; *VAR_2 = 0; *VAR_0 += VAR_4; return 0; } return AVERROR(EINVAL); }