diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-11-02 23:36:39 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-11-02 23:36:39 +0000 |
commit | dd7e46e7c3d0bf34a6840bd848b9406df3a4d815 (patch) | |
tree | d612dbb4127479430618e73cb4201a488d8662d0 /libavcodec/motion_est.c | |
parent | f932cdf2096d57a0f22189ca9defdf3a15d4b674 (diff) | |
download | android_external_ffmpeg-dd7e46e7c3d0bf34a6840bd848b9406df3a4d815.tar.gz android_external_ffmpeg-dd7e46e7c3d0bf34a6840bd848b9406df3a4d815.tar.bz2 android_external_ffmpeg-dd7e46e7c3d0bf34a6840bd848b9406df3a4d815.zip |
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
Diffstat (limited to 'libavcodec/motion_est.c')
-rw-r--r-- | libavcodec/motion_est.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index fb32ec5912..4dc17b99b8 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1178,13 +1178,11 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, vard= check_input_motion(s, mb_x, mb_y, 1); 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; c->mc_mb_var_sum_temp += (vard+128)>>8; - if (vard <= 64<<8 || vard < varc) { //FIXME - c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); - }else{ - c->scene_change_score+= s->qscale * s->avctx->scenechange_factor; - } + c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); return; } 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); #endif if(mb_type){ - if (vard <= 64<<8 || vard < varc) - c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); - else - c->scene_change_score+= s->qscale * s->avctx->scenechange_factor; + int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); + int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; + c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); if(mb_type == CANDIDATE_MB_TYPE_INTER){ 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); } }else if(c->avctx->mb_decision > FF_MB_DECISION_SIMPLE){ - if (vard <= 64<<8 || vard < varc) - c->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc); - else - c->scene_change_score+= s->qscale * s->avctx->scenechange_factor; + int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); + int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; + c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); if (vard*2 + 200*256 > varc) mb_type|= CANDIDATE_MB_TYPE_INTRA; @@ -1399,10 +1395,10 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, }else 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); - }else{ - c->scene_change_score+= s->qscale * s->avctx->scenechange_factor; + { + int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); + int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; + c->scene_change_score+= ff_sqrt(p_score) - ff_sqrt(i_score); } } |