libavcodec/atrac3plus.c:1797: error: Integer Overflow L2
  ([-1, +oo] - 1):unsigned32 by call to `get_subband_flags`.

libavcodec/atrac3plus.c:1793:5: Call
1791.         return ret;
1792. 
1793.     decode_spectrum(bc, ctx, num_channels, avctx);
          ^
1794. 
1795.     if (num_channels == 2) {

libavcodec/atrac3plus.c:852:1: Parameter `bc->bits_left`
  850.  * @param[in]     avctx         ptr to the AVCodecContext
  851.  */
  852. static void decode_spectrum(BitstreamContext *bc, Atrac3pChanUnitCtx *ctx,
       ^
  853.                             int num_channels, AVCodecContext *avctx)
  854. {

libavcodec/atrac3plus.c:1796:9: Call
1794. 
1795.     if (num_channels == 2) {
1796.         get_subband_flags(bc, ctx->swap_channels, ctx->num_coded_subbands);
              ^
1797.         get_subband_flags(bc, ctx->negate_coeffs, ctx->num_coded_subbands);
1798.     }

libavcodec/atrac3plus.c:922:1: Parameter `bc->bits_left`
  920.  * @return: 0 = all flag bits are zero, 1 = there is at least one non-zero flag bit
  921.  */
  922. static int get_subband_flags(BitstreamContext *bc, uint8_t *out, int num_flags)
       ^
  923. {
  924.     int i, result;

libavcodec/atrac3plus.c:928:14: Call
  926.     memset(out, 0, num_flags);
  927. 
  928.     result = bitstream_read_bit(bc);
                    ^
  929.     if (result) {
  930.         if (bitstream_read_bit(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/atrac3plus.c:1797:9: Call
1795.     if (num_channels == 2) {
1796.         get_subband_flags(bc, ctx->swap_channels, ctx->num_coded_subbands);
1797.         get_subband_flags(bc, ctx->negate_coeffs, ctx->num_coded_subbands);
              ^
1798.     }
1799. 

libavcodec/atrac3plus.c:922:1: Parameter `bc->bits_left`
  920.  * @return: 0 = all flag bits are zero, 1 = there is at least one non-zero flag bit
  921.  */
  922. static int get_subband_flags(BitstreamContext *bc, uint8_t *out, int num_flags)
       ^
  923. {
  924.     int i, result;

libavcodec/atrac3plus.c:928:14: Call
  926.     memset(out, 0, num_flags);
  927. 
  928.     result = bitstream_read_bit(bc);
                    ^
  929.     if (result) {
  930.         if (bitstream_read_bit(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/atrac3plus.c:930:13: Call
  928.     result = bitstream_read_bit(bc);
  929.     if (result) {
  930.         if (bitstream_read_bit(bc))
                   ^
  931.             for (i = 0; i < num_flags; i++)
  932.                 out[i] = bitstream_read_bit(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: <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] - 1):unsigned32 by call to `get_subband_flags` 
      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;
}
['int ff_atrac3p_decode_channel_unit(BitstreamContext *bc, Atrac3pChanUnitCtx *ctx,\n                                   int num_channels, AVCodecContext *avctx)\n{\n    int ret;\n    ctx->num_quant_units = bitstream_read(bc, 5) + 1;\n    if (ctx->num_quant_units > 28 && ctx->num_quant_units < 32) {\n        av_log(avctx, AV_LOG_ERROR,\n               "Invalid number of quantization units: %d!\\n",\n               ctx->num_quant_units);\n        return AVERROR_INVALIDDATA;\n    }\n    ctx->mute_flag = bitstream_read_bit(bc);\n    if ((ret = decode_quant_wordlen(bc, ctx, num_channels, avctx)) < 0)\n        return ret;\n    ctx->num_subbands       = atrac3p_qu_to_subband[ctx->num_quant_units - 1] + 1;\n    ctx->num_coded_subbands = ctx->used_quant_units\n                              ? atrac3p_qu_to_subband[ctx->used_quant_units - 1] + 1\n                              : 0;\n    if ((ret = decode_scale_factors(bc, ctx, num_channels, avctx)) < 0)\n        return ret;\n    if ((ret = decode_code_table_indexes(bc, ctx, num_channels, avctx)) < 0)\n        return ret;\n    decode_spectrum(bc, ctx, num_channels, avctx);\n    if (num_channels == 2) {\n        get_subband_flags(bc, ctx->swap_channels, ctx->num_coded_subbands);\n        get_subband_flags(bc, ctx->negate_coeffs, ctx->num_coded_subbands);\n    }\n    decode_window_shape(bc, ctx, num_channels);\n    if ((ret = decode_gainc_data(bc, ctx, num_channels, avctx)) < 0)\n        return ret;\n    if ((ret = decode_tones_info(bc, ctx, num_channels, avctx)) < 0)\n        return ret;\n    ctx->noise_present = bitstream_read_bit(bc);\n    if (ctx->noise_present) {\n        ctx->noise_level_index = bitstream_read(bc, 4);\n        ctx->noise_table_index = bitstream_read(bc, 4);\n    }\n    return 0;\n}', 'static void decode_spectrum(BitstreamContext *bc, Atrac3pChanUnitCtx *ctx,\n                            int num_channels, AVCodecContext *avctx)\n{\n    int i, ch_num, qu, wordlen, codetab, tab_index, num_specs;\n    const Atrac3pSpecCodeTab *tab;\n    Atrac3pChanParams *chan;\n    for (ch_num = 0; ch_num < num_channels; ch_num++) {\n        chan = &ctx->channels[ch_num];\n        memset(chan->spectrum, 0, sizeof(chan->spectrum));\n        memset(chan->power_levs, ATRAC3P_POWER_COMP_OFF, sizeof(chan->power_levs));\n        for (qu = 0; qu < ctx->used_quant_units; qu++) {\n            num_specs = ff_atrac3p_qu_to_spec_pos[qu + 1] -\n                        ff_atrac3p_qu_to_spec_pos[qu];\n            wordlen = chan->qu_wordlen[qu];\n            codetab = chan->qu_tab_idx[qu];\n            if (wordlen) {\n                if (!ctx->use_full_table)\n                    codetab = atrac3p_ct_restricted_to_full[chan->table_type][wordlen - 1][codetab];\n                tab_index = (chan->table_type * 8 + codetab) * 7 + wordlen - 1;\n                tab       = &atrac3p_spectra_tabs[tab_index];\n                if (tab->redirect >= 0)\n                    tab_index = tab->redirect;\n                decode_qu_spectra(bc, tab, &spec_vlc_tabs[tab_index],\n                                  &chan->spectrum[ff_atrac3p_qu_to_spec_pos[qu]],\n                                  num_specs);\n            } else if (ch_num && ctx->channels[0].qu_wordlen[qu] && !codetab) {\n                memcpy(&chan->spectrum[ff_atrac3p_qu_to_spec_pos[qu]],\n                       &ctx->channels[0].spectrum[ff_atrac3p_qu_to_spec_pos[qu]],\n                       num_specs *\n                       sizeof(chan->spectrum[ff_atrac3p_qu_to_spec_pos[qu]]));\n                chan->qu_wordlen[qu] = ctx->channels[0].qu_wordlen[qu];\n            }\n        }\n        if (ctx->used_quant_units > 2) {\n            num_specs = atrac3p_subband_to_num_powgrps[ctx->num_coded_subbands - 1];\n            for (i = 0; i < num_specs; i++)\n                chan->power_levs[i] = bitstream_read(bc, 4);\n        }\n    }\n}', 'static int get_subband_flags(BitstreamContext *bc, uint8_t *out, int num_flags)\n{\n    int i, result;\n    memset(out, 0, num_flags);\n    result = bitstream_read_bit(bc);\n    if (result) {\n        if (bitstream_read_bit(bc))\n            for (i = 0; i < num_flags; i++)\n                out[i] = bitstream_read_bit(bc);\n        else\n            memset(out, 1, num_flags);\n    }\n    return result;\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}']