* Motion estimation template.
*/
+#include "mpegvideo.h"
+
//Let us hope gcc will remove the unused vars ...(gcc 3.2.2 seems to do it ...)
#define LOAD_COMMON\
uint32_t av_unused * const score_map= c->score_map;\
//FIXME factorize
- cmp_sub= s->dsp.me_sub_cmp[size];
- chroma_cmp_sub= s->dsp.me_sub_cmp[size+1];
+ cmp_sub = s->mecc.me_sub_cmp[size];
+ chroma_cmp_sub = s->mecc.me_sub_cmp[size + 1];
if(c->skip){ //FIXME move out of hpel?
*mx_ptr = 0;
return dmin;
}
-inline int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
- int ref_index, int size, int h, int add_rate)
+static inline int get_mb_score(MpegEncContext *s, int mx, int my,
+ int src_index, int ref_index, int size,
+ int h, int add_rate)
{
-// const int check_luma= s->dsp.me_sub_cmp != s->dsp.mb_cmp;
MotionEstContext * const c= &s->me;
const int penalty_factor= c->mb_penalty_factor;
const int flags= c->mb_flags;
//FIXME factorize
- cmp_sub= s->dsp.mb_cmp[size];
- chroma_cmp_sub= s->dsp.mb_cmp[size+1];
+ cmp_sub = s->mecc.mb_cmp[size];
+ chroma_cmp_sub = s->mecc.mb_cmp[size + 1];
// assert(!c->skip);
// assert(c->avctx->me_sub_cmp != c->avctx->mb_cmp);
return d;
}
+int ff_get_mb_score(MpegEncContext *s, int mx, int my, int src_index,
+ int ref_index, int size, int h, int add_rate)
+{
+ return get_mb_score(s, mx, my, src_index, ref_index, size, h, add_rate);
+}
+
#define CHECK_QUARTER_MV(dx, dy, x, y)\
{\
const int hx= 4*(x)+(dx);\
LOAD_COMMON
int flags= c->sub_flags;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1]; //factorize FIXME
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1]; // FIXME: factorize
//FIXME factorize
- cmp_sub= s->dsp.me_sub_cmp[size];
- chroma_cmp_sub= s->dsp.me_sub_cmp[size+1];
+ cmp_sub = s->mecc.me_sub_cmp[size];
+ chroma_cmp_sub = s->mecc.me_sub_cmp[size + 1];
if(c->skip){ //FIXME somehow move up (benchmark)
*mx_ptr = 0;
assert((x) <= xmax);\
assert((y) >= ymin);\
assert((y) <= ymax);\
-/*printf("check_mv %d %d\n", x, y);*/\
if(map[index]!=key){\
d= cmp(s, x, y, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
map[index]= key;\
score_map[index]= d;\
d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*penalty_factor;\
-/*printf("score:%d\n", d);*/\
COPY3_IF_LT(dmin, d, best[0], x, best[1], y)\
}\
}
{\
const unsigned key = ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
-/*printf("check_mv_dir %d %d %d\n", x, y, new_dir);*/\
if(map[index]!=key){\
d= cmp(s, x, y, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
map[index]= key;\
score_map[index]= d;\
d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*penalty_factor;\
-/*printf("score:%d\n", d);*/\
if(d<dmin){\
best[0]=x;\
best[1]=y;\
LOAD_COMMON2
unsigned map_generation = c->map_generation;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
{ /* ensure that the best point is in the MAP as h/qpel refinement needs it */
const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
const int y= best[1];
next_dir=-1;
-//printf("%d", dir);
if(dir!=2 && x>xmin) CHECK_MV_DIR(x-1, y , 0)
if(dir!=3 && y>ymin) CHECK_MV_DIR(x , y-1, 1)
if(dir!=0 && x<xmax) CHECK_MV_DIR(x+1, y , 2)
LOAD_COMMON2
unsigned map_generation = c->map_generation;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
for(dia_size=1; dia_size<=4; dia_size++){
int dir;
int x,y,d;
const int dec= dia_size & (dia_size-1);
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
for(;dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){
do{
static const int hex[8][2]={{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1},
{ 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}};
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
for(; dia_size; dia_size= dec ? dia_size-1 : dia_size>>1){
do{
{-2, 3}, { 0, 4}, { 2, 3},
{-2,-3}, { 0,-4}, { 2,-3},};
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
x= best[0];
y= best[1];
int x,y, d;
const int dia_size= c->dia_size&0xFF;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
for(y=FFMAX(-dia_size, ymin); y<=FFMIN(dia_size,ymax); y++){
for(x=FFMAX(-dia_size, xmin); x<=FFMIN(dia_size,xmax); x++){
{\
const unsigned key = ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\
const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\
-/*printf("sab check %d %d\n", ax, ay);*/\
if(map[index]!=key){\
d= cmp(s, ax, ay, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
map[index]= key;\
score_map[index]= d;\
d += (mv_penalty[((ax)<<shift)-pred_x] + mv_penalty[((ay)<<shift)-pred_y])*penalty_factor;\
-/*printf("score: %d\n", d);*/\
if(d < minima[minima_count-1].height){\
int j=0;\
\
LOAD_COMMON2
unsigned map_generation = c->map_generation;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
/*Note j<MAX_SAB_SIZE is needed if MAX_SAB_SIZE < ME_MAP_SIZE as j can
become larger due to MVs overflowing their ME_MAP_MV_BITS bits space in map
LOAD_COMMON2
unsigned map_generation = c->map_generation;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
for(dia_size=1; dia_size<=c->dia_size; dia_size++){
int dir, start, end;
if(c->pre_pass){
penalty_factor= c->pre_penalty_factor;
- cmpf= s->dsp.me_pre_cmp[size];
- chroma_cmpf= s->dsp.me_pre_cmp[size+1];
+ cmpf = s->mecc.me_pre_cmp[size];
+ chroma_cmpf = s->mecc.me_pre_cmp[size + 1];
}else{
penalty_factor= c->penalty_factor;
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
}
map_generation= update_map_generation(c);
score_map[0]= dmin;
//FIXME precalc first term below?
- if((s->pict_type == AV_PICTURE_TYPE_B && !(c->flags & FLAG_DIRECT)) || s->flags&CODEC_FLAG_MV0)
+ if ((s->pict_type == AV_PICTURE_TYPE_B && !(c->flags & FLAG_DIRECT)) ||
+ s->mpv_flags & FF_MPV_FLAG_MV0)
dmin += (mv_penalty[pred_x] + mv_penalty[pred_y])*penalty_factor;
/* first line */
*mx_ptr= best[0];
*my_ptr= best[1];
-// printf("%d %d %d \n", best[0], best[1], dmin);
return dmin;
}
//this function is dedicated to the braindamaged gcc
-inline int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
- int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2],
- int ref_mv_scale, int size, int h)
+int ff_epzs_motion_search(MpegEncContext *s, int *mx_ptr, int *my_ptr,
+ int P[10][2], int src_index, int ref_index,
+ int16_t (*last_mv)[2], int ref_mv_scale,
+ int size, int h)
{
MotionEstContext * const c= &s->me;
//FIXME convert other functions in the same way if faster
int flags= c->flags;
LOAD_COMMON2
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
map_generation= update_map_generation(c);
dmin = 1000000;
-//printf("%d %d %d %d //",xmin, ymin, xmax, ymax);
+
/* first line */
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
*mx_ptr= best[0];
*my_ptr= best[1];
-// printf("%d %d %d \n", best[0], best[1], dmin);
return dmin;
}
int flags= c->flags;
LOAD_COMMON2
- cmpf= s->dsp.me_cmp[size];
- chroma_cmpf= s->dsp.me_cmp[size+1];
+ cmpf = s->mecc.me_cmp[size];
+ chroma_cmpf = s->mecc.me_cmp[size + 1];
map_generation= update_map_generation(c);
dmin = 1000000;
-//printf("%d %d %d %d //",xmin, ymin, xmax, ymax);
+
/* first line */
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
*mx_ptr= best[0];
*my_ptr= best[1];
-// printf("%d %d %d \n", best[0], best[1], dmin);
return dmin;
}