1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

new I/P frame selection heuristic

PSNR/bitrate is slightly better for my (short) test videos
more tests welcome ...

Originally committed as revision 6876 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2006-11-02 23:36:39 +00:00
parent f932cdf209
commit dd7e46e7c3

View File

@ -1178,13 +1178,11 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
vard= check_input_motion(s, mb_x, mb_y, 1); vard= check_input_motion(s, mb_x, mb_y, 1);
if((vard+128)>>8 < c->avctx->me_threshold){ if((vard+128)>>8 < c->avctx->me_threshold){
int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8; pic->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
c->mc_mb_var_sum_temp += (vard+128)>>8; c->mc_mb_var_sum_temp += (vard+128)>>8;
if (vard <= 64<<8 || vard < varc) { //FIXME c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
}else{
c->scene_change_score+= s->qscale * s->avctx->scenechange_factor;
}
return; return;
} }
if((vard+128)>>8 < c->avctx->mb_threshold) if((vard+128)>>8 < c->avctx->mb_threshold)
@ -1271,10 +1269,9 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
varc, s->avg_mb_var, sum, vard, mx - xx, my - yy); varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);
#endif #endif
if(mb_type){ if(mb_type){
if (vard <= 64<<8 || vard < varc) int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
else c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
c->scene_change_score+= s->qscale * s->avctx->scenechange_factor;
if(mb_type == CANDIDATE_MB_TYPE_INTER){ if(mb_type == CANDIDATE_MB_TYPE_INTER){
c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16); c->sub_motion_search(s, &mx, &my, dmin, 0, 0, 0, 16);
@ -1292,10 +1289,9 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1); interlaced_search(s, 0, s->p_field_mv_table, s->p_field_select_table, mx, my, 1);
} }
}else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){ }else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){
if (vard <= 64<<8 || vard < varc) int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
else c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
c->scene_change_score+= s->qscale * s->avctx->scenechange_factor;
if (vard*2 + 200*256 > varc) if (vard*2 + 200*256 > varc)
mb_type|= CANDIDATE_MB_TYPE_INTRA; mb_type|= CANDIDATE_MB_TYPE_INTRA;
@ -1399,10 +1395,10 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
}else }else
s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= 0; s->current_picture.mb_type[mb_y*s->mb_stride + mb_x]= 0;
if (vard <= 64<<8 || vard < varc) { //FIXME {
c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100);
}else{ int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20;
c->scene_change_score+= s->qscale * s->avctx->scenechange_factor; c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score);
} }
} }