libavcodec/vp9_raw_reorder_bsf.c:134: error: Integer Overflow L2
  ([0, +oo] - 2):unsigned32 by call to `bitstream_skip`.

libavcodec/vp9_raw_reorder_bsf.c:88:20: Call
86.         return err;
87. 
88.     frame_marker = bitstream_read(&bc, 2);
                       ^
89.     if (frame_marker != 2) {
90.         av_log(bsf, AV_LOG_ERROR, "Invalid frame marker: %u.\n",

libavcodec/bitstream.h:182:1: Parameter `bc->bits_left`
  180. 
  181. /* Return n bits from the buffer. n has to be in the 0-32 range. */
  182. static inline uint32_t bitstream_read(BitstreamContext *bc, unsigned n)
       ^
  183. {
  184.     if (!n)

libavcodec/vp9_raw_reorder_bsf.c:95:24: Call
93.     }
94. 
95.     profile_low_bit  = bitstream_read_bit(&bc);
                           ^
96.     profile_high_bit = bitstream_read_bit(&bc);
97.     frame->profile = (profile_high_bit << 1) | profile_low_bit;

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/vp9_raw_reorder_bsf.c:96:24: Call
94. 
95.     profile_low_bit  = bitstream_read_bit(&bc);
96.     profile_high_bit = bitstream_read_bit(&bc);
                           ^
97.     frame->profile = (profile_high_bit << 1) | profile_low_bit;
98.     if (frame->profile == 3) {

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/vp9_raw_reorder_bsf.c:107:34: Call
105.     }
106. 
107.     frame->show_existing_frame = bitstream_read_bit(&bc);
                                      ^
108.     if (frame->show_existing_frame) {
109.         frame->frame_to_show = bitstream_read(&bc, 3);

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/vp9_raw_reorder_bsf.c:113:25: Call
111.     }
112. 
113.     frame->frame_type = bitstream_read_bit(&bc);
                             ^
114.     frame->show_frame = bitstream_read_bit(&bc);
115.     error_resilient_mode = bitstream_read_bit(&bc);

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/vp9_raw_reorder_bsf.c:114:25: Call
112. 
113.     frame->frame_type = bitstream_read_bit(&bc);
114.     frame->show_frame = bitstream_read_bit(&bc);
                             ^
115.     error_resilient_mode = bitstream_read_bit(&bc);
116. 

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/vp9_raw_reorder_bsf.c:115:28: Call
113.     frame->frame_type = bitstream_read_bit(&bc);
114.     frame->show_frame = bitstream_read_bit(&bc);
115.     error_resilient_mode = bitstream_read_bit(&bc);
                                ^
116. 
117.     if (frame->frame_type == 0) {

libavcodec/bitstream.h:144:1: Parameter `bc->bits_left`
  142. 
  143. /* Return one bit from the buffer. */
  144. static inline unsigned bitstream_read_bit(BitstreamContext *bc)
       ^
  145. {
  146.     if (!bc->bits_left)

libavcodec/bitstream.h:149:12: Call
  147.         refill_64(bc);
  148. 
  149.     return get_val(bc, 1);
                  ^
  150. }
  151. 

libavcodec/bitstream.h:129:1: Parameter `n`
    127. }
    128. 
    129. static inline uint64_t get_val(BitstreamContext *bc, unsigned n)
         ^
    130. {
    131. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:138:5: Assignment
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     return ret;

libavcodec/vp9_raw_reorder_bsf.c:134:13: Call
132.         if (error_resilient_mode == 0) {
133.             // reset_frame_context
134.             bitstream_skip(&bc, 2);
                 ^
135.         }
136.         if (intra_only) {

libavcodec/bitstream.h:240:1: Parameter `n`
  238. 
  239. /* Skip n bits in the buffer. */
  240. static inline void bitstream_skip(BitstreamContext *bc, unsigned n)
       ^
  241. {
  242.     if (n < bc->bits_left)

libavcodec/bitstream.h:243:9: Call
  241. {
  242.     if (n < bc->bits_left)
  243.         skip_remaining(bc, n);
               ^
  244.     else {
  245.         n -= bc->bits_left;

libavcodec/bitstream.h:229:1: <LHS trace>
227. }
228. 
229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
     ^
230. {
231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:229:1: Parameter `bc->bits_left`
    227. }
    228. 
    229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
         ^
    230. {
    231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:229:1: <RHS trace>
227. }
228. 
229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
     ^
230. {
231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:229:1: Parameter `n`
    227. }
    228. 
    229. static inline void skip_remaining(BitstreamContext *bc, unsigned n)
         ^
    230. {
    231. #ifdef BITSTREAM_READER_LE

libavcodec/bitstream.h:236:5: Binary operation: ([0, +oo] - 2):unsigned32 by call to `bitstream_skip` 
    234.     bc->bits <<= n;
    235. #endif
    236.     bc->bits_left -= n;
             ^
    237. }
    238. 

static inline void skip_remaining(BitstreamContext *bc, unsigned n)
{
#ifdef BITSTREAM_READER_LE
    bc->bits >>= n;
#else
    bc->bits <<= n;
#endif
    bc->bits_left -= n;
}
['static int vp9_raw_reorder_frame_parse(AVBSFContext *bsf, VP9RawReorderFrame *frame)\n{\n    BitstreamContext bc;\n    int err;\n    unsigned int frame_marker;\n    unsigned int profile_low_bit, profile_high_bit, reserved_zero;\n    unsigned int error_resilient_mode;\n    unsigned int frame_sync_code;\n    err = bitstream_init8(&bc, frame->packet->data, frame->packet->size);\n    if (err)\n        return err;\n    frame_marker = bitstream_read(&bc, 2);\n    if (frame_marker != 2) {\n        av_log(bsf, AV_LOG_ERROR, "Invalid frame marker: %u.\\n",\n               frame_marker);\n        return AVERROR_INVALIDDATA;\n    }\n    profile_low_bit  = bitstream_read_bit(&bc);\n    profile_high_bit = bitstream_read_bit(&bc);\n    frame->profile = (profile_high_bit << 1) | profile_low_bit;\n    if (frame->profile == 3) {\n        reserved_zero = bitstream_read_bit(&bc);\n        if (reserved_zero != 0) {\n            av_log(bsf, AV_LOG_ERROR, "Profile reserved_zero bit set: "\n                   "unsupported profile or invalid bitstream.\\n");\n            return AVERROR_INVALIDDATA;\n        }\n    }\n    frame->show_existing_frame = bitstream_read_bit(&bc);\n    if (frame->show_existing_frame) {\n        frame->frame_to_show = bitstream_read(&bc, 3);\n        return 0;\n    }\n    frame->frame_type = bitstream_read_bit(&bc);\n    frame->show_frame = bitstream_read_bit(&bc);\n    error_resilient_mode = bitstream_read_bit(&bc);\n    if (frame->frame_type == 0) {\n        frame_sync_code = bitstream_read(&bc, 24);\n        if (frame_sync_code != 0x498342) {\n            av_log(bsf, AV_LOG_ERROR, "Invalid frame sync code: %06x.\\n",\n                   frame_sync_code);\n            return AVERROR_INVALIDDATA;\n        }\n        frame->refresh_frame_flags = 0xff;\n    } else {\n        unsigned int intra_only;\n        if (frame->show_frame == 0)\n            intra_only = bitstream_read_bit(&bc);\n        else\n            intra_only = 0;\n        if (error_resilient_mode == 0) {\n            bitstream_skip(&bc, 2);\n        }\n        if (intra_only) {\n            frame_sync_code = bitstream_read(&bc, 24);\n            if (frame_sync_code != 0x498342) {\n                av_log(bsf, AV_LOG_ERROR, "Invalid frame sync code: "\n                       "%06x.\\n", frame_sync_code);\n                return AVERROR_INVALIDDATA;\n            }\n            if (frame->profile > 0) {\n                unsigned int color_space;\n                if (frame->profile >= 2) {\n                    bitstream_skip(&bc, 1);\n                }\n                color_space = bitstream_read(&bc, 3);\n                if (color_space != 7  ) {\n                    bitstream_skip(&bc, 1);\n                    if (frame->profile == 1 || frame->profile == 3) {\n                        bitstream_skip(&bc, 3);\n                    }\n                } else {\n                    if (frame->profile == 1 || frame->profile == 3)\n                        bitstream_skip(&bc, 1);\n                }\n            }\n            frame->refresh_frame_flags = bitstream_read(&bc, 8);\n        } else {\n            frame->refresh_frame_flags = bitstream_read(&bc, 8);\n        }\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}', '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}', 'static inline void bitstream_skip(BitstreamContext *bc, unsigned n)\n{\n    if (n < bc->bits_left)\n        skip_remaining(bc, n);\n    else {\n        n -= bc->bits_left;\n        bc->bits      = 0;\n        bc->bits_left = 0;\n        if (n >= 64) {\n            unsigned skip = n / 8;\n            n -= skip * 8;\n            bc->ptr += skip;\n        }\n        refill_64(bc);\n        if (n)\n            skip_remaining(bc, n);\n    }\n}', 'static inline void skip_remaining(BitstreamContext *bc, unsigned n)\n{\n#ifdef BITSTREAM_READER_LE\n    bc->bits >>= n;\n#else\n    bc->bits <<= n;\n#endif\n    bc->bits_left -= n;\n}']