[FFmpeg-cvslog] vc2enc: fix use of uninitialized variables in the rate control system
Rostislav Pehlivanov
git at videolan.org
Mon Feb 15 16:37:29 CET 2016
ffmpeg | branch: release/3.0 | Rostislav Pehlivanov <atomnuker at gmail.com> | Mon Feb 15 12:08:11 2016 +0000| [0aa2fbddb19035cd715130bc9b7c643e240ed74e] | committer: Rostislav Pehlivanov
vc2enc: fix use of uninitialized variables in the rate control system
Fixes: CID1352550
Fixes: CID1352549
Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
(cherry picked from commit 7cdea450c67d24a3503a0eb64f491f58e474973f)
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0aa2fbddb19035cd715130bc9b7c643e240ed74e
---
libavcodec/vc2enc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index 5472609..f42b10f 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;
More information about the ffmpeg-cvslog
mailing list