aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-06-14 16:18:04 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-06-14 16:18:04 +0000
commit0da6315a70396572319e6e8726159b6f4f3ead3f (patch)
tree22156303637486d20b77c73418ef40f153d891eb
parent3f1899a8340e0b012bec1a257db04dca8282bcb4 (diff)
downloadffmpeg-0da6315a70396572319e6e8726159b6f4f3ead3f.tar.gz
fewer overflows
Originally committed as revision 3222 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/motion_est_template.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c
index fd293fa2fd..567f84d2c6 100644
--- a/libavcodec/motion_est_template.c
+++ b/libavcodec/motion_est_template.c
@@ -323,15 +323,16 @@ static int qpel_motion_search(MpegEncContext * s,
for(ny= -3; ny <= 3; ny++){
for(nx= -3; nx <= 3; nx++){
- const int t2= nx*nx*(tr + tl - 2*t) + 4*nx*(tr-tl) + 32*t;
- const int c2= nx*nx*( r + l - 2*c) + 4*nx*( r- l) + 32*c;
- const int b2= nx*nx*(br + bl - 2*b) + 4*nx*(br-bl) + 32*b;
- int score= ny*ny*(b2 + t2 - 2*c2) + 4*ny*(b2 - t2) + 32*c2;
+ //FIXME this could overflow (unlikely though)
+ const int64_t t2= nx*nx*(tr + tl - 2*t) + 4*nx*(tr-tl) + 32*t;
+ const int64_t c2= nx*nx*( r + l - 2*c) + 4*nx*( r- l) + 32*c;
+ const int64_t b2= nx*nx*(br + bl - 2*b) + 4*nx*(br-bl) + 32*b;
+ int score= (ny*ny*(b2 + t2 - 2*c2) + 4*ny*(b2 - t2) + 32*c2 + 512)>>10;
int i;
if((nx&3)==0 && (ny&3)==0) continue;
- score += 1024*(mv_penalty[4*mx + nx - pred_x] + mv_penalty[4*my + ny - pred_y])*penalty_factor;
+ score += (mv_penalty[4*mx + nx - pred_x] + mv_penalty[4*my + ny - pred_y])*penalty_factor;
// if(nx&1) score-=1024*c->penalty_factor;
// if(ny&1) score-=1024*c->penalty_factor;
@@ -350,6 +351,7 @@ static int qpel_motion_search(MpegEncContext * s,
}
}else{
int tl;
+ //FIXME this could overflow (unlikely though)
const int cx = 4*(r - l);
const int cx2= r + l - 2*c;
const int cy = 4*(b - t);
@@ -372,6 +374,7 @@ static int qpel_motion_search(MpegEncContext * s,
for(ny= -3; ny <= 3; ny++){
for(nx= -3; nx <= 3; nx++){
+ //FIXME this could overflow (unlikely though)
int score= ny*nx*cxy + nx*nx*cx2 + ny*ny*cy2 + nx*cx + ny*cy + 32*c; //FIXME factor
int i;