static void pred_weight_table(HEVCContext *s, GetBitContext *gb)

{

    int i = 0;

    int j = 0;

    uint8_t luma_weight_l0_flag[16];

    uint8_t chroma_weight_l0_flag[16];

    uint8_t luma_weight_l1_flag[16];

    uint8_t chroma_weight_l1_flag[16];

    int luma_log2_weight_denom;



    luma_log2_weight_denom = get_ue_golomb_long(gb);

    if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7)

        av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);

    s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);

    if (s->ps.sps->chroma_format_idc != 0) {

        int delta = get_se_golomb(gb);

        s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3);

    }



    for (i = 0; i < s->sh.nb_refs[L0]; i++) {

        luma_weight_l0_flag[i] = get_bits1(gb);

        if (!luma_weight_l0_flag[i]) {

            s->sh.luma_weight_l0[i] = 1 << s->sh.luma_log2_weight_denom;

            s->sh.luma_offset_l0[i] = 0;

        }

    }

    if (s->ps.sps->chroma_format_idc != 0) {

        for (i = 0; i < s->sh.nb_refs[L0]; i++)

            chroma_weight_l0_flag[i] = get_bits1(gb);

    } else {

        for (i = 0; i < s->sh.nb_refs[L0]; i++)

            chroma_weight_l0_flag[i] = 0;

    }

    for (i = 0; i < s->sh.nb_refs[L0]; i++) {

        if (luma_weight_l0_flag[i]) {

            int delta_luma_weight_l0 = get_se_golomb(gb);

            s->sh.luma_weight_l0[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l0;

            s->sh.luma_offset_l0[i] = get_se_golomb(gb);

        }

        if (chroma_weight_l0_flag[i]) {

            for (j = 0; j < 2; j++) {

                int delta_chroma_weight_l0 = get_se_golomb(gb);

                int delta_chroma_offset_l0 = get_se_golomb(gb);

                s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;

                s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])

                                                                                    >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);

            }

        } else {

            s->sh.chroma_weight_l0[i][0] = 1 << s->sh.chroma_log2_weight_denom;

            s->sh.chroma_offset_l0[i][0] = 0;

            s->sh.chroma_weight_l0[i][1] = 1 << s->sh.chroma_log2_weight_denom;

            s->sh.chroma_offset_l0[i][1] = 0;

        }

    }

    if (s->sh.slice_type == HEVC_SLICE_B) {

        for (i = 0; i < s->sh.nb_refs[L1]; i++) {

            luma_weight_l1_flag[i] = get_bits1(gb);

            if (!luma_weight_l1_flag[i]) {

                s->sh.luma_weight_l1[i] = 1 << s->sh.luma_log2_weight_denom;

                s->sh.luma_offset_l1[i] = 0;

            }

        }

        if (s->ps.sps->chroma_format_idc != 0) {

            for (i = 0; i < s->sh.nb_refs[L1]; i++)

                chroma_weight_l1_flag[i] = get_bits1(gb);

        } else {

            for (i = 0; i < s->sh.nb_refs[L1]; i++)

                chroma_weight_l1_flag[i] = 0;

        }

        for (i = 0; i < s->sh.nb_refs[L1]; i++) {

            if (luma_weight_l1_flag[i]) {

                int delta_luma_weight_l1 = get_se_golomb(gb);

                s->sh.luma_weight_l1[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;

                s->sh.luma_offset_l1[i] = get_se_golomb(gb);

            }

            if (chroma_weight_l1_flag[i]) {

                for (j = 0; j < 2; j++) {

                    int delta_chroma_weight_l1 = get_se_golomb(gb);

                    int delta_chroma_offset_l1 = get_se_golomb(gb);

                    s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;

                    s->sh.chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])

                                                                                        >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);

                }

            } else {

                s->sh.chroma_weight_l1[i][0] = 1 << s->sh.chroma_log2_weight_denom;

                s->sh.chroma_offset_l1[i][0] = 0;

                s->sh.chroma_weight_l1[i][1] = 1 << s->sh.chroma_log2_weight_denom;

                s->sh.chroma_offset_l1[i][1] = 0;

            }

        }

    }

}

static void pred_weight_table(HEVCContext *s, GetBitContext *gb)

{

    int i = 0;

    int j = 0;

    uint8_t luma_weight_l0_flag[16];

    uint8_t chroma_weight_l0_flag[16];

    uint8_t luma_weight_l1_flag[16];

    uint8_t chroma_weight_l1_flag[16];

    int luma_log2_weight_denom;



    luma_log2_weight_denom = get_ue_golomb_long(gb);

    if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7)

        av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);

    s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);

    if (s->ps.sps->chroma_format_idc != 0) {

        int delta = get_se_golomb(gb);

        s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3);

    }



    for (i = 0; i < s->sh.nb_refs[L0]; i++) {

        luma_weight_l0_flag[i] = get_bits1(gb);

        if (!luma_weight_l0_flag[i]) {

            s->sh.luma_weight_l0[i] = 1 << s->sh.luma_log2_weight_denom;

            s->sh.luma_offset_l0[i] = 0;

        }

    }

    if (s->ps.sps->chroma_format_idc != 0) {

        for (i = 0; i < s->sh.nb_refs[L0]; i++)

            chroma_weight_l0_flag[i] = get_bits1(gb);

    } else {

        for (i = 0; i < s->sh.nb_refs[L0]; i++)

            chroma_weight_l0_flag[i] = 0;

    }

    for (i = 0; i < s->sh.nb_refs[L0]; i++) {

        if (luma_weight_l0_flag[i]) {

            int delta_luma_weight_l0 = get_se_golomb(gb);

            s->sh.luma_weight_l0[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l0;

            s->sh.luma_offset_l0[i] = get_se_golomb(gb);

        }

        if (chroma_weight_l0_flag[i]) {

            for (j = 0; j < 2; j++) {

                int delta_chroma_weight_l0 = get_se_golomb(gb);

                int delta_chroma_offset_l0 = get_se_golomb(gb);

                s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;

                s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])

                                                                                    >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);

            }

        } else {

            s->sh.chroma_weight_l0[i][0] = 1 << s->sh.chroma_log2_weight_denom;

            s->sh.chroma_offset_l0[i][0] = 0;

            s->sh.chroma_weight_l0[i][1] = 1 << s->sh.chroma_log2_weight_denom;

            s->sh.chroma_offset_l0[i][1] = 0;

        }

    }

    if (s->sh.slice_type == HEVC_SLICE_B) {

        for (i = 0; i < s->sh.nb_refs[L1]; i++) {

            luma_weight_l1_flag[i] = get_bits1(gb);

            if (!luma_weight_l1_flag[i]) {

                s->sh.luma_weight_l1[i] = 1 << s->sh.luma_log2_weight_denom;

                s->sh.luma_offset_l1[i] = 0;

            }

        }

        if (s->ps.sps->chroma_format_idc != 0) {

            for (i = 0; i < s->sh.nb_refs[L1]; i++)

                chroma_weight_l1_flag[i] = get_bits1(gb);

        } else {

            for (i = 0; i < s->sh.nb_refs[L1]; i++)

                chroma_weight_l1_flag[i] = 0;

        }

        for (i = 0; i < s->sh.nb_refs[L1]; i++) {

            if (luma_weight_l1_flag[i]) {

                int delta_luma_weight_l1 = get_se_golomb(gb);

                s->sh.luma_weight_l1[i] = (1 << s->sh.luma_log2_weight_denom) + delta_luma_weight_l1;

                s->sh.luma_offset_l1[i] = get_se_golomb(gb);

            }

            if (chroma_weight_l1_flag[i]) {

                for (j = 0; j < 2; j++) {

                    int delta_chroma_weight_l1 = get_se_golomb(gb);

                    int delta_chroma_offset_l1 = get_se_golomb(gb);

                    s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;

                    s->sh.chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])

                                                                                        >> s->sh.chroma_log2_weight_denom) + 128), -128, 127);

                }

            } else {

                s->sh.chroma_weight_l1[i][0] = 1 << s->sh.chroma_log2_weight_denom;

                s->sh.chroma_offset_l1[i][0] = 0;

                s->sh.chroma_weight_l1[i][1] = 1 << s->sh.chroma_log2_weight_denom;

                s->sh.chroma_offset_l1[i][1] = 0;

            }

        }

    }

}

static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
static void FUNC_0(HEVCContext *VAR_0, GetBitContext *VAR_1)

{

    int VAR_2 = 0;

    int VAR_3 = 0;

    uint8_t luma_weight_l0_flag[16];

    uint8_t chroma_weight_l0_flag[16];

    uint8_t luma_weight_l1_flag[16];

    uint8_t chroma_weight_l1_flag[16];

    int VAR_4;



    VAR_4 = get_ue_golomb_long(VAR_1);

    if (VAR_4 < 0 || VAR_4 > 7)

        av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_4 %d is invalid\n", VAR_4);

    VAR_0->sh.VAR_4 = av_clip_uintp2(VAR_4, 3);

    if (VAR_0->ps.sps->chroma_format_idc != 0) {

        int VAR_5 = get_se_golomb(VAR_1);

        VAR_0->sh.chroma_log2_weight_denom = av_clip_uintp2(VAR_0->sh.VAR_4 + VAR_5, 3);

    }



    for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++) {

        luma_weight_l0_flag[VAR_2] = get_bits1(VAR_1);

        if (!luma_weight_l0_flag[VAR_2]) {

            VAR_0->sh.luma_weight_l0[VAR_2] = 1 << VAR_0->sh.VAR_4;

            VAR_0->sh.luma_offset_l0[VAR_2] = 0;

        }

    }

    if (VAR_0->ps.sps->chroma_format_idc != 0) {

        for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++)

            chroma_weight_l0_flag[VAR_2] = get_bits1(VAR_1);

    } else {

        for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++)

            chroma_weight_l0_flag[VAR_2] = 0;

    }

    for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++) {

        if (luma_weight_l0_flag[VAR_2]) {

            int delta_luma_weight_l0 = get_se_golomb(VAR_1);

            VAR_0->sh.luma_weight_l0[VAR_2] = (1 << VAR_0->sh.VAR_4) + delta_luma_weight_l0;

            VAR_0->sh.luma_offset_l0[VAR_2] = get_se_golomb(VAR_1);

        }

        if (chroma_weight_l0_flag[VAR_2]) {

            for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {

                int delta_chroma_weight_l0 = get_se_golomb(VAR_1);

                int delta_chroma_offset_l0 = get_se_golomb(VAR_1);

                VAR_0->sh.chroma_weight_l0[VAR_2][VAR_3] = (1 << VAR_0->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;

                VAR_0->sh.chroma_offset_l0[VAR_2][VAR_3] = av_clip((delta_chroma_offset_l0 - ((128 * VAR_0->sh.chroma_weight_l0[VAR_2][VAR_3])

                                                                                    >> VAR_0->sh.chroma_log2_weight_denom) + 128), -128, 127);

            }

        } else {

            VAR_0->sh.chroma_weight_l0[VAR_2][0] = 1 << VAR_0->sh.chroma_log2_weight_denom;

            VAR_0->sh.chroma_offset_l0[VAR_2][0] = 0;

            VAR_0->sh.chroma_weight_l0[VAR_2][1] = 1 << VAR_0->sh.chroma_log2_weight_denom;

            VAR_0->sh.chroma_offset_l0[VAR_2][1] = 0;

        }

    }

    if (VAR_0->sh.slice_type == HEVC_SLICE_B) {

        for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++) {

            luma_weight_l1_flag[VAR_2] = get_bits1(VAR_1);

            if (!luma_weight_l1_flag[VAR_2]) {

                VAR_0->sh.luma_weight_l1[VAR_2] = 1 << VAR_0->sh.VAR_4;

                VAR_0->sh.luma_offset_l1[VAR_2] = 0;

            }

        }

        if (VAR_0->ps.sps->chroma_format_idc != 0) {

            for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++)

                chroma_weight_l1_flag[VAR_2] = get_bits1(VAR_1);

        } else {

            for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++)

                chroma_weight_l1_flag[VAR_2] = 0;

        }

        for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++) {

            if (luma_weight_l1_flag[VAR_2]) {

                int delta_luma_weight_l1 = get_se_golomb(VAR_1);

                VAR_0->sh.luma_weight_l1[VAR_2] = (1 << VAR_0->sh.VAR_4) + delta_luma_weight_l1;

                VAR_0->sh.luma_offset_l1[VAR_2] = get_se_golomb(VAR_1);

            }

            if (chroma_weight_l1_flag[VAR_2]) {

                for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {

                    int delta_chroma_weight_l1 = get_se_golomb(VAR_1);

                    int delta_chroma_offset_l1 = get_se_golomb(VAR_1);

                    VAR_0->sh.chroma_weight_l1[VAR_2][VAR_3] = (1 << VAR_0->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;

                    VAR_0->sh.chroma_offset_l1[VAR_2][VAR_3] = av_clip((delta_chroma_offset_l1 - ((128 * VAR_0->sh.chroma_weight_l1[VAR_2][VAR_3])

                                                                                        >> VAR_0->sh.chroma_log2_weight_denom) + 128), -128, 127);

                }

            } else {

                VAR_0->sh.chroma_weight_l1[VAR_2][0] = 1 << VAR_0->sh.chroma_log2_weight_denom;

                VAR_0->sh.chroma_offset_l1[VAR_2][0] = 0;

                VAR_0->sh.chroma_weight_l1[VAR_2][1] = 1 << VAR_0->sh.chroma_log2_weight_denom;

                VAR_0->sh.chroma_offset_l1[VAR_2][1] = 0;

            }

        }

    }

}

static void FUNC_0(HEVCContext *VAR_0, GetBitContext *VAR_1)
{ int VAR_2 = 0; int VAR_3 = 0; uint8_t luma_weight_l0_flag[16]; uint8_t chroma_weight_l0_flag[16]; uint8_t luma_weight_l1_flag[16]; uint8_t chroma_weight_l1_flag[16]; int VAR_4; VAR_4 = get_ue_golomb_long(VAR_1); if (VAR_4 < 0 || VAR_4 > 7)
av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_4 %d is invalid\n", VAR_4); VAR_0->sh.VAR_4 = av_clip_uintp2(VAR_4, 3); if (VAR_0->ps.sps->chroma_format_idc != 0) { int VAR_5 = get_se_golomb(VAR_1); VAR_0->sh.chroma_log2_weight_denom = av_clip_uintp2(VAR_0->sh.VAR_4 + VAR_5, 3); } for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++) { luma_weight_l0_flag[VAR_2] = get_bits1(VAR_1); if (!luma_weight_l0_flag[VAR_2]) { VAR_0->sh.luma_weight_l0[VAR_2] = 1 << VAR_0->sh.VAR_4; VAR_0->sh.luma_offset_l0[VAR_2] = 0; } } if (VAR_0->ps.sps->chroma_format_idc != 0) { for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++) chroma_weight_l0_flag[VAR_2] = get_bits1(VAR_1); } else { for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++) chroma_weight_l0_flag[VAR_2] = 0; } for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L0]; VAR_2++) { if (luma_weight_l0_flag[VAR_2]) { int delta_luma_weight_l0 = get_se_golomb(VAR_1); VAR_0->sh.luma_weight_l0[VAR_2] = (1 << VAR_0->sh.VAR_4) + delta_luma_weight_l0; VAR_0->sh.luma_offset_l0[VAR_2] = get_se_golomb(VAR_1); } if (chroma_weight_l0_flag[VAR_2]) { for (VAR_3 = 0; VAR_3 < 2; VAR_3++) { int delta_chroma_weight_l0 = get_se_golomb(VAR_1); int delta_chroma_offset_l0 = get_se_golomb(VAR_1); VAR_0->sh.chroma_weight_l0[VAR_2][VAR_3] = (1 << VAR_0->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0; VAR_0->sh.chroma_offset_l0[VAR_2][VAR_3] = av_clip((delta_chroma_offset_l0 - ((128 * VAR_0->sh.chroma_weight_l0[VAR_2][VAR_3])
>> VAR_0->sh.chroma_log2_weight_denom) + 128), -128, 127); } } else { VAR_0->sh.chroma_weight_l0[VAR_2][0] = 1 << VAR_0->sh.chroma_log2_weight_denom; VAR_0->sh.chroma_offset_l0[VAR_2][0] = 0; VAR_0->sh.chroma_weight_l0[VAR_2][1] = 1 << VAR_0->sh.chroma_log2_weight_denom; VAR_0->sh.chroma_offset_l0[VAR_2][1] = 0; } } if (VAR_0->sh.slice_type == HEVC_SLICE_B) { for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++) { luma_weight_l1_flag[VAR_2] = get_bits1(VAR_1); if (!luma_weight_l1_flag[VAR_2]) { VAR_0->sh.luma_weight_l1[VAR_2] = 1 << VAR_0->sh.VAR_4; VAR_0->sh.luma_offset_l1[VAR_2] = 0; } } if (VAR_0->ps.sps->chroma_format_idc != 0) { for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++) chroma_weight_l1_flag[VAR_2] = get_bits1(VAR_1); } else { for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++) chroma_weight_l1_flag[VAR_2] = 0; } for (VAR_2 = 0; VAR_2 < VAR_0->sh.nb_refs[L1]; VAR_2++) { if (luma_weight_l1_flag[VAR_2]) { int delta_luma_weight_l1 = get_se_golomb(VAR_1); VAR_0->sh.luma_weight_l1[VAR_2] = (1 << VAR_0->sh.VAR_4) + delta_luma_weight_l1; VAR_0->sh.luma_offset_l1[VAR_2] = get_se_golomb(VAR_1); } if (chroma_weight_l1_flag[VAR_2]) { for (VAR_3 = 0; VAR_3 < 2; VAR_3++) { int delta_chroma_weight_l1 = get_se_golomb(VAR_1); int delta_chroma_offset_l1 = get_se_golomb(VAR_1); VAR_0->sh.chroma_weight_l1[VAR_2][VAR_3] = (1 << VAR_0->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1; VAR_0->sh.chroma_offset_l1[VAR_2][VAR_3] = av_clip((delta_chroma_offset_l1 - ((128 * VAR_0->sh.chroma_weight_l1[VAR_2][VAR_3])
>> VAR_0->sh.chroma_log2_weight_denom) + 128), -128, 127); } } else { VAR_0->sh.chroma_weight_l1[VAR_2][0] = 1 << VAR_0->sh.chroma_log2_weight_denom; VAR_0->sh.chroma_offset_l1[VAR_2][0] = 0; VAR_0->sh.chroma_weight_l1[VAR_2][1] = 1 << VAR_0->sh.chroma_log2_weight_denom; VAR_0->sh.chroma_offset_l1[VAR_2][1] = 0; } } } }