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 out of range\n");
                return -1;
            }
            if (!h->pps_buffers[pps_id]) {
                av_log(h->avctx, AV_LOG_ERROR,
                       "non-existing PPS referenced\n");
                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 referenced\n");
                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 out of range\\n");\n                return -1;\n            }\n            if (!h->pps_buffers[pps_id]) {\n                av_log(h->avctx, AV_LOG_ERROR,\n                       "non-existing PPS referenced\\n");\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 referenced\\n");\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}', '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    get_bits(&h->gb, 4);\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 (%d) 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->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 || sps->profile_idc == 110 ||\n        sps->profile_idc == 122 || sps->profile_idc == 244 ||\n        sps->profile_idc ==  44 || sps->profile_idc ==  83 ||\n        sps->profile_idc ==  86 || sps->profile_idc == 118 ||\n        sps->profile_idc == 128 || sps->profile_idc == 144) {\n        sps->chroma_format_idc = get_ue_golomb_31(&h->gb);\n        if (sps->chroma_format_idc > 3) {\n            av_log(h->avctx, AV_LOG_ERROR,\n                   "chroma_format_idc (%u) out of range\\n",\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        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 > MAX_PICTURE_COUNT - 2 ||\n        sps->ref_frame_count >= 32U) {\n        av_log(h->avctx, AV_LOG_ERROR, "too many reference frames\\n");\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        if (decode_vui_parameters(h, sps) < 0)\n            goto fail;\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    h->current_sps_id      = sps_id;\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}']