static int decode_profile_tier_level(HEVCLocalContext *lc, PTL *ptl,

                                     int max_num_sub_layers)

{

    int i, j;

    GetBitContext *gb = &lc->gb;



    ptl->general_profile_space = get_bits(gb, 2);

    ptl->general_tier_flag     = get_bits1(gb);

    ptl->general_profile_idc   = get_bits(gb, 5);

    for (i = 0; i < 32; i++)

        ptl->general_profile_compatibility_flag[i] = get_bits1(gb);

    skip_bits1(gb); // general_progressive_source_flag

    skip_bits1(gb); // general_interlaced_source_flag

    skip_bits1(gb); // general_non_packed_constraint_flag

    skip_bits1(gb); // general_frame_only_constraint_flag

    if (get_bits(gb, 16) != 0) // XXX_reserved_zero_44bits[0..15]

        return -1;

    if (get_bits(gb, 16) != 0) // XXX_reserved_zero_44bits[16..31]

        return -1;

    if (get_bits(gb, 12) != 0) // XXX_reserved_zero_44bits[32..43]

        return -1;



    ptl->general_level_idc = get_bits(gb, 8);

    for (i = 0; i < max_num_sub_layers - 1; i++) {

        ptl->sub_layer_profile_present_flag[i] = get_bits1(gb);

        ptl->sub_layer_level_present_flag[i]   = get_bits1(gb);

    }

    if (max_num_sub_layers - 1 > 0)

        for (i = max_num_sub_layers - 1; i < 8; i++)

            skip_bits(gb, 2);  // reserved_zero_2bits[i]

    for (i = 0; i < max_num_sub_layers - 1; i++) {

        if (ptl->sub_layer_profile_present_flag[i]) {

            ptl->sub_layer_profile_space[i] = get_bits(gb, 2);

            ptl->sub_layer_tier_flag[i]     = get_bits(gb, 1);

            ptl->sub_layer_profile_idc[i]   = get_bits(gb, 5);

            for (j = 0; j < 32; j++)

                ptl->sub_layer_profile_compatibility_flags[i][j] = get_bits1(gb);

            skip_bits1(gb); // sub_layer_progressive_source_flag

            skip_bits1(gb); // sub_layer_interlaced_source_flag

            skip_bits1(gb); // sub_layer_non_packed_constraint_flag

            skip_bits1(gb); // sub_layer_frame_only_constraint_flag



            if (get_bits(gb, 16) != 0) // sub_layer_reserved_zero_44bits[0..15]

                return -1;

            if (get_bits(gb, 16) != 0) // sub_layer_reserved_zero_44bits[16..31]

                return -1;

            if (get_bits(gb, 12) != 0) // sub_layer_reserved_zero_44bits[32..43]

                return -1;

        }

        if (ptl->sub_layer_level_present_flag[i])

            ptl->sub_layer_level_idc[i] = get_bits(gb, 8);

    }

    return 0;

}

static int decode_profile_tier_level(HEVCLocalContext *lc, PTL *ptl,

                                     int max_num_sub_layers)

{

    int i, j;

    GetBitContext *gb = &lc->gb;



    ptl->general_profile_space = get_bits(gb, 2);

    ptl->general_tier_flag     = get_bits1(gb);

    ptl->general_profile_idc   = get_bits(gb, 5);

    for (i = 0; i < 32; i++)

        ptl->general_profile_compatibility_flag[i] = get_bits1(gb);

    skip_bits1(gb); 

    skip_bits1(gb); 

    skip_bits1(gb); 

    skip_bits1(gb); 

    if (get_bits(gb, 16) != 0) 

        return -1;

    if (get_bits(gb, 16) != 0) 

        return -1;

    if (get_bits(gb, 12) != 0) 

        return -1;



    ptl->general_level_idc = get_bits(gb, 8);

    for (i = 0; i < max_num_sub_layers - 1; i++) {

        ptl->sub_layer_profile_present_flag[i] = get_bits1(gb);

        ptl->sub_layer_level_present_flag[i]   = get_bits1(gb);

    }

    if (max_num_sub_layers - 1 > 0)

        for (i = max_num_sub_layers - 1; i < 8; i++)

            skip_bits(gb, 2);  

    for (i = 0; i < max_num_sub_layers - 1; i++) {

        if (ptl->sub_layer_profile_present_flag[i]) {

            ptl->sub_layer_profile_space[i] = get_bits(gb, 2);

            ptl->sub_layer_tier_flag[i]     = get_bits(gb, 1);

            ptl->sub_layer_profile_idc[i]   = get_bits(gb, 5);

            for (j = 0; j < 32; j++)

                ptl->sub_layer_profile_compatibility_flags[i][j] = get_bits1(gb);

            skip_bits1(gb); 

            skip_bits1(gb); 

            skip_bits1(gb); 

            skip_bits1(gb); 



            if (get_bits(gb, 16) != 0) 

                return -1;

            if (get_bits(gb, 16) != 0) 

                return -1;

            if (get_bits(gb, 12) != 0) 

                return -1;

        }

        if (ptl->sub_layer_level_present_flag[i])

            ptl->sub_layer_level_idc[i] = get_bits(gb, 8);

    }

    return 0;

}

static int FUNC_0(HEVCLocalContext *VAR_0, PTL *VAR_1,

                                     int VAR_2)

{

    int VAR_3, VAR_4;

    GetBitContext *gb = &VAR_0->gb;



    VAR_1->general_profile_space = get_bits(gb, 2);

    VAR_1->general_tier_flag     = get_bits1(gb);

    VAR_1->general_profile_idc   = get_bits(gb, 5);

    for (VAR_3 = 0; VAR_3 < 32; VAR_3++)

        VAR_1->general_profile_compatibility_flag[VAR_3] = get_bits1(gb);

    skip_bits1(gb); 

    skip_bits1(gb); 

    skip_bits1(gb); 

    skip_bits1(gb); 

    if (get_bits(gb, 16) != 0) 

        return -1;

    if (get_bits(gb, 16) != 0) 

        return -1;

    if (get_bits(gb, 12) != 0) 

        return -1;



    VAR_1->general_level_idc = get_bits(gb, 8);

    for (VAR_3 = 0; VAR_3 < VAR_2 - 1; VAR_3++) {

        VAR_1->sub_layer_profile_present_flag[VAR_3] = get_bits1(gb);

        VAR_1->sub_layer_level_present_flag[VAR_3]   = get_bits1(gb);

    }

    if (VAR_2 - 1 > 0)

        for (VAR_3 = VAR_2 - 1; VAR_3 < 8; VAR_3++)

            skip_bits(gb, 2);  

    for (VAR_3 = 0; VAR_3 < VAR_2 - 1; VAR_3++) {

        if (VAR_1->sub_layer_profile_present_flag[VAR_3]) {

            VAR_1->sub_layer_profile_space[VAR_3] = get_bits(gb, 2);

            VAR_1->sub_layer_tier_flag[VAR_3]     = get_bits(gb, 1);

            VAR_1->sub_layer_profile_idc[VAR_3]   = get_bits(gb, 5);

            for (VAR_4 = 0; VAR_4 < 32; VAR_4++)

                VAR_1->sub_layer_profile_compatibility_flags[VAR_3][VAR_4] = get_bits1(gb);

            skip_bits1(gb); 

            skip_bits1(gb); 

            skip_bits1(gb); 

            skip_bits1(gb); 



            if (get_bits(gb, 16) != 0) 

                return -1;

            if (get_bits(gb, 16) != 0) 

                return -1;

            if (get_bits(gb, 12) != 0) 

                return -1;

        }

        if (VAR_1->sub_layer_level_present_flag[VAR_3])

            VAR_1->sub_layer_level_idc[VAR_3] = get_bits(gb, 8);

    }

    return 0;

}

static int FUNC_0(HEVCLocalContext *VAR_0, PTL *VAR_1,
int VAR_2)
{ int VAR_3, VAR_4; GetBitContext *gb = &VAR_0->gb; VAR_1->general_profile_space = get_bits(gb, 2); VAR_1->general_tier_flag     = get_bits1(gb); VAR_1->general_profile_idc   = get_bits(gb, 5); for (VAR_3 = 0; VAR_3 < 32; VAR_3++) VAR_1->general_profile_compatibility_flag[VAR_3] = get_bits1(gb); skip_bits1(gb); skip_bits1(gb); skip_bits1(gb); skip_bits1(gb); if (get_bits(gb, 16) != 0)
return -1; if (get_bits(gb, 16) != 0)
return -1; if (get_bits(gb, 12) != 0)
return -1; VAR_1->general_level_idc = get_bits(gb, 8); for (VAR_3 = 0; VAR_3 < VAR_2 - 1; VAR_3++) { VAR_1->sub_layer_profile_present_flag[VAR_3] = get_bits1(gb); VAR_1->sub_layer_level_present_flag[VAR_3]   = get_bits1(gb); } if (VAR_2 - 1 > 0)
for (VAR_3 = VAR_2 - 1; VAR_3 < 8; VAR_3++) skip_bits(gb, 2); for (VAR_3 = 0; VAR_3 < VAR_2 - 1; VAR_3++) { if (VAR_1->sub_layer_profile_present_flag[VAR_3]) { VAR_1->sub_layer_profile_space[VAR_3] = get_bits(gb, 2); VAR_1->sub_layer_tier_flag[VAR_3]     = get_bits(gb, 1); VAR_1->sub_layer_profile_idc[VAR_3]   = get_bits(gb, 5); for (VAR_4 = 0; VAR_4 < 32; VAR_4++) VAR_1->sub_layer_profile_compatibility_flags[VAR_3][VAR_4] = get_bits1(gb); skip_bits1(gb); skip_bits1(gb); skip_bits1(gb); skip_bits1(gb); if (get_bits(gb, 16) != 0)
return -1; if (get_bits(gb, 16) != 0)
return -1; if (get_bits(gb, 12) != 0)
return -1; } if (VAR_1->sub_layer_level_present_flag[VAR_3])
VAR_1->sub_layer_level_idc[VAR_3] = get_bits(gb, 8); } return 0; }