44 #define P_TOPRIGHT P[3]
49 int *mx_ptr,
int *my_ptr,
int dmin,
50 int src_index,
int ref_index,
77 #define FLAG_QPEL 1 //must be 1
89 c->
src[0][i]= src [i] + offset[i];
90 c->
ref[0][i]= ref [i] + offset[i];
94 c->
ref[ref_index][i]= ref2[i] + offset[i];
106 const int size,
const int h,
int ref_index,
int src_index,
110 const int hx= subx + (x<<(1+qpel));
111 const int hy= suby + (y<<(1+qpel));
112 uint8_t *
const *
const ref= c->
ref[ref_index];
113 uint8_t *
const *
const src= c->
src[src_index];
116 av_assert2(x >= c->
xmin && hx <= c->xmax<<(qpel+1) && y >= c->
ymin && hy <= c->ymax<<(qpel+1));
117 if(x >= c->
xmin && hx <= c->xmax<<(qpel+1) && y >= c->
ymin && hy <= c->ymax<<(qpel+1)){
120 const int mask= 2*qpel+1;
128 int fxy= (fx&
mask) + ((fy&mask)<<(qpel+1));
129 int bxy= (bx&
mask) + ((by&mask)<<(qpel+1));
145 int fxy= (fx&
mask) + ((fy&mask)<<(qpel+1));
146 int bxy= (bx&
mask) + ((by&mask)<<(qpel+1));
171 d = cmp_func(s, c->
temp, src[0], stride, 16);
178 const int size,
const int h,
int ref_index,
int src_index,
183 const int dxy= subx + (suby<<(1+qpel));
184 const int hx= subx + (x<<(1+qpel));
185 const int hy= suby + (y<<(1+qpel));
186 uint8_t *
const *
const ref= c->
ref[ref_index];
187 uint8_t *
const *
const src= c->
src[src_index];
199 uvdxy= (cx&1) + 2*(cy&1);
205 uvdxy= dxy | (x&1) | (2*(y&1));
207 d = cmp_func(s, c->
temp, src[0], stride, h);
209 d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h);
211 uvdxy= (x&1) + 2*(y&1);
215 c->
hpel_put[size+1][uvdxy](uvtemp , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
216 c->
hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
217 d += chroma_cmp_func(s, uvtemp , src[1], uvstride, h>>1);
218 d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);
224 int ref_index,
int src_index,
226 return cmp_inline(s,x,y,0,0,0,16,ref_index,src_index, cmp_func, chroma_cmp_func, 0, 0);
230 const int size,
const int h,
int ref_index,
int src_index,
233 return cmp_direct_inline(s,x,y,0,0,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&
FLAG_QPEL);
235 return cmp_inline(s,x,y,0,0,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0, flags&
FLAG_CHROMA);
240 const int size,
const int h,
int ref_index,
int src_index,
243 return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&
FLAG_QPEL);
245 return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&
FLAG_QPEL, flags&
FLAG_CHROMA);
253 const int size,
const int h,
int ref_index,
int src_index,
257 && flags==0 && h==16 && size==0 && subx==0 && suby==0){
258 return cmp_simple(s,x,y,ref_index,src_index, cmp_func, chroma_cmp_func);
260 && subx==0 && suby==0){
261 return cmp_fpel_internal(s,x,y,size,h,ref_index,src_index, cmp_func, chroma_cmp_func,flags);
263 return cmp_internal(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags);
268 const int size,
const int h,
int ref_index,
int src_index,
271 return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0);
273 return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0, flags&
FLAG_CHROMA);
278 const int size,
const int h,
int ref_index,
int src_index,
281 return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 1);
283 return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 1, flags&
FLAG_CHROMA);
307 av_log(s->
avctx,
AV_LOG_ERROR,
"me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see dia_size\n");
313 if(cache_size < 2*dia_size && !c->
stride){
375 #define CHECK_SAD_HALF_MV(suffix, x, y) \
377 d= s->dsp.pix_abs[size][(x?1:0)+(y?2:0)](NULL, pix, ptr+((x)>>1), stride, h);\
378 d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
379 COPY3_IF_LT(dminh, d, dx, x, dy, y)\
383 int *mx_ptr,
int *my_ptr,
int dmin,
384 int src_index,
int ref_index,
403 pix = c->
src[src_index][0];
407 ptr = c->
ref[ref_index][0] + (my *
stride) + mx;
411 if (mx > xmin && mx < xmax &&
412 my > ymin && my < ymax) {
417 const int l= score_map[(index- 1 )&(
ME_MAP_SIZE-1)];
530 c->
xmin = (x > 15) ? - 15 : 0;
531 c->
ymin = (y > 15) ? - 15 : 0;
551 c->
ref[1][0] = c->
ref[0][0] + 8;
553 c->
ref[3][0] = c->
ref[2][0] + 8;
554 c->
src[1][0] = c->
src[0][0] + 8;
556 c->
src[3][0] = c->
src[2][0] + 8;
566 int dmin_sum=0, mx4_sum=0, my4_sum=0, i;
574 for(block=0; block<4; block++){
576 int pred_x4, pred_y4;
578 static const int off[4]= {2, 1, 1, -1};
617 if(P[i][1] > (c->
ymax<<shift)) P[i][1]= (c->
ymax<<shift);
630 dxy = ((my4 & 3) << 2) | (mx4 & 3);
638 dxy = ((my4 & 1) << 1) | (mx4 & 1);
645 dmin_sum+= (mv_penalty[mx4-pred_x4] + mv_penalty[my4-pred_y4])*c->
mb_penalty_factor;
660 if(mx4 != mx || my4 != my) same=0;
677 dxy = ((my & 1) << 1) | (mx & 1);
720 int16_t (*mv_tables[2][2])[2],
uint8_t *field_select_tables[2],
int mx,
int my,
int user_field_select)
732 const int xy= s->
mb_x + s->
mb_y*mot_stride;
740 for(block=0; block<2; block++){
742 int best_dmin= INT_MAX;
745 for(field_select=0; field_select<2; field_select++){
746 int dmin, mx_i, my_i;
747 int16_t (*mv_table)[2]= mv_tables[
block][field_select];
749 if(user_field_select){
750 av_assert1(field_select==0 || field_select==1);
751 av_assert1(field_select_tables[block][xy]==0 || field_select_tables[block][xy]==1);
752 if(field_select_tables[block][xy] != field_select)
756 P_LEFT[0] = mv_table[xy - 1][0];
757 P_LEFT[1] = mv_table[xy - 1][1];
764 P_TOP[0] = mv_table[xy - mot_stride][0];
765 P_TOP[1] = mv_table[xy - mot_stride][1];
766 P_TOPRIGHT[0] = mv_table[xy - mot_stride + 1][0];
767 P_TOPRIGHT[1] = mv_table[xy - mot_stride + 1][1];
779 dmin =
epzs_motion_search2(s, &mx_i, &my_i, P, block, field_select+ref_index, mv_table, (1<<16)>>1);
781 dmin= c->
sub_motion_search(s, &mx_i, &my_i, dmin, block, field_select+ref_index, size, h);
783 mv_table[xy][0]= mx_i;
784 mv_table[xy][1]= my_i;
790 uint8_t *ref= c->
ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*
stride;
791 dxy = ((my_i & 1) << 1) | (mx_i & 1);
803 dmin += field_select !=
block;
805 if(dmin < best_dmin){
807 best_field= field_select;
811 int16_t (*mv_table)[2]= mv_tables[
block][best_field];
813 if(mv_table[xy][0] != mx) same=0;
814 if(mv_table[xy][1]&1) same=0;
815 if(mv_table[xy][1]*2 != my) same=0;
816 if(best_field != block) same=0;
819 field_select_tables[
block][xy]= best_field;
820 dmin_sum += best_dmin;
842 int ymax= s->
me.
ymax>>interlaced;
843 int ymin= s->
me.
ymin>>interlaced;
847 if(mv[1] < ymin) mv[1] = ymin;
848 if(mv[1] > ymax) mv[1] = ymax;
889 int field_select0= p->
f.
ref_index[0][4*mb_xy ];
890 int field_select1= p->
f.
ref_index[0][4*mb_xy+2];
891 av_assert0(field_select0==0 ||field_select0==1);
892 av_assert0(field_select1==0 ||field_select1==1);
911 d =
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags);
914 d+=
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags);
917 int field_select0 = p->
f.
ref_index[1][4 * mb_xy ];
918 int field_select1 = p->
f.
ref_index[1][4 * mb_xy + 2];
919 av_assert0(field_select0==0 ||field_select0==1);
920 av_assert0(field_select1==0 ||field_select1==1);
935 d =
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags);
938 d+=
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags);
943 }
else if(
IS_8X8(mb_type)){
949 chroma_cmpf= s->
dsp.
sse[1];
955 d+=
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags);
973 d =
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags);
980 d =
cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags);
992 int sum, mx, my, dmin;
1120 if (vard*2 + 200*256 > varc)
1122 if (varc*2 + 200*256 > vard || s->
qscale > 24){
1134 && !c->
skip && varc>50<<8 && vard>10<<8){
1155 && !c->
skip && varc>50<<8 && vard>10<<8){
1176 intra_score= varc - 500;
1178 unsigned mean = (sum+128)>>8;
1181 for(i=0; i<16; i++){
1192 if(intra_score < dmin){
1262 int mb_x,
int mb_y, int16_t (*mv_table)[2],
int ref_index,
int f_code)
1269 const int mot_xy = mb_y*mot_stride + mb_x;
1289 P_LEFT[0] = mv_table[mot_xy - 1][0];
1290 P_LEFT[1] = mv_table[mot_xy - 1][1];
1296 P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
1297 P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
1298 P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1][0];
1299 P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1][1];
1327 mv_table[mot_xy][0]= mx;
1328 mv_table[mot_xy][1]= my;
1334 int motion_fx,
int motion_fy,
1335 int motion_bx,
int motion_by,
1336 int pred_fx,
int pred_fy,
1337 int pred_bx,
int pred_by,
1357 dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
1358 src_x = motion_fx >> 2;
1359 src_y = motion_fy >> 2;
1361 ptr = ref_data[0] + (src_y *
stride) + src_x;
1364 dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
1365 src_x = motion_bx >> 2;
1366 src_y = motion_by >> 2;
1368 ptr = ref2_data[0] + (src_y *
stride) + src_x;
1371 dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
1372 src_x = motion_fx >> 1;
1373 src_y = motion_fy >> 1;
1375 ptr = ref_data[0] + (src_y *
stride) + src_x;
1378 dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
1379 src_x = motion_bx >> 1;
1380 src_y = motion_by >> 1;
1382 ptr = ref2_data[0] + (src_y *
stride) + src_x;
1386 fbmin = (mv_penalty_f[motion_fx-pred_fx] + mv_penalty_f[motion_fy-pred_fy])*c->
mb_penalty_factor
1387 +(mv_penalty_b[motion_bx-pred_bx] + mv_penalty_b[motion_by-pred_by])*c->
mb_penalty_factor
1402 const int xy = mb_y *mot_stride + mb_x;
1414 const int shift= 1+qpel;
1419 #define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by))
1420 #define HASH8(fx,fy,bx,by) ((uint8_t)HASH(fx,fy,bx,by))
1421 int hashidx=
HASH(motion_fx,motion_fy, motion_bx, motion_by);
1424 map[hashidx&255] = 1;
1427 motion_bx, motion_by,
1434 static const uint8_t limittab[5]={0,8,32,64,80};
1436 static const int8_t vect[][4]={
1437 { 0, 0, 0, 1}, { 0, 0, 0,-1}, { 0, 0, 1, 0}, { 0, 0,-1, 0}, { 0, 1, 0, 0}, { 0,-1, 0, 0}, { 1, 0, 0, 0}, {-1, 0, 0, 0},
1439 { 0, 0, 1, 1}, { 0, 0,-1,-1}, { 0, 1, 1, 0}, { 0,-1,-1, 0}, { 1, 1, 0, 0}, {-1,-1, 0, 0}, { 1, 0, 0, 1}, {-1, 0, 0,-1},
1440 { 0, 1, 0, 1}, { 0,-1, 0,-1}, { 1, 0, 1, 0}, {-1, 0,-1, 0},
1441 { 0, 0,-1, 1}, { 0, 0, 1,-1}, { 0,-1, 1, 0}, { 0, 1,-1, 0}, {-1, 1, 0, 0}, { 1,-1, 0, 0}, { 1, 0, 0,-1}, {-1, 0, 0, 1},
1442 { 0,-1, 0, 1}, { 0, 1, 0,-1}, {-1, 0, 1, 0}, { 1, 0,-1, 0},
1444 { 0, 1, 1, 1}, { 0,-1,-1,-1}, { 1, 1, 1, 0}, {-1,-1,-1, 0}, { 1, 1, 0, 1}, {-1,-1, 0,-1}, { 1, 0, 1, 1}, {-1, 0,-1,-1},
1445 { 0,-1, 1, 1}, { 0, 1,-1,-1}, {-1, 1, 1, 0}, { 1,-1,-1, 0}, { 1, 1, 0,-1}, {-1,-1, 0, 1}, { 1, 0,-1, 1}, {-1, 0, 1,-1},
1446 { 0, 1,-1, 1}, { 0,-1, 1,-1}, { 1,-1, 1, 0}, {-1, 1,-1, 0}, {-1, 1, 0, 1}, { 1,-1, 0,-1}, { 1, 0, 1,-1}, {-1, 0,-1, 1},
1447 { 0, 1, 1,-1}, { 0,-1,-1, 1}, { 1, 1,-1, 0}, {-1,-1, 1, 0}, { 1,-1, 0, 1}, {-1, 1, 0,-1}, {-1, 0, 1, 1}, { 1, 0,-1,-1},
1449 { 1, 1, 1, 1}, {-1,-1,-1,-1},
1450 { 1, 1, 1,-1}, {-1,-1,-1, 1}, { 1, 1,-1, 1}, {-1,-1, 1,-1}, { 1,-1, 1, 1}, {-1, 1,-1,-1}, {-1, 1, 1, 1}, { 1,-1,-1,-1},
1451 { 1, 1,-1,-1}, {-1,-1, 1, 1}, { 1,-1,-1, 1}, {-1, 1, 1,-1}, { 1,-1, 1,-1}, {-1, 1,-1, 1},
1454 HASH8( 0, 0, 0, 1),
HASH8( 0, 0, 0,-1),
HASH8( 0, 0, 1, 0),
HASH8( 0, 0,-1, 0),
HASH8( 0, 1, 0, 0),
HASH8( 0,-1, 0, 0),
HASH8( 1, 0, 0, 0),
HASH8(-1, 0, 0, 0),
1456 HASH8( 0, 0, 1, 1),
HASH8( 0, 0,-1,-1),
HASH8( 0, 1, 1, 0),
HASH8( 0,-1,-1, 0),
HASH8( 1, 1, 0, 0),
HASH8(-1,-1, 0, 0),
HASH8( 1, 0, 0, 1),
HASH8(-1, 0, 0,-1),
1457 HASH8( 0, 1, 0, 1),
HASH8( 0,-1, 0,-1),
HASH8( 1, 0, 1, 0),
HASH8(-1, 0,-1, 0),
1458 HASH8( 0, 0,-1, 1),
HASH8( 0, 0, 1,-1),
HASH8( 0,-1, 1, 0),
HASH8( 0, 1,-1, 0),
HASH8(-1, 1, 0, 0),
HASH8( 1,-1, 0, 0),
HASH8( 1, 0, 0,-1),
HASH8(-1, 0, 0, 1),
1459 HASH8( 0,-1, 0, 1),
HASH8( 0, 1, 0,-1),
HASH8(-1, 0, 1, 0),
HASH8( 1, 0,-1, 0),
1461 HASH8( 0, 1, 1, 1),
HASH8( 0,-1,-1,-1),
HASH8( 1, 1, 1, 0),
HASH8(-1,-1,-1, 0),
HASH8( 1, 1, 0, 1),
HASH8(-1,-1, 0,-1),
HASH8( 1, 0, 1, 1),
HASH8(-1, 0,-1,-1),
1462 HASH8( 0,-1, 1, 1),
HASH8( 0, 1,-1,-1),
HASH8(-1, 1, 1, 0),
HASH8( 1,-1,-1, 0),
HASH8( 1, 1, 0,-1),
HASH8(-1,-1, 0, 1),
HASH8( 1, 0,-1, 1),
HASH8(-1, 0, 1,-1),
1463 HASH8( 0, 1,-1, 1),
HASH8( 0,-1, 1,-1),
HASH8( 1,-1, 1, 0),
HASH8(-1, 1,-1, 0),
HASH8(-1, 1, 0, 1),
HASH8( 1,-1, 0,-1),
HASH8( 1, 0, 1,-1),
HASH8(-1, 0,-1, 1),
1464 HASH8( 0, 1, 1,-1),
HASH8( 0,-1,-1, 1),
HASH8( 1, 1,-1, 0),
HASH8(-1,-1, 1, 0),
HASH8( 1,-1, 0, 1),
HASH8(-1, 1, 0,-1),
HASH8(-1, 0, 1, 1),
HASH8( 1, 0,-1,-1),
1467 HASH8( 1, 1, 1,-1),
HASH8(-1,-1,-1, 1),
HASH8( 1, 1,-1, 1),
HASH8(-1,-1, 1,-1),
HASH8( 1,-1, 1, 1),
HASH8(-1, 1,-1,-1),
HASH8(-1, 1, 1, 1),
HASH8( 1,-1,-1,-1),
1468 HASH8( 1, 1,-1,-1),
HASH8(-1,-1, 1, 1),
HASH8( 1,-1,-1, 1),
HASH8(-1, 1, 1,-1),
HASH8( 1,-1, 1,-1),
HASH8(-1, 1,-1, 1),
1471 #define CHECK_BIDIR(fx,fy,bx,by)\
1472 if( !map[(hashidx+HASH(fx,fy,bx,by))&255]\
1473 &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
1474 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
1476 map[(hashidx+HASH(fx,fy,bx,by))&255] = 1;\
1477 score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\
1479 hashidx += HASH(fx,fy,bx,by);\
1488 #define CHECK_BIDIR2(a,b,c,d)\
1489 CHECK_BIDIR(a,b,c,d)\
1490 CHECK_BIDIR(-(a),-(b),-(c),-(d))
1502 for(i=8; i<limit; i++){
1503 int fx= motion_fx+vect[i][0];
1504 int fy= motion_fy+vect[i][1];
1505 int bx= motion_bx+vect[i][2];
1506 int by= motion_by+vect[i][3];
1508 int a= (xmax -
FFMAX(fx,bx))|(
FFMIN(fx,bx) - xmin);
1509 int b= (ymax -
FFMAX(fy,by))|(
FFMIN(fy,by) - ymin);
1511 map[(hashidx+hash[i])&255] = 1;
1513 if(!map[(hashidx+hash[i])&255]){
1515 map[(hashidx+hash[i])&255] = 1;
1516 score=
check_bidir_mv(s, fx, fy, bx, by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);
1529 borderdist=
FFMIN(a,b);
1550 const int mot_xy = mb_y*mot_stride + mb_x;
1553 const int time_pp= s->
pp_time;
1554 const int time_pb= s->
pb_time;
1555 int mx, my, xmin, xmax, ymin, ymax;
1559 ymin= xmin=(-32)>>shift;
1560 ymax= xmax= 31>>
shift;
1584 xmin=
FFMAX(xmin, - 16 - min);
1591 ymin=
FFMAX(ymin, - 16 - min);
1596 av_assert2(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);
1598 if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){
1602 return 256*256*256*64;
1614 P_LEFT[0] = av_clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
1615 P_LEFT[1] = av_clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
1619 P_TOP[0] = av_clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift);
1620 P_TOP[1] = av_clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift);
1621 P_TOPRIGHT[0] = av_clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift);
1622 P_TOPRIGHT[1] = av_clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift);
1639 mv_table[mot_xy][0]= mx;
1640 mv_table[mot_xy][1]= my;
1652 int fmin, bmin, dmin, fbmin, bimin, fimin;
1654 const int xy = mb_y*s->
mb_stride + mb_x;
1665 score= ((unsigned)(score*score + 128*256))>>16;
1738 av_dlog(s,
"%d %d %d %d\n", dmin, fmin, bmin, fbmin);
1752 fimin= bimin= INT_MAX;
1779 score= ((unsigned)(score*score + 128*256))>>16;
1790 if(fimin < INT_MAX && bimin < INT_MAX){
1810 int best_score=-10000000;
1813 range=
FFMIN(range, 16);
1815 range=
FFMIN(range, 256);
1817 for(i=0; i<8; i++) score[i]= s->
mb_num*(8-i);
1824 int mx= mv_table[xy][0];
1825 int my= mv_table[xy][1];
1830 if(mx >= range || mx < -range ||
1831 my >= range || my < -range)
1834 for(j=0; j<fcode && j<8; j++){
1844 if(score[i] > best_score){
1845 best_score= score[i];
1859 const int f_code= s->
f_code;
1865 av_assert0(range <= 16 || !s->msmpeg4_version);
1882 for(block=0; block<4; block++){
1883 int off= (block& 1) + (block>>1)*
wrap;
1887 if( mx >=range || mx <-range
1888 || my >=range || my <-range){
1889 s->
mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V;
1907 int16_t (*mv_table)[2],
int f_code,
int type,
int truncate)
1910 int y, h_range, v_range;
1918 v_range= field_select_table ? range>>1 : range;
1926 if(field_select_table==
NULL || field_select_table[xy] == field_select){
1927 if( mv_table[xy][0] >=h_range || mv_table[xy][0] <-h_range
1928 || mv_table[xy][1] >=v_range || mv_table[xy][1] <-v_range){
1931 if (mv_table[xy][0] > h_range-1) mv_table[xy][0]= h_range-1;
1932 else if(mv_table[xy][0] < -h_range ) mv_table[xy][0]= -h_range;
1933 if (mv_table[xy][1] > v_range-1) mv_table[xy][1]= v_range-1;
1934 else if(mv_table[xy][1] < -v_range ) mv_table[xy][1]= -v_range;