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 12:12:16 +0000
commit7cdea450c67d24a3503a0eb64f491f58e474973f (patch)
treeb8412ac03f58fb10381b7927b1aa0aa59991e795
parenta655bc834479024ff4d60d0b8ecca290e73eb96c (diff)
downloadffmpeg-7cdea450c67d24a3503a0eb64f491f58e474973f.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>
-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;