Mercurial > libavcodec.hg
comparison h264.c @ 7902:8b8be8f2b647 libavcodec
Fix ref_shift so that it is correct for more/all? MBAFF/PAFF mixes.
Fixes at least MR9_BT_B.
author | michael |
---|---|
date | Mon, 22 Sep 2008 02:32:22 +0000 |
parents | a7d78c0657f1 |
children | 5be944626072 |
comparison
equal
deleted
inserted
replaced
7901:a7d78c0657f1 | 7902:8b8be8f2b647 |
---|---|
936 } | 936 } |
937 if(s->picture_structure == PICT_FRAME){ | 937 if(s->picture_structure == PICT_FRAME){ |
938 memcpy(cur->ref_count[0], cur->ref_count[1], sizeof(cur->ref_count[0])); | 938 memcpy(cur->ref_count[0], cur->ref_count[1], sizeof(cur->ref_count[0])); |
939 memcpy(cur->ref_poc [0], cur->ref_poc [1], sizeof(cur->ref_poc [0])); | 939 memcpy(cur->ref_poc [0], cur->ref_poc [1], sizeof(cur->ref_poc [0])); |
940 } | 940 } |
941 cur->mbaff= FRAME_MBAFF; | |
941 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred) | 942 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred) |
942 return; | 943 return; |
943 for(list=0; list<2; list++){ | 944 for(list=0; list<2; list++){ |
944 for(field=0; field<2; field++){ | 945 for(field=0; field<2; field++){ |
945 for(i=0; i<ref1->ref_count[field][list]; i++){ | 946 for(i=0; i<ref1->ref_count[field][list]; i++){ |
1177 } | 1178 } |
1178 } | 1179 } |
1179 }else{ /* direct temporal mv pred */ | 1180 }else{ /* direct temporal mv pred */ |
1180 const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]}; | 1181 const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]}; |
1181 const int *dist_scale_factor = h->dist_scale_factor; | 1182 const int *dist_scale_factor = h->dist_scale_factor; |
1183 int ref_shift= 1; | |
1182 | 1184 |
1183 if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){ | 1185 if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){ |
1184 map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0]; | 1186 map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0]; |
1185 map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1]; | 1187 map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1]; |
1186 dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1]; | 1188 dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1]; |
1187 } | 1189 ref_shift--; |
1190 } | |
1191 if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) | |
1192 ref_shift++; | |
1193 | |
1188 if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ | 1194 if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){ |
1189 /* FIXME assumes direct_8x8_inference == 1 */ | 1195 /* FIXME assumes direct_8x8_inference == 1 */ |
1190 int y_shift = 2*!IS_INTERLACED(*mb_type); | 1196 int y_shift = 2*!IS_INTERLACED(*mb_type); |
1191 int ref_shift= FRAME_MBAFF ? y_shift : 1; | |
1192 | 1197 |
1193 for(i8=0; i8<4; i8++){ | 1198 for(i8=0; i8<4; i8++){ |
1194 const int x8 = i8&1; | 1199 const int x8 = i8&1; |
1195 const int y8 = i8>>1; | 1200 const int y8 = i8>>1; |
1196 int ref0, scale; | 1201 int ref0, scale; |
1237 | 1242 |
1238 fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1); | 1243 fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1); |
1239 if(IS_INTRA(mb_type_col[0])){ | 1244 if(IS_INTRA(mb_type_col[0])){ |
1240 ref=mv0=mv1=0; | 1245 ref=mv0=mv1=0; |
1241 }else{ | 1246 }else{ |
1242 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0]] | 1247 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][(l1ref0[0]*2)>>ref_shift] |
1243 : map_col_to_list0[1][l1ref1[0]]; | 1248 : map_col_to_list0[1][(l1ref1[0]*2)>>ref_shift]; |
1244 const int scale = dist_scale_factor[ref0]; | 1249 const int scale = dist_scale_factor[ref0]; |
1245 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0]; | 1250 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0]; |
1246 int mv_l0[2]; | 1251 int mv_l0[2]; |
1247 mv_l0[0] = (scale * mv_col[0] + 128) >> 8; | 1252 mv_l0[0] = (scale * mv_col[0] + 128) >> 8; |
1248 mv_l0[1] = (scale * mv_col[1] + 128) >> 8; | 1253 mv_l0[1] = (scale * mv_col[1] + 128) >> 8; |
1269 fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); | 1274 fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4); |
1270 fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); | 1275 fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4); |
1271 continue; | 1276 continue; |
1272 } | 1277 } |
1273 | 1278 |
1274 ref0 = l1ref0[x8 + y8*b8_stride]; | 1279 ref0 = (l1ref0[x8 + y8*b8_stride]*2)>>ref_shift; |
1275 if(ref0 >= 0) | 1280 if(ref0 >= 0) |
1276 ref0 = map_col_to_list0[0][ref0]; | 1281 ref0 = map_col_to_list0[0][ref0]; |
1277 else{ | 1282 else{ |
1278 ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride]]; | 1283 ref0 = map_col_to_list0[1][(l1ref1[x8 + y8*b8_stride]*2)>>ref_shift]; |
1279 l1mv= l1mv1; | 1284 l1mv= l1mv1; |
1280 } | 1285 } |
1281 scale = dist_scale_factor[ref0]; | 1286 scale = dist_scale_factor[ref0]; |
1282 | 1287 |
1283 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1); | 1288 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1); |