44 #define P_TOPRIGHT P[3]
48 #define ME_MAP_SHIFT 3
49 #define ME_MAP_MV_BITS 11
52 int *mx_ptr,
int *my_ptr,
int dmin,
53 int src_index,
int ref_index,
80 #define FLAG_QPEL 1 //must be 1
92 c->
src[0][i]= src [i] + offset[i];
93 c->
ref[0][i]= ref [i] + offset[i];
97 c->
ref[ref_index][i]= ref2[i] + offset[i];
109 const int size,
const int h,
int ref_index,
int src_index,
113 const int hx= subx + (x<<(1+qpel));
114 const int hy= suby + (y<<(1+qpel));
115 uint8_t *
const *
const ref= c->
ref[ref_index];
119 av_assert2(x >= c->
xmin && hx <= c->xmax<<(qpel+1) && y >= c->
ymin && hy <= c->ymax<<(qpel+1));
120 if(x >= c->
xmin && hx <= c->xmax<<(qpel+1) && y >= c->
ymin && hy <= c->ymax<<(qpel+1)){
123 const int mask= 2*qpel+1;
131 int fxy= (fx&
mask) + ((fy&mask)<<(qpel+1));
132 int bxy= (bx&
mask) + ((by&mask)<<(qpel+1));
136 c->
qpel_put[1][fxy](dst, ref[0] + (fx>>2) + (fy>>2)*stride, stride);
137 c->
qpel_avg[1][bxy](dst, ref[8] + (bx>>2) + (by>>2)*stride, stride);
139 c->
hpel_put[1][fxy](dst, ref[0] + (fx>>1) + (fy>>1)*stride, stride, 8);
140 c->
hpel_avg[1][bxy](dst, ref[8] + (bx>>1) + (by>>1)*stride, stride, 8);
148 int fxy= (fx&
mask) + ((fy&mask)<<(qpel+1));
149 int bxy= (bx&
mask) + ((by&mask)<<(qpel+1));
152 c->
qpel_put[1][fxy](c->
temp , ref[0] + (fx>>2) + (fy>>2)*stride , stride);
153 c->
qpel_put[1][fxy](c->
temp + 8 , ref[0] + (fx>>2) + (fy>>2)*stride + 8 , stride);
154 c->
qpel_put[1][fxy](c->
temp + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8*stride, stride);
155 c->
qpel_put[1][fxy](c->
temp + 8 + 8*stride, ref[0] + (fx>>2) + (fy>>2)*stride + 8 + 8*stride, stride);
156 c->
qpel_avg[1][bxy](c->
temp , ref[8] + (bx>>2) + (by>>2)*stride , stride);
157 c->
qpel_avg[1][bxy](c->
temp + 8 , ref[8] + (bx>>2) + (by>>2)*stride + 8 , stride);
158 c->
qpel_avg[1][bxy](c->
temp + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8*stride, stride);
159 c->
qpel_avg[1][bxy](c->
temp + 8 + 8*stride, ref[8] + (bx>>2) + (by>>2)*stride + 8 + 8*stride, stride);
170 c->
hpel_put[0][fxy](c->
temp, ref[0] + (fx>>1) + (fy>>1)*stride, stride, 16);
171 c->
hpel_avg[0][bxy](c->
temp, ref[8] + (bx>>1) + (by>>1)*stride, stride, 16);
174 d = cmp_func(s, c->
temp, src[0], stride, 16);
181 const int size,
const int h,
int ref_index,
int src_index,
186 const int dxy= subx + (suby<<(1+qpel));
187 const int hx= subx + (x<<(1+qpel));
188 const int hy= suby + (y<<(1+qpel));
189 uint8_t *
const *
const ref= c->
ref[ref_index];
202 uvdxy= (cx&1) + 2*(cy&1);
208 uvdxy= dxy | (x&1) | (2*(y&1));
210 d = cmp_func(s, c->
temp, src[0], stride, h);
212 d = cmp_func(s, src[0], ref[0] + x + y*stride, stride, h);
214 uvdxy= (x&1) + 2*(y&1);
218 c->
hpel_put[size+1][uvdxy](uvtemp , ref[1] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
219 c->
hpel_put[size+1][uvdxy](uvtemp+8, ref[2] + (x>>1) + (y>>1)*uvstride, uvstride, h>>1);
220 d += chroma_cmp_func(s, uvtemp , src[1], uvstride, h>>1);
221 d += chroma_cmp_func(s, uvtemp+8, src[2], uvstride, h>>1);
227 int ref_index,
int src_index,
229 return cmp_inline(s,x,y,0,0,0,16,ref_index,src_index, cmp_func, chroma_cmp_func, 0, 0);
233 const int size,
const int h,
int ref_index,
int src_index,
236 return cmp_direct_inline(s,x,y,0,0,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&
FLAG_QPEL);
238 return cmp_inline(s,x,y,0,0,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0, flags&
FLAG_CHROMA);
243 const int size,
const int h,
int ref_index,
int src_index,
246 return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags&
FLAG_QPEL);
248 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);
256 const int size,
const int h,
int ref_index,
int src_index,
260 && flags==0 && h==16 && size==0 && subx==0 && suby==0){
261 return cmp_simple(s,x,y,ref_index,src_index, cmp_func, chroma_cmp_func);
263 && subx==0 && suby==0){
264 return cmp_fpel_internal(s,x,y,size,h,ref_index,src_index, cmp_func, chroma_cmp_func,flags);
266 return cmp_internal(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, flags);
271 const int size,
const int h,
int ref_index,
int src_index,
274 return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0);
276 return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 0, flags&
FLAG_CHROMA);
281 const int size,
const int h,
int ref_index,
int src_index,
284 return cmp_direct_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 1);
286 return cmp_inline(s,x,y,subx,suby,size,h,ref_index,src_index, cmp_func, chroma_cmp_func, 1, flags&
FLAG_CHROMA);
312 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");
318 if(cache_size < 2*dia_size && !c->
stride){
382 #define CHECK_SAD_HALF_MV(suffix, x, y) \
384 d = s->mecc.pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 1), stride, h); \
385 d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
386 COPY3_IF_LT(dminh, d, dx, x, dy, y)\
390 int *mx_ptr,
int *my_ptr,
int dmin,
391 int src_index,
int ref_index,
409 pix = c->
src[src_index][0];
413 ptr = c->
ref[ref_index][0] + (my * stride) + mx;
417 if (mx > xmin && mx < xmax &&
418 my > ymin && my < ymax) {
423 const int l= score_map[(index- 1 )&(
ME_MAP_SIZE-1)];
537 c->
xmin = (x > 15) ? - 15 : 0;
538 c->
ymin = (y > 15) ? - 15 : 0;
547 if(!range || range > max_range)
560 c->
ref[1][0] = c->
ref[0][0] + 8;
561 c->
ref[2][0] = c->
ref[0][0] + 8*stride;
562 c->
ref[3][0] = c->
ref[2][0] + 8;
563 c->
src[1][0] = c->
src[0][0] + 8;
564 c->
src[2][0] = c->
src[0][0] + 8*stride;
565 c->
src[3][0] = c->
src[2][0] + 8;
575 int dmin_sum=0, mx4_sum=0, my4_sum=0, i;
583 for(block=0; block<4; block++){
585 int pred_x4, pred_y4;
587 static const int off[4]= {2, 1, 1, -1};
630 if(P[i][1] > (c->
ymax<<shift)) P[i][1]= (c->
ymax<<shift);
639 const int offset= ((block&1) + (block>>1)*stride)*8;
643 dxy = ((my4 & 3) << 2) | (mx4 & 3);
651 dxy = ((my4 & 1) << 1) | (mx4 & 1);
658 dmin_sum+= (mv_penalty[mx4-pred_x4] + mv_penalty[my4-pred_y4])*c->
mb_penalty_factor;
673 if(mx4 != mx || my4 != my) same=0;
682 s->
mb_x * 16 + s->
mb_y * 16 * stride,
693 dxy = ((my & 1) << 1) | (mx & 1);
736 int16_t (*mv_tables[2][2])[2],
uint8_t *field_select_tables[2],
int mx,
int my,
int user_field_select)
748 const int xy= s->
mb_x + s->
mb_y*mot_stride;
756 for(block=0; block<2; block++){
758 int best_dmin= INT_MAX;
761 for(field_select=0; field_select<2; field_select++){
762 int dmin, mx_i, my_i;
763 int16_t (*mv_table)[2]= mv_tables[
block][field_select];
765 if(user_field_select){
766 av_assert1(field_select==0 || field_select==1);
767 av_assert1(field_select_tables[block][xy]==0 || field_select_tables[block][xy]==1);
768 if(field_select_tables[block][xy] != field_select)
772 P_LEFT[0] = mv_table[xy - 1][0];
773 P_LEFT[1] = mv_table[xy - 1][1];
780 P_TOP[0] = mv_table[xy - mot_stride][0];
781 P_TOP[1] = mv_table[xy - mot_stride][1];
782 P_TOPRIGHT[0] = mv_table[xy - mot_stride + 1][0];
783 P_TOPRIGHT[1] = mv_table[xy - mot_stride + 1][1];
795 dmin =
epzs_motion_search2(s, &mx_i, &my_i, P, block, field_select+ref_index, mv_table, (1<<16)>>1);
797 dmin= c->
sub_motion_search(s, &mx_i, &my_i, dmin, block, field_select+ref_index, size, h);
799 mv_table[xy][0]= mx_i;
800 mv_table[xy][1]= my_i;
806 uint8_t *ref= c->
ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
807 dxy = ((my_i & 1) << 1) | (mx_i & 1);
819 dmin += field_select !=
block;
821 if(dmin < best_dmin){
823 best_field= field_select;
827 int16_t (*mv_table)[2]= mv_tables[
block][best_field];
829 if(mv_table[xy][0] != mx) same=0;
830 if(mv_table[xy][1]&1) same=0;
831 if(mv_table[xy][1]*2 != my) same=0;
832 if(best_field != block) same=0;
835 field_select_tables[
block][xy]= best_field;
836 dmin_sum += best_dmin;
863 return (3*lambda)>>(FF_LAMBDA_SHIFT+1);
886 int sum, mx, my, dmin;
912 (((unsigned) sum * sum) >> 8) + 500;
999 if (vard*2 + 200*256 > varc)
1001 if (varc*2 + 200*256 > vard || s->
qscale > 24){
1013 && !c->
skip && varc>50<<8 && vard>10<<8){
1034 && !c->
skip && varc>50<<8 && vard>10<<8){
1054 intra_score= varc - 500;
1056 unsigned mean = (sum+128)>>8;
1059 for(i=0; i<16; i++){
1070 if(intra_score < dmin){
1140 int16_t (*mv_table)[2],
int ref_index,
int f_code)
1147 const int mot_xy = mb_y*mot_stride + mb_x;
1167 P_LEFT[0] = mv_table[mot_xy - 1][0];
1168 P_LEFT[1] = mv_table[mot_xy - 1][1];
1174 P_TOP[0] = mv_table[mot_xy - mot_stride ][0];
1175 P_TOP[1] = mv_table[mot_xy - mot_stride ][1];
1176 P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1][0];
1177 P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1][1];
1205 mv_table[mot_xy][0]= mx;
1206 mv_table[mot_xy][1]= my;
1212 int motion_fx,
int motion_fy,
1213 int motion_bx,
int motion_by,
1214 int pred_fx,
int pred_fy,
1215 int pred_bx,
int pred_by,
1235 dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
1236 src_x = motion_fx >> 2;
1237 src_y = motion_fy >> 2;
1239 ptr = ref_data[0] + (src_y * stride) + src_x;
1242 dxy = ((motion_by & 3) << 2) | (motion_bx & 3);
1243 src_x = motion_bx >> 2;
1244 src_y = motion_by >> 2;
1246 ptr = ref2_data[0] + (src_y * stride) + src_x;
1249 dxy = ((motion_fy & 1) << 1) | (motion_fx & 1);
1250 src_x = motion_fx >> 1;
1251 src_y = motion_fy >> 1;
1253 ptr = ref_data[0] + (src_y * stride) + src_x;
1256 dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
1257 src_x = motion_bx >> 1;
1258 src_y = motion_by >> 1;
1260 ptr = ref2_data[0] + (src_y * stride) + src_x;
1264 fbmin = (mv_penalty_f[motion_fx-pred_fx] + mv_penalty_f[motion_fy-pred_fy])*c->
mb_penalty_factor
1265 +(mv_penalty_b[motion_bx-pred_bx] + mv_penalty_b[motion_by-pred_by])*c->
mb_penalty_factor
1280 const int xy = mb_y *mot_stride + mb_x;
1292 const int shift= 1+qpel;
1297 #define HASH(fx,fy,bx,by) ((fx)+17*(fy)+63*(bx)+117*(by))
1298 #define HASH8(fx,fy,bx,by) ((uint8_t)HASH(fx,fy,bx,by))
1299 int hashidx=
HASH(motion_fx,motion_fy, motion_bx, motion_by);
1302 map[hashidx&255] = 1;
1305 motion_bx, motion_by,
1312 static const uint8_t limittab[5]={0,8,32,64,80};
1314 static const int8_t vect[][4]={
1315 { 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},
1317 { 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},
1318 { 0, 1, 0, 1}, { 0,-1, 0,-1}, { 1, 0, 1, 0}, {-1, 0,-1, 0},
1319 { 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},
1320 { 0,-1, 0, 1}, { 0, 1, 0,-1}, {-1, 0, 1, 0}, { 1, 0,-1, 0},
1322 { 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},
1323 { 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},
1324 { 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},
1325 { 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},
1327 { 1, 1, 1, 1}, {-1,-1,-1,-1},
1328 { 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},
1329 { 1, 1,-1,-1}, {-1,-1, 1, 1}, { 1,-1,-1, 1}, {-1, 1, 1,-1}, { 1,-1, 1,-1}, {-1, 1,-1, 1},
1332 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),
1334 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),
1335 HASH8( 0, 1, 0, 1),
HASH8( 0,-1, 0,-1),
HASH8( 1, 0, 1, 0),
HASH8(-1, 0,-1, 0),
1336 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),
1337 HASH8( 0,-1, 0, 1),
HASH8( 0, 1, 0,-1),
HASH8(-1, 0, 1, 0),
HASH8( 1, 0,-1, 0),
1339 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),
1340 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),
1341 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),
1342 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),
1345 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),
1346 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),
1349 #define CHECK_BIDIR(fx,fy,bx,by)\
1350 if( !map[(hashidx+HASH(fx,fy,bx,by))&255]\
1351 &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\
1352 &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\
1354 map[(hashidx+HASH(fx,fy,bx,by))&255] = 1;\
1355 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);\
1357 hashidx += HASH(fx,fy,bx,by);\
1366 #define CHECK_BIDIR2(a,b,c,d)\
1367 CHECK_BIDIR(a,b,c,d)\
1368 CHECK_BIDIR(-(a),-(b),-(c),-(d))
1380 for(i=8; i<limit; i++){
1381 int fx= motion_fx+vect[i][0];
1382 int fy= motion_fy+vect[i][1];
1383 int bx= motion_bx+vect[i][2];
1384 int by= motion_by+vect[i][3];
1386 int a= (xmax -
FFMAX(fx,bx))|(
FFMIN(fx,bx) - xmin);
1387 int b= (ymax -
FFMAX(fy,by))|(
FFMIN(fy,by) - ymin);
1389 map[(hashidx+hash[i])&255] = 1;
1391 if(!map[(hashidx+hash[i])&255]){
1393 map[(hashidx+hash[i])&255] = 1;
1394 score=
check_bidir_mv(s, fx, fy, bx, by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);
1407 borderdist=
FFMIN(a,b);
1428 const int mot_xy = mb_y*mot_stride + mb_x;
1431 const int time_pp= s->
pp_time;
1432 const int time_pb= s->
pb_time;
1433 int mx, my, xmin, xmax, ymin, ymax;
1437 ymin= xmin=(-32)>>shift;
1438 ymax= xmax= 31>>
shift;
1462 xmin=
FFMAX(xmin, - 16 - min);
1469 ymin=
FFMAX(ymin, - 16 - min);
1474 av_assert2(xmax <= 15 && ymax <= 15 && xmin >= -16 && ymin >= -16);
1476 if(xmax < 0 || xmin >0 || ymax < 0 || ymin > 0){
1480 return 256*256*256*64;
1492 P_LEFT[0] = av_clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
1493 P_LEFT[1] = av_clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
1497 P_TOP[0] = av_clip(mv_table[mot_xy - mot_stride ][0], xmin<<shift, xmax<<shift);
1498 P_TOP[1] = av_clip(mv_table[mot_xy - mot_stride ][1], ymin<<shift, ymax<<shift);
1499 P_TOPRIGHT[0] = av_clip(mv_table[mot_xy - mot_stride + 1 ][0], xmin<<shift, xmax<<shift);
1500 P_TOPRIGHT[1] = av_clip(mv_table[mot_xy - mot_stride + 1 ][1], ymin<<shift, ymax<<shift);
1517 mv_table[mot_xy][0]= mx;
1518 mv_table[mot_xy][1]= my;
1530 int fmin, bmin, dmin, fbmin, bimin, fimin;
1532 const int xy = mb_y*s->
mb_stride + mb_x;
1543 score= ((unsigned)(score*score + 128*256))>>16;
1567 av_dlog(s,
"%d %d %d %d\n", dmin, fmin, bmin, fbmin);
1581 fimin= bimin= INT_MAX;
1608 score= ((unsigned)(score*score + 128*256))>>16;
1619 if(fimin < INT_MAX && bimin < INT_MAX){
1640 int best_score=-10000000;
1643 range=
FFMIN(range, 16);
1645 range=
FFMIN(range, 256);
1647 for(i=0; i<8; i++) score[i]= s->
mb_num*(8-i);
1654 int mx= mv_table[xy][0];
1655 int my= mv_table[xy][1];
1660 if(mx >= range || mx < -range ||
1661 my >= range || my < -range)
1664 for(j=0; j<fcode && j<8; j++){
1674 if(score[i] > best_score){
1675 best_score= score[i];
1689 const int f_code= s->
f_code;
1695 av_assert0(range <= 16 || !s->msmpeg4_version);
1712 for(block=0; block<4; block++){
1713 int off= (block& 1) + (block>>1)*
wrap;
1717 if( mx >=range || mx <-range
1718 || my >=range || my <-range){
1719 s->
mb_type[i] &= ~CANDIDATE_MB_TYPE_INTER4V;
1737 int16_t (*mv_table)[2],
int f_code,
int type,
int truncate)
1740 int y, h_range, v_range;
1748 v_range= field_select_table ? range>>1 : range;
1756 if (!field_select_table || field_select_table[xy] == field_select) {
1757 if( mv_table[xy][0] >=h_range || mv_table[xy][0] <-h_range
1758 || mv_table[xy][1] >=v_range || mv_table[xy][1] <-v_range){
1761 if (mv_table[xy][0] > h_range-1) mv_table[xy][0]= h_range-1;
1762 else if(mv_table[xy][0] < -h_range ) mv_table[xy][0]= -h_range;
1763 if (mv_table[xy][1] > v_range-1) mv_table[xy][1]= v_range-1;
1764 else if(mv_table[xy][1] < -v_range ) mv_table[xy][1]= -v_range;