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

libavcodec/ivi.c:909:1: Parameter `ctx->bc.bits_left`
907.  *  @return         result code: 0 = OK, -1 = error
908.  */
909. static int decode_band(IVI45DecContext *ctx,
     ^
910.                        IVIBandDesc *band, AVCodecContext *avctx)
911. {

libavcodec/ivi.c:961:26: Call
959.             return AVERROR_INVALIDDATA;
960.         }
961.         tile->is_empty = bitstream_read_bit(&ctx->bc);
                              ^
962.         if (tile->is_empty) {
963.             result = ivi_process_empty_tile(avctx, band, tile,

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 decode_band(IVI45DecContext *ctx,\n                       IVIBandDesc *band, AVCodecContext *avctx)\n{\n    int         result, i, t, idx1, idx2, pos;\n    IVITile     *tile;\n    band->buf     = band->bufs[ctx->dst_buf];\n    if (!band->buf) {\n        av_log(avctx, AV_LOG_ERROR, "Band buffer points to no data!\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    if (ctx->is_indeo4 && ctx->frame_type == IVI4_FRAMETYPE_BIDIR) {\n        band->ref_buf   = band->bufs[ctx->b_ref_buf];\n        band->b_ref_buf = band->bufs[ctx->ref_buf];\n    } else {\n        band->ref_buf   = band->bufs[ctx->ref_buf];\n        band->b_ref_buf = 0;\n    }\n    band->data_ptr  = ctx->frame_data + (bitstream_tell(&ctx->bc) >> 3);\n    result = ctx->decode_band_hdr(ctx, band, avctx);\n    if (result) {\n        av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\\n",\n               result);\n        return result;\n    }\n    if (band->is_empty) {\n        av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\\n");\n        return AVERROR_INVALIDDATA;\n    }\n    band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];\n    for (i = 0; i < band->num_corr; i++) {\n        idx1 = band->corr[i * 2];\n        idx2 = band->corr[i * 2 + 1];\n        FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);\n        FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);\n    }\n    pos = bitstream_tell(&ctx->bc);\n    for (t = 0; t < band->num_tiles; t++) {\n        tile = &band->tiles[t];\n        if (tile->mb_size != band->mb_size) {\n            av_log(avctx, AV_LOG_ERROR, "MB sizes mismatch: %d vs. %d\\n",\n                   band->mb_size, tile->mb_size);\n            return AVERROR_INVALIDDATA;\n        }\n        tile->is_empty = bitstream_read_bit(&ctx->bc);\n        if (tile->is_empty) {\n            result = ivi_process_empty_tile(avctx, band, tile,\n                                      (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));\n            if (result < 0)\n                break;\n            ff_dlog(avctx, "Empty tile encountered!\\n");\n        } else {\n            tile->data_size = ivi_dec_tile_data_size(&ctx->bc);\n            if (!tile->data_size) {\n                av_log(avctx, AV_LOG_ERROR, "Tile data size is zero!\\n");\n                return AVERROR_INVALIDDATA;\n            }\n            result = ctx->decode_mb_info(ctx, band, tile, avctx);\n            if (result < 0)\n                break;\n            result = ivi_decode_blocks(&ctx->bc, band, tile, avctx);\n            if (result < 0) {\n                av_log(avctx, AV_LOG_ERROR,\n                       "Corrupted tile data encountered!\\n");\n                break;\n            }\n            if (((bitstream_tell(&ctx->bc) - pos) >> 3) != tile->data_size) {\n                av_log(avctx, AV_LOG_ERROR,\n                       "Tile data_size mismatch!\\n");\n                result = AVERROR_INVALIDDATA;\n                break;\n            }\n            pos += tile->data_size << 3;\n        }\n    }\n    for (i = band->num_corr-1; i >= 0; i--) {\n        idx1 = band->corr[i*2];\n        idx2 = band->corr[i*2+1];\n        FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);\n        FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);\n    }\n#ifdef DEBUG\n    if (band->checksum_present) {\n        uint16_t chksum = ivi_calc_band_checksum(band);\n        if (chksum != band->checksum) {\n            av_log(avctx, AV_LOG_ERROR,\n                   "Band checksum mismatch! Plane %d, band %d, "\n                   "received: %"PRIx32", calculated: %"PRIx16"\\n",\n                   band->plane, band->band_num, band->checksum, chksum);\n        }\n    }\n#endif\n    bitstream_align(&ctx->bc);\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}']