int av_get_channel_layout_channel_index(uint64_t channel_layout,
                                        uint64_t channel)
{
    if (!(channel_layout & channel) ||
        av_get_channel_layout_nb_channels(channel) != 1)
        return AVERROR(EINVAL);
    channel_layout &= channel - 1;
    return av_get_channel_layout_nb_channels(channel_layout);
}
['static int channelmap_config_input(AVFilterLink *inlink)\n{\n    AVFilterContext *ctx = inlink->dst;\n    ChannelMapContext *s = ctx->priv;\n    int nb_channels = av_get_channel_layout_nb_channels(inlink->channel_layout);\n    int i, err = 0;\n    const char *channel_name;\n    char layout_name[256];\n    for (i = 0; i < s->nch; i++) {\n        struct ChannelMap *m = &s->map[i];\n        if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR) {\n            m->in_channel_idx = av_get_channel_layout_channel_index(\n                inlink->channel_layout, m->in_channel);\n        }\n        if (m->in_channel_idx < 0 || m->in_channel_idx >= nb_channels) {\n            av_get_channel_layout_string(layout_name, sizeof(layout_name),\n                                         0, inlink->channel_layout);\n            if (m->in_channel) {\n                channel_name = av_get_channel_name(m->in_channel);\n                av_log(ctx, AV_LOG_ERROR,\n                       "input channel \'%s\' not available from input layout \'%s\'\\n",\n                       channel_name, layout_name);\n            } else {\n                av_log(ctx, AV_LOG_ERROR,\n                       "input channel #%d not available from input layout \'%s\'\\n",\n                       m->in_channel_idx, layout_name);\n            }\n            err = AVERROR(EINVAL);\n        }\n    }\n    return err;\n}', 'int av_get_channel_layout_channel_index(uint64_t channel_layout,\n                                        uint64_t channel)\n{\n    if (!(channel_layout & channel) ||\n        av_get_channel_layout_nb_channels(channel) != 1)\n        return AVERROR(EINVAL);\n    channel_layout &= channel - 1;\n    return av_get_channel_layout_nb_channels(channel_layout);\n}']