libavcodec/cbs_h2645.c:1043: error: Integer Overflow L2
  ([1, +oo] - 16):unsigned32 by call to `bitstream_read`.

libavcodec/cbs_h2645.c:1043:39: Call
1041.                 // rbsp_stop_one_bit in the final byte.
1042.                 while (bitstream_bits_left(&bc) > 23)
1043.                     put_bits(pbc, 16, bitstream_read(&bc, 16));
                                            ^
1044. 
1045.                 bits_left = bitstream_bits_left(&bc);

libavcodec/bitstream.h:182:1: Parameter `n`
  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/bitstream.h:193:12: Call
  191.     }
  192. 
  193.     return get_val(bc, n);
                  ^
  194. }
  195. 

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

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

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

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: Binary operation: ([1, +oo] - 16):unsigned32 by call to `bitstream_read` 
    136.     bc->bits <<= n;
    137. #endif
    138.     bc->bits_left -= n;
             ^
    139. 
    140.     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 cbs_h264_write_nal_unit(CodedBitstreamContext *ctx,\n                                   CodedBitstreamUnit *unit,\n                                   PutBitContext *pbc)\n{\n    int err;\n    switch (unit->type) {\n    case H264_NAL_SPS:\n        {\n            H264RawSPS *sps = unit->content;\n            err = cbs_h264_write_sps(ctx, pbc, sps);\n            if (err < 0)\n                return err;\n            err = cbs_h264_replace_sps(ctx, sps);\n            if (err < 0)\n                return err;\n        }\n        break;\n    case H264_NAL_SPS_EXT:\n        {\n            H264RawSPSExtension *sps_ext;\n            err = cbs_h264_write_sps_extension(ctx, pbc, sps_ext);\n            if (err < 0)\n                return err;\n        }\n        break;\n    case H264_NAL_PPS:\n        {\n            H264RawPPS *pps = unit->content;\n            err = cbs_h264_write_pps(ctx, pbc, pps);\n            if (err < 0)\n                return err;\n            err = cbs_h264_replace_pps(ctx, pps);\n            if (err < 0)\n                return err;\n        }\n        break;\n    case H264_NAL_SLICE:\n    case H264_NAL_IDR_SLICE:\n        {\n            H264RawSlice *slice = unit->content;\n            BitstreamContext bc;\n            int bits_left, end, zeroes;\n            err = cbs_h264_write_slice_header(ctx, pbc, &slice->header);\n            if (err < 0)\n                return err;\n            if (slice->data) {\n                if (slice->data_size * 8 + 8 > put_bits_left(pbc))\n                    return AVERROR(ENOSPC);\n                bitstream_init(&bc, slice->data, slice->data_size * 8);\n                bitstream_skip(&bc, slice->data_bit_start);\n                while (bitstream_bits_left(&bc) > 23)\n                    put_bits(pbc, 16, bitstream_read(&bc, 16));\n                bits_left = bitstream_bits_left(&bc);\n                end = bitstream_read(&bc, bits_left);\n                av_assert0(end);\n                zeroes = ff_ctz(end);\n                if (bits_left > zeroes + 1)\n                    put_bits(pbc, bits_left - zeroes - 1,\n                             end >> (zeroes + 1));\n                put_bits(pbc, 1, 1);\n                while (put_bits_count(pbc) % 8 != 0)\n                    put_bits(pbc, 1, 0);\n            } else {\n            }\n        }\n        break;\n    case H264_NAL_AUD:\n        {\n            err = cbs_h264_write_aud(ctx, pbc, unit->content);\n            if (err < 0)\n                return err;\n        }\n        break;\n    case H264_NAL_SEI:\n        {\n            err = cbs_h264_write_sei(ctx, pbc, unit->content);\n            if (err < 0)\n                return err;\n        }\n        break;\n    default:\n        av_log(ctx->log_ctx, AV_LOG_ERROR, "Write unimplemented for "\n               "NAL unit type %"PRIu32".\\n", unit->type);\n        return AVERROR_PATCHWELCOME;\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 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}']