static int pred_weight_table(H264Context *h)

{

    int list, i;

    int luma_def, chroma_def;



    h->use_weight             = 0;

    h->use_weight_chroma      = 0;

    h->luma_log2_weight_denom = get_ue_golomb(&h->gb);

    if (h->sps.chroma_format_idc)

        h->chroma_log2_weight_denom = get_ue_golomb(&h->gb);

    luma_def   = 1 << h->luma_log2_weight_denom;

    chroma_def = 1 << h->chroma_log2_weight_denom;



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

        h->luma_weight_flag[list]   = 0;

        h->chroma_weight_flag[list] = 0;

        for (i = 0; i < h->ref_count[list]; i++) {

            int luma_weight_flag, chroma_weight_flag;



            luma_weight_flag = get_bits1(&h->gb);

            if (luma_weight_flag) {

                h->luma_weight[i][list][0] = get_se_golomb(&h->gb);

                h->luma_weight[i][list][1] = get_se_golomb(&h->gb);

                if (h->luma_weight[i][list][0] != luma_def ||

                    h->luma_weight[i][list][1] != 0) {

                    h->use_weight             = 1;

                    h->luma_weight_flag[list] = 1;

                }

            } else {

                h->luma_weight[i][list][0] = luma_def;

                h->luma_weight[i][list][1] = 0;

            }



            if (h->sps.chroma_format_idc) {

                chroma_weight_flag = get_bits1(&h->gb);

                if (chroma_weight_flag) {

                    int j;

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

                        h->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb);

                        h->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb);

                        if (h->chroma_weight[i][list][j][0] != chroma_def ||

                            h->chroma_weight[i][list][j][1] != 0) {

                            h->use_weight_chroma        = 1;

                            h->chroma_weight_flag[list] = 1;

                        }

                    }

                } else {

                    int j;

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

                        h->chroma_weight[i][list][j][0] = chroma_def;

                        h->chroma_weight[i][list][j][1] = 0;

                    }

                }

            }

        }

        if (h->slice_type_nos != AV_PICTURE_TYPE_B)

            break;

    }

    h->use_weight = h->use_weight || h->use_weight_chroma;

    return 0;

}

static int pred_weight_table(H264Context *h)

{

    int list, i;

    int luma_def, chroma_def;



    h->use_weight             = 0;

    h->use_weight_chroma      = 0;

    h->luma_log2_weight_denom = get_ue_golomb(&h->gb);

    if (h->sps.chroma_format_idc)

        h->chroma_log2_weight_denom = get_ue_golomb(&h->gb);

    luma_def   = 1 << h->luma_log2_weight_denom;

    chroma_def = 1 << h->chroma_log2_weight_denom;



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

        h->luma_weight_flag[list]   = 0;

        h->chroma_weight_flag[list] = 0;

        for (i = 0; i < h->ref_count[list]; i++) {

            int luma_weight_flag, chroma_weight_flag;



            luma_weight_flag = get_bits1(&h->gb);

            if (luma_weight_flag) {

                h->luma_weight[i][list][0] = get_se_golomb(&h->gb);

                h->luma_weight[i][list][1] = get_se_golomb(&h->gb);

                if (h->luma_weight[i][list][0] != luma_def ||

                    h->luma_weight[i][list][1] != 0) {

                    h->use_weight             = 1;

                    h->luma_weight_flag[list] = 1;

                }

            } else {

                h->luma_weight[i][list][0] = luma_def;

                h->luma_weight[i][list][1] = 0;

            }



            if (h->sps.chroma_format_idc) {

                chroma_weight_flag = get_bits1(&h->gb);

                if (chroma_weight_flag) {

                    int j;

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

                        h->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb);

                        h->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb);

                        if (h->chroma_weight[i][list][j][0] != chroma_def ||

                            h->chroma_weight[i][list][j][1] != 0) {

                            h->use_weight_chroma        = 1;

                            h->chroma_weight_flag[list] = 1;

                        }

                    }

                } else {

                    int j;

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

                        h->chroma_weight[i][list][j][0] = chroma_def;

                        h->chroma_weight[i][list][j][1] = 0;

                    }

                }

            }

        }

        if (h->slice_type_nos != AV_PICTURE_TYPE_B)

            break;

    }

    h->use_weight = h->use_weight || h->use_weight_chroma;

    return 0;

}

static int FUNC_0(H264Context *VAR_0)

{

    int VAR_1, VAR_2;

    int VAR_3, VAR_4;



    VAR_0->use_weight             = 0;

    VAR_0->use_weight_chroma      = 0;

    VAR_0->luma_log2_weight_denom = get_ue_golomb(&VAR_0->gb);

    if (VAR_0->sps.chroma_format_idc)

        VAR_0->chroma_log2_weight_denom = get_ue_golomb(&VAR_0->gb);

    VAR_3   = 1 << VAR_0->luma_log2_weight_denom;

    VAR_4 = 1 << VAR_0->chroma_log2_weight_denom;



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

        VAR_0->luma_weight_flag[VAR_1]   = 0;

        VAR_0->chroma_weight_flag[VAR_1] = 0;

        for (VAR_2 = 0; VAR_2 < VAR_0->ref_count[VAR_1]; VAR_2++) {

            int luma_weight_flag, chroma_weight_flag;



            luma_weight_flag = get_bits1(&VAR_0->gb);

            if (luma_weight_flag) {

                VAR_0->luma_weight[VAR_2][VAR_1][0] = get_se_golomb(&VAR_0->gb);

                VAR_0->luma_weight[VAR_2][VAR_1][1] = get_se_golomb(&VAR_0->gb);

                if (VAR_0->luma_weight[VAR_2][VAR_1][0] != VAR_3 ||

                    VAR_0->luma_weight[VAR_2][VAR_1][1] != 0) {

                    VAR_0->use_weight             = 1;

                    VAR_0->luma_weight_flag[VAR_1] = 1;

                }

            } else {

                VAR_0->luma_weight[VAR_2][VAR_1][0] = VAR_3;

                VAR_0->luma_weight[VAR_2][VAR_1][1] = 0;

            }



            if (VAR_0->sps.chroma_format_idc) {

                chroma_weight_flag = get_bits1(&VAR_0->gb);

                if (chroma_weight_flag) {

                    int j;

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

                        VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = get_se_golomb(&VAR_0->gb);

                        VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = get_se_golomb(&VAR_0->gb);

                        if (VAR_0->chroma_weight[VAR_2][VAR_1][j][0] != VAR_4 ||

                            VAR_0->chroma_weight[VAR_2][VAR_1][j][1] != 0) {

                            VAR_0->use_weight_chroma        = 1;

                            VAR_0->chroma_weight_flag[VAR_1] = 1;

                        }

                    }

                } else {

                    int j;

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

                        VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = VAR_4;

                        VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = 0;

                    }

                }

            }

        }

        if (VAR_0->slice_type_nos != AV_PICTURE_TYPE_B)

            break;

    }

    VAR_0->use_weight = VAR_0->use_weight || VAR_0->use_weight_chroma;

    return 0;

}

static int FUNC_0(H264Context *VAR_0)
{ int VAR_1, VAR_2; int VAR_3, VAR_4; VAR_0->use_weight             = 0; VAR_0->use_weight_chroma      = 0; VAR_0->luma_log2_weight_denom = get_ue_golomb(&VAR_0->gb); if (VAR_0->sps.chroma_format_idc)
VAR_0->chroma_log2_weight_denom = get_ue_golomb(&VAR_0->gb); VAR_3   = 1 << VAR_0->luma_log2_weight_denom; VAR_4 = 1 << VAR_0->chroma_log2_weight_denom; for (VAR_1 = 0; VAR_1 < 2; VAR_1++) { VAR_0->luma_weight_flag[VAR_1]   = 0; VAR_0->chroma_weight_flag[VAR_1] = 0; for (VAR_2 = 0; VAR_2 < VAR_0->ref_count[VAR_1]; VAR_2++) { int luma_weight_flag, chroma_weight_flag; luma_weight_flag = get_bits1(&VAR_0->gb); if (luma_weight_flag) { VAR_0->luma_weight[VAR_2][VAR_1][0] = get_se_golomb(&VAR_0->gb); VAR_0->luma_weight[VAR_2][VAR_1][1] = get_se_golomb(&VAR_0->gb); if (VAR_0->luma_weight[VAR_2][VAR_1][0] != VAR_3 ||
VAR_0->luma_weight[VAR_2][VAR_1][1] != 0) { VAR_0->use_weight             = 1; VAR_0->luma_weight_flag[VAR_1] = 1; } } else { VAR_0->luma_weight[VAR_2][VAR_1][0] = VAR_3; VAR_0->luma_weight[VAR_2][VAR_1][1] = 0; } if (VAR_0->sps.chroma_format_idc) { chroma_weight_flag = get_bits1(&VAR_0->gb); if (chroma_weight_flag) { int j; for (j = 0; j < 2; j++) { VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = get_se_golomb(&VAR_0->gb); VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = get_se_golomb(&VAR_0->gb); if (VAR_0->chroma_weight[VAR_2][VAR_1][j][0] != VAR_4 ||
VAR_0->chroma_weight[VAR_2][VAR_1][j][1] != 0) { VAR_0->use_weight_chroma        = 1; VAR_0->chroma_weight_flag[VAR_1] = 1; } } } else { int j; for (j = 0; j < 2; j++) { VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = VAR_4; VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = 0; } } } } if (VAR_0->slice_type_nos != AV_PICTURE_TYPE_B)
break; } VAR_0->use_weight = VAR_0->use_weight || VAR_0->use_weight_chroma; return 0; }