libavcodec/h264_parser.c:224: error: Null Dereference
  pointer `h->gb.buffer` last assigned on line 221 could be null and is dereferenced by call to `ff_h264_decode_seq_parameter_set()` at line 224, column 13.

libavcodec/h264_parser.c:171:1: start of procedure parse_nal_units()
169.  * @param buf_size size of the buffer.
170.  */
171. static inline int parse_nal_units(AVCodecParserContext *s,
     ^
172.                                   AVCodecContext *avctx,
173.                                   const uint8_t *buf, int buf_size)

libavcodec/h264_parser.c:175:5: 
173.                                   const uint8_t *buf, int buf_size)
174. {
175.     H264Context *h         = s->priv_data;
         ^
176.     const uint8_t *buf_end = buf + buf_size;
177.     unsigned int pps_id;

libavcodec/h264_parser.c:176:5: 
174. {
175.     H264Context *h         = s->priv_data;
176.     const uint8_t *buf_end = buf + buf_size;
         ^
177.     unsigned int pps_id;
178.     unsigned int slice_type;

libavcodec/h264_parser.c:179:5: 
177.     unsigned int pps_id;
178.     unsigned int slice_type;
179.     int state = -1, got_reset = 0;
         ^
180.     const uint8_t *ptr;
181.     int field_poc[2];

libavcodec/h264_parser.c:184:5: 
182. 
183.     /* set some sane default values */
184.     s->pict_type         = AV_PICTURE_TYPE_I;
         ^
185.     s->key_frame         = 0;
186.     s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;

libavcodec/h264_parser.c:185:5: 
183.     /* set some sane default values */
184.     s->pict_type         = AV_PICTURE_TYPE_I;
185.     s->key_frame         = 0;
         ^
186.     s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
187. 

libavcodec/h264_parser.c:186:5: 
184.     s->pict_type         = AV_PICTURE_TYPE_I;
185.     s->key_frame         = 0;
186.     s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
         ^
187. 
188.     h->avctx = avctx;

libavcodec/h264_parser.c:188:5: 
186.     s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
187. 
188.     h->avctx = avctx;
         ^
189.     ff_h264_reset_sei(h);
190. 

libavcodec/h264_parser.c:189:5: 
187. 
188.     h->avctx = avctx;
189.     ff_h264_reset_sei(h);
         ^
190. 
191.     if (!buf_size)

libavcodec/h264_sei.c:37:1: start of procedure ff_h264_reset_sei()
  35. };
  36. 
  37. void ff_h264_reset_sei(H264Context *h)
      ^
  38. {
  39.     h->sei_recovery_frame_cnt       = -1;

libavcodec/h264_sei.c:39:5: 
  37. void ff_h264_reset_sei(H264Context *h)
  38. {
  39.     h->sei_recovery_frame_cnt       = -1;
          ^
  40.     h->sei_dpb_output_delay         =  0;
  41.     h->sei_cpb_removal_delay        = -1;

libavcodec/h264_sei.c:40:5: 
  38. {
  39.     h->sei_recovery_frame_cnt       = -1;
  40.     h->sei_dpb_output_delay         =  0;
          ^
  41.     h->sei_cpb_removal_delay        = -1;
  42.     h->sei_buffering_period_present =  0;

libavcodec/h264_sei.c:41:5: 
  39.     h->sei_recovery_frame_cnt       = -1;
  40.     h->sei_dpb_output_delay         =  0;
  41.     h->sei_cpb_removal_delay        = -1;
          ^
  42.     h->sei_buffering_period_present =  0;
  43.     h->sei_frame_packing_present    =  0;

libavcodec/h264_sei.c:42:5: 
  40.     h->sei_dpb_output_delay         =  0;
  41.     h->sei_cpb_removal_delay        = -1;
  42.     h->sei_buffering_period_present =  0;
          ^
  43.     h->sei_frame_packing_present    =  0;
  44. }

libavcodec/h264_sei.c:43:5: 
  41.     h->sei_cpb_removal_delay        = -1;
  42.     h->sei_buffering_period_present =  0;
  43.     h->sei_frame_packing_present    =  0;
          ^
  44. }
  45. 

libavcodec/h264_sei.c:44:1: return from a call to ff_h264_reset_sei
  42.     h->sei_buffering_period_present =  0;
  43.     h->sei_frame_packing_present    =  0;
  44. }
      ^
  45. 
  46. static int decode_picture_timing(H264Context *h)

libavcodec/h264_parser.c:191:10: Taking false branch
189.     ff_h264_reset_sei(h);
190. 
191.     if (!buf_size)
              ^
192.         return 0;
193. 

libavcodec/h264_parser.c:393:5: Loop condition is true. Entering loop body
391.         }
392.         buf += consumed;
393.     }
         ^
394.     /* didn't find a picture! */
395.     av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");

libavcodec/h264_parser.c:196:9: Skipping avpriv_find_start_code(): empty list of specs
194.     for (;;) {
195.         int src_length, dst_length, consumed;
196.         buf = avpriv_find_start_code(buf, buf_end, &state);
             ^
197.         if (buf >= buf_end)
198.             break;

libavcodec/h264_parser.c:197:13: Taking false branch
195.         int src_length, dst_length, consumed;
196.         buf = avpriv_find_start_code(buf, buf_end, &state);
197.         if (buf >= buf_end)
                 ^
198.             break;
199.         --buf;

libavcodec/h264_parser.c:199:9: 
197.         if (buf >= buf_end)
198.             break;
199.         --buf;
             ^
200.         src_length = buf_end - buf;
201.         switch (state & 0x1f) {

libavcodec/h264_parser.c:200:9: 
198.             break;
199.         --buf;
200.         src_length = buf_end - buf;
             ^
201.         switch (state & 0x1f) {
202.         case NAL_SLICE:

libavcodec/h264_parser.c:201:9: 
199.         --buf;
200.         src_length = buf_end - buf;
201.         switch (state & 0x1f) {
             ^
202.         case NAL_SLICE:
203.         case NAL_IDR_SLICE:

libavcodec/h264_parser.c:202:9: Switch condition is true. Entering switch case
200.         src_length = buf_end - buf;
201.         switch (state & 0x1f) {
202.         case NAL_SLICE:
             ^
203.         case NAL_IDR_SLICE:
204.             // Do not walk the whole buffer just to decode slice header

libavcodec/h264_parser.c:205:17: Taking false branch
203.         case NAL_IDR_SLICE:
204.             // Do not walk the whole buffer just to decode slice header
205.             if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
                     ^
206.                 /* IDR or disposable slice
207.                  * No need to decode many bytes because MMCOs shall not be present. */

libavcodec/h264_parser.c:205:52: Taking false branch
203.         case NAL_IDR_SLICE:
204.             // Do not walk the whole buffer just to decode slice header
205.             if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
                                                        ^
206.                 /* IDR or disposable slice
207.                  * No need to decode many bytes because MMCOs shall not be present. */

libavcodec/h264_parser.c:212:21: Taking false branch
210.             } else {
211.                 /* To decode up to MMCOs */
212.                 if (src_length > 1000)
                         ^
213.                     src_length = 1000;
214.             }

libavcodec/h264_parser.c:217:9: Skipping ff_h264_decode_nal(): empty list of specs
215.             break;
216.         }
217.         ptr = ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
             ^
218.         if (ptr == NULL || dst_length < 0)
219.             break;

libavcodec/h264_parser.c:218:13: Taking false branch
216.         }
217.         ptr = ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
218.         if (ptr == NULL || dst_length < 0)
                 ^
219.             break;
220. 

libavcodec/h264_parser.c:218:28: Taking false branch
216.         }
217.         ptr = ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
218.         if (ptr == NULL || dst_length < 0)
                                ^
219.             break;
220. 

libavcodec/h264_parser.c:221:9: 
219.             break;
220. 
221.         init_get_bits(&h->gb, ptr, 8 * dst_length);
             ^
222.         switch (h->nal_unit_type) {
223.         case NAL_SPS:

libavcodec/get_bits.h:375:1: start of procedure init_get_bits()
  373.  * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
  374.  */
  375. static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
       ^
  376.                                 int bit_size)
  377. {

libavcodec/get_bits.h:379:5: 
  377. {
  378.     int buffer_size;
  379.     int ret = 0;
           ^
  380. 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {

libavcodec/get_bits.h:381:9: Taking true branch
  379.     int ret = 0;
  380. 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
               ^
  382.         buffer_size = bit_size = 0;
  383.         buffer      = NULL;

libavcodec/get_bits.h:382:9: 
  380. 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
  382.         buffer_size = bit_size = 0;
               ^
  383.         buffer      = NULL;
  384.         ret         = AVERROR_INVALIDDATA;

libavcodec/get_bits.h:383:9: 
  381.     if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {
  382.         buffer_size = bit_size = 0;
  383.         buffer      = NULL;
               ^
  384.         ret         = AVERROR_INVALIDDATA;
  385.     }

libavcodec/get_bits.h:384:9: 
  382.         buffer_size = bit_size = 0;
  383.         buffer      = NULL;
  384.         ret         = AVERROR_INVALIDDATA;
               ^
  385.     }
  386. 

libavcodec/get_bits.h:387:5: 
  385.     }
  386. 
  387.     buffer_size = (bit_size + 7) >> 3;
           ^
  388. 
  389.     s->buffer             = buffer;

libavcodec/get_bits.h:389:5: 
  387.     buffer_size = (bit_size + 7) >> 3;
  388. 
  389.     s->buffer             = buffer;
           ^
  390.     s->size_in_bits       = bit_size;
  391. #if !UNCHECKED_BITSTREAM_READER

libavcodec/get_bits.h:390:5: 
  388. 
  389.     s->buffer             = buffer;
  390.     s->size_in_bits       = bit_size;
           ^
  391. #if !UNCHECKED_BITSTREAM_READER
  392.     s->size_in_bits_plus8 = bit_size + 8;

libavcodec/get_bits.h:392:5: 
  390.     s->size_in_bits       = bit_size;
  391. #if !UNCHECKED_BITSTREAM_READER
  392.     s->size_in_bits_plus8 = bit_size + 8;
           ^
  393. #endif
  394.     s->buffer_end         = buffer + buffer_size;

libavcodec/get_bits.h:394:5: 
  392.     s->size_in_bits_plus8 = bit_size + 8;
  393. #endif
  394.     s->buffer_end         = buffer + buffer_size;
           ^
  395.     s->index              = 0;
  396. 

libavcodec/get_bits.h:395:5: 
  393. #endif
  394.     s->buffer_end         = buffer + buffer_size;
  395.     s->index              = 0;
           ^
  396. 
  397.     return ret;

libavcodec/get_bits.h:397:5: 
  395.     s->index              = 0;
  396. 
  397.     return ret;
           ^
  398. }
  399. 

libavcodec/get_bits.h:398:1: return from a call to init_get_bits
  396. 
  397.     return ret;
  398. }
       ^
  399. 
  400. /**

libavcodec/h264_parser.c:222:9: 
220. 
221.         init_get_bits(&h->gb, ptr, 8 * dst_length);
222.         switch (h->nal_unit_type) {
             ^
223.         case NAL_SPS:
224.             ff_h264_decode_seq_parameter_set(h);

libavcodec/h264_parser.c:223:9: Switch condition is true. Entering switch case
221.         init_get_bits(&h->gb, ptr, 8 * dst_length);
222.         switch (h->nal_unit_type) {
223.         case NAL_SPS:
             ^
224.             ff_h264_decode_seq_parameter_set(h);
225.             break;

libavcodec/h264_parser.c:224:13: 
222.         switch (h->nal_unit_type) {
223.         case NAL_SPS:
224.             ff_h264_decode_seq_parameter_set(h);
                 ^
225.             break;
226.         case NAL_PPS:

libavcodec/h264_ps.c:297:1: start of procedure ff_h264_decode_seq_parameter_set()
  295. }
  296. 
  297. int ff_h264_decode_seq_parameter_set(H264Context *h)
       ^
  298. {
  299.     int profile_idc, level_idc, constraint_set_flags = 0;

libavcodec/h264_ps.c:299:5: 
  297. int ff_h264_decode_seq_parameter_set(H264Context *h)
  298. {
  299.     int profile_idc, level_idc, constraint_set_flags = 0;
           ^
  300.     unsigned int sps_id;
  301.     int i, log2_max_frame_num_minus4;

libavcodec/h264_ps.c:304:5: Skipping get_bits(): empty list of specs
  302.     SPS *sps;
  303. 
  304.     profile_idc           = get_bits(&h->gb, 8);
           ^
  305.     constraint_set_flags |= get_bits1(&h->gb) << 0;   // constraint_set0_flag
  306.     constraint_set_flags |= get_bits1(&h->gb) << 1;   // constraint_set1_flag

libavcodec/h264_ps.c:305:5: 
  303. 
  304.     profile_idc           = get_bits(&h->gb, 8);
  305.     constraint_set_flags |= get_bits1(&h->gb) << 0;   // constraint_set0_flag
           ^
  306.     constraint_set_flags |= get_bits1(&h->gb) << 1;   // constraint_set1_flag
  307.     constraint_set_flags |= get_bits1(&h->gb) << 2;   // constraint_set2_flag

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
    269. }
    270. 
    271. static inline unsigned int get_bits1(GetBitContext *s)
         ^
    272. {
    273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
    271. static inline unsigned int get_bits1(GetBitContext *s)
    272. {
    273.     unsigned int index = s->index;
             ^
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
    272. {
    273.     unsigned int index = s->index;
    274.     uint8_t result     = s->buffer[index >> 3];
             ^
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;

libavcodec/get_bits.h:276:5: 
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
             ^
    277.     result  &= 1;
    278. #else

libavcodec/get_bits.h:277:5: 
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
    277.     result  &= 1;
             ^
    278. #else
    279.     result <<= index & 7;

libavcodec/get_bits.h:283:9: Taking true branch
    281. #endif
    282. #if !UNCHECKED_BITSTREAM_READER
    283.     if (s->index < s->size_in_bits_plus8)
                 ^
    284. #endif
    285.         index++;

libavcodec/get_bits.h:285:9: 
    283.     if (s->index < s->size_in_bits_plus8)
    284. #endif
    285.         index++;
                 ^
    286.     s->index = index;
    287. 

libavcodec/get_bits.h:286:5: 
    284. #endif
    285.         index++;
    286.     s->index = index;
             ^
    287. 
    288.     return result;

libavcodec/get_bits.h:288:5: 
    286.     s->index = index;
    287. 
    288.     return result;
             ^
    289. }
    290. 

libavcodec/get_bits.h:289:1: return from a call to get_bits1
    287. 
    288.     return result;
    289. }
         ^
    290. 
    291. static inline unsigned int show_bits1(GetBitContext *s)

libavcodec/h264_ps.c:306:5: 
  304.     profile_idc           = get_bits(&h->gb, 8);
  305.     constraint_set_flags |= get_bits1(&h->gb) << 0;   // constraint_set0_flag
  306.     constraint_set_flags |= get_bits1(&h->gb) << 1;   // constraint_set1_flag
           ^
  307.     constraint_set_flags |= get_bits1(&h->gb) << 2;   // constraint_set2_flag
  308.     constraint_set_flags |= get_bits1(&h->gb) << 3;   // constraint_set3_flag

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
    269. }
    270. 
    271. static inline unsigned int get_bits1(GetBitContext *s)
         ^
    272. {
    273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
    271. static inline unsigned int get_bits1(GetBitContext *s)
    272. {
    273.     unsigned int index = s->index;
             ^
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
    272. {
    273.     unsigned int index = s->index;
    274.     uint8_t result     = s->buffer[index >> 3];
             ^
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;

libavcodec/get_bits.h:276:5: 
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
             ^
    277.     result  &= 1;
    278. #else

libavcodec/get_bits.h:277:5: 
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
    277.     result  &= 1;
             ^
    278. #else
    279.     result <<= index & 7;

libavcodec/get_bits.h:283:9: Taking true branch
    281. #endif
    282. #if !UNCHECKED_BITSTREAM_READER
    283.     if (s->index < s->size_in_bits_plus8)
                 ^
    284. #endif
    285.         index++;

libavcodec/get_bits.h:285:9: 
    283.     if (s->index < s->size_in_bits_plus8)
    284. #endif
    285.         index++;
                 ^
    286.     s->index = index;
    287. 

libavcodec/get_bits.h:286:5: 
    284. #endif
    285.         index++;
    286.     s->index = index;
             ^
    287. 
    288.     return result;

libavcodec/get_bits.h:288:5: 
    286.     s->index = index;
    287. 
    288.     return result;
             ^
    289. }
    290. 

libavcodec/get_bits.h:289:1: return from a call to get_bits1
    287. 
    288.     return result;
    289. }
         ^
    290. 
    291. static inline unsigned int show_bits1(GetBitContext *s)

libavcodec/h264_ps.c:307:5: 
  305.     constraint_set_flags |= get_bits1(&h->gb) << 0;   // constraint_set0_flag
  306.     constraint_set_flags |= get_bits1(&h->gb) << 1;   // constraint_set1_flag
  307.     constraint_set_flags |= get_bits1(&h->gb) << 2;   // constraint_set2_flag
           ^
  308.     constraint_set_flags |= get_bits1(&h->gb) << 3;   // constraint_set3_flag
  309.     constraint_set_flags |= get_bits1(&h->gb) << 4;   // constraint_set4_flag

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
    269. }
    270. 
    271. static inline unsigned int get_bits1(GetBitContext *s)
         ^
    272. {
    273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
    271. static inline unsigned int get_bits1(GetBitContext *s)
    272. {
    273.     unsigned int index = s->index;
             ^
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
    272. {
    273.     unsigned int index = s->index;
    274.     uint8_t result     = s->buffer[index >> 3];
             ^
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;

libavcodec/get_bits.h:276:5: 
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
             ^
    277.     result  &= 1;
    278. #else

libavcodec/get_bits.h:277:5: 
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
    277.     result  &= 1;
             ^
    278. #else
    279.     result <<= index & 7;

libavcodec/get_bits.h:283:9: Taking true branch
    281. #endif
    282. #if !UNCHECKED_BITSTREAM_READER
    283.     if (s->index < s->size_in_bits_plus8)
                 ^
    284. #endif
    285.         index++;

libavcodec/get_bits.h:285:9: 
    283.     if (s->index < s->size_in_bits_plus8)
    284. #endif
    285.         index++;
                 ^
    286.     s->index = index;
    287. 

libavcodec/get_bits.h:286:5: 
    284. #endif
    285.         index++;
    286.     s->index = index;
             ^
    287. 
    288.     return result;

libavcodec/get_bits.h:288:5: 
    286.     s->index = index;
    287. 
    288.     return result;
             ^
    289. }
    290. 

libavcodec/get_bits.h:289:1: return from a call to get_bits1
    287. 
    288.     return result;
    289. }
         ^
    290. 
    291. static inline unsigned int show_bits1(GetBitContext *s)

libavcodec/h264_ps.c:308:5: 
  306.     constraint_set_flags |= get_bits1(&h->gb) << 1;   // constraint_set1_flag
  307.     constraint_set_flags |= get_bits1(&h->gb) << 2;   // constraint_set2_flag
  308.     constraint_set_flags |= get_bits1(&h->gb) << 3;   // constraint_set3_flag
           ^
  309.     constraint_set_flags |= get_bits1(&h->gb) << 4;   // constraint_set4_flag
  310.     constraint_set_flags |= get_bits1(&h->gb) << 5;   // constraint_set5_flag

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
    269. }
    270. 
    271. static inline unsigned int get_bits1(GetBitContext *s)
         ^
    272. {
    273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
    271. static inline unsigned int get_bits1(GetBitContext *s)
    272. {
    273.     unsigned int index = s->index;
             ^
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
    272. {
    273.     unsigned int index = s->index;
    274.     uint8_t result     = s->buffer[index >> 3];
             ^
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;

libavcodec/get_bits.h:276:5: 
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
             ^
    277.     result  &= 1;
    278. #else

libavcodec/get_bits.h:277:5: 
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
    277.     result  &= 1;
             ^
    278. #else
    279.     result <<= index & 7;

libavcodec/get_bits.h:283:9: Taking true branch
    281. #endif
    282. #if !UNCHECKED_BITSTREAM_READER
    283.     if (s->index < s->size_in_bits_plus8)
                 ^
    284. #endif
    285.         index++;

libavcodec/get_bits.h:285:9: 
    283.     if (s->index < s->size_in_bits_plus8)
    284. #endif
    285.         index++;
                 ^
    286.     s->index = index;
    287. 

libavcodec/get_bits.h:286:5: 
    284. #endif
    285.         index++;
    286.     s->index = index;
             ^
    287. 
    288.     return result;

libavcodec/get_bits.h:288:5: 
    286.     s->index = index;
    287. 
    288.     return result;
             ^
    289. }
    290. 

libavcodec/get_bits.h:289:1: return from a call to get_bits1
    287. 
    288.     return result;
    289. }
         ^
    290. 
    291. static inline unsigned int show_bits1(GetBitContext *s)

libavcodec/h264_ps.c:309:5: 
  307.     constraint_set_flags |= get_bits1(&h->gb) << 2;   // constraint_set2_flag
  308.     constraint_set_flags |= get_bits1(&h->gb) << 3;   // constraint_set3_flag
  309.     constraint_set_flags |= get_bits1(&h->gb) << 4;   // constraint_set4_flag
           ^
  310.     constraint_set_flags |= get_bits1(&h->gb) << 5;   // constraint_set5_flag
  311.     skip_bits(&h->gb, 2);                             // reserved_zero_2bits

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
    269. }
    270. 
    271. static inline unsigned int get_bits1(GetBitContext *s)
         ^
    272. {
    273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
    271. static inline unsigned int get_bits1(GetBitContext *s)
    272. {
    273.     unsigned int index = s->index;
             ^
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
    272. {
    273.     unsigned int index = s->index;
    274.     uint8_t result     = s->buffer[index >> 3];
             ^
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;

libavcodec/get_bits.h:276:5: 
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
             ^
    277.     result  &= 1;
    278. #else

libavcodec/get_bits.h:277:5: 
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;
    277.     result  &= 1;
             ^
    278. #else
    279.     result <<= index & 7;

libavcodec/get_bits.h:283:9: Taking true branch
    281. #endif
    282. #if !UNCHECKED_BITSTREAM_READER
    283.     if (s->index < s->size_in_bits_plus8)
                 ^
    284. #endif
    285.         index++;

libavcodec/get_bits.h:285:9: 
    283.     if (s->index < s->size_in_bits_plus8)
    284. #endif
    285.         index++;
                 ^
    286.     s->index = index;
    287. 

libavcodec/get_bits.h:286:5: 
    284. #endif
    285.         index++;
    286.     s->index = index;
             ^
    287. 
    288.     return result;

libavcodec/get_bits.h:288:5: 
    286.     s->index = index;
    287. 
    288.     return result;
             ^
    289. }
    290. 

libavcodec/get_bits.h:289:1: return from a call to get_bits1
    287. 
    288.     return result;
    289. }
         ^
    290. 
    291. static inline unsigned int show_bits1(GetBitContext *s)

libavcodec/h264_ps.c:310:5: 
  308.     constraint_set_flags |= get_bits1(&h->gb) << 3;   // constraint_set3_flag
  309.     constraint_set_flags |= get_bits1(&h->gb) << 4;   // constraint_set4_flag
  310.     constraint_set_flags |= get_bits1(&h->gb) << 5;   // constraint_set5_flag
           ^
  311.     skip_bits(&h->gb, 2);                             // reserved_zero_2bits
  312.     level_idc = get_bits(&h->gb, 8);

libavcodec/get_bits.h:271:1: start of procedure get_bits1()
    269. }
    270. 
    271. static inline unsigned int get_bits1(GetBitContext *s)
         ^
    272. {
    273.     unsigned int index = s->index;

libavcodec/get_bits.h:273:5: 
    271. static inline unsigned int get_bits1(GetBitContext *s)
    272. {
    273.     unsigned int index = s->index;
             ^
    274.     uint8_t result     = s->buffer[index >> 3];
    275. #ifdef BITSTREAM_READER_LE

libavcodec/get_bits.h:274:5: 
    272. {
    273.     unsigned int index = s->index;
    274.     uint8_t result     = s->buffer[index >> 3];
             ^
    275. #ifdef BITSTREAM_READER_LE
    276.     result >>= index & 7;

static inline int parse_nal_units(AVCodecParserContext *s,
                                  AVCodecContext *avctx,
                                  const uint8_t *buf, int buf_size)
{
    H264Context *h         = s->priv_data;
    const uint8_t *buf_end = buf + buf_size;
    unsigned int pps_id;
    unsigned int slice_type;
    int state = -1, got_reset = 0;
    const uint8_t *ptr;
    int field_poc[2];
    s->pict_type         = AV_PICTURE_TYPE_I;
    s->key_frame         = 0;
    s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
    h->avctx = avctx;
    ff_h264_reset_sei(h);
    if (!buf_size)
        return 0;
    for (;;) {
        int src_length, dst_length, consumed;
        buf = avpriv_find_start_code(buf, buf_end, &state);
        if (buf >= buf_end)
            break;
        --buf;
        src_length = buf_end - buf;
        switch (state & 0x1f) {
        case NAL_SLICE:
        case NAL_IDR_SLICE:
            if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
                if (src_length > 60)
                    src_length = 60;
            } else {
                if (src_length > 1000)
                    src_length = 1000;
            }
            break;
        }
        ptr = ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
        if (ptr == NULL || dst_length < 0)
            break;
        init_get_bits(&h->gb, ptr, 8 * dst_length);
        switch (h->nal_unit_type) {
        case NAL_SPS:
            ff_h264_decode_seq_parameter_set(h);
            break;
        case NAL_PPS:
            ff_h264_decode_picture_parameter_set(h, h->gb.size_in_bits);
            break;
        case NAL_SEI:
            ff_h264_decode_sei(h);
            break;
        case NAL_IDR_SLICE:
            s->key_frame = 1;
            h->prev_frame_num        = 0;
            h->prev_frame_num_offset = 0;
            h->prev_poc_msb          =
            h->prev_poc_lsb          = 0;
        case NAL_SLICE:
            get_ue_golomb(&h->gb);
            slice_type   = get_ue_golomb_31(&h->gb);
            s->pict_type = golomb_to_pict_type[slice_type % 5];
            if (h->sei_recovery_frame_cnt >= 0) {
                s->key_frame = 1;
            }
            pps_id = get_ue_golomb(&h->gb);
            if (pps_id >= MAX_PPS_COUNT) {
                av_log(h->avctx, AV_LOG_ERROR,
                       "pps_id %u out of range\n", pps_id);
                return -1;
            }
            if (!h->pps_buffers[pps_id]) {
                av_log(h->avctx, AV_LOG_ERROR,
                       "non-existing PPS %u referenced\n", pps_id);
                return -1;
            }
            h->pps = *h->pps_buffers[pps_id];
            if (!h->sps_buffers[h->pps.sps_id]) {
                av_log(h->avctx, AV_LOG_ERROR,
                       "non-existing SPS %u referenced\n", h->pps.sps_id);
                return -1;
            }
            h->sps       = *h->sps_buffers[h->pps.sps_id];
            h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
            avctx->profile = ff_h264_get_profile(&h->sps);
            avctx->level   = h->sps.level_idc;
            if (h->sps.frame_mbs_only_flag) {
                h->picture_structure = PICT_FRAME;
            } else {
                if (get_bits1(&h->gb)) {
                    h->picture_structure = PICT_TOP_FIELD + get_bits1(&h->gb);
                } else {
                    h->picture_structure = PICT_FRAME;
                }
            }
            if (h->nal_unit_type == NAL_IDR_SLICE)
                get_ue_golomb(&h->gb);
            if (h->sps.poc_type == 0) {
                h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
                if (h->pps.pic_order_present == 1 &&
                    h->picture_structure == PICT_FRAME)
                    h->delta_poc_bottom = get_se_golomb(&h->gb);
            }
            if (h->sps.poc_type == 1 &&
                !h->sps.delta_pic_order_always_zero_flag) {
                h->delta_poc[0] = get_se_golomb(&h->gb);
                if (h->pps.pic_order_present == 1 &&
                    h->picture_structure == PICT_FRAME)
                    h->delta_poc[1] = get_se_golomb(&h->gb);
            }
            field_poc[0] = field_poc[1] = INT_MAX;
            ff_init_poc(h, field_poc, &s->output_picture_number);
            if (h->nal_ref_idc && h->nal_unit_type != NAL_IDR_SLICE) {
                got_reset = scan_mmco_reset(s);
                if (got_reset < 0)
                    return got_reset;
            }
            h->prev_frame_num        = got_reset ? 0 : h->frame_num;
            h->prev_frame_num_offset = got_reset ? 0 : h->frame_num_offset;
            if (h->nal_ref_idc != 0) {
                if (!got_reset) {
                    h->prev_poc_msb = h->poc_msb;
                    h->prev_poc_lsb = h->poc_lsb;
                } else {
                    h->prev_poc_msb = 0;
                    h->prev_poc_lsb =
                        h->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0];
                }
            }
            if (h->sps.pic_struct_present_flag) {
                switch (h->sei_pic_struct) {
                case SEI_PIC_STRUCT_TOP_FIELD:
                case SEI_PIC_STRUCT_BOTTOM_FIELD:
                    s->repeat_pict = 0;
                    break;
                case SEI_PIC_STRUCT_FRAME:
                case SEI_PIC_STRUCT_TOP_BOTTOM:
                case SEI_PIC_STRUCT_BOTTOM_TOP:
                    s->repeat_pict = 1;
                    break;
                case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
                case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
                    s->repeat_pict = 2;
                    break;
                case SEI_PIC_STRUCT_FRAME_DOUBLING:
                    s->repeat_pict = 3;
                    break;
                case SEI_PIC_STRUCT_FRAME_TRIPLING:
                    s->repeat_pict = 5;
                    break;
                default:
                    s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
                    break;
                }
            } else {
                s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
            }
            if (h->picture_structure == PICT_FRAME) {
                s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
                if (h->sps.pic_struct_present_flag) {
                    switch (h->sei_pic_struct) {
                    case SEI_PIC_STRUCT_TOP_BOTTOM:
                    case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
                        s->field_order = AV_FIELD_TT;
                        break;
                    case SEI_PIC_STRUCT_BOTTOM_TOP:
                    case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
                        s->field_order = AV_FIELD_BB;
                        break;
                    default:
                        s->field_order = AV_FIELD_PROGRESSIVE;
                        break;
                    }
                } else {
                    if (field_poc[0] < field_poc[1])
                        s->field_order = AV_FIELD_TT;
                    else if (field_poc[0] > field_poc[1])
                        s->field_order = AV_FIELD_BB;
                    else
                        s->field_order = AV_FIELD_PROGRESSIVE;
                }
            } else {
                if (h->picture_structure == PICT_TOP_FIELD)
                    s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD;
                else
                    s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;
                s->field_order = AV_FIELD_UNKNOWN;
            }
            return 0;
        }
        buf += consumed;
    }
    av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\n");
    return -1;
}
['static inline int parse_nal_units(AVCodecParserContext *s,\n                                  AVCodecContext *avctx,\n                                  const uint8_t *buf, int buf_size)\n{\n    H264Context *h         = s->priv_data;\n    const uint8_t *buf_end = buf + buf_size;\n    unsigned int pps_id;\n    unsigned int slice_type;\n    int state = -1, got_reset = 0;\n    const uint8_t *ptr;\n    int field_poc[2];\n    s->pict_type         = AV_PICTURE_TYPE_I;\n    s->key_frame         = 0;\n    s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;\n    h->avctx = avctx;\n    ff_h264_reset_sei(h);\n    if (!buf_size)\n        return 0;\n    for (;;) {\n        int src_length, dst_length, consumed;\n        buf = avpriv_find_start_code(buf, buf_end, &state);\n        if (buf >= buf_end)\n            break;\n        --buf;\n        src_length = buf_end - buf;\n        switch (state & 0x1f) {\n        case NAL_SLICE:\n        case NAL_IDR_SLICE:\n            if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {\n                if (src_length > 60)\n                    src_length = 60;\n            } else {\n                if (src_length > 1000)\n                    src_length = 1000;\n            }\n            break;\n        }\n        ptr = ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);\n        if (ptr == NULL || dst_length < 0)\n            break;\n        init_get_bits(&h->gb, ptr, 8 * dst_length);\n        switch (h->nal_unit_type) {\n        case NAL_SPS:\n            ff_h264_decode_seq_parameter_set(h);\n            break;\n        case NAL_PPS:\n            ff_h264_decode_picture_parameter_set(h, h->gb.size_in_bits);\n            break;\n        case NAL_SEI:\n            ff_h264_decode_sei(h);\n            break;\n        case NAL_IDR_SLICE:\n            s->key_frame = 1;\n            h->prev_frame_num        = 0;\n            h->prev_frame_num_offset = 0;\n            h->prev_poc_msb          =\n            h->prev_poc_lsb          = 0;\n        case NAL_SLICE:\n            get_ue_golomb(&h->gb);\n            slice_type   = get_ue_golomb_31(&h->gb);\n            s->pict_type = golomb_to_pict_type[slice_type % 5];\n            if (h->sei_recovery_frame_cnt >= 0) {\n                s->key_frame = 1;\n            }\n            pps_id = get_ue_golomb(&h->gb);\n            if (pps_id >= MAX_PPS_COUNT) {\n                av_log(h->avctx, AV_LOG_ERROR,\n                       "pps_id %u out of range\\n", pps_id);\n                return -1;\n            }\n            if (!h->pps_buffers[pps_id]) {\n                av_log(h->avctx, AV_LOG_ERROR,\n                       "non-existing PPS %u referenced\\n", pps_id);\n                return -1;\n            }\n            h->pps = *h->pps_buffers[pps_id];\n            if (!h->sps_buffers[h->pps.sps_id]) {\n                av_log(h->avctx, AV_LOG_ERROR,\n                       "non-existing SPS %u referenced\\n", h->pps.sps_id);\n                return -1;\n            }\n            h->sps       = *h->sps_buffers[h->pps.sps_id];\n            h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);\n            avctx->profile = ff_h264_get_profile(&h->sps);\n            avctx->level   = h->sps.level_idc;\n            if (h->sps.frame_mbs_only_flag) {\n                h->picture_structure = PICT_FRAME;\n            } else {\n                if (get_bits1(&h->gb)) {\n                    h->picture_structure = PICT_TOP_FIELD + get_bits1(&h->gb);\n                } else {\n                    h->picture_structure = PICT_FRAME;\n                }\n            }\n            if (h->nal_unit_type == NAL_IDR_SLICE)\n                get_ue_golomb(&h->gb);\n            if (h->sps.poc_type == 0) {\n                h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);\n                if (h->pps.pic_order_present == 1 &&\n                    h->picture_structure == PICT_FRAME)\n                    h->delta_poc_bottom = get_se_golomb(&h->gb);\n            }\n            if (h->sps.poc_type == 1 &&\n                !h->sps.delta_pic_order_always_zero_flag) {\n                h->delta_poc[0] = get_se_golomb(&h->gb);\n                if (h->pps.pic_order_present == 1 &&\n                    h->picture_structure == PICT_FRAME)\n                    h->delta_poc[1] = get_se_golomb(&h->gb);\n            }\n            field_poc[0] = field_poc[1] = INT_MAX;\n            ff_init_poc(h, field_poc, &s->output_picture_number);\n            if (h->nal_ref_idc && h->nal_unit_type != NAL_IDR_SLICE) {\n                got_reset = scan_mmco_reset(s);\n                if (got_reset < 0)\n                    return got_reset;\n            }\n            h->prev_frame_num        = got_reset ? 0 : h->frame_num;\n            h->prev_frame_num_offset = got_reset ? 0 : h->frame_num_offset;\n            if (h->nal_ref_idc != 0) {\n                if (!got_reset) {\n                    h->prev_poc_msb = h->poc_msb;\n                    h->prev_poc_lsb = h->poc_lsb;\n                } else {\n                    h->prev_poc_msb = 0;\n                    h->prev_poc_lsb =\n                        h->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0];\n                }\n            }\n            if (h->sps.pic_struct_present_flag) {\n                switch (h->sei_pic_struct) {\n                case SEI_PIC_STRUCT_TOP_FIELD:\n                case SEI_PIC_STRUCT_BOTTOM_FIELD:\n                    s->repeat_pict = 0;\n                    break;\n                case SEI_PIC_STRUCT_FRAME:\n                case SEI_PIC_STRUCT_TOP_BOTTOM:\n                case SEI_PIC_STRUCT_BOTTOM_TOP:\n                    s->repeat_pict = 1;\n                    break;\n                case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:\n                case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:\n                    s->repeat_pict = 2;\n                    break;\n                case SEI_PIC_STRUCT_FRAME_DOUBLING:\n                    s->repeat_pict = 3;\n                    break;\n                case SEI_PIC_STRUCT_FRAME_TRIPLING:\n                    s->repeat_pict = 5;\n                    break;\n                default:\n                    s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;\n                    break;\n                }\n            } else {\n                s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;\n            }\n            if (h->picture_structure == PICT_FRAME) {\n                s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;\n                if (h->sps.pic_struct_present_flag) {\n                    switch (h->sei_pic_struct) {\n                    case SEI_PIC_STRUCT_TOP_BOTTOM:\n                    case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:\n                        s->field_order = AV_FIELD_TT;\n                        break;\n                    case SEI_PIC_STRUCT_BOTTOM_TOP:\n                    case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:\n                        s->field_order = AV_FIELD_BB;\n                        break;\n                    default:\n                        s->field_order = AV_FIELD_PROGRESSIVE;\n                        break;\n                    }\n                } else {\n                    if (field_poc[0] < field_poc[1])\n                        s->field_order = AV_FIELD_TT;\n                    else if (field_poc[0] > field_poc[1])\n                        s->field_order = AV_FIELD_BB;\n                    else\n                        s->field_order = AV_FIELD_PROGRESSIVE;\n                }\n            } else {\n                if (h->picture_structure == PICT_TOP_FIELD)\n                    s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD;\n                else\n                    s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;\n                s->field_order = AV_FIELD_UNKNOWN;\n            }\n            return 0;\n        }\n        buf += consumed;\n    }\n    av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit\\n");\n    return -1;\n}', 'void ff_h264_reset_sei(H264Context *h)\n{\n    h->sei_recovery_frame_cnt       = -1;\n    h->sei_dpb_output_delay         =  0;\n    h->sei_cpb_removal_delay        = -1;\n    h->sei_buffering_period_present =  0;\n    h->sei_frame_packing_present    =  0;\n}', 'static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,\n                                int bit_size)\n{\n    int buffer_size;\n    int ret = 0;\n    if (bit_size > INT_MAX - 7 || bit_size < 0 || !buffer) {\n        buffer_size = bit_size = 0;\n        buffer      = NULL;\n        ret         = AVERROR_INVALIDDATA;\n    }\n    buffer_size = (bit_size + 7) >> 3;\n    s->buffer             = buffer;\n    s->size_in_bits       = bit_size;\n#if !UNCHECKED_BITSTREAM_READER\n    s->size_in_bits_plus8 = bit_size + 8;\n#endif\n    s->buffer_end         = buffer + buffer_size;\n    s->index              = 0;\n    return ret;\n}', 'int ff_h264_decode_seq_parameter_set(H264Context *h)\n{\n    int profile_idc, level_idc, constraint_set_flags = 0;\n    unsigned int sps_id;\n    int i, log2_max_frame_num_minus4;\n    SPS *sps;\n    profile_idc           = get_bits(&h->gb, 8);\n    constraint_set_flags |= get_bits1(&h->gb) << 0;\n    constraint_set_flags |= get_bits1(&h->gb) << 1;\n    constraint_set_flags |= get_bits1(&h->gb) << 2;\n    constraint_set_flags |= get_bits1(&h->gb) << 3;\n    constraint_set_flags |= get_bits1(&h->gb) << 4;\n    constraint_set_flags |= get_bits1(&h->gb) << 5;\n    skip_bits(&h->gb, 2);\n    level_idc = get_bits(&h->gb, 8);\n    sps_id    = get_ue_golomb_31(&h->gb);\n    if (sps_id >= MAX_SPS_COUNT) {\n        av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\\n", sps_id);\n        return AVERROR_INVALIDDATA;\n    }\n    sps = av_mallocz(sizeof(SPS));\n    if (!sps)\n        return AVERROR(ENOMEM);\n    sps->sps_id               = sps_id;\n    sps->time_offset_length   = 24;\n    sps->profile_idc          = profile_idc;\n    sps->constraint_set_flags = constraint_set_flags;\n    sps->level_idc            = level_idc;\n    memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));\n    memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));\n    sps->scaling_matrix_present = 0;\n    if (sps->profile_idc == 100 ||\n        sps->profile_idc == 110 ||\n        sps->profile_idc == 122 ||\n        sps->profile_idc == 244 ||\n        sps->profile_idc ==  44 ||\n        sps->profile_idc ==  83 ||\n        sps->profile_idc ==  86 ||\n        sps->profile_idc == 118 ||\n        sps->profile_idc == 128 ||\n        sps->profile_idc == 138 ||\n        sps->profile_idc == 144) {\n        sps->chroma_format_idc = get_ue_golomb_31(&h->gb);\n        if (sps->chroma_format_idc > 3) {\n            avpriv_request_sample(h->avctx, "chroma_format_idc %u",\n                                  sps->chroma_format_idc);\n            goto fail;\n        } else if (sps->chroma_format_idc == 3) {\n            sps->residual_color_transform_flag = get_bits1(&h->gb);\n        }\n        sps->bit_depth_luma   = get_ue_golomb(&h->gb) + 8;\n        sps->bit_depth_chroma = get_ue_golomb(&h->gb) + 8;\n        if (sps->bit_depth_chroma != sps->bit_depth_luma) {\n            avpriv_request_sample(h->avctx,\n                                  "Different chroma and luma bit depth");\n            goto fail;\n        }\n        sps->transform_bypass = get_bits1(&h->gb);\n        decode_scaling_matrices(h, sps, NULL, 1,\n                                sps->scaling_matrix4, sps->scaling_matrix8);\n    } else {\n        sps->chroma_format_idc = 1;\n        sps->bit_depth_luma    = 8;\n        sps->bit_depth_chroma  = 8;\n    }\n    log2_max_frame_num_minus4 = get_ue_golomb(&h->gb);\n    if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||\n        log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {\n        av_log(h->avctx, AV_LOG_ERROR,\n               "log2_max_frame_num_minus4 out of range (0-12): %d\\n",\n               log2_max_frame_num_minus4);\n        goto fail;\n    }\n    sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;\n    sps->poc_type = get_ue_golomb_31(&h->gb);\n    if (sps->poc_type == 0) {\n        sps->log2_max_poc_lsb = get_ue_golomb(&h->gb) + 4;\n    } else if (sps->poc_type == 1) {\n        sps->delta_pic_order_always_zero_flag = get_bits1(&h->gb);\n        sps->offset_for_non_ref_pic           = get_se_golomb(&h->gb);\n        sps->offset_for_top_to_bottom_field   = get_se_golomb(&h->gb);\n        sps->poc_cycle_length                 = get_ue_golomb(&h->gb);\n        if ((unsigned)sps->poc_cycle_length >=\n            FF_ARRAY_ELEMS(sps->offset_for_ref_frame)) {\n            av_log(h->avctx, AV_LOG_ERROR,\n                   "poc_cycle_length overflow %u\\n", sps->poc_cycle_length);\n            goto fail;\n        }\n        for (i = 0; i < sps->poc_cycle_length; i++)\n            sps->offset_for_ref_frame[i] = get_se_golomb(&h->gb);\n    } else if (sps->poc_type != 2) {\n        av_log(h->avctx, AV_LOG_ERROR, "illegal POC type %d\\n", sps->poc_type);\n        goto fail;\n    }\n    sps->ref_frame_count = get_ue_golomb_31(&h->gb);\n    if (sps->ref_frame_count > H264_MAX_PICTURE_COUNT - 2 ||\n        sps->ref_frame_count >= 32U) {\n        av_log(h->avctx, AV_LOG_ERROR,\n               "too many reference frames %d\\n", sps->ref_frame_count);\n        goto fail;\n    }\n    sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb);\n    sps->mb_width                       = get_ue_golomb(&h->gb) + 1;\n    sps->mb_height                      = get_ue_golomb(&h->gb) + 1;\n    if ((unsigned)sps->mb_width  >= INT_MAX / 16 ||\n        (unsigned)sps->mb_height >= INT_MAX / 16 ||\n        av_image_check_size(16 * sps->mb_width,\n                            16 * sps->mb_height, 0, h->avctx)) {\n        av_log(h->avctx, AV_LOG_ERROR, "mb_width/height overflow\\n");\n        goto fail;\n    }\n    sps->frame_mbs_only_flag = get_bits1(&h->gb);\n    if (!sps->frame_mbs_only_flag)\n        sps->mb_aff = get_bits1(&h->gb);\n    else\n        sps->mb_aff = 0;\n    sps->direct_8x8_inference_flag = get_bits1(&h->gb);\n    if (!sps->frame_mbs_only_flag && !sps->direct_8x8_inference_flag) {\n        av_log(h->avctx, AV_LOG_ERROR,\n               "This stream was generated by a broken encoder, invalid 8x8 inference\\n");\n        goto fail;\n    }\n#ifndef ALLOW_INTERLACE\n    if (sps->mb_aff)\n        av_log(h->avctx, AV_LOG_ERROR,\n               "MBAFF support not included; enable it at compile-time.\\n");\n#endif\n    sps->crop = get_bits1(&h->gb);\n    if (sps->crop) {\n        int crop_left   = get_ue_golomb(&h->gb);\n        int crop_right  = get_ue_golomb(&h->gb);\n        int crop_top    = get_ue_golomb(&h->gb);\n        int crop_bottom = get_ue_golomb(&h->gb);\n        if (h->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) {\n            av_log(h->avctx, AV_LOG_DEBUG, "discarding sps cropping, original "\n                                           "values are l:%u r:%u t:%u b:%u\\n",\n                   crop_left, crop_right, crop_top, crop_bottom);\n            sps->crop_left   =\n            sps->crop_right  =\n            sps->crop_top    =\n            sps->crop_bottom = 0;\n        } else {\n            int vsub   = (sps->chroma_format_idc == 1) ? 1 : 0;\n            int hsub   = (sps->chroma_format_idc == 1 ||\n                          sps->chroma_format_idc == 2) ? 1 : 0;\n            int step_x = 1 << hsub;\n            int step_y = (2 - sps->frame_mbs_only_flag) << vsub;\n            if (crop_left & (0x1F >> (sps->bit_depth_luma > 8)) &&\n                !(h->avctx->flags & CODEC_FLAG_UNALIGNED)) {\n                crop_left &= ~(0x1F >> (sps->bit_depth_luma > 8));\n                av_log(h->avctx, AV_LOG_WARNING,\n                       "Reducing left cropping to %d "\n                       "chroma samples to preserve alignment.\\n",\n                       crop_left);\n            }\n            sps->crop_left   = crop_left   * step_x;\n            sps->crop_right  = crop_right  * step_x;\n            sps->crop_top    = crop_top    * step_y;\n            sps->crop_bottom = crop_bottom * step_y;\n        }\n    } else {\n        sps->crop_left   =\n        sps->crop_right  =\n        sps->crop_top    =\n        sps->crop_bottom =\n        sps->crop        = 0;\n    }\n    sps->vui_parameters_present_flag = get_bits1(&h->gb);\n    if (sps->vui_parameters_present_flag) {\n        int ret = decode_vui_parameters(h, sps);\n        if (ret < 0 && h->avctx->err_recognition & AV_EF_EXPLODE)\n            goto fail;\n    }\n    if (!sps->sar.den)\n        sps->sar.den = 1;\n    if (h->avctx->debug & FF_DEBUG_PICT_INFO) {\n        static const char csp[4][5] = { "Gray", "420", "422", "444" };\n        av_log(h->avctx, AV_LOG_DEBUG,\n               "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\\n",\n               sps_id, sps->profile_idc, sps->level_idc,\n               sps->poc_type,\n               sps->ref_frame_count,\n               sps->mb_width, sps->mb_height,\n               sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),\n               sps->direct_8x8_inference_flag ? "8B8" : "",\n               sps->crop_left, sps->crop_right,\n               sps->crop_top, sps->crop_bottom,\n               sps->vui_parameters_present_flag ? "VUI" : "",\n               csp[sps->chroma_format_idc],\n               sps->timing_info_present_flag ? sps->num_units_in_tick : 0,\n               sps->timing_info_present_flag ? sps->time_scale : 0);\n    }\n    sps->new = 1;\n    av_free(h->sps_buffers[sps_id]);\n    h->sps_buffers[sps_id] = sps;\n    h->sps                 = *sps;\n    return 0;\nfail:\n    av_free(sps);\n    return -1;\n}', 'static inline unsigned int get_bits1(GetBitContext *s)\n{\n    unsigned int index = s->index;\n    uint8_t result     = s->buffer[index >> 3];\n#ifdef BITSTREAM_READER_LE\n    result >>= index & 7;\n    result  &= 1;\n#else\n    result <<= index & 7;\n    result >>= 8 - 1;\n#endif\n#if !UNCHECKED_BITSTREAM_READER\n    if (s->index < s->size_in_bits_plus8)\n#endif\n        index++;\n    s->index = index;\n    return result;\n}']