libavcodec/bink.c:616: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32.

libavcodec/bink.c:616:17: <LHS trace>
614.     coef_list[list_end] = 3;  mode_list[list_end++] = 3;
615. 
616.     for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
                     ^
617.         list_pos = list_start;
618.         while (list_pos < list_end) {

libavcodec/bink.c:616:17: Call
614.     coef_list[list_end] = 3;  mode_list[list_end++] = 3;
615. 
616.     for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
                     ^
617.         list_pos = list_start;
618.         while (list_pos < list_end) {

libavcodec/bitstream.h:186:9: Assignment
  184. {
  185.     if (!n)
  186.         return 0;
               ^
  187. 
  188.     if (n > bc->bits_left) {

libavcodec/bink.c:616:10: Binary operation: ([0, +oo] - 1):unsigned32
614.     coef_list[list_end] = 3;  mode_list[list_end++] = 3;
615. 
616.     for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
              ^
617.         list_pos = list_start;
618.         while (list_pos < list_end) {

static int read_dct_coeffs(BitstreamContext *bc, int32_t block[64],
                           const uint8_t *scan,
                           const int32_t quant_matrices[16][64], int q)
{
    int coef_list[128];
    int mode_list[128];
    int i, t, bits, ccoef, mode;
    int list_start = 64, list_end = 64, list_pos;
    int coef_count = 0;
    int coef_idx[64];
    int quant_idx;
    const int32_t *quant;
    coef_list[list_end] = 4;  mode_list[list_end++] = 0;
    coef_list[list_end] = 24; mode_list[list_end++] = 0;
    coef_list[list_end] = 44; mode_list[list_end++] = 0;
    coef_list[list_end] = 1;  mode_list[list_end++] = 3;
    coef_list[list_end] = 2;  mode_list[list_end++] = 3;
    coef_list[list_end] = 3;  mode_list[list_end++] = 3;
    for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {
        list_pos = list_start;
        while (list_pos < list_end) {
            if (!(mode_list[list_pos] | coef_list[list_pos]) || !bitstream_read_bit(bc)) {
                list_pos++;
                continue;
            }
            ccoef = coef_list[list_pos];
            mode  = mode_list[list_pos];
            switch (mode) {
            case 0:
                coef_list[list_pos] = ccoef + 4;
                mode_list[list_pos] = 1;
            case 2:
                if (mode == 2) {
                    coef_list[list_pos]   = 0;
                    mode_list[list_pos++] = 0;
                }
                for (i = 0; i < 4; i++, ccoef++) {
                    if (bitstream_read_bit(bc)) {
                        coef_list[--list_start] = ccoef;
                        mode_list[  list_start] = 3;
                    } else {
                        if (!bits) {
                            t = 1 - (bitstream_read_bit(bc) << 1);
                        } else {
                            t = bitstream_read(bc, bits) | 1 << bits;
                            t = bitstream_apply_sign(bc, t);
                        }
                        block[scan[ccoef]] = t;
                        coef_idx[coef_count++] = ccoef;
                    }
                }
                break;
            case 1:
                mode_list[list_pos] = 2;
                for (i = 0; i < 3; i++) {
                    ccoef += 4;
                    coef_list[list_end]   = ccoef;
                    mode_list[list_end++] = 2;
                }
                break;
            case 3:
                if (!bits) {
                    t = 1 - (bitstream_read_bit(bc) << 1);
                } else {
                    t = bitstream_read(bc, bits) | 1 << bits;
                    t = bitstream_apply_sign(bc, t);
                }
                block[scan[ccoef]] = t;
                coef_idx[coef_count++] = ccoef;
                coef_list[list_pos]   = 0;
                mode_list[list_pos++] = 0;
                break;
            }
        }
    }
    if (q == -1) {
        quant_idx = bitstream_read(bc, 4);
    } else {
        quant_idx = q;
    }
    if (quant_idx >= 16)
        return AVERROR_INVALIDDATA;
    quant = quant_matrices[quant_idx];
    block[0] = (block[0] * quant[0]) >> 11;
    for (i = 0; i < coef_count; i++) {
        int idx = coef_idx[i];
        block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
    }
    return 0;
}
['static int read_dct_coeffs(BitstreamContext *bc, int32_t block[64],\n                           const uint8_t *scan,\n                           const int32_t quant_matrices[16][64], int q)\n{\n    int coef_list[128];\n    int mode_list[128];\n    int i, t, bits, ccoef, mode;\n    int list_start = 64, list_end = 64, list_pos;\n    int coef_count = 0;\n    int coef_idx[64];\n    int quant_idx;\n    const int32_t *quant;\n    coef_list[list_end] = 4;  mode_list[list_end++] = 0;\n    coef_list[list_end] = 24; mode_list[list_end++] = 0;\n    coef_list[list_end] = 44; mode_list[list_end++] = 0;\n    coef_list[list_end] = 1;  mode_list[list_end++] = 3;\n    coef_list[list_end] = 2;  mode_list[list_end++] = 3;\n    coef_list[list_end] = 3;  mode_list[list_end++] = 3;\n    for (bits = bitstream_read(bc, 4) - 1; bits >= 0; bits--) {\n        list_pos = list_start;\n        while (list_pos < list_end) {\n            if (!(mode_list[list_pos] | coef_list[list_pos]) || !bitstream_read_bit(bc)) {\n                list_pos++;\n                continue;\n            }\n            ccoef = coef_list[list_pos];\n            mode  = mode_list[list_pos];\n            switch (mode) {\n            case 0:\n                coef_list[list_pos] = ccoef + 4;\n                mode_list[list_pos] = 1;\n            case 2:\n                if (mode == 2) {\n                    coef_list[list_pos]   = 0;\n                    mode_list[list_pos++] = 0;\n                }\n                for (i = 0; i < 4; i++, ccoef++) {\n                    if (bitstream_read_bit(bc)) {\n                        coef_list[--list_start] = ccoef;\n                        mode_list[  list_start] = 3;\n                    } else {\n                        if (!bits) {\n                            t = 1 - (bitstream_read_bit(bc) << 1);\n                        } else {\n                            t = bitstream_read(bc, bits) | 1 << bits;\n                            t = bitstream_apply_sign(bc, t);\n                        }\n                        block[scan[ccoef]] = t;\n                        coef_idx[coef_count++] = ccoef;\n                    }\n                }\n                break;\n            case 1:\n                mode_list[list_pos] = 2;\n                for (i = 0; i < 3; i++) {\n                    ccoef += 4;\n                    coef_list[list_end]   = ccoef;\n                    mode_list[list_end++] = 2;\n                }\n                break;\n            case 3:\n                if (!bits) {\n                    t = 1 - (bitstream_read_bit(bc) << 1);\n                } else {\n                    t = bitstream_read(bc, bits) | 1 << bits;\n                    t = bitstream_apply_sign(bc, t);\n                }\n                block[scan[ccoef]] = t;\n                coef_idx[coef_count++] = ccoef;\n                coef_list[list_pos]   = 0;\n                mode_list[list_pos++] = 0;\n                break;\n            }\n        }\n    }\n    if (q == -1) {\n        quant_idx = bitstream_read(bc, 4);\n    } else {\n        quant_idx = q;\n    }\n    if (quant_idx >= 16)\n        return AVERROR_INVALIDDATA;\n    quant = quant_matrices[quant_idx];\n    block[0] = (block[0] * quant[0]) >> 11;\n    for (i = 0; i < coef_count; i++) {\n        int idx = coef_idx[i];\n        block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;\n    }\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}']