aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-11-26 20:11:12 +0000
committerMans Rullgard <mans@mansr.com>2011-11-26 20:52:10 +0000
commit3a83b2461e4ce9d48ad6ab037eb14569d0e53506 (patch)
treeba494bbdce50604c08c839e938166bf628a5b07d
parentb6ae0866821df5f3b83f6b7f5c281d9a3e36b7ee (diff)
downloadffmpeg-3a83b2461e4ce9d48ad6ab037eb14569d0e53506.tar.gz
dnxhdenc: fix signed overflows
Signed-off-by: Mans Rullgard <mans@mansr.com>
-rw-r--r--libavcodec/dnxhdenc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 89e5c085ab..d1ab597d1d 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -682,7 +682,8 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
int qscale = 1;
int mb = y*ctx->m.mb_width+x;
for (q = 1; q < avctx->qmax; q++) {
- unsigned score = ctx->mb_rc[q][mb].bits*lambda+(ctx->mb_rc[q][mb].ssd<<LAMBDA_FRAC_BITS);
+ unsigned score = ctx->mb_rc[q][mb].bits*lambda+
+ ((unsigned)ctx->mb_rc[q][mb].ssd<<LAMBDA_FRAC_BITS);
if (score < min) {
min = score;
qscale = q;
@@ -709,7 +710,7 @@ static int dnxhd_encode_rdo(AVCodecContext *avctx, DNXHDEncContext *ctx)
lambda = (lambda+last_higher)>>1;
else
lambda -= down_step;
- down_step *= 5; // XXX tune ?
+ down_step = FFMIN((int64_t)down_step*5, INT_MAX);
up_step = 1<<LAMBDA_FRAC_BITS;
lambda = FFMAX(1, lambda);
if (lambda == last_lower)