libavcodec/mlpdec.c:483: error: Integer Overflow L1
  (0 - 1):unsigned64 by call to `av_get_channel_layout_channel_index`.

libavcodec/mlpdec.c:481:32: Call
479.         int ch_assign = get_bits(gbp, 6);
480.         if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) {
481.             uint64_t channel = thd_channel_layout_extract_channel(s->ch_layout,
                                    ^
482.                                                                   ch_assign);
483.             ch_assign = av_get_channel_layout_channel_index(s->ch_layout,

libavcodec/mlpdec.c:174:9: Assignment
  172. 
  173.     if (av_get_channel_layout_nb_channels(channel_layout) <= index)
  174.         return 0;
               ^
  175. 
  176.     for (i = 0; i < FF_ARRAY_ELEMS(thd_channel_order); i++)

libavcodec/mlpdec.c:481:13: Assignment
479.         int ch_assign = get_bits(gbp, 6);
480.         if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) {
481.             uint64_t channel = thd_channel_layout_extract_channel(s->ch_layout,
                 ^
482.                                                                   ch_assign);
483.             ch_assign = av_get_channel_layout_channel_index(s->ch_layout,

libavcodec/mlpdec.c:483:25: Call
481.             uint64_t channel = thd_channel_layout_extract_channel(s->ch_layout,
482.                                                                   ch_assign);
483.             ch_assign = av_get_channel_layout_channel_index(s->ch_layout,
                             ^
484.                                                             channel);
485.         }

libavutil/channel_layout.c:198:1: <LHS trace>
196. }
197. 
198. int av_get_channel_layout_channel_index(uint64_t channel_layout,
     ^
199.                                         uint64_t channel)
200. {

libavutil/channel_layout.c:198:1: Parameter `channel`
  196. }
  197. 
  198. int av_get_channel_layout_channel_index(uint64_t channel_layout,
       ^
  199.                                         uint64_t channel)
  200. {

libavutil/channel_layout.c:204:5: Binary operation: (0 - 1):unsigned64 by call to `av_get_channel_layout_channel_index` 
  202.         av_get_channel_layout_nb_channels(channel) != 1)
  203.         return AVERROR(EINVAL);
  204.     channel_layout &= channel - 1;
           ^
  205.     return av_get_channel_layout_nb_channels(channel_layout);
  206. }

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 read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,\n                               const uint8_t *buf, unsigned int substr)\n{\n    SubStream *s = &m->substream[substr];\n    unsigned int ch;\n    int sync_word, tmp;\n    uint8_t checksum;\n    uint8_t lossless_check;\n    int start_count = get_bits_count(gbp);\n    const int max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP\n                                 ? MAX_MATRIX_CHANNEL_MLP\n                                 : MAX_MATRIX_CHANNEL_TRUEHD;\n    sync_word = get_bits(gbp, 13);\n    if (sync_word != 0x31ea >> 1) {\n        av_log(m->avctx, AV_LOG_ERROR,\n               "restart header sync incorrect (got 0x%04x)\\n", sync_word);\n        return AVERROR_INVALIDDATA;\n    }\n    s->noise_type = get_bits1(gbp);\n    if (m->avctx->codec_id == AV_CODEC_ID_MLP && s->noise_type) {\n        av_log(m->avctx, AV_LOG_ERROR, "MLP must have 0x31ea sync word.\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    skip_bits(gbp, 16);\n    s->min_channel        = get_bits(gbp, 4);\n    s->max_channel        = get_bits(gbp, 4);\n    s->max_matrix_channel = get_bits(gbp, 4);\n    if (s->max_matrix_channel > max_matrix_channel) {\n        av_log(m->avctx, AV_LOG_ERROR,\n               "Max matrix channel cannot be greater than %d.\\n",\n               max_matrix_channel);\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->max_channel != s->max_matrix_channel) {\n        av_log(m->avctx, AV_LOG_ERROR,\n               "Max channel must be equal max matrix channel.\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->max_channel > MAX_MATRIX_CHANNEL_MLP && !s->noise_type) {\n        av_log_ask_for_sample(m->avctx,\n               "Number of channels %d is larger than the maximum supported "\n               "by the decoder.\\n", s->max_channel + 2);\n        return AVERROR_PATCHWELCOME;\n    }\n    if (s->min_channel > s->max_channel) {\n        av_log(m->avctx, AV_LOG_ERROR,\n               "Substream min channel cannot be greater than max channel.\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if (m->avctx->request_channels > 0\n        && s->max_channel + 1 >= m->avctx->request_channels\n        && substr < m->max_decoded_substream) {\n        av_log(m->avctx, AV_LOG_DEBUG,\n               "Extracting %d channel downmix from substream %d. "\n               "Further substreams will be skipped.\\n",\n               s->max_channel + 1, substr);\n        m->max_decoded_substream = substr;\n    }\n    s->noise_shift   = get_bits(gbp,  4);\n    s->noisegen_seed = get_bits(gbp, 23);\n    skip_bits(gbp, 19);\n    s->data_check_present = get_bits1(gbp);\n    lossless_check = get_bits(gbp, 8);\n    if (substr == m->max_decoded_substream\n        && s->lossless_check_data != 0xffffffff) {\n        tmp = xor_32_to_8(s->lossless_check_data);\n        if (tmp != lossless_check)\n            av_log(m->avctx, AV_LOG_WARNING,\n                   "Lossless check failed - expected %02x, calculated %02x.\\n",\n                   lossless_check, tmp);\n    }\n    skip_bits(gbp, 16);\n    memset(s->ch_assign, 0, sizeof(s->ch_assign));\n    for (ch = 0; ch <= s->max_matrix_channel; ch++) {\n        int ch_assign = get_bits(gbp, 6);\n        if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) {\n            uint64_t channel = thd_channel_layout_extract_channel(s->ch_layout,\n                                                                  ch_assign);\n            ch_assign = av_get_channel_layout_channel_index(s->ch_layout,\n                                                            channel);\n        }\n        if (ch_assign > s->max_matrix_channel) {\n            av_log_ask_for_sample(m->avctx,\n                   "Assignment of matrix channel %d to invalid output channel %d.\\n",\n                   ch, ch_assign);\n            return AVERROR_PATCHWELCOME;\n        }\n        s->ch_assign[ch_assign] = ch;\n    }\n    checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);\n    if (checksum != get_bits(gbp, 8))\n        av_log(m->avctx, AV_LOG_ERROR, "restart header checksum error\\n");\n    s->param_presence_flags   = 0xff;\n    s->num_primitive_matrices = 0;\n    s->blocksize              = 8;\n    s->lossless_check_data    = 0;\n    memset(s->output_shift   , 0, sizeof(s->output_shift   ));\n    memset(s->quant_step_size, 0, sizeof(s->quant_step_size));\n    for (ch = s->min_channel; ch <= s->max_channel; ch++) {\n        ChannelParams *cp = &s->channel_params[ch];\n        cp->filter_params[FIR].order = 0;\n        cp->filter_params[IIR].order = 0;\n        cp->filter_params[FIR].shift = 0;\n        cp->filter_params[IIR].shift = 0;\n        cp->huff_offset      = 0;\n        cp->sign_huff_offset = (-1) << 23;\n        cp->codebook         = 0;\n        cp->huff_lsbs        = 24;\n    }\n    if (substr == m->max_decoded_substream)\n        m->avctx->channels = s->max_matrix_channel + 1;\n    return 0;\n}', 'static uint64_t thd_channel_layout_extract_channel(uint64_t channel_layout,\n                                                   int index)\n{\n    int i;\n    if (av_get_channel_layout_nb_channels(channel_layout) <= index)\n        return 0;\n    for (i = 0; i < FF_ARRAY_ELEMS(thd_channel_order); i++)\n        if (channel_layout & thd_channel_order[i] && !index--)\n            return thd_channel_order[i];\n    return 0;\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}']