Commit 1f202b0d authored by Michael Niedermayer's avatar Michael Niedermayer

moving motion estimation specific variables from MpegEncContext -> MotionEstContext

Originally committed as revision 3124 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent af4091f1
This diff is collapsed.
......@@ -79,7 +79,7 @@ static int hpel_motion_search)(MpegEncContext * s,
return dmin;
}
if(s->avctx->me_cmp != s->avctx->me_sub_cmp){
if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
CMP_HPEL(dmin, 0, 0, mx, my, size);
if(mx || my)
dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor;
......@@ -138,7 +138,7 @@ static int hpel_motion_search(MpegEncContext * s,
return dmin;
}
if(s->avctx->me_cmp != s->avctx->me_sub_cmp){
if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
dmin= cmp(s, mx, my, 0, 0, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
if(mx || my || size>0)
dmin += (mv_penalty[2*mx - pred_x] + mv_penalty[2*my - pred_y])*penalty_factor;
......@@ -243,7 +243,7 @@ static int inline get_mb_score(MpegEncContext * s, int mx, int my, int src_index
chroma_cmp_sub= s->dsp.mb_cmp[size+1];
assert(!c->skip);
assert(s->avctx->me_sub_cmp != s->avctx->mb_cmp);
assert(c->avctx->me_sub_cmp != c->avctx->mb_cmp);
d= cmp(s, mx>>(qpel+1), my>>(qpel+1), mx&mask, my&mask, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
//FIXME check cbp before adding penalty for (0,0) vector
......@@ -272,7 +272,7 @@ static int qpel_motion_search(MpegEncContext * s,
const int my = *my_ptr;
const int penalty_factor= c->sub_penalty_factor;
const int map_generation= c->map_generation;
const int subpel_quality= s->avctx->me_subpel_quality;
const int subpel_quality= c->avctx->me_subpel_quality;
uint32_t *map= c->map;
me_cmp_func cmpf, chroma_cmpf;
me_cmp_func cmp_sub, chroma_cmp_sub;
......@@ -293,7 +293,7 @@ static int qpel_motion_search(MpegEncContext * s,
return dmin;
}
if(s->avctx->me_cmp != s->avctx->me_sub_cmp){
if(c->avctx->me_cmp != c->avctx->me_sub_cmp){
dmin= cmp(s, mx, my, 0, 0, size, h, ref_index, src_index, cmp_sub, chroma_cmp_sub, flags);
if(mx || my || size>0)
dmin += (mv_penalty[4*mx - pred_x] + mv_penalty[4*my - pred_y])*penalty_factor;
......@@ -908,8 +908,8 @@ static always_inline int epzs_motion_search_internal(MpegEncContext * s, int *mx
}
}
if(s->avctx->last_predictor_count){
const int count= s->avctx->last_predictor_count;
if(c->avctx->last_predictor_count){
const int count= c->avctx->last_predictor_count;
const int xstart= FFMAX(0, s->mb_x - count);
const int ystart= FFMAX(0, s->mb_y - count);
const int xend= FFMIN(s->mb_width , s->mb_x + count + 1);
......
......@@ -3958,7 +3958,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
s->current_picture.mb_var [s->mb_stride * mb_y + mb_x] = varc;
s->current_picture.mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8;
s->mb_var_sum_temp += varc;
s->me.mb_var_sum_temp += varc;
}
}
return 0;
......@@ -4552,9 +4552,9 @@ static int encode_thread(AVCodecContext *c, void *arg){
#define MERGE(field) dst->field += src->field; src->field=0
static void merge_context_after_me(MpegEncContext *dst, MpegEncContext *src){
MERGE(scene_change_score);
MERGE(mc_mb_var_sum_temp);
MERGE(mb_var_sum_temp);
MERGE(me.scene_change_score);
MERGE(me.mc_mb_var_sum_temp);
MERGE(me.mb_var_sum_temp);
}
static void merge_context_after_encode(MpegEncContext *dst, MpegEncContext *src){
......@@ -4595,8 +4595,8 @@ static void encode_picture(MpegEncContext *s, int picture_number)
s->picture_number = picture_number;
/* Reset the average MB variance */
s->mb_var_sum_temp =
s->mc_mb_var_sum_temp = 0;
s->me.mb_var_sum_temp =
s->me.mc_mb_var_sum_temp = 0;
#ifdef CONFIG_RISKY
/* we need to initialize some time vars before we can encode b-frames */
......@@ -4605,7 +4605,7 @@ static void encode_picture(MpegEncContext *s, int picture_number)
ff_set_mpeg4_time(s, s->picture_number); //FIXME rename and use has_b_frames or similar
#endif
s->scene_change_score=0;
s->me.scene_change_score=0;
s->lambda= s->current_picture_ptr->quality; //FIXME qscale / ... stuff for ME ratedistoration
......@@ -4646,11 +4646,11 @@ static void encode_picture(MpegEncContext *s, int picture_number)
for(i=1; i<s->avctx->thread_count; i++){
merge_context_after_me(s, s->thread_context[i]);
}
s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->mc_mb_var_sum_temp;
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s-> mb_var_sum_temp;
s->current_picture.mc_mb_var_sum= s->current_picture_ptr->mc_mb_var_sum= s->me.mc_mb_var_sum_temp;
s->current_picture. mb_var_sum= s->current_picture_ptr-> mb_var_sum= s->me. mb_var_sum_temp;
emms_c();
if(s->scene_change_score > s->avctx->scenechange_threshold && s->pict_type == P_TYPE){
if(s->me.scene_change_score > s->avctx->scenechange_threshold && s->pict_type == P_TYPE){
s->pict_type= I_TYPE;
for(i=0; i<s->mb_stride*s->mb_height; i++)
s->mb_type[i]= CANDIDATE_MB_TYPE_INTRA;
......
......@@ -196,6 +196,7 @@ struct MpegEncContext;
* Motion estimation context.
*/
typedef struct MotionEstContext{
AVCodecContext *avctx;
int skip; ///< set if ME is skiped for the current MB
int co_located_mv[4][2]; ///< mv from last p frame for direct mode ME
int direct_basis_mv[4][2];
......@@ -226,6 +227,10 @@ typedef struct MotionEstContext{
uint8_t *ref[4][4];
int stride;
int uvstride;
/* temp variables for picture complexity calculation */
int mc_mb_var_sum_temp;
int mb_var_sum_temp;
int scene_change_score;
/* cmp, chroma_cmp;*/
op_pixels_func (*hpel_put)[4];
op_pixels_func (*hpel_avg)[4];
......@@ -393,7 +398,6 @@ typedef struct MpegEncContext {
uint8_t (*p_field_select_table[2]);
uint8_t (*b_field_select_table[2][2]);
int me_method; ///< ME algorithm
int scene_change_score;
int mv_dir;
#define MV_DIR_BACKWARD 1
#define MV_DIR_FORWARD 2
......@@ -508,10 +512,6 @@ typedef struct MpegEncContext {
int misc_bits; ///< cbp, mb_type
int last_bits; ///< temp var used for calculating the above vars
/* temp variables for picture complexity calculation */
int mc_mb_var_sum_temp;
int mb_var_sum_temp;
/* error concealment / resync */
int error_count;
uint8_t *error_status_table; ///< table of the error status of each MB
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment