comparison mpeg12.c @ 1841:05017f3b87d9 libavcodec

mpeg2 field pic decoding fix simplifiations
author michael
date Sat, 28 Feb 2004 21:02:49 +0000
parents a4d9e8b4e2f8
children c72589baee53
comparison
equal deleted inserted replaced
1840:0287241a0c18 1841:05017f3b87d9
1026 1026
1027 /* skip mb */ 1027 /* skip mb */
1028 s->mb_intra = 0; 1028 s->mb_intra = 0;
1029 for(i=0;i<6;i++) 1029 for(i=0;i<6;i++)
1030 s->block_last_index[i] = -1; 1030 s->block_last_index[i] = -1;
1031 s->mv_type = MV_TYPE_16X16; 1031 if(s->picture_structure == PICT_FRAME)
1032 s->mv_type = MV_TYPE_16X16;
1033 else
1034 s->mv_type = MV_TYPE_FIELD;
1032 if (s->pict_type == P_TYPE) { 1035 if (s->pict_type == P_TYPE) {
1033 /* if P type, zero motion vector is implied */ 1036 /* if P type, zero motion vector is implied */
1034 s->mv_dir = MV_DIR_FORWARD; 1037 s->mv_dir = MV_DIR_FORWARD;
1035 s->mv[0][0][0] = s->mv[0][0][1] = 0; 1038 s->mv[0][0][0] = s->mv[0][0][1] = 0;
1036 s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; 1039 s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
1037 s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; 1040 s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
1041 s->field_select[0][0]= s->picture_structure - 1;
1038 s->mb_skiped = 1; 1042 s->mb_skiped = 1;
1039 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; 1043 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
1040 } else { 1044 } else {
1041 /* if B type, reuse previous vectors and directions */ 1045 /* if B type, reuse previous vectors and directions */
1042 s->mv[0][0][0] = s->last_mv[0][0][0]; 1046 s->mv[0][0][0] = s->last_mv[0][0][0];
1144 1148
1145 if (IS_QUANT(mb_type)) 1149 if (IS_QUANT(mb_type))
1146 s->qscale = get_qscale(s); 1150 s->qscale = get_qscale(s);
1147 1151
1148 s->mv_dir = MV_DIR_FORWARD; 1152 s->mv_dir = MV_DIR_FORWARD;
1149 s->mv_type = MV_TYPE_16X16; 1153 if(s->picture_structure == PICT_FRAME)
1154 s->mv_type = MV_TYPE_16X16;
1155 else{
1156 s->mv_type = MV_TYPE_FIELD;
1157 mb_type |= MB_TYPE_INTERLACED;
1158 s->field_select[0][0]= s->picture_structure - 1;
1159 }
1150 s->last_mv[0][0][0] = 0; 1160 s->last_mv[0][0][0] = 0;
1151 s->last_mv[0][0][1] = 0; 1161 s->last_mv[0][0][1] = 0;
1152 s->last_mv[0][1][0] = 0; 1162 s->last_mv[0][1][0] = 0;
1153 s->last_mv[0][1][1] = 0; 1163 s->last_mv[0][1][1] = 0;
1154 s->mv[0][0][0] = 0; 1164 s->mv[0][0][0] = 0;
2163 return -1; 2173 return -1;
2164 2174
2165 if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs 2175 if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs
2166 const int wrap = field_pic ? 2*s->block_wrap[0] : s->block_wrap[0]; 2176 const int wrap = field_pic ? 2*s->block_wrap[0] : s->block_wrap[0];
2167 int xy = s->mb_x*2 + 1 + (s->mb_y*2 +1)*wrap; 2177 int xy = s->mb_x*2 + 1 + (s->mb_y*2 +1)*wrap;
2168 int motion_for_top_x, motion_for_top_y, motion_back_top_x, motion_back_top_y; 2178 int motion_x, motion_y, dir, i;
2169 int motion_for_bottom_x, motion_for_bottom_y, motion_back_bottom_x, motion_back_bottom_y;
2170 if(field_pic && !s->first_field) 2179 if(field_pic && !s->first_field)
2171 xy += wrap/2; 2180 xy += wrap/2;
2172 2181
2173 if (s->mb_intra) { 2182 for(dir=0; dir<2; dir++){
2174 motion_for_top_x = motion_for_top_y = motion_back_top_x = motion_back_top_y = 2183 for(i=0; i<2; i++){
2175 motion_for_bottom_x = motion_for_bottom_y = motion_back_bottom_x = motion_back_bottom_y = 0; 2184 if (s->mb_intra || (dir==1 && s->pict_type != B_TYPE)) {
2176 }else if (s->mv_type == MV_TYPE_16X16){ 2185 motion_x = motion_y = 0;
2177 motion_for_top_x = motion_for_bottom_x = s->mv[0][0][0]; 2186 }else if (s->mv_type == MV_TYPE_16X16){
2178 motion_for_top_y = motion_for_bottom_y = s->mv[0][0][1]; 2187 motion_x = s->mv[dir][0][0];
2179 motion_back_top_x = motion_back_bottom_x = s->mv[1][0][0]; 2188 motion_y = s->mv[dir][0][1];
2180 motion_back_top_y = motion_back_bottom_y = s->mv[1][0][1]; 2189 } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ {
2181 } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ { 2190 motion_x = s->mv[dir][i][0];
2182 motion_for_top_x = s->mv[0][0][0]; 2191 motion_y = s->mv[dir][i][1];
2183 motion_for_top_y = s->mv[0][0][1]; 2192 }
2184 motion_for_bottom_x = s->mv[0][1][0]; 2193
2185 motion_for_bottom_y = s->mv[0][1][1]; 2194 s->current_picture.motion_val[dir][xy ][0] = motion_x;
2186 motion_back_top_x = s->mv[1][0][0]; 2195 s->current_picture.motion_val[dir][xy ][1] = motion_y;
2187 motion_back_top_y = s->mv[1][0][1]; 2196 s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
2188 motion_back_bottom_x = s->mv[1][1][0]; 2197 s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
2189 motion_back_bottom_y = s->mv[1][1][1]; 2198 xy += wrap;
2190 } 2199 }
2191 2200 }
2192 s->current_picture.motion_val[0][xy][0] = motion_for_top_x;
2193 s->current_picture.motion_val[0][xy][1] = motion_for_top_y;
2194 s->current_picture.motion_val[0][xy + 1][0] = motion_for_top_x;
2195 s->current_picture.motion_val[0][xy + 1][1] = motion_for_top_y;
2196 s->current_picture.motion_val[0][xy + wrap][0] = motion_for_bottom_x;
2197 s->current_picture.motion_val[0][xy + wrap][1] = motion_for_bottom_y;
2198 s->current_picture.motion_val[0][xy + 1 + wrap][0] = motion_for_bottom_x;
2199 s->current_picture.motion_val[0][xy + 1 + wrap][1] = motion_for_bottom_y;
2200
2201 if(s->pict_type != B_TYPE){
2202 motion_back_top_x = motion_back_top_y = motion_back_bottom_x = motion_back_bottom_y = 0;
2203 }
2204
2205 s->current_picture.motion_val[1][xy][0] = motion_back_top_x;
2206 s->current_picture.motion_val[1][xy][1] = motion_back_top_y;
2207 s->current_picture.motion_val[1][xy + 1][0] = motion_back_top_x;
2208 s->current_picture.motion_val[1][xy + 1][1] = motion_back_top_y;
2209 s->current_picture.motion_val[1][xy + wrap][0] = motion_back_bottom_x;
2210 s->current_picture.motion_val[1][xy + wrap][1] = motion_back_bottom_y;
2211 s->current_picture.motion_val[1][xy + 1 + wrap][0] = motion_back_bottom_x;
2212 s->current_picture.motion_val[1][xy + 1 + wrap][1] = motion_back_bottom_y;
2213 } 2201 }
2214 2202
2215 s->dest[0] += 16; 2203 s->dest[0] += 16;
2216 s->dest[1] += 8; 2204 s->dest[1] += 8;
2217 s->dest[2] += 8; 2205 s->dest[2] += 8;