comparison h264_direct.c @ 11093:788db3371366 libavcodec

Precalculate a few variables for direct mv prediction for interlaced MBs.
author michael
date Sun, 07 Feb 2010 21:09:09 +0000
parents 64c36264b13f
children 323491bb995c
comparison
equal deleted inserted replaced
11092:64c36264b13f 11093:788db3371366
118 memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0])); 118 memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0]));
119 } 119 }
120 120
121 cur->mbaff= FRAME_MBAFF; 121 cur->mbaff= FRAME_MBAFF;
122 122
123 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred) 123 h->col_fieldoff= 0;
124 return;
125
126 if(s->picture_structure == PICT_FRAME){ 124 if(s->picture_structure == PICT_FRAME){
127 int cur_poc = s->current_picture_ptr->poc; 125 int cur_poc = s->current_picture_ptr->poc;
128 int *col_poc = h->ref_list[1]->field_poc; 126 int *col_poc = h->ref_list[1]->field_poc;
129 ref1sidx=sidx= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc)); 127 h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc));
130 } 128 ref1sidx=sidx= h->col_parity;
129 }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){ // FL -> FL & differ parity
130 h->col_fieldoff= s->mb_stride*(2*(h->ref_list[1][0].reference) - 3);
131 }
132
133 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred)
134 return;
131 135
132 for(list=0; list<2; list++){ 136 for(list=0; list<2; list++){
133 fill_colmap(h, h->map_col_to_list0, list, sidx, ref1sidx, 0); 137 fill_colmap(h, h->map_col_to_list0, list, sidx, ref1sidx, 0);
134 if(FRAME_MBAFF) 138 if(FRAME_MBAFF)
135 for(field=0; field<2; field++) 139 for(field=0; field<2; field++)
153 157
154 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM) 158 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
155 159
156 if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL 160 if(IS_INTERLACED(h->ref_list[1][0].mb_type[mb_xy])){ // AFL/AFR/FR/FL -> AFL/FL
157 if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL 161 if(!IS_INTERLACED(*mb_type)){ // AFR/FR -> AFL/FL
158 int cur_poc = s->current_picture_ptr->poc; 162 mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
159 int *col_poc = h->ref_list[1]->field_poc;
160 int col_parity = FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc);
161 mb_xy= s->mb_x + ((s->mb_y&~1) + col_parity)*s->mb_stride;
162 b8_stride = 0; 163 b8_stride = 0;
163 }else if(!(s->picture_structure & h->ref_list[1][0].reference) && !h->ref_list[1][0].mbaff){// FL -> FL & differ parity 164 }else{
164 int fieldoff= 2*(h->ref_list[1][0].reference)-3; 165 mb_xy += h->col_fieldoff; // non zero for FL -> FL & differ parity
165 mb_xy += s->mb_stride*fieldoff;
166 } 166 }
167 goto single_col; 167 goto single_col;
168 }else{ // AFL/AFR/FR/FL -> AFR/FR 168 }else{ // AFL/AFR/FR/FL -> AFR/FR
169 if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR 169 if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR
170 mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride; 170 mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;