libavcodec/mlpdec.c:1145: error: Integer Overflow L2
  ([0, 8182] - 1):unsigned32 by call to `mlp_checksum8`.

libavcodec/mlpdec.c:994:1: Parameter `buf_size`
992.  *  otherwise returns the number of bytes consumed. */
993. 
994. static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,
     ^
995.                             const uint8_t *buf, int buf_size)
996. {

libavcodec/mlpdec.c:1069:9: Assignment
1067. 
1068.         substream_parity_present[substr] = checkdata_present;
1069.         substream_data_len[substr] = end - substream_start;
              ^
1070.         substream_start = end;
1071.     }

libavcodec/mlpdec.c:1145:24: Call
1143.                        "Substream %d parity check failed.\n", substr);
1144. 
1145.             checksum = mlp_checksum8(buf, substream_data_len[substr] - 2);
                             ^
1146.             if (checksum != get_bits(&gb, 8))
1147.                 av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n",

libavcodec/mlpdec.c:246:1: <LHS trace>
244.  *  last element, then XOR that with the last element. */
245. 
246. static uint8_t mlp_checksum8(const uint8_t *buf, unsigned int buf_size)
     ^
247. {
248.     uint8_t checksum = av_crc(crc_63, 0x3c, buf, buf_size - 1); // crc_63[0xa2] == 0x3c

libavcodec/mlpdec.c:246:1: Parameter `buf_size`
  244.  *  last element, then XOR that with the last element. */
  245. 
  246. static uint8_t mlp_checksum8(const uint8_t *buf, unsigned int buf_size)
       ^
  247. {
  248.     uint8_t checksum = av_crc(crc_63, 0x3c, buf, buf_size - 1); // crc_63[0xa2] == 0x3c

libavcodec/mlpdec.c:248:24: Binary operation: ([0, 8182] - 1):unsigned32 by call to `mlp_checksum8` 
  246. static uint8_t mlp_checksum8(const uint8_t *buf, unsigned int buf_size)
  247. {
  248.     uint8_t checksum = av_crc(crc_63, 0x3c, buf, buf_size - 1); // crc_63[0xa2] == 0x3c
                              ^
  249.     checksum ^= buf[buf_size-1];
  250.     return checksum;

static uint8_t mlp_checksum8(const uint8_t *buf, unsigned int buf_size)
{
    uint8_t checksum = av_crc(crc_63, 0x3c, buf, buf_size - 1);
    checksum ^= buf[buf_size-1];
    return checksum;
}
['static int read_access_unit(AVCodecContext *avctx, void* data, int *data_size,\n                            const uint8_t *buf, int buf_size)\n{\n    MLPDecodeContext *m = avctx->priv_data;\n    GetBitContext gb;\n    unsigned int length, substr;\n    unsigned int substream_start;\n    unsigned int header_size = 4;\n    unsigned int substr_header_size = 0;\n    uint8_t substream_parity_present[MAX_SUBSTREAMS];\n    uint16_t substream_data_len[MAX_SUBSTREAMS];\n    uint8_t parity_bits;\n    if (buf_size < 4)\n        return 0;\n    length = (AV_RB16(buf) & 0xfff) * 2;\n    if (length > buf_size)\n        return -1;\n    init_get_bits(&gb, (buf + 4), (length - 4) * 8);\n    if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {\n        dprintf(m->avctx, "Found major sync.\\n");\n        if (read_major_sync(m, &gb) < 0)\n            goto error;\n        header_size += 28;\n    }\n    if (!m->params_valid) {\n        av_log(m->avctx, AV_LOG_WARNING,\n               "Stream parameters not seen; skipping frame.\\n");\n        *data_size = 0;\n        return length;\n    }\n    substream_start = 0;\n    for (substr = 0; substr < m->num_substreams; substr++) {\n        int extraword_present, checkdata_present, end;\n        extraword_present = get_bits1(&gb);\n        skip_bits1(&gb);\n        checkdata_present = get_bits1(&gb);\n        skip_bits1(&gb);\n        end = get_bits(&gb, 12) * 2;\n        substr_header_size += 2;\n        if (extraword_present) {\n            skip_bits(&gb, 16);\n            substr_header_size += 2;\n        }\n        if (end + header_size + substr_header_size > length) {\n            av_log(m->avctx, AV_LOG_ERROR,\n                   "Indicated length of substream %d data goes off end of "\n                   "packet.\\n", substr);\n            end = length - header_size - substr_header_size;\n        }\n        if (end < substream_start) {\n            av_log(avctx, AV_LOG_ERROR,\n                   "Indicated end offset of substream %d data "\n                   "is smaller than calculated start offset.\\n",\n                   substr);\n            goto error;\n        }\n        if (substr > m->max_decoded_substream)\n            continue;\n        substream_parity_present[substr] = checkdata_present;\n        substream_data_len[substr] = end - substream_start;\n        substream_start = end;\n    }\n    parity_bits  = calculate_parity(buf, 4);\n    parity_bits ^= calculate_parity(buf + header_size, substr_header_size);\n    if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {\n        av_log(avctx, AV_LOG_ERROR, "Parity check failed.\\n");\n        goto error;\n    }\n    buf += header_size + substr_header_size;\n    for (substr = 0; substr <= m->max_decoded_substream; substr++) {\n        SubStream *s = &m->substream[substr];\n        init_get_bits(&gb, buf, substream_data_len[substr] * 8);\n        s->blockpos = 0;\n        do {\n            if (get_bits1(&gb)) {\n                if (get_bits1(&gb)) {\n                    if (read_restart_header(m, &gb, buf, substr) < 0)\n                        goto next_substr;\n                    s->restart_seen = 1;\n                }\n                if (!s->restart_seen) {\n                    av_log(m->avctx, AV_LOG_ERROR,\n                           "No restart header present in substream %d.\\n",\n                           substr);\n                    goto next_substr;\n                }\n                if (read_decoding_params(m, &gb, substr) < 0)\n                    goto next_substr;\n            }\n            if (!s->restart_seen) {\n                av_log(m->avctx, AV_LOG_ERROR,\n                       "No restart header present in substream %d.\\n",\n                       substr);\n                goto next_substr;\n            }\n            if (read_block_data(m, &gb, substr) < 0)\n                return -1;\n        } while ((get_bits_count(&gb) < substream_data_len[substr] * 8)\n                 && get_bits1(&gb) == 0);\n        skip_bits(&gb, (-get_bits_count(&gb)) & 15);\n        if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32 &&\n            (show_bits_long(&gb, 32) == 0xd234d234 ||\n             show_bits_long(&gb, 20) == 0xd234e)) {\n            skip_bits(&gb, 18);\n            if (substr == m->max_decoded_substream)\n                av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\\n");\n            if (get_bits1(&gb)) {\n                int shorten_by = get_bits(&gb, 13);\n                shorten_by = FFMIN(shorten_by, s->blockpos);\n                s->blockpos -= shorten_by;\n            } else\n                skip_bits(&gb, 13);\n        }\n        if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 16 &&\n            substream_parity_present[substr]) {\n            uint8_t parity, checksum;\n            parity = calculate_parity(buf, substream_data_len[substr] - 2);\n            if ((parity ^ get_bits(&gb, 8)) != 0xa9)\n                av_log(m->avctx, AV_LOG_ERROR,\n                       "Substream %d parity check failed.\\n", substr);\n            checksum = mlp_checksum8(buf, substream_data_len[substr] - 2);\n            if (checksum != get_bits(&gb, 8))\n                av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\\n",\n                       substr);\n        }\n        if (substream_data_len[substr] * 8 != get_bits_count(&gb)) {\n            av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\\n",\n                   substr);\n            return -1;\n        }\nnext_substr:\n        buf += substream_data_len[substr];\n    }\n    rematrix_channels(m, m->max_decoded_substream);\n    if (output_data(m, m->max_decoded_substream, data, data_size) < 0)\n        return -1;\n    return length;\nerror:\n    m->params_valid = 0;\n    return -1;\n}', 'static uint8_t mlp_checksum8(const uint8_t *buf, unsigned int buf_size)\n{\n    uint8_t checksum = av_crc(crc_63, 0x3c, buf, buf_size - 1);\n    checksum ^= buf[buf_size-1];\n    return checksum;\n}']