libavcodec/takdec.c:785: error: Integer Overflow L2
  ([0, +oo] - 6):unsigned32 by call to `bitstream_skip`.

libavcodec/takdec.c:688:16: Call
686.     bitstream_init8(bc, pkt->data, pkt->size);
687. 
688.     if ((ret = ff_tak_decode_frame_header(avctx, bc, &s->ti, 0)) < 0)
                    ^
689.         return ret;
690. 

libavcodec/tak.c:127:9: Call
  125.                                TAKStreamInfo *ti, int log_level_offset)
  126. {
  127.     if (bitstream_read(bc, TAK_FRAME_HEADER_SYNC_ID_BITS) != TAK_FRAME_HEADER_SYNC_ID) {
               ^
  128.         av_log(avctx, AV_LOG_ERROR + log_level_offset, "missing sync id\n");
  129.         return AVERROR_INVALIDDATA;

libavcodec/bitstream.h:182:1: Parameter `bc->bits_left`
    180. 
    181. /* Return n bits from the buffer. n has to be in the 0-32 range. */
    182. static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)
         ^
    183. {
    184.     if (!n)

libavcodec/takdec.c:783:21: Call
781. 
782.             if (avctx->channels == 2) {
783.                 if (bitstream_read_bit(bc)) {
                         ^
784.                     // some kind of subframe length, but it seems to be unused
785.                     bitstream_skip(bc, 6);

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/takdec.c:785:21: Call
783.                 if (bitstream_read_bit(bc)) {
784.                     // some kind of subframe length, but it seems to be unused
785.                     bitstream_skip(bc, 6);
                         ^
786.                 }
787. 

libavcodec/bitstream.h:240:1: Parameter `n`
  238. 
  239. /* Skip n bits in the buffer. */
  240. static inline void bitstream_skip(BitstreamContext *bc, unsigned n)
       ^
  241. {
  242.     if (n < bc->bits_left)

libavcodec/bitstream.h:243:9: Call
  241. {
  242.     if (n < bc->bits_left)
  243.         skip_remaining(bc, n);
               ^
  244.     else {
  245.         n -= bc->bits_left;

libavcodec/bitstream.h:229:1: <LHS trace>
227. }
228. 
229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
     ^
230. {
231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:229:1: Parameter `bc->bits_left`
    227. }
    228. 
    229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
         ^
    230. {
    231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:229:1: <RHS trace>
227. }
228. 
229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
     ^
230. {
231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:229:1: Parameter `n`
    227. }
    228. 
    229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
         ^
    230. {
    231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:236:5: Binary operation: ([0, +oo] - 6):unsigned32 by call to `bitstream_skip` 
    234.     bc->bits <<= n;
    235. #endif
    236.     bc->bits_left -= n;
             ^
    237. }
    238. 

static inline void skip_remaining(BitstreamContext *bc, unsigned n)
{
#ifdef BITSTREAM_READER_LE
    bc->bits >>= n;
#else
    bc->bits <<= n;
#endif
    bc->bits_left -= n;
}
['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    BitstreamContext *bc = &s->bc;\n    int chan, i, ret, hsize;\n    if (pkt->size < TAK_MIN_FRAME_HEADER_BYTES)\n        return AVERROR_INVALIDDATA;\n    bitstream_init8(bc, pkt->data, pkt->size);\n    if ((ret = ff_tak_decode_frame_header(avctx, bc, &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 = bitstream_tell(bc) / 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        avpriv_report_missing_feature(avctx, "TAK codec type %d", 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        if (buf_size < 0)\n            return buf_size;\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] = bitstream_read_signed(bc, 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 (bitstream_read_bit(bc)) {\n                    bitstream_skip(bc, 6);\n                }\n                s->dmode = bitstream_read(bc, 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 (bitstream_read_bit(bc)) {\n                int ch_mask = 0;\n                chan = bitstream_read(bc, 4) + 1;\n                if (chan > avctx->channels)\n                    return AVERROR_INVALIDDATA;\n                for (i = 0; i < chan; i++) {\n                    int nbit = bitstream_read(bc, 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 = bitstream_read_bit(bc);\n                    if (s->mcdparams[i].present) {\n                        s->mcdparams[i].index = bitstream_read(bc, 2);\n                        s->mcdparams[i].chan2 = bitstream_read(bc, 4);\n                        if (s->mcdparams[i].chan2 >= avctx->channels) {\n                            av_log(avctx, AV_LOG_ERROR,\n                                   "invalid channel 2 (%d) for %d channel(s)\\n",\n                                   s->mcdparams[i].chan2, avctx->channels);\n                            return AVERROR_INVALIDDATA;\n                        }\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    bitstream_align(bc);\n    bitstream_skip(bc, 24);\n    if (bitstream_bits_left(bc) < 0)\n        av_log(avctx, AV_LOG_DEBUG, "overread\\n");\n    else if (bitstream_bits_left(bc) > 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                             bitstream_tell(bc) / 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, BitstreamContext *bc,\n                               TAKStreamInfo *ti, int log_level_offset)\n{\n    if (bitstream_read(bc, 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     = bitstream_read(bc, TAK_FRAME_HEADER_FLAGS_BITS);\n    ti->frame_num = bitstream_read(bc, TAK_FRAME_HEADER_NO_BITS);\n    if (ti->flags & TAK_FRAME_FLAG_IS_LAST) {\n        ti->last_frame_samples = bitstream_read(bc, TAK_FRAME_HEADER_SAMPLE_COUNT_BITS) + 1;\n        bitstream_skip(bc, 2);\n    } else {\n        ti->last_frame_samples = 0;\n    }\n    if (ti->flags & TAK_FRAME_FLAG_HAS_INFO) {\n        avpriv_tak_parse_streaminfo(bc, ti);\n        if (bitstream_read(bc, 6))\n            bitstream_skip(bc, 25);\n        bitstream_align(bc);\n    }\n    bitstream_skip(bc, 24);\n    return 0;\n}', 'static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)\n{\n    if (!n)\n        return 0;\n    if (n > bc->bits_left) {\n        refill_32(bc);\n        if (bc->bits_left < 32)\n            bc->bits_left = n;\n    }\n    return get_val(bc, n);\n}', 'static inline unsigned bitstream_read_bit(BitstreamContext *bc)\n{\n    if (!bc->bits_left)\n        refill_64(bc);\n    return get_val(bc, 1);\n}', 'static inline uint64_t get_val(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);\n    bc->bits >>= n;\n#else\n    uint64_t ret = bc->bits >> (64 - n);\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\n    return ret;\n}', 'static inline void bitstream_skip(BitstreamContext *bc, unsigned n)\n{\n    if (n < bc->bits_left)\n        skip_remaining(bc, n);\n    else {\n        n -= bc->bits_left;\n        bc->bits      = 0;\n        bc->bits_left = 0;\n        if (n >= 64) {\n            unsigned skip = n / 8;\n            n -= skip * 8;\n            bc->ptr += skip;\n        }\n        refill_64(bc);\n        if (n)\n            skip_remaining(bc, n);\n    }\n}', 'static inline void skip_remaining(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    bc->bits >>= n;\n#else\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\n}']