40 int td = av_clip(poc1 - poc0, -128, 127);
44 int tb = av_clip(poc - poc0, -128, 127);
45 int tx = (16384 + (
FFABS(td) >> 1)) /
td;
46 return av_clip((tb*tx + 32) >> 6, -1024, 1023);
56 for (field = 0; field < 2; field++){
71 int j, old_ref, rfield;
72 int start= mbafi ? 16 : 0;
77 memset(map[list], 0,
sizeof(map[list]));
79 for(rfield=0; rfield<2; rfield++){
80 for(old_ref=0; old_ref<ref1->
ref_count[colfield][list]; old_ref++){
81 int poc = ref1->
ref_poc[colfield][list][old_ref];
85 else if( interl && (poc&3) == 3)
86 poc= (poc&~3) + rfield + 1;
88 for(j=start; j<
end; j++){
90 int cur_ref= mbafi ? (j-16)^field : j;
92 map[list][2 * old_ref + (rfield^field) + 16] = cur_ref;
93 if(rfield == field || !interl)
94 map[list][old_ref] = cur_ref;
109 for(list=0; list<2; list++){
135 for(list=0; list<2; list++){
138 for(field=0; field<2; field++)
147 int ref_height = 16*h->
mb_height >> ref_field_picture;
156 FFMIN(16 * mb_y >> ref_field_picture, ref_height - 1),
157 ref_field_picture && ref_field);
165 const int16_t (*l1mv0)[2], (*l1mv1)[2];
166 const int8_t *l1ref0, *l1ref1;
167 const int is_b8x8 =
IS_8X8(*mb_type);
178 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
182 for(list=0; list<2; list++){
191 ref[list] =
FFMIN3((
unsigned)left_ref, (
unsigned)top_ref, (
unsigned)refc);
197 int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]);
202 assert(match_count==1);
203 if(left_ref==ref[list]){
205 }
else if(top_ref==ref[list]){
221 if(ref[0] < 0 && ref[1] < 0){
228 if(!(is_b8x8|mv[0]|mv[1])){
262 && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
299 l1mv0 += 2*b4_stride;
300 l1mv1 += 2*b4_stride;
307 for(i8=0; i8<4; i8++){
310 int xy8 = x8+y8*b8_stride;
311 int xy4 = 3*x8+y8*b4_stride;
321 && ( (l1ref0[xy8] == 0 &&
FFABS(l1mv0[xy4][0]) <= 1 &&
FFABS(l1mv0[xy4][1]) <= 1)
322 || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 &&
FFABS(l1mv1[xy4][0]) <= 1 &&
FFABS(l1mv1[xy4][1]) <= 1))){
336 if(!is_b8x8 && !(n&3))
344 && ( (l1ref0[0] == 0 &&
FFABS(l1mv0[0][0]) <= 1 &&
FFABS(l1mv0[0][1]) <= 1)
345 || (l1ref0[0] < 0 && l1ref1[0] == 0 &&
FFABS(l1mv1[0][0]) <= 1 &&
FFABS(l1mv1[0][1]) <= 1
360 for(i8=0; i8<4; i8++){
362 const int y8 = i8>>1;
373 assert(b8_stride==2);
376 || (l1ref0[i8] < 0 && l1ref1[i8] == 0
378 const int16_t (*l1mv)[2]= l1ref0[i8] == 0 ? l1mv0 : l1mv1;
380 const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
381 if(
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1){
390 for(i4=0; i4<4; i4++){
391 const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
392 if(
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1){
406 if(!is_b8x8 && !(n&15))
416 const int16_t (*l1mv0)[2], (*l1mv1)[2];
417 const int8_t *l1ref0, *l1ref1;
418 const int is_b8x8 =
IS_8X8(*mb_type);
452 && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
489 l1mv0 += 2*b4_stride;
490 l1mv1 += 2*b4_stride;
504 ref_offset = (h->
ref_list[1][0].
mbaff<<4) & (mb_type_col[0]>>3);
510 for(i8=0; i8<4; i8++){
512 const int y8 = i8>>1;
514 const int16_t (*l1mv)[2]= l1mv0;
528 ref0 = l1ref0[x8 + y8*b8_stride];
530 ref0 = map_col_to_list0[0][ref0 + ref_offset];
532 ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
535 scale = dist_scale_factor[ref0];
539 const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride];
540 int my_col = (mv_col[1]<<y_shift)/2;
541 int mx = (scale * mv_col[0] + 128) >> 8;
542 int my = (scale * my_col + 128) >> 8;
559 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
560 : map_col_to_list0[1][l1ref1[0] + ref_offset];
561 const int scale = dist_scale_factor[ref0];
562 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
564 mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
565 mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
568 mv1=
pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
574 for(i8=0; i8<4; i8++){
576 const int y8 = i8>>1;
578 const int16_t (*l1mv)[2]= l1mv0;
591 assert(b8_stride == 2);
594 ref0 = map_col_to_list0[0][ref0 + ref_offset];
596 ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
599 scale = dist_scale_factor[ref0];
603 const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
604 int mx = (scale * mv_col[0] + 128) >> 8;
605 int my = (scale * mv_col[1] + 128) >> 8;
609 for(i4=0; i4<4; i4++){
610 const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
612 mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
613 mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
615 pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]));