libavcodec/dvdec.c:182: error: Integer Overflow L2
  (32 - [0, 64]):unsigned32 by call to `bitstream_read_signed`.

libavcodec/dvdec.c:179:13: Call
177.         for (j = 0; j < s->sys->bpm; j++) {
178.             last_index = s->sys->block_sizes[j];
179.             bitstream_init(&bc, buf_ptr, last_index);
                 ^
180. 
181.             /* get the DC */

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

libavcodec/dvdec.c:182:24: Call
180. 
181.             /* get the DC */
182.             dc       = bitstream_read_signed(&bc, 9);
                            ^
183.             dct_mode = bitstream_read_bit(&bc);
184.             class1   = bitstream_read(&bc, 2);

libavcodec/bitstream.h:199:1: Parameter `bc->bits_left`
  197. /* Return n bits from the buffer as a signed integer.
  198.  * n has to be in the 0-32 range. */
  199. static inline int32_t bitstream_read_signed(BitstreamContext *bc, unsigned n)
       ^
  200. {
  201.     return sign_extend(bitstream_read(bc, n), n);

libavcodec/bitstream.h:201:24: Call
  199. static inline int32_t bitstream_read_signed(BitstreamContext *bc, unsigned n)
  200. {
  201.     return sign_extend(bitstream_read(bc, n), n);
                              ^
  202. }
  203. 

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 `bitstream_read_signed` 
      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 dv_decode_video_segment(AVCodecContext *avctx, void *arg)\n{\n    DVVideoContext *s = avctx->priv_data;\n    DVwork_chunk *work_chunk = arg;\n    int quant, dc, dct_mode, class1, j;\n    int mb_index, mb_x, mb_y, last_index;\n    int y_stride, linesize;\n    int16_t *block, *block1;\n    int c_offset;\n    uint8_t *y_ptr;\n    const uint8_t *buf_ptr;\n    PutBitContext pb, vs_pb;\n    BitstreamContext bc;\n    BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1;\n    LOCAL_ALIGNED_16(int16_t, sblock, [5 * DV_MAX_BPM], [64]);\n    LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80     + AV_INPUT_BUFFER_PADDING_SIZE]);\n    LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [80 * 5 + AV_INPUT_BUFFER_PADDING_SIZE]);\n    const int log2_blocksize = 3;\n    int is_field_mode[5];\n    int mb_bits;\n    assert((((int) mb_bit_buffer) & 7) == 0);\n    assert((((int) vs_bit_buffer) & 7) == 0);\n    memset(sblock, 0, 5 * DV_MAX_BPM * sizeof(*sblock));\n    buf_ptr = &s->buf[work_chunk->buf_offset * 80];\n    block1  = &sblock[0][0];\n    mb1     = mb_data;\n    init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80);\n    for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s->sys->bpm * 64) {\n        quant    = buf_ptr[3] & 0x0f;\n        buf_ptr += 4;\n        init_put_bits(&pb, mb_bit_buffer, 80);\n        mb    = mb1;\n        block = block1;\n        is_field_mode[mb_index] = 0;\n        for (j = 0; j < s->sys->bpm; j++) {\n            last_index = s->sys->block_sizes[j];\n            bitstream_init(&bc, buf_ptr, last_index);\n            dc       = bitstream_read_signed(&bc, 9);\n            dct_mode = bitstream_read_bit(&bc);\n            class1   = bitstream_read(&bc, 2);\n            if (DV_PROFILE_IS_HD(s->sys)) {\n                mb->idct_put     = s->idct_put[0];\n                mb->scan_table   = s->dv_zigzag[0];\n                mb->factor_table = &s->idct_factor[(j >= 4) * 4 * 16 * 64 +\n                                                   class1       * 16 * 64 +\n                                                   quant             * 64];\n                is_field_mode[mb_index] |= !j && dct_mode;\n            } else {\n                mb->idct_put     = s->idct_put[dct_mode && log2_blocksize == 3];\n                mb->scan_table   = s->dv_zigzag[dct_mode];\n                mb->factor_table =\n                    &s->idct_factor[(class1 == 3)               * 2 * 22 * 64 +\n                                    dct_mode                        * 22 * 64 +\n                                    (quant + ff_dv_quant_offset[class1]) * 64];\n            }\n            dc = dc << 2;\n            dc                   += 1024;\n            block[0]              = dc;\n            buf_ptr              += last_index >> 3;\n            mb->pos               = 0;\n            mb->partial_bit_count = 0;\n            ff_dlog(avctx, "MB block: %d, %d ", mb_index, j);\n            dv_decode_ac(&bc, mb, block);\n            if (mb->pos >= 64)\n                bit_copy(&pb, &bc);\n            block += 64;\n            mb++;\n        }\n        ff_dlog(avctx, "***pass 2 size=%d MB#=%d\\n", put_bits_count(&pb), mb_index);\n        block = block1;\n        mb    = mb1;\n        mb_bits = put_bits_count(&pb);\n        put_bits32(&pb, 0);\n        flush_put_bits(&pb);\n        bitstream_init(&bc, mb_bit_buffer, mb_bits);\n        for (j = 0; j < s->sys->bpm; j++, block += 64, mb++) {\n            if (mb->pos < 64 && bitstream_bits_left(&bc) > 0) {\n                dv_decode_ac(&bc, mb, block);\n                if (mb->pos < 64)\n                    break;\n            }\n        }\n        if (j >= s->sys->bpm)\n            bit_copy(&vs_pb, &bc);\n    }\n    ff_dlog(avctx, "***pass 3 size=%d\\n", put_bits_count(&vs_pb));\n    block = &sblock[0][0];\n    mb    = mb_data;\n    mb_bits = put_bits_count(&vs_pb);\n    put_bits32(&vs_pb, 0);\n    flush_put_bits(&vs_pb);\n    bitstream_init(&bc, vs_bit_buffer, mb_bits);\n    for (mb_index = 0; mb_index < 5; mb_index++) {\n        for (j = 0; j < s->sys->bpm; j++) {\n            if (mb->pos < 64) {\n                ff_dlog(avctx, "start %d:%d\\n", mb_index, j);\n                dv_decode_ac(&bc, mb, block);\n            }\n            if (mb->pos >= 64 && mb->pos < 127)\n                av_log(avctx, AV_LOG_ERROR,\n                       "AC EOB marker is absent pos=%"PRIu8"\\n", mb->pos);\n            block += 64;\n            mb++;\n        }\n    }\n    block = &sblock[0][0];\n    mb    = mb_data;\n    for (mb_index = 0; mb_index < 5; mb_index++) {\n        dv_calculate_mb_xy(s, work_chunk, mb_index, &mb_x, &mb_y);\n        if ((s->sys->pix_fmt == AV_PIX_FMT_YUV420P)                      ||\n            (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) ||\n            (s->sys->height >= 720 && mb_y != 134)) {\n            y_stride = (s->frame->linesize[0] <<\n                        ((!is_field_mode[mb_index]) * log2_blocksize));\n        } else {\n            y_stride = (2 << log2_blocksize);\n        }\n        y_ptr    = s->frame->data[0] +\n                   ((mb_y * s->frame->linesize[0] + mb_x) << log2_blocksize);\n        linesize = s->frame->linesize[0] << is_field_mode[mb_index];\n        mb[0].idct_put(y_ptr, linesize, block + 0 * 64);\n        if (s->sys->video_stype == 4) {\n            mb[2].idct_put(y_ptr + (1 << log2_blocksize),            linesize, block + 2 * 64);\n        } else {\n            mb[1].idct_put(y_ptr + (1 << log2_blocksize),            linesize, block + 1 * 64);\n            mb[2].idct_put(y_ptr                         + y_stride, linesize, block + 2 * 64);\n            mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize, block + 3 * 64);\n        }\n        mb    += 4;\n        block += 4 * 64;\n        c_offset = (((mb_y >>  (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] +\n                     (mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) << log2_blocksize);\n        for (j = 2; j; j--) {\n            uint8_t *c_ptr = s->frame->data[j] + c_offset;\n            if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {\n                uint64_t aligned_pixels[64 / 8];\n                uint8_t *pixels = (uint8_t *) aligned_pixels;\n                uint8_t *c_ptr1, *ptr1;\n                int x, y;\n                mb->idct_put(pixels, 8, block);\n                for (y = 0; y < (1 << log2_blocksize); y++, c_ptr += s->frame->linesize[j], pixels += 8) {\n                    ptr1   = pixels + (1 << (log2_blocksize - 1));\n                    c_ptr1 = c_ptr + (s->frame->linesize[j] << log2_blocksize);\n                    for (x = 0; x < (1 << (log2_blocksize - 1)); x++) {\n                        c_ptr[x]  = pixels[x];\n                        c_ptr1[x] = ptr1[x];\n                    }\n                }\n                block += 64;\n                mb++;\n            } else {\n                y_stride = (mb_y == 134) ? (1 << log2_blocksize) :\n                           s->frame->linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);\n                linesize = s->frame->linesize[j] << is_field_mode[mb_index];\n                (mb++)->idct_put(c_ptr, linesize, block);\n                block += 64;\n                if (s->sys->bpm == 8) {\n                    (mb++)->idct_put(c_ptr + y_stride, linesize, block);\n                    block += 64;\n                }\n            }\n        }\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 inline int32_t bitstream_read_signed(BitstreamContext *bc, unsigned n)\n{\n    return sign_extend(bitstream_read(bc, n), n);\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}']