libavcodec/takdec.c:748: error: Integer Overflow L2
  ([1, 2147483616] + 32):signed32 by call to `av_samples_get_buffer_size`.

libavcodec/takdec.c:684:16: Call
682.     init_get_bits(gb, pkt->data, pkt->size * 8);
683. 
684.     if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0)
                    ^
685.         return ret;
686. 

libavcodec/tak.c:121:1: Parameter `ti->frame_samples`
  119. }
  120. 
  121. int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
       ^
  122.                                TAKStreamInfo *ti, int log_level_offset)
  123. {

libavcodec/takdec.c:740:21: Assignment
738.     avctx->channels = s->ti.channels;
739. 
740.     s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples
                         ^
741.                                              : s->ti.frame_samples;
742. 

libavcodec/takdec.c:740:5: Assignment
738.     avctx->channels = s->ti.channels;
739. 
740.     s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples
         ^
741.                                              : s->ti.frame_samples;
742. 

libavcodec/takdec.c:748:24: Call
746. 
747.     if (avctx->bits_per_coded_sample <= 16) {
748.         int buf_size = av_samples_get_buffer_size(NULL, avctx->channels,
                            ^
749.                                                   s->nb_samples,
750.                                                   AV_SAMPLE_FMT_S32P, 0);

libavutil/samplefmt.c:108:1: <LHS trace>
106. }
107. 
108. int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
     ^
109.                                enum AVSampleFormat sample_fmt, int align)
110. {

libavutil/samplefmt.c:108:1: Parameter `nb_samples`
  106. }
  107. 
  108. int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
       ^
  109.                                enum AVSampleFormat sample_fmt, int align)
  110. {

libavutil/samplefmt.c:124:9: Binary operation: ([1, 2147483616] + 32):signed32 by call to `av_samples_get_buffer_size` 
  122.             return AVERROR(EINVAL);
  123.         align = 1;
  124.         nb_samples = FFALIGN(nb_samples, 32);
               ^
  125.     }
  126. 

int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
                               enum AVSampleFormat sample_fmt, int align)
{
    int line_size;
    int sample_size = av_get_bytes_per_sample(sample_fmt);
    int planar      = av_sample_fmt_is_planar(sample_fmt);
    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
        return AVERROR(EINVAL);
    if (!align) {
        if (nb_samples > INT_MAX - 31)
            return AVERROR(EINVAL);
        align = 1;
        nb_samples = FFALIGN(nb_samples, 32);
    }
    if (nb_channels > INT_MAX / align ||
        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
        return AVERROR(EINVAL);
    line_size = planar ? FFALIGN(nb_samples * sample_size,               align) :
                         FFALIGN(nb_samples * sample_size * nb_channels, align);
    if (linesize)
        *linesize = line_size;
    return planar ? line_size * nb_channels : line_size;
}
['static int tak_decode_frame(AVCodecContext *avctx, void *data,\n                            int *got_frame_ptr, AVPacket *pkt)\n{\n    TAKDecContext *s  = avctx->priv_data;\n    AVFrame *frame    = data;\n    GetBitContext *gb = &s->gb;\n    int chan, i, ret, hsize;\n    if (pkt->size < TAK_MIN_FRAME_HEADER_BYTES)\n        return AVERROR_INVALIDDATA;\n    init_get_bits(gb, pkt->data, pkt->size * 8);\n    if ((ret = ff_tak_decode_frame_header(avctx, gb, &s->ti, 0)) < 0)\n        return ret;\n    if (s->ti.flags & TAK_FRAME_FLAG_HAS_METADATA) {\n        avpriv_request_sample(avctx, "Frame metadata");\n        return AVERROR_PATCHWELCOME;\n    }\n    hsize = get_bits_count(gb) / 8;\n    if (avctx->err_recognition & AV_EF_CRCCHECK) {\n        if (ff_tak_check_crc(pkt->data, hsize)) {\n            av_log(avctx, AV_LOG_ERROR, "CRC error\\n");\n            if (avctx->err_recognition & AV_EF_EXPLODE)\n                return AVERROR_INVALIDDATA;\n        }\n    }\n    if (s->ti.codec != TAK_CODEC_MONO_STEREO &&\n        s->ti.codec != TAK_CODEC_MULTICHANNEL) {\n        av_log(avctx, AV_LOG_ERROR, "unsupported codec: %d\\n", s->ti.codec);\n        return AVERROR_PATCHWELCOME;\n    }\n    if (s->ti.data_type) {\n        av_log(avctx, AV_LOG_ERROR,\n               "unsupported data type: %d\\n", s->ti.data_type);\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->ti.codec == TAK_CODEC_MONO_STEREO && s->ti.channels > 2) {\n        av_log(avctx, AV_LOG_ERROR,\n               "invalid number of channels: %d\\n", s->ti.channels);\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->ti.channels > 6) {\n        av_log(avctx, AV_LOG_ERROR,\n               "unsupported number of channels: %d\\n", s->ti.channels);\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->ti.frame_samples <= 0) {\n        av_log(avctx, AV_LOG_ERROR, "unsupported/invalid number of samples\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if (s->ti.bps != avctx->bits_per_coded_sample) {\n        avctx->bits_per_coded_sample = s->ti.bps;\n        if ((ret = set_bps_params(avctx)) < 0)\n            return ret;\n    }\n    if (s->ti.sample_rate != avctx->sample_rate) {\n        avctx->sample_rate = s->ti.sample_rate;\n        set_sample_rate_params(avctx);\n    }\n    if (s->ti.ch_layout)\n        avctx->channel_layout = s->ti.ch_layout;\n    avctx->channels = s->ti.channels;\n    s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples\n                                             : s->ti.frame_samples;\n    frame->nb_samples = s->nb_samples;\n    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)\n        return ret;\n    if (avctx->bits_per_coded_sample <= 16) {\n        int buf_size = av_samples_get_buffer_size(NULL, avctx->channels,\n                                                  s->nb_samples,\n                                                  AV_SAMPLE_FMT_S32P, 0);\n        av_fast_malloc(&s->decode_buffer, &s->decode_buffer_size, buf_size);\n        if (!s->decode_buffer)\n            return AVERROR(ENOMEM);\n        ret = av_samples_fill_arrays((uint8_t **)s->decoded, NULL,\n                                     s->decode_buffer, avctx->channels,\n                                     s->nb_samples, AV_SAMPLE_FMT_S32P, 0);\n        if (ret < 0)\n            return ret;\n    } else {\n        for (chan = 0; chan < avctx->channels; chan++)\n            s->decoded[chan] = (int32_t *)frame->extended_data[chan];\n    }\n    if (s->nb_samples < 16) {\n        for (chan = 0; chan < avctx->channels; chan++) {\n            int32_t *decoded = s->decoded[chan];\n            for (i = 0; i < s->nb_samples; i++)\n                decoded[i] = get_sbits(gb, avctx->bits_per_coded_sample);\n        }\n    } else {\n        if (s->ti.codec == TAK_CODEC_MONO_STEREO) {\n            for (chan = 0; chan < avctx->channels; chan++)\n                if (ret = decode_channel(s, chan))\n                    return ret;\n            if (avctx->channels == 2) {\n                if (get_bits1(gb)) {\n                    skip_bits(gb, 6);\n                }\n                s->dmode = get_bits(gb, 3);\n                if (ret = decorrelate(s, 0, 1, s->nb_samples - 1))\n                    return ret;\n            }\n        } else if (s->ti.codec == TAK_CODEC_MULTICHANNEL) {\n            if (get_bits1(gb)) {\n                int ch_mask = 0;\n                chan = get_bits(gb, 4) + 1;\n                if (chan > avctx->channels)\n                    return AVERROR_INVALIDDATA;\n                for (i = 0; i < chan; i++) {\n                    int nbit = get_bits(gb, 4);\n                    if (nbit >= avctx->channels)\n                        return AVERROR_INVALIDDATA;\n                    if (ch_mask & 1 << nbit)\n                        return AVERROR_INVALIDDATA;\n                    s->mcdparams[i].present = get_bits1(gb);\n                    if (s->mcdparams[i].present) {\n                        s->mcdparams[i].index = get_bits(gb, 2);\n                        s->mcdparams[i].chan2 = get_bits(gb, 4);\n                        if (s->mcdparams[i].index == 1) {\n                            if ((nbit == s->mcdparams[i].chan2) ||\n                                (ch_mask & 1 << s->mcdparams[i].chan2))\n                                return AVERROR_INVALIDDATA;\n                            ch_mask |= 1 << s->mcdparams[i].chan2;\n                        } else if (!(ch_mask & 1 << s->mcdparams[i].chan2)) {\n                            return AVERROR_INVALIDDATA;\n                        }\n                    }\n                    s->mcdparams[i].chan1 = nbit;\n                    ch_mask |= 1 << nbit;\n                }\n            } else {\n                chan = avctx->channels;\n                for (i = 0; i < chan; i++) {\n                    s->mcdparams[i].present = 0;\n                    s->mcdparams[i].chan1   = i;\n                }\n            }\n            for (i = 0; i < chan; i++) {\n                if (s->mcdparams[i].present && s->mcdparams[i].index == 1)\n                    if (ret = decode_channel(s, s->mcdparams[i].chan2))\n                        return ret;\n                if (ret = decode_channel(s, s->mcdparams[i].chan1))\n                    return ret;\n                if (s->mcdparams[i].present) {\n                    s->dmode = mc_dmodes[s->mcdparams[i].index];\n                    if (ret = decorrelate(s,\n                                          s->mcdparams[i].chan2,\n                                          s->mcdparams[i].chan1,\n                                          s->nb_samples - 1))\n                        return ret;\n                }\n            }\n        }\n        for (chan = 0; chan < avctx->channels; chan++) {\n            int32_t *decoded = s->decoded[chan];\n            if (s->lpc_mode[chan])\n                decode_lpc(decoded, s->lpc_mode[chan], s->nb_samples);\n            if (s->sample_shift[chan] > 0)\n                for (i = 0; i < s->nb_samples; i++)\n                    decoded[i] <<= s->sample_shift[chan];\n        }\n    }\n    align_get_bits(gb);\n    skip_bits(gb, 24);\n    if (get_bits_left(gb) < 0)\n        av_log(avctx, AV_LOG_DEBUG, "overread\\n");\n    else if (get_bits_left(gb) > 0)\n        av_log(avctx, AV_LOG_DEBUG, "underread\\n");\n    if (avctx->err_recognition & AV_EF_CRCCHECK) {\n        if (ff_tak_check_crc(pkt->data + hsize,\n                             get_bits_count(gb) / 8 - hsize)) {\n            av_log(avctx, AV_LOG_ERROR, "CRC error\\n");\n            if (avctx->err_recognition & AV_EF_EXPLODE)\n                return AVERROR_INVALIDDATA;\n        }\n    }\n    switch (avctx->sample_fmt) {\n    case AV_SAMPLE_FMT_U8P:\n        for (chan = 0; chan < avctx->channels; chan++) {\n            uint8_t *samples = (uint8_t *)frame->extended_data[chan];\n            int32_t *decoded = s->decoded[chan];\n            for (i = 0; i < s->nb_samples; i++)\n                samples[i] = decoded[i] + 0x80;\n        }\n        break;\n    case AV_SAMPLE_FMT_S16P:\n        for (chan = 0; chan < avctx->channels; chan++) {\n            int16_t *samples = (int16_t *)frame->extended_data[chan];\n            int32_t *decoded = s->decoded[chan];\n            for (i = 0; i < s->nb_samples; i++)\n                samples[i] = decoded[i];\n        }\n        break;\n    case AV_SAMPLE_FMT_S32P:\n        for (chan = 0; chan < avctx->channels; chan++) {\n            int32_t *samples = (int32_t *)frame->extended_data[chan];\n            for (i = 0; i < s->nb_samples; i++)\n                samples[i] <<= 8;\n        }\n        break;\n    }\n    *got_frame_ptr = 1;\n    return pkt->size;\n}', 'int ff_tak_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,\n                               TAKStreamInfo *ti, int log_level_offset)\n{\n    if (get_bits(gb, TAK_FRAME_HEADER_SYNC_ID_BITS) != TAK_FRAME_HEADER_SYNC_ID) {\n        av_log(avctx, AV_LOG_ERROR + log_level_offset, "missing sync id\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    ti->flags     = get_bits(gb, TAK_FRAME_HEADER_FLAGS_BITS);\n    ti->frame_num = get_bits(gb, TAK_FRAME_HEADER_NO_BITS);\n    if (ti->flags & TAK_FRAME_FLAG_IS_LAST) {\n        ti->last_frame_samples = get_bits(gb, TAK_FRAME_HEADER_SAMPLE_COUNT_BITS) + 1;\n        skip_bits(gb, 2);\n    } else {\n        ti->last_frame_samples = 0;\n    }\n    if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {\n        avpriv_tak_parse_streaminfo(gb, ti);\n        if (get_bits(gb, 6))\n            skip_bits(gb, 25);\n        align_get_bits(gb);\n    }\n    skip_bits(gb, 24);\n    return 0;\n}', 'int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,\n                               enum AVSampleFormat sample_fmt, int align)\n{\n    int line_size;\n    int sample_size = av_get_bytes_per_sample(sample_fmt);\n    int planar      = av_sample_fmt_is_planar(sample_fmt);\n    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)\n        return AVERROR(EINVAL);\n    if (!align) {\n        if (nb_samples > INT_MAX - 31)\n            return AVERROR(EINVAL);\n        align = 1;\n        nb_samples = FFALIGN(nb_samples, 32);\n    }\n    if (nb_channels > INT_MAX / align ||\n        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)\n        return AVERROR(EINVAL);\n    line_size = planar ? FFALIGN(nb_samples * sample_size,               align) :\n                         FFALIGN(nb_samples * sample_size * nb_channels, align);\n    if (linesize)\n        *linesize = line_size;\n    return planar ? line_size * nb_channels : line_size;\n}']