libavcodec/atrac3.c:580: error: Integer Overflow L2
  ([1, +oo] - 2):unsigned32 by call to `bitstream_read`.

libavcodec/atrac3.c:580:13: Call
578. 
579.     if (coding_mode == JOINT_STEREO && channel_num == 1) {
580.         if (bitstream_read(bc, 2) != 3) {
                 ^
581.             av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");
582.             return AVERROR_INVALIDDATA;

libavcodec/bitstream.h:183:1: Parameter `n`
  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/bitstream.h:194:12: Call
  192.     }
  193. 
  194.     return get_val(bc, n);
                  ^
  195. }
  196. 

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: ([1, +oo] - 2):unsigned32 by call to `bitstream_read` 
    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_channel_sound_unit(ATRAC3Context *q, BitstreamContext *bc,\n                                     ChannelUnit *snd, float *output,\n                                     int channel_num, int coding_mode)\n{\n    int band, ret, num_subbands, last_tonal, num_bands;\n    GainBlock *gain1 = &snd->gain_block[    snd->gc_blk_switch];\n    GainBlock *gain2 = &snd->gain_block[1 - snd->gc_blk_switch];\n    if (coding_mode == JOINT_STEREO && channel_num == 1) {\n        if (bitstream_read(bc, 2) != 3) {\n            av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\\n");\n            return AVERROR_INVALIDDATA;\n        }\n    } else {\n        if (bitstream_read(bc, 6) != 0x28) {\n            av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\\n");\n            return AVERROR_INVALIDDATA;\n        }\n    }\n    snd->bands_coded = bitstream_read(bc, 2);\n    ret = decode_gain_control(bc, gain2, snd->bands_coded);\n    if (ret)\n        return ret;\n    snd->num_components = decode_tonal_components(bc, snd->components,\n                                                  snd->bands_coded);\n    if (snd->num_components < 0)\n        return snd->num_components;\n    num_subbands = decode_spectrum(bc, snd->spectrum);\n    last_tonal = add_tonal_components(snd->spectrum, snd->num_components,\n                                      snd->components);\n    num_bands = (subband_tab[num_subbands] - 1) >> 8;\n    if (last_tonal >= 0)\n        num_bands = FFMAX((last_tonal + 256) >> 8, num_bands);\n    for (band = 0; band < 4; band++) {\n        if (band <= num_bands)\n            imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);\n        else\n            memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf));\n        ff_atrac_gain_compensation(&q->gainc_ctx, snd->imdct_buf,\n                                   &snd->prev_frame[band * 256],\n                                   &gain1->g_block[band], &gain2->g_block[band],\n                                   256, &output[band * 256]);\n    }\n    snd->gc_blk_switch ^= 1;\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 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}']