comparison motion_est_template.c @ 1013:5d4c95f323d0 libavcodec

finetuneing thresholds/factors nicer mb decission a few minor improvements & fixes
author michaelni
date Sun, 19 Jan 2003 17:55:13 +0000
parents 3b7fcfb9c551
children 1e39f273ecd6
comparison
equal deleted inserted replaced
1012:7a5038ec769b 1013:5d4c95f323d0
37 op_pixels_func (*hpel_avg)[4]= &s->dsp.avg_pixels_tab[size];\ 37 op_pixels_func (*hpel_avg)[4]= &s->dsp.avg_pixels_tab[size];\
38 op_pixels_func (*chroma_hpel_put)[4];\ 38 op_pixels_func (*chroma_hpel_put)[4];\
39 qpel_mc_func (*qpel_put)[16];\ 39 qpel_mc_func (*qpel_put)[16];\
40 qpel_mc_func (*qpel_avg)[16]= &s->dsp.avg_qpel_pixels_tab[size];\ 40 qpel_mc_func (*qpel_avg)[16]= &s->dsp.avg_qpel_pixels_tab[size];\
41 const __attribute__((unused)) int unu= time_pp + time_pb + (int)src_u + (int)src_v + (int)ref_u + (int)ref_v\ 41 const __attribute__((unused)) int unu= time_pp + time_pb + (int)src_u + (int)src_v + (int)ref_u + (int)ref_v\
42 + (int)ref2_y + (int)hpel_avg + (int)qpel_avg;\ 42 + (int)ref2_y + (int)hpel_avg + (int)qpel_avg + (int)score_map;\
43 if(s->no_rounding /*FIXME b_type*/){\ 43 if(s->no_rounding /*FIXME b_type*/){\
44 hpel_put= &s->dsp.put_no_rnd_pixels_tab[size];\ 44 hpel_put= &s->dsp.put_no_rnd_pixels_tab[size];\
45 chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1];\ 45 chroma_hpel_put= &s->dsp.put_no_rnd_pixels_tab[size+1];\
46 qpel_put= &s->dsp.put_no_rnd_qpel_pixels_tab[size];\ 46 qpel_put= &s->dsp.put_no_rnd_qpel_pixels_tab[size];\
47 }else{\ 47 }else{\
142 const int yy = 16 * s->mb_y + 8*(n>>1); 142 const int yy = 16 * s->mb_y + 8*(n>>1);
143 const int mx = *mx_ptr; 143 const int mx = *mx_ptr;
144 const int my = *my_ptr; 144 const int my = *my_ptr;
145 const int penalty_factor= s->me.sub_penalty_factor; 145 const int penalty_factor= s->me.sub_penalty_factor;
146 me_cmp_func cmp_sub, chroma_cmp_sub; 146 me_cmp_func cmp_sub, chroma_cmp_sub;
147 int bx=2*mx, by=2*my;
147 148
148 LOAD_COMMON(xx, yy); 149 LOAD_COMMON(xx, yy);
149 150
150 //FIXME factorize 151 //FIXME factorize
151 152
164 dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor; 165 dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor;
165 } 166 }
166 167
167 if (mx > xmin && mx < xmax && 168 if (mx > xmin && mx < xmax &&
168 my > ymin && my < ymax) { 169 my > ymin && my < ymax) {
169 int bx=2*mx, by=2*my;
170 int d= dmin; 170 int d= dmin;
171 const int index= (my<<ME_MAP_SHIFT) + mx; 171 const int index= (my<<ME_MAP_SHIFT) + mx;
172 const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] 172 const int t= score_map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]
173 + (mv_penalty[bx - pred_x] + mv_penalty[by-2 - pred_y])*s->me.penalty_factor; 173 + (mv_penalty[bx - pred_x] + mv_penalty[by-2 - pred_y])*s->me.penalty_factor;
174 const int l= score_map[(index- 1 )&(ME_MAP_SIZE-1)] 174 const int l= score_map[(index- 1 )&(ME_MAP_SIZE-1)]
176 const int r= score_map[(index+ 1 )&(ME_MAP_SIZE-1)] 176 const int r= score_map[(index+ 1 )&(ME_MAP_SIZE-1)]
177 + (mv_penalty[bx+2 - pred_x] + mv_penalty[by - pred_y])*s->me.penalty_factor; 177 + (mv_penalty[bx+2 - pred_x] + mv_penalty[by - pred_y])*s->me.penalty_factor;
178 const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] 178 const int b= score_map[(index+(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)]
179 + (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*s->me.penalty_factor; 179 + (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*s->me.penalty_factor;
180 180
181 #if 0 181 #if 1
182 int key; 182 int key;
183 int map_generation= s->me.map_generation; 183 int map_generation= s->me.map_generation;
184 uint32_t *map= s->me.map; 184 uint32_t *map= s->me.map;
185 key= ((my-1)<<ME_MAP_MV_BITS) + (mx) + map_generation; 185 key= ((my-1)<<ME_MAP_MV_BITS) + (mx) + map_generation;
186 assert(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key); 186 assert(map[(index-(1<<ME_MAP_SHIFT))&(ME_MAP_SIZE-1)] == key);
229 CHECK_HALF_MV(1, 1, mx , my) 229 CHECK_HALF_MV(1, 1, mx , my)
230 } 230 }
231 CHECK_HALF_MV(0, 1, mx , my) 231 CHECK_HALF_MV(0, 1, mx , my)
232 } 232 }
233 assert(bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2); 233 assert(bx >= xmin*2 && bx <= xmax*2 && by >= ymin*2 && by <= ymax*2);
234 234 }
235 *mx_ptr = bx; 235
236 *my_ptr = by; 236 *mx_ptr = bx;
237 }else{ 237 *my_ptr = by;
238 *mx_ptr =2*mx; 238
239 *my_ptr =2*my;
240 }
241
242 return dmin; 239 return dmin;
243 } 240 }
244 #endif 241 #endif
245 242
243 static int RENAME(hpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture,
244 uint16_t * const mv_penalty)
245 {
246 // const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp;
247 const int size= 0;
248 const int xx = 16 * s->mb_x;
249 const int yy = 16 * s->mb_y;
250 const int penalty_factor= s->me.mb_penalty_factor;
251 const int xmin= -256*256, ymin= -256*256, xmax= 256*256, ymax= 256*256; //assume that the caller checked these
252 const __attribute__((unused)) int unu2= xmin + xmax +ymin + ymax; //no unused warning shit
253 me_cmp_func cmp_sub, chroma_cmp_sub;
254 int d;
255
256 LOAD_COMMON(xx, yy);
257
258 //FIXME factorize
259
260 cmp_sub= s->dsp.mb_cmp[size];
261 chroma_cmp_sub= s->dsp.mb_cmp[size+1];
262
263 assert(!s->me.skip);
264 assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp);
265
266 CMP_HPEL(d, mx&1, my&1, mx>>1, my>>1, size);
267 //FIXME check cbp before adding penalty for (0,0) vector
268 if(mx || my || size>0)
269 d += (mv_penalty[mx - pred_x] + mv_penalty[my - pred_y])*penalty_factor;
270
271 return d;
272 }
273
246 #endif /* CMP_HPEL */ 274 #endif /* CMP_HPEL */
275
276
247 277
248 #ifdef CMP_QPEL 278 #ifdef CMP_QPEL
249 279
250 #define CHECK_QUARTER_MV(dx, dy, x, y)\ 280 #define CHECK_QUARTER_MV(dx, dy, x, y)\
251 {\ 281 {\
475 } 505 }
476 506
477 return dmin; 507 return dmin;
478 } 508 }
479 509
510 static int RENAME(qpel_get_mb_score)(MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture,
511 uint16_t * const mv_penalty)
512 {
513 const int size= 0;
514 const int xx = 16 * s->mb_x;
515 const int yy = 16 * s->mb_y;
516 const int penalty_factor= s->me.mb_penalty_factor;
517 const int xmin= -256*256, ymin= -256*256, xmax= 256*256, ymax= 256*256; //assume that the caller checked these
518 const __attribute__((unused)) int unu2= xmin + xmax +ymin + ymax; //no unused warning shit
519 me_cmp_func cmp_sub, chroma_cmp_sub;
520 int d;
521
522 LOAD_COMMON(xx, yy);
523
524 //FIXME factorize
525
526 cmp_sub= s->dsp.mb_cmp[size];
527 chroma_cmp_sub= s->dsp.mb_cmp[size+1];
528
529 assert(!s->me.skip);
530 assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp);
531
532 CMP_QPEL(d, mx&3, my&3, mx>>2, my>>2, size);
533 //FIXME check cbp before adding penalty for (0,0) vector
534 if(mx || my || size>0)
535 d += (mv_penalty[mx - pred_x] + mv_penalty[my - pred_y])*penalty_factor;
536
537 return d;
538 }
539
540
480 #endif /* CMP_QPEL */ 541 #endif /* CMP_QPEL */
481 542
482 #define CHECK_MV(x,y)\ 543 #define CHECK_MV(x,y)\
483 {\ 544 {\
484 const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\ 545 const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\