aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2016-02-15 12:08:11 +0000
committerRostislav Pehlivanov <atomnuker@gmail.com>2016-02-15 15:36:59 +0000
commit0aa2fbddb19035cd715130bc9b7c643e240ed74e (patch)
treef919212e2d289d113eb424ac4005d29013b5e74e
parentc40983a6f631d22fede713d535bb9c31d5c9740c (diff)
downloadffmpeg-0aa2fbddb19035cd715130bc9b7c643e240ed74e.tar.gz
vc2enc: fix use of uninitialized variables in the rate control system
Fixes: CID1352550 Fixes: CID1352549 Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com> (cherry picked from commit 7cdea450c67d24a3503a0eb64f491f58e474973f)
-rw-r--r--libavcodec/vc2enc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 5472609efd..f42b10ffef 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -658,7 +658,8 @@ static int rate_control(AVCodecContext *avctx, void *arg)
VC2EncContext *s = slice_dat->ctx;
const int sx = slice_dat->x;
const int sy = slice_dat->y;
- int quant_buf[2], bits_buf[2], quant = s->q_start, range = s->q_start/3;
+ int bits_last = INT_MAX, quant_buf[2] = {-1, -1};
+ int quant = s->q_start, range = s->q_start/3;
const int64_t top = slice_dat->bits_ceil;
const double percent = s->tolerance;
const double bottom = top - top*(percent/100.0f);
@@ -670,14 +671,13 @@ static int rate_control(AVCodecContext *avctx, void *arg)
bits = count_hq_slice(s, sx, sy, quant);
range = av_clip(range/2, 1, s->q_ceil);
if (quant_buf[1] == quant) {
- quant = bits_buf[0] < bits ? quant_buf[0] : quant;
- bits = bits_buf[0] < bits ? bits_buf[0] : bits;
+ quant = bits_last < bits ? quant_buf[0] : quant;
+ bits = bits_last < bits ? bits_last : bits;
break;
}
quant_buf[1] = quant_buf[0];
quant_buf[0] = quant;
- bits_buf[1] = bits_buf[0];
- bits_buf[0] = bits;
+ bits_last = bits;
}
slice_dat->quant_idx = av_clip(quant, 0, s->q_ceil);
slice_dat->bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;