void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *sl)

{

    H264Ref *const ref1 = &sl->ref_list[1][0];

    H264Picture *const cur = h->cur_pic_ptr;

    int list, j, field;

    int sidx     = (h->picture_structure & 1) ^ 1;

    int ref1sidx = (ref1->reference      & 1) ^ 1;



    for (list = 0; list < sl->list_count; list++) {

        cur->ref_count[sidx][list] = sl->ref_count[list];

        for (j = 0; j < sl->ref_count[list]; j++)

            cur->ref_poc[sidx][list][j] = 4 * sl->ref_list[list][j].parent->frame_num +

                                          (sl->ref_list[list][j].reference & 3);

    }



    if (h->picture_structure == PICT_FRAME) {

        memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));

        memcpy(cur->ref_poc[1],   cur->ref_poc[0],   sizeof(cur->ref_poc[0]));

    }



    cur->mbaff = FRAME_MBAFF(h);



    sl->col_fieldoff = 0;



    if (sl->list_count != 2 || !sl->ref_count[1])

        return;



    if (h->picture_structure == PICT_FRAME) {

        int cur_poc  = h->cur_pic_ptr->poc;

        int *col_poc = sl->ref_list[1][0].parent->field_poc;





        sl->col_parity = (FFABS(col_poc[0] - cur_poc) >=

                          FFABS(col_poc[1] - cur_poc));

        ref1sidx =

        sidx     = sl->col_parity;

    // FL -> FL & differ parity

    } else if (!(h->picture_structure & sl->ref_list[1][0].reference) &&

               !sl->ref_list[1][0].parent->mbaff) {

        sl->col_fieldoff = 2 * sl->ref_list[1][0].reference - 3;

    }



    if (sl->slice_type_nos != AV_PICTURE_TYPE_B || sl->direct_spatial_mv_pred)

        return;



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

        fill_colmap(h, sl, sl->map_col_to_list0, list, sidx, ref1sidx, 0);

        if (FRAME_MBAFF(h))

            for (field = 0; field < 2; field++)

                fill_colmap(h, sl, sl->map_col_to_list0_field[field], list, field,

                            field, 1);

    }

}
void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *sl)

{

    H264Ref *const ref1 = &sl->ref_list[1][0];

    H264Picture *const cur = h->cur_pic_ptr;

    int list, j, field;

    int sidx     = (h->picture_structure & 1) ^ 1;

    int ref1sidx = (ref1->reference      & 1) ^ 1;



    for (list = 0; list < sl->list_count; list++) {

        cur->ref_count[sidx][list] = sl->ref_count[list];

        for (j = 0; j < sl->ref_count[list]; j++)

            cur->ref_poc[sidx][list][j] = 4 * sl->ref_list[list][j].parent->frame_num +

                                          (sl->ref_list[list][j].reference & 3);

    }



    if (h->picture_structure == PICT_FRAME) {

        memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));

        memcpy(cur->ref_poc[1],   cur->ref_poc[0],   sizeof(cur->ref_poc[0]));

    }



    cur->mbaff = FRAME_MBAFF(h);



    sl->col_fieldoff = 0;



    if (sl->list_count != 2 || !sl->ref_count[1])

        return;



    if (h->picture_structure == PICT_FRAME) {

        int cur_poc  = h->cur_pic_ptr->poc;

        int *col_poc = sl->ref_list[1][0].parent->field_poc;





        sl->col_parity = (FFABS(col_poc[0] - cur_poc) >=

                          FFABS(col_poc[1] - cur_poc));

        ref1sidx =

        sidx     = sl->col_parity;

    

    } else if (!(h->picture_structure & sl->ref_list[1][0].reference) &&

               !sl->ref_list[1][0].parent->mbaff) {

        sl->col_fieldoff = 2 * sl->ref_list[1][0].reference - 3;

    }



    if (sl->slice_type_nos != AV_PICTURE_TYPE_B || sl->direct_spatial_mv_pred)

        return;



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

        fill_colmap(h, sl, sl->map_col_to_list0, list, sidx, ref1sidx, 0);

        if (FRAME_MBAFF(h))

            for (field = 0; field < 2; field++)

                fill_colmap(h, sl, sl->map_col_to_list0_field[field], list, field,

                            field, 1);

    }

}
void FUNC_0(const H264Context *const VAR_0, H264SliceContext *VAR_1)

{

    H264Ref *const ref1 = &VAR_1->ref_list[1][0];

    H264Picture *const cur = VAR_0->cur_pic_ptr;

    int VAR_2, VAR_3, VAR_4;

    int VAR_5     = (VAR_0->picture_structure & 1) ^ 1;

    int VAR_6 = (ref1->reference      & 1) ^ 1;



    for (VAR_2 = 0; VAR_2 < VAR_1->list_count; VAR_2++) {

        cur->ref_count[VAR_5][VAR_2] = VAR_1->ref_count[VAR_2];

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

            cur->ref_poc[VAR_5][VAR_2][VAR_3] = 4 * VAR_1->ref_list[VAR_2][VAR_3].parent->frame_num +

                                          (VAR_1->ref_list[VAR_2][VAR_3].reference & 3);

    }



    if (VAR_0->picture_structure == PICT_FRAME) {

        memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));

        memcpy(cur->ref_poc[1],   cur->ref_poc[0],   sizeof(cur->ref_poc[0]));

    }



    cur->mbaff = FRAME_MBAFF(VAR_0);



    VAR_1->col_fieldoff = 0;



    if (VAR_1->list_count != 2 || !VAR_1->ref_count[1])

        return;



    if (VAR_0->picture_structure == PICT_FRAME) {

        int VAR_7  = VAR_0->cur_pic_ptr->poc;

        int *VAR_8 = VAR_1->ref_list[1][0].parent->field_poc;





        VAR_1->col_parity = (FFABS(VAR_8[0] - VAR_7) >=

                          FFABS(VAR_8[1] - VAR_7));

        VAR_6 =

        VAR_5     = VAR_1->col_parity;

    

    } else if (!(VAR_0->picture_structure & VAR_1->ref_list[1][0].reference) &&

               !VAR_1->ref_list[1][0].parent->mbaff) {

        VAR_1->col_fieldoff = 2 * VAR_1->ref_list[1][0].reference - 3;

    }



    if (VAR_1->slice_type_nos != AV_PICTURE_TYPE_B || VAR_1->direct_spatial_mv_pred)

        return;



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

        fill_colmap(VAR_0, VAR_1, VAR_1->map_col_to_list0, VAR_2, VAR_5, VAR_6, 0);

        if (FRAME_MBAFF(VAR_0))

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

                fill_colmap(VAR_0, VAR_1, VAR_1->map_col_to_list0_field[VAR_4], VAR_2, VAR_4,

                            VAR_4, 1);

    }

}
void FUNC_0(const H264Context *const VAR_0, H264SliceContext *VAR_1)
{ H264Ref *const ref1 = &VAR_1->ref_list[1][0]; H264Picture *const cur = VAR_0->cur_pic_ptr; int VAR_2, VAR_3, VAR_4; int VAR_5     = (VAR_0->picture_structure & 1) ^ 1; int VAR_6 = (ref1->reference      & 1) ^ 1; for (VAR_2 = 0; VAR_2 < VAR_1->list_count; VAR_2++) { cur->ref_count[VAR_5][VAR_2] = VAR_1->ref_count[VAR_2]; for (VAR_3 = 0; VAR_3 < VAR_1->ref_count[VAR_2]; VAR_3++) cur->ref_poc[VAR_5][VAR_2][VAR_3] = 4 * VAR_1->ref_list[VAR_2][VAR_3].parent->frame_num +
(VAR_1->ref_list[VAR_2][VAR_3].reference & 3); } if (VAR_0->picture_structure == PICT_FRAME) { memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0])); memcpy(cur->ref_poc[1],   cur->ref_poc[0],   sizeof(cur->ref_poc[0])); } cur->mbaff = FRAME_MBAFF(VAR_0); VAR_1->col_fieldoff = 0; if (VAR_1->list_count != 2 || !VAR_1->ref_count[1])
return; if (VAR_0->picture_structure == PICT_FRAME) { int VAR_7  = VAR_0->cur_pic_ptr->poc; int *VAR_8 = VAR_1->ref_list[1][0].parent->field_poc; VAR_1->col_parity = (FFABS(VAR_8[0] - VAR_7) >=
FFABS(VAR_8[1] - VAR_7)); VAR_6 =
VAR_5     = VAR_1->col_parity; } else if (!(VAR_0->picture_structure & VAR_1->ref_list[1][0].reference) && !VAR_1->ref_list[1][0].parent->mbaff) { VAR_1->col_fieldoff = 2 * VAR_1->ref_list[1][0].reference - 3; } if (VAR_1->slice_type_nos != AV_PICTURE_TYPE_B || VAR_1->direct_spatial_mv_pred)
return; for (VAR_2 = 0; VAR_2 < 2; VAR_2++) { fill_colmap(VAR_0, VAR_1, VAR_1->map_col_to_list0, VAR_2, VAR_5, VAR_6, 0); if (FRAME_MBAFF(VAR_0))
for (VAR_4 = 0; VAR_4 < 2; VAR_4++) fill_colmap(VAR_0, VAR_1, VAR_1->map_col_to_list0_field[VAR_4], VAR_2, VAR_4,
VAR_4, 1); } }