libavcodec/wmalosslessdec.c:1076: error: Integer Overflow L2
  ([-4, +oo] - 1):unsigned32 by call to `decode_subframe`.

libavcodec/wmalosslessdec.c:1061:39: Unknown value from: __builtin_clz
1059.         /* sometimes true for the last frame */
1060.         if (bitstream_read_bit(bc)) {
1061.             skip = bitstream_read(bc, av_log2(s->samples_per_frame * 2));
                                            ^
1062.             ff_dlog(s->avctx, "end skip: %i\n", skip);
1063.         }

libavcodec/wmalosslessdec.c:1061:20: Call
1059.         /* sometimes true for the last frame */
1060.         if (bitstream_read_bit(bc)) {
1061.             skip = bitstream_read(bc, av_log2(s->samples_per_frame * 2));
                         ^
1062.             ff_dlog(s->avctx, "end skip: %i\n", skip);
1063.         }

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

libavcodec/wmalosslessdec.c:1076:13: Call
1074.     /* decode all subframes */
1075.     while (!s->parsed_all_subframes) {
1076.         if (decode_subframe(s) < 0) {
                  ^
1077.             s->packet_loss = 1;
1078.             return 0;

libavcodec/wmalosslessdec.c:842:1: Parameter `s->bc.bits_left`
  840. }
  841. 
  842. static int decode_subframe(WmallDecodeCtx *s)
       ^
  843. {
  844.     int offset        = s->samples_per_frame;

libavcodec/wmalosslessdec.c:886:24: Call
  884. 
  885. 
  886.     s->seekable_tile = bitstream_read_bit(&s->bc);
                              ^
  887.     if (s->seekable_tile) {
  888.         clear_codec_buffers(s);

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: 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: Assignment
      137.     bc->bits <<= n;
      138. #endif
      139.     bc->bits_left -= n;
               ^
      140. 
      141.     return ret;

libavcodec/wmalosslessdec.c:890:33: Call
  888.         clear_codec_buffers(s);
  889. 
  890.         s->do_arith_coding    = bitstream_read_bit(&s->bc);
                                       ^
  891.         if (s->do_arith_coding) {
  892.             avpriv_request_sample(s->avctx, "Arithmetic coding");

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: 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: Assignment
      137.     bc->bits <<= n;
      138. #endif
      139.     bc->bits_left -= n;
               ^
      140. 
      141.     return ret;

libavcodec/wmalosslessdec.c:895:33: Call
  893.             return AVERROR_PATCHWELCOME;
  894.         }
  895.         s->do_ac_filter       = bitstream_read_bit(&s->bc);
                                       ^
  896.         s->do_inter_ch_decorr = bitstream_read_bit(&s->bc);
  897.         s->do_mclms           = bitstream_read_bit(&s->bc);

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: 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: Assignment
      137.     bc->bits <<= n;
      138. #endif
      139.     bc->bits_left -= n;
               ^
      140. 
      141.     return ret;

libavcodec/wmalosslessdec.c:896:33: Call
  894.         }
  895.         s->do_ac_filter       = bitstream_read_bit(&s->bc);
  896.         s->do_inter_ch_decorr = bitstream_read_bit(&s->bc);
                                       ^
  897.         s->do_mclms           = bitstream_read_bit(&s->bc);
  898. 

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: 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: Assignment
      137.     bc->bits <<= n;
      138. #endif
      139.     bc->bits_left -= n;
               ^
      140. 
      141.     return ret;

libavcodec/wmalosslessdec.c:897:33: Call
  895.         s->do_ac_filter       = bitstream_read_bit(&s->bc);
  896.         s->do_inter_ch_decorr = bitstream_read_bit(&s->bc);
  897.         s->do_mclms           = bitstream_read_bit(&s->bc);
                                       ^
  898. 
  899.         if (s->do_ac_filter)

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: ([-4, +oo] - 1):unsigned32 by call to `decode_subframe` 
      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 decode_frame(WmallDecodeCtx *s)\n{\n    BitstreamContext *bc = &s->bc;\n    int more_frames = 0, len = 0, i, ret;\n    s->frame->nb_samples = s->samples_per_frame;\n    if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) {\n        av_log(s->avctx, AV_LOG_ERROR,\n               "not enough space for the output samples\\n");\n        s->packet_loss = 1;\n        return ret;\n    }\n    for (i = 0; i < s->num_channels; i++) {\n        s->samples_16[i] = (int16_t *)s->frame->extended_data[i];\n        s->samples_32[i] = (int32_t *)s->frame->extended_data[i];\n    }\n    if (s->len_prefix)\n        len = bitstream_read(bc, s->log2_frame_size);\n    if (decode_tilehdr(s)) {\n        s->packet_loss = 1;\n        return 0;\n    }\n    if (s->dynamic_range_compression)\n        s->drc_gain = bitstream_read(bc, 8);\n    if (bitstream_read_bit(bc)) {\n        int av_unused skip;\n        if (bitstream_read_bit(bc)) {\n            skip = bitstream_read(bc, av_log2(s->samples_per_frame * 2));\n            ff_dlog(s->avctx, "start skip: %i\\n", skip);\n        }\n        if (bitstream_read_bit(bc)) {\n            skip = bitstream_read(bc, av_log2(s->samples_per_frame * 2));\n            ff_dlog(s->avctx, "end skip: %i\\n", skip);\n        }\n    }\n    s->parsed_all_subframes = 0;\n    for (i = 0; i < s->num_channels; i++) {\n        s->channel[i].decoded_samples = 0;\n        s->channel[i].cur_subframe    = 0;\n    }\n    while (!s->parsed_all_subframes) {\n        if (decode_subframe(s) < 0) {\n            s->packet_loss = 1;\n            return 0;\n        }\n    }\n    ff_dlog(s->avctx, "Frame done\\n");\n    if (s->skip_frame)\n        s->skip_frame = 0;\n    if (s->len_prefix) {\n        if (len != (bitstream_tell(bc) - s->frame_offset) + 2) {\n            av_log(s->avctx, AV_LOG_ERROR,\n                   "frame[%"PRIu32"] would have to skip %i bits\\n",\n                   s->frame_num,\n                   len - (bitstream_tell(bc) - s->frame_offset) - 1);\n            s->packet_loss = 1;\n            return 0;\n        }\n        bitstream_skip(bc, len - (bitstream_tell(bc) - s->frame_offset) - 1);\n    }\n    more_frames = bitstream_read_bit(bc);\n    ++s->frame_num;\n    return more_frames;\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 int decode_subframe(WmallDecodeCtx *s)\n{\n    int offset        = s->samples_per_frame;\n    int subframe_len  = s->samples_per_frame;\n    int total_samples = s->samples_per_frame * s->num_channels;\n    int i, j, rawpcm_tile, padding_zeroes, res;\n    s->subframe_offset = bitstream_tell(&s->bc);\n    for (i = 0; i < s->num_channels; i++) {\n        if (offset > s->channel[i].decoded_samples) {\n            offset = s->channel[i].decoded_samples;\n            subframe_len =\n                s->channel[i].subframe_len[s->channel[i].cur_subframe];\n        }\n    }\n    s->channels_for_cur_subframe = 0;\n    for (i = 0; i < s->num_channels; i++) {\n        const int cur_subframe = s->channel[i].cur_subframe;\n        total_samples -= s->channel[i].decoded_samples;\n        if (offset == s->channel[i].decoded_samples &&\n            subframe_len == s->channel[i].subframe_len[cur_subframe]) {\n            total_samples -= s->channel[i].subframe_len[cur_subframe];\n            s->channel[i].decoded_samples +=\n                s->channel[i].subframe_len[cur_subframe];\n            s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i;\n            ++s->channels_for_cur_subframe;\n        }\n    }\n    if (!total_samples)\n        s->parsed_all_subframes = 1;\n    s->seekable_tile = bitstream_read_bit(&s->bc);\n    if (s->seekable_tile) {\n        clear_codec_buffers(s);\n        s->do_arith_coding    = bitstream_read_bit(&s->bc);\n        if (s->do_arith_coding) {\n            avpriv_request_sample(s->avctx, "Arithmetic coding");\n            return AVERROR_PATCHWELCOME;\n        }\n        s->do_ac_filter       = bitstream_read_bit(&s->bc);\n        s->do_inter_ch_decorr = bitstream_read_bit(&s->bc);\n        s->do_mclms           = bitstream_read_bit(&s->bc);\n        if (s->do_ac_filter)\n            decode_ac_filter(s);\n        if (s->do_mclms)\n            decode_mclms(s);\n        if ((res = decode_cdlms(s)) < 0)\n            return res;\n        s->movave_scaling = bitstream_read(&s->bc, 3);\n        s->quant_stepsize = bitstream_read(&s->bc, 8) + 1;\n        reset_codec(s);\n    } else if (!s->cdlms[0][0].order) {\n        av_log(s->avctx, AV_LOG_DEBUG,\n               "Waiting for seekable tile\\n");\n        av_frame_unref(s->frame);\n        return -1;\n    }\n    rawpcm_tile = bitstream_read_bit(&s->bc);\n    for (i = 0; i < s->num_channels; i++)\n        s->is_channel_coded[i] = 1;\n    if (!rawpcm_tile) {\n        for (i = 0; i < s->num_channels; i++)\n            s->is_channel_coded[i] = bitstream_read_bit(&s->bc);\n        if (s->bV3RTM) {\n            s->do_lpc = bitstream_read_bit(&s->bc);\n            if (s->do_lpc) {\n                decode_lpc(s);\n                avpriv_request_sample(s->avctx, "Expect wrong output since "\n                                      "inverse LPC filter");\n            }\n        } else\n            s->do_lpc = 0;\n    }\n    if (bitstream_read_bit(&s->bc))\n        padding_zeroes = bitstream_read(&s->bc, 5);\n    else\n        padding_zeroes = 0;\n    if (rawpcm_tile) {\n        int bits = s->bits_per_sample - padding_zeroes;\n        if (bits <= 0) {\n            av_log(s->avctx, AV_LOG_ERROR,\n                   "Invalid number of padding bits in raw PCM tile\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        ff_dlog(s->avctx, "RAWPCM %d bits per sample. "\n                "total %d bits, remain=%d\\n", bits,\n                bits * s->num_channels * subframe_len, bitstream_tell(&s->bc));\n        for (i = 0; i < s->num_channels; i++)\n            for (j = 0; j < subframe_len; j++)\n                s->channel_coeffs[i][j] = bitstream_read_signed(&s->bc, bits);\n    } else {\n        for (i = 0; i < s->num_channels; i++)\n            if (s->is_channel_coded[i]) {\n                decode_channel_residues(s, i, subframe_len);\n                if (s->seekable_tile)\n                    use_high_update_speed(s, i);\n                else\n                    use_normal_update_speed(s, i);\n                revert_cdlms(s, i, 0, subframe_len);\n            } else {\n                memset(s->channel_residues[i], 0, sizeof(**s->channel_residues) * subframe_len);\n            }\n    }\n    if (s->do_mclms)\n        revert_mclms(s, subframe_len);\n    if (s->do_inter_ch_decorr)\n        revert_inter_ch_decorr(s, subframe_len);\n    if (s->do_ac_filter)\n        revert_acfilter(s, subframe_len);\n    if (s->quant_stepsize != 1)\n        for (i = 0; i < s->num_channels; i++)\n            for (j = 0; j < subframe_len; j++)\n                s->channel_residues[i][j] *= s->quant_stepsize;\n    for (i = 0; i < s->channels_for_cur_subframe; i++) {\n        int c = s->channel_indexes_for_cur_subframe[i];\n        int subframe_len = s->channel[c].subframe_len[s->channel[c].cur_subframe];\n        for (j = 0; j < subframe_len; j++) {\n            if (s->bits_per_sample == 16) {\n                *s->samples_16[c]++ = (int16_t) s->channel_residues[c][j] << padding_zeroes;\n            } else {\n                *s->samples_32[c]++ = s->channel_residues[c][j] << padding_zeroes;\n            }\n        }\n    }\n    for (i = 0; i < s->channels_for_cur_subframe; i++) {\n        int c = s->channel_indexes_for_cur_subframe[i];\n        if (s->channel[c].cur_subframe >= s->channel[c].num_subframes) {\n            av_log(s->avctx, AV_LOG_ERROR, "broken subframe\\n");\n            return AVERROR_INVALIDDATA;\n        }\n        ++s->channel[c].cur_subframe;\n    }\n    return 0;\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}']