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

libavformat/mpegts.c:745:5: Call
743.     int dts_flag = -1, cts_flag = -1;
744.     int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;
745.     bitstream_init8(&bc, buf, buf_size);
         ^
746. 
747.     if (sl->use_au_start)

libavcodec/bitstream.h:104:1: Parameter `bc->bits_left`
  102. 
  103. /* Initialize BitstreamContext with buffer size in bytes instead of bits. */
  104. static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,
       ^
  105.                                   unsigned byte_size)
  106. {

libavformat/mpegts.c:781:33: Call
779.         }
780.         if (sl->inst_bitrate_len)
781.             inst_bitrate_flag = bitstream_read_bit(&bc);
                                     ^
782.         if (dts_flag == 1)
783.             dts = bitstream_read_63(&bc, sl->timestamp_len);

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 read_sl_header(PESContext *pes, SLConfigDescr *sl,\n                          const uint8_t *buf, int buf_size)\n{\n    BitstreamContext bc;\n    int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;\n    int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;\n    int dts_flag = -1, cts_flag = -1;\n    int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;\n    bitstream_init8(&bc, buf, buf_size);\n    if (sl->use_au_start)\n        au_start_flag = bitstream_read_bit(&bc);\n    if (sl->use_au_end)\n        au_end_flag = bitstream_read_bit(&bc);\n    if (!sl->use_au_start && !sl->use_au_end)\n        au_start_flag = au_end_flag = 1;\n    if (sl->ocr_len > 0)\n        ocr_flag = bitstream_read_bit(&bc);\n    if (sl->use_idle)\n        idle_flag = bitstream_read_bit(&bc);\n    if (sl->use_padding)\n        padding_flag = bitstream_read_bit(&bc);\n    if (padding_flag)\n        padding_bits = bitstream_read(&bc, 3);\n    if (!idle_flag && (!padding_flag || padding_bits != 0)) {\n        if (sl->packet_seq_num_len)\n            bitstream_skip(&bc, sl->packet_seq_num_len);\n        if (sl->degr_prior_len)\n            if (bitstream_read_bit(&bc))\n                bitstream_skip(&bc, sl->degr_prior_len);\n        if (ocr_flag)\n            bitstream_skip(&bc, sl->ocr_len);\n        if (au_start_flag) {\n            if (sl->use_rand_acc_pt)\n                bitstream_read_bit(&bc);\n            if (sl->au_seq_num_len > 0)\n                bitstream_skip(&bc, sl->au_seq_num_len);\n            if (sl->use_timestamps) {\n                dts_flag = bitstream_read_bit(&bc);\n                cts_flag = bitstream_read_bit(&bc);\n            }\n        }\n        if (sl->inst_bitrate_len)\n            inst_bitrate_flag = bitstream_read_bit(&bc);\n        if (dts_flag == 1)\n            dts = bitstream_read_63(&bc, sl->timestamp_len);\n        if (cts_flag == 1)\n            cts = bitstream_read_63(&bc, sl->timestamp_len);\n        if (sl->au_len > 0)\n            bitstream_skip(&bc, sl->au_len);\n        if (inst_bitrate_flag)\n            bitstream_skip(&bc, sl->inst_bitrate_len);\n    }\n    if (dts != AV_NOPTS_VALUE)\n        pes->dts = dts;\n    if (cts != AV_NOPTS_VALUE)\n        pes->pts = cts;\n    if (sl->timestamp_len && sl->timestamp_res)\n        avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res);\n    return (bitstream_tell(&bc) + 7) >> 3;\n}', 'static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,\n                                  unsigned byte_size)\n{\n    if (byte_size > INT_MAX / 8)\n        return AVERROR_INVALIDDATA;\n    return bitstream_init(bc, buffer, byte_size * 8);\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}']