aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/motion_est.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2002-08-22 19:41:06 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-08-22 19:41:06 +0000
commit1fb4890b5195db4de31733a234abb946f9399f3e (patch)
treee7f8052f50224fe83f3160d1e2047469f12562c4 /libavcodec/motion_est.c
parent90cee0c351f43a37b626c08d8262eaa3237f4de9 (diff)
downloadffmpeg-1fb4890b5195db4de31733a234abb946f9399f3e.tar.gz
better scene change detection
Originally committed as revision 858 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/motion_est.c')
-rw-r--r--libavcodec/motion_est.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index ffc251da70..612c22cf9f 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1183,6 +1183,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
sum= (sum+8)>>4;
varc = (pix_norm1(pix, s->linesize) - sum*sum + 500 + 128)>>8;
vard = (pix_norm(pix, ppix, s->linesize)+128)>>8;
+
//printf("%d %d %d %X %X %X\n", s->mb_width, mb_x, mb_y,(int)s, (int)s->mb_var, (int)s->mc_mb_var); fflush(stdout);
s->mb_var [s->mb_width * mb_y + mb_x] = varc;
s->mc_mb_var[s->mb_width * mb_y + mb_x] = vard;
@@ -1195,6 +1196,11 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
varc, s->avg_mb_var, sum, vard, mx - xx, my - yy);
#endif
if(s->flags&CODEC_FLAG_HQ){
+ if (vard <= 64 || vard < varc)
+ s->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
+ else
+ s->scene_change_score+= 20;
+
if (vard*2 + 200 > varc)
mb_type|= MB_TYPE_INTRA;
if (varc*2 + 200 > vard){
@@ -1221,6 +1227,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
set_p_mv_tables(s, mx, my, 1);
}else{
if (vard <= 64 || vard < varc) {
+ s->scene_change_score+= ff_sqrt(vard) - ff_sqrt(varc);
mb_type|= MB_TYPE_INTER;
if (s->me_method != ME_ZERO) {
if(s->me_method >= ME_EPZS)
@@ -1251,6 +1258,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
}
#endif
}else{
+ s->scene_change_score+= 20;
mb_type|= MB_TYPE_INTRA;
mx = 0;
my = 0;