libavcodec/smacker.c:623: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `bitstream_read_bit`.

libavcodec/smacker.c:621:5: Call
619.     unp_size = AV_RL32(buf);
620. 
621.     bitstream_init8(&bc, buf + 4, buf_size - 4);
         ^
622. 
623.     if (!bitstream_read_bit(&bc)) {

libavcodec/bitstream.h:104:1: Parameter `bc->bits_left`
  102. 
  103. /* Initialize BitstreamContext with buffer size in bytes instead of bits. */
  104. static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,
       ^
  105.                                   unsigned byte_size)
  106. {

libavcodec/smacker.c:623:10: Call
621.     bitstream_init8(&bc, buf + 4, buf_size - 4);
622. 
623.     if (!bitstream_read_bit(&bc)) {
              ^
624.         av_log(avctx, AV_LOG_INFO, "Sound: no data\n");
625.         *got_frame_ptr = 0;

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

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

libavcodec/bitstream.h:130:1: <LHS trace>
128. }
129. 
130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
     ^
131. {
132. #ifdef BITSTREAM_READER_LE

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

libavcodec/bitstream.h:130:1: <RHS trace>
128. }
129. 
130. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
     ^
131. {
132. #ifdef BITSTREAM_READER_LE

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

libavcodec/bitstream.h:139:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `bitstream_read_bit` 
    137.     bc->bits <<= n;
    138. #endif
    139.     bc->bits_left -= n;
             ^
    140. 
    141.     return ret;

static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
{
#ifdef BITSTREAM_READER_LE
    uint64_t ret = bc->bits & ((UINT64_C(1) << n) - 1);
    bc->bits >>= n;
#else
    uint64_t ret = bc->bits >> (64 - n);
    bc->bits <<= n;
#endif
    bc->bits_left -= n;
    return ret;
}
['static int smka_decode_frame(AVCodecContext *avctx, void *data,\n                             int *got_frame_ptr, AVPacket *avpkt)\n{\n    AVFrame *frame     = data;\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    BitstreamContext bc;\n    HuffContext h[4] = { { 0 } };\n    VLC vlc[4]       = { { 0 } };\n    int16_t *samples;\n    uint8_t *samples8;\n    int val;\n    int i, res, ret;\n    int unp_size;\n    int bits, stereo;\n    int pred[2] = {0, 0};\n    if (buf_size <= 4) {\n        av_log(avctx, AV_LOG_ERROR, "packet is too small\\n");\n        return AVERROR(EINVAL);\n    }\n    unp_size = AV_RL32(buf);\n    bitstream_init8(&bc, buf + 4, buf_size - 4);\n    if (!bitstream_read_bit(&bc)) {\n        av_log(avctx, AV_LOG_INFO, "Sound: no data\\n");\n        *got_frame_ptr = 0;\n        return 1;\n    }\n    stereo = bitstream_read_bit(&bc);\n    bits   = bitstream_read_bit(&bc);\n    if (stereo ^ (avctx->channels != 1)) {\n        av_log(avctx, AV_LOG_ERROR, "channels mismatch\\n");\n        return AVERROR(EINVAL);\n    }\n    if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {\n        av_log(avctx, AV_LOG_ERROR, "sample format mismatch\\n");\n        return AVERROR(EINVAL);\n    }\n    frame->nb_samples = unp_size / (avctx->channels * (bits + 1));\n    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return ret;\n    }\n    samples  = (int16_t *)frame->data[0];\n    samples8 =            frame->data[0];\n    for(i = 0; i < (1 << (bits + stereo)); i++) {\n        h[i].length = 256;\n        h[i].maxlength = 0;\n        h[i].current = 0;\n        h[i].bits = av_mallocz(256 * 4);\n        h[i].lengths = av_mallocz(256 * sizeof(int));\n        h[i].values = av_mallocz(256 * sizeof(int));\n        if (!h[i].bits || !h[i].lengths || !h[i].values) {\n            ret = AVERROR(ENOMEM);\n            goto error;\n        }\n        bitstream_skip(&bc, 1);\n        if (smacker_decode_tree(&bc, &h[i], 0, 0) < 0) {\n            ret = AVERROR_INVALIDDATA;\n            goto error;\n        }\n        bitstream_skip(&bc, 1);\n        if(h[i].current > 1) {\n            res = init_vlc(&vlc[i], SMKTREE_BITS, h[i].length,\n                    h[i].lengths, sizeof(int), sizeof(int),\n                    h[i].bits, sizeof(uint32_t), sizeof(uint32_t), INIT_VLC_LE);\n            if(res < 0) {\n                av_log(avctx, AV_LOG_ERROR, "Cannot build VLC table\\n");\n                ret = AVERROR_INVALIDDATA;\n                goto error;\n            }\n        }\n    }\n    if(bits) {\n        for(i = stereo; i >= 0; i--)\n            pred[i] = sign_extend(av_bswap16(bitstream_read(&bc, 16)), 16);\n        for(i = 0; i <= stereo; i++)\n            *samples++ = pred[i];\n        for(; i < unp_size / 2; i++) {\n            if(i & stereo) {\n                if(vlc[2].table)\n                    res = bitstream_read_vlc(&bc, vlc[2].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val  = h[2].values[res];\n                if(vlc[3].table)\n                    res = bitstream_read_vlc(&bc, vlc[3].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val |= h[3].values[res] << 8;\n                pred[1] += sign_extend(val, 16);\n                *samples++ = pred[1];\n            } else {\n                if(vlc[0].table)\n                    res = bitstream_read_vlc(&bc, vlc[0].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val  = h[0].values[res];\n                if(vlc[1].table)\n                    res = bitstream_read_vlc(&bc, vlc[1].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                val |= h[1].values[res] << 8;\n                pred[0] += sign_extend(val, 16);\n                *samples++ = pred[0];\n            }\n        }\n    } else {\n        for(i = stereo; i >= 0; i--)\n            pred[i] = bitstream_read(&bc, 8);\n        for(i = 0; i <= stereo; i++)\n            *samples8++ = pred[i];\n        for(; i < unp_size; i++) {\n            if(i & stereo){\n                if(vlc[1].table)\n                    res = bitstream_read_vlc(&bc, vlc[1].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                pred[1] += sign_extend(h[1].values[res], 8);\n                *samples8++ = pred[1];\n            } else {\n                if(vlc[0].table)\n                    res = bitstream_read_vlc(&bc, vlc[0].table, SMKTREE_BITS, 3);\n                else\n                    res = 0;\n                pred[0] += sign_extend(h[0].values[res], 8);\n                *samples8++ = pred[0];\n            }\n        }\n    }\n    *got_frame_ptr = 1;\n    ret = buf_size;\nerror:\n    for(i = 0; i < 4; i++) {\n        if(vlc[i].table)\n            ff_free_vlc(&vlc[i]);\n        av_free(h[i].bits);\n        av_free(h[i].lengths);\n        av_free(h[i].values);\n    }\n    return ret;\n}', 'static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,\n                                  unsigned byte_size)\n{\n    if (byte_size > INT_MAX / 8)\n        return AVERROR_INVALIDDATA;\n    return bitstream_init(bc, buffer, byte_size * 8);\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}']