libavcodec/atrac3.c:712: error: Integer Overflow L2
  (32 - [0, 64]):unsigned32 by call to `decode_channel_sound_unit`.

libavcodec/atrac3.c:708:13: Call
706.         for (i = 0; i < avctx->channels; i++) {
707.             /* Set the bitstream reader at the start of a channel sound unit. */
708.             bitstream_init(&q->bc,
                 ^
709.                            databuf + i * avctx->block_align / avctx->channels,
710.                            avctx->block_align * 8 / avctx->channels);

libavcodec/bitstream.h:85:9: Assignment
  83.         bc->buffer    =
  84.         bc->ptr       = NULL;
  85.         bc->bits_left = 0;
              ^
  86.         return AVERROR_INVALIDDATA;
  87.     }

libavcodec/atrac3.c:712:19: Call
710.                            avctx->block_align * 8 / avctx->channels);
711. 
712.             ret = decode_channel_sound_unit(q, &q->bc, &q->units[i],
                       ^
713.                                             out_samples[i], i, q->coding_mode);
714.             if (ret != 0)

libavcodec/atrac3.c:571:1: Parameter `bc->bits_left`
  569.  * @param coding_mode   the coding mode (JOINT_STEREO or regular stereo/mono)
  570.  */
  571. static int decode_channel_sound_unit(ATRAC3Context *q, BitstreamContext *bc,
       ^
  572.                                      ChannelUnit *snd, float *output,
  573.                                      int channel_num, int coding_mode)

libavcodec/atrac3.c:585:13: Call
  583.         }
  584.     } else {
  585.         if (bitstream_read(bc, 6) != 0x28) {
                   ^
  586.             av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");
  587.             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:189:9: Call
    187. 
    188.     if (n > bc->bits_left) {
    189.         refill_32(bc);
                 ^
    190.         if (bc->bits_left < 32)
    191.             bc->bits_left = n;

libavcodec/bitstream.h:60:1: <RHS trace>
58. }
59. 
60. static inline void refill_32(BitstreamContext *bc)
    ^
61. {
62.     if (bc->ptr >= bc->buffer_end)

libavcodec/bitstream.h:60:1: Parameter `bc->bits_left`
      58. }
      59. 
      60. static inline void refill_32(BitstreamContext *bc)
          ^
      61. {
      62.     if (bc->ptr >= bc->buffer_end)

libavcodec/bitstream.h:68:5: Binary operation: (32 - [0, 64]):unsigned32 by call to `decode_channel_sound_unit` 
      66.     bc->bits       = (uint64_t)AV_RL32(bc->ptr) << bc->bits_left | bc->bits;
      67. #else
      68.     bc->bits       = bc->bits | (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_left);
              ^
      69. #endif
      70.     bc->ptr       += 4;

static inline void refill_32(BitstreamContext *bc)
{
    if (bc->ptr >= bc->buffer_end)
        return;
#ifdef BITSTREAM_READER_LE
    bc->bits       = (uint64_t)AV_RL32(bc->ptr) << bc->bits_left | bc->bits;
#else
    bc->bits       = bc->bits | (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_left);
#endif
    bc->ptr       += 4;
    bc->bits_left += 32;
}
['static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,\n                        float **out_samples)\n{\n    ATRAC3Context *q = avctx->priv_data;\n    int ret, i;\n    uint8_t *ptr1;\n    if (q->coding_mode == JOINT_STEREO) {\n        bitstream_init(&q->bc, databuf, avctx->block_align * 8);\n        ret = decode_channel_sound_unit(q, &q->bc, q->units, out_samples[0], 0,\n                                        JOINT_STEREO);\n        if (ret != 0)\n            return ret;\n        if (databuf == q->decoded_bytes_buffer) {\n            uint8_t *ptr2 = q->decoded_bytes_buffer + avctx->block_align - 1;\n            ptr1          = q->decoded_bytes_buffer;\n            for (i = 0; i < avctx->block_align / 2; i++, ptr1++, ptr2--)\n                FFSWAP(uint8_t, *ptr1, *ptr2);\n        } else {\n            const uint8_t *ptr2 = databuf + avctx->block_align - 1;\n            for (i = 0; i < avctx->block_align; i++)\n                q->decoded_bytes_buffer[i] = *ptr2--;\n        }\n        ptr1 = q->decoded_bytes_buffer;\n        for (i = 4; *ptr1 == 0xF8; i++, ptr1++) {\n            if (i >= avctx->block_align)\n                return AVERROR_INVALIDDATA;\n        }\n        bitstream_init(&q->bc, ptr1, (avctx->block_align - i) * 8);\n        memmove(q->weighting_delay, &q->weighting_delay[2],\n                4 * sizeof(*q->weighting_delay));\n        q->weighting_delay[4] = bitstream_read_bit(&q->bc);\n        q->weighting_delay[5] = bitstream_read(&q->bc, 3);\n        for (i = 0; i < 4; i++) {\n            q->matrix_coeff_index_prev[i] = q->matrix_coeff_index_now[i];\n            q->matrix_coeff_index_now[i]  = q->matrix_coeff_index_next[i];\n            q->matrix_coeff_index_next[i] = bitstream_read(&q->bc, 2);\n        }\n        ret = decode_channel_sound_unit(q, &q->bc, &q->units[1],\n                                        out_samples[1], 1, JOINT_STEREO);\n        if (ret != 0)\n            return ret;\n        reverse_matrixing(out_samples[0], out_samples[1],\n                          q->matrix_coeff_index_prev,\n                          q->matrix_coeff_index_now);\n        channel_weighting(out_samples[0], out_samples[1], q->weighting_delay);\n    } else {\n        for (i = 0; i < avctx->channels; i++) {\n            bitstream_init(&q->bc,\n                           databuf + i * avctx->block_align / avctx->channels,\n                           avctx->block_align * 8 / avctx->channels);\n            ret = decode_channel_sound_unit(q, &q->bc, &q->units[i],\n                                            out_samples[i], i, q->coding_mode);\n            if (ret != 0)\n                return ret;\n        }\n    }\n    for (i = 0; i < avctx->channels; i++) {\n        float *p1 = out_samples[i];\n        float *p2 = p1 + 256;\n        float *p3 = p2 + 256;\n        float *p4 = p3 + 256;\n        ff_atrac_iqmf(p1, p2, 256, p1, q->units[i].delay_buf1, q->temp_buf);\n        ff_atrac_iqmf(p4, p3, 256, p3, q->units[i].delay_buf2, q->temp_buf);\n        ff_atrac_iqmf(p1, p3, 512, p1, q->units[i].delay_buf3, q->temp_buf);\n    }\n    return 0;\n}', 'static inline int bitstream_init(BitstreamContext *bc, const uint8_t *buffer,\n                                 unsigned bit_size)\n{\n    unsigned buffer_size;\n    if (bit_size > INT_MAX - 7 || !buffer) {\n        buffer        =\n        bc->buffer    =\n        bc->ptr       = NULL;\n        bc->bits_left = 0;\n        return AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    bc->buffer       = buffer;\n    bc->buffer_end   = buffer + buffer_size;\n    bc->ptr          = bc->buffer;\n    bc->size_in_bits = bit_size;\n    bc->bits_left    = 0;\n    bc->bits         = 0;\n    refill_64(bc);\n    return 0;\n}', '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 void refill_32(BitstreamContext *bc)\n{\n    if (bc->ptr >= bc->buffer_end)\n        return;\n#ifdef BITSTREAM_READER_LE\n    bc->bits       = (uint64_t)AV_RL32(bc->ptr) << bc->bits_left | bc->bits;\n#else\n    bc->bits       = bc->bits | (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_left);\n#endif\n    bc->ptr       += 4;\n    bc->bits_left += 32;\n}']