void ff_h264_direct_ref_list_init(H264Context * const h){

    MpegEncContext * const s = &h->s;

    Picture * const ref1 = &h->ref_list[1][0];

    Picture * const cur = s->current_picture_ptr;

    int list, j, field;

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

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



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

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

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

            cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3);

    }



    if(s->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->col_fieldoff= 0;

    if(s->picture_structure == PICT_FRAME){

        int cur_poc = s->current_picture_ptr->poc;

        int *col_poc = h->ref_list[1]->field_poc;

        h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc));

        ref1sidx=sidx= h->col_parity;

    } else if (!(s->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { // FL -> FL & differ parity

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

    }



    if (cur->f.pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)

        return;



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

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

        if(FRAME_MBAFF)

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

            fill_colmap(h, h->map_col_to_list0_field[field], list, field, field, 1);

    }

}

void ff_h264_direct_ref_list_init(H264Context * const h){

    MpegEncContext * const s = &h->s;

    Picture * const ref1 = &h->ref_list[1][0];

    Picture * const cur = s->current_picture_ptr;

    int list, j, field;

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

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



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

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

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

            cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3);

    }



    if(s->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->col_fieldoff= 0;

    if(s->picture_structure == PICT_FRAME){

        int cur_poc = s->current_picture_ptr->poc;

        int *col_poc = h->ref_list[1]->field_poc;

        h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc));

        ref1sidx=sidx= h->col_parity;

    } else if (!(s->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { 

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

    }



    if (cur->f.pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)

        return;



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

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

        if(FRAME_MBAFF)

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

            fill_colmap(h, h->map_col_to_list0_field[field], list, field, field, 1);

    }

}

    if (cur->f.pict_type != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)
void FUNC_0(H264Context * const VAR_0){

    MpegEncContext * const s = &VAR_0->s;

    Picture * const ref1 = &VAR_0->ref_list[1][0];

    Picture * const cur = s->current_picture_ptr;

    int VAR_1, VAR_2, VAR_3;

    int VAR_4= (s->picture_structure&1)^1;

    int VAR_5 = (ref1->f.reference&1)^1;



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

        cur->ref_count[VAR_4][VAR_1] = VAR_0->ref_count[VAR_1];

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

            cur->ref_poc[VAR_4][VAR_1][VAR_2] = 4 * VAR_0->ref_list[VAR_1][VAR_2].frame_num + (VAR_0->ref_list[VAR_1][VAR_2].f.reference & 3);

    }



    if(s->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->col_fieldoff= 0;

    if(s->picture_structure == PICT_FRAME){

        int VAR_6 = s->current_picture_ptr->poc;

        int *VAR_7 = VAR_0->ref_list[1]->field_poc;

        VAR_0->col_parity= (FFABS(VAR_7[0] - VAR_6) >= FFABS(VAR_7[1] - VAR_6));

        VAR_5=VAR_4= VAR_0->col_parity;

    } else if (!(s->picture_structure & VAR_0->ref_list[1][0].f.reference) && !VAR_0->ref_list[1][0].mbaff) { 

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

    }



    if (cur->f.pict_type != AV_PICTURE_TYPE_B || VAR_0->direct_spatial_mv_pred)

        return;



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

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

        if(FRAME_MBAFF)

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

            fill_colmap(VAR_0, VAR_0->map_col_to_list0_field[VAR_3], VAR_1, VAR_3, VAR_3, 1);

    }

}

void FUNC_0(H264Context * const VAR_0){ MpegEncContext * const s = &VAR_0->s; Picture * const ref1 = &VAR_0->ref_list[1][0]; Picture * const cur = s->current_picture_ptr; int VAR_1, VAR_2, VAR_3; int VAR_4= (s->picture_structure&1)^1; int VAR_5 = (ref1->f.reference&1)^1; for(VAR_1=0; VAR_1<2; VAR_1++){ cur->ref_count[VAR_4][VAR_1] = VAR_0->ref_count[VAR_1]; for(VAR_2=0; VAR_2<VAR_0->ref_count[VAR_1]; VAR_2++) cur->ref_poc[VAR_4][VAR_1][VAR_2] = 4 * VAR_0->ref_list[VAR_1][VAR_2].frame_num + (VAR_0->ref_list[VAR_1][VAR_2].f.reference & 3); } if(s->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->col_fieldoff= 0; if(s->picture_structure == PICT_FRAME){ int VAR_6 = s->current_picture_ptr->poc; int *VAR_7 = VAR_0->ref_list[1]->field_poc; VAR_0->col_parity= (FFABS(VAR_7[0] - VAR_6) >= FFABS(VAR_7[1] - VAR_6)); VAR_5=VAR_4= VAR_0->col_parity; } else if (!(s->picture_structure & VAR_0->ref_list[1][0].f.reference) && !VAR_0->ref_list[1][0].mbaff) { VAR_0->col_fieldoff = 2 * VAR_0->ref_list[1][0].f.reference - 3; } if (cur->f.pict_type != AV_PICTURE_TYPE_B || VAR_0->direct_spatial_mv_pred)
return; for(VAR_1=0; VAR_1<2; VAR_1++){ fill_colmap(VAR_0, VAR_0->map_col_to_list0, VAR_1, VAR_4, VAR_5, 0); if(FRAME_MBAFF)
for(VAR_3=0; VAR_3<2; VAR_3++) fill_colmap(VAR_0, VAR_0->map_col_to_list0_field[VAR_3], VAR_1, VAR_3, VAR_3, 1); } }