Commit 7cdea450 authored by Rostislav Pehlivanov's avatar Rostislav Pehlivanov

vc2enc: fix use of uninitialized variables in the rate control system

Fixes: CID1352550
Fixes: CID1352549
Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
parent a655bc83
...@@ -658,7 +658,8 @@ static int rate_control(AVCodecContext *avctx, void *arg) ...@@ -658,7 +658,8 @@ static int rate_control(AVCodecContext *avctx, void *arg)
VC2EncContext *s = slice_dat->ctx; VC2EncContext *s = slice_dat->ctx;
const int sx = slice_dat->x; const int sx = slice_dat->x;
const int sy = slice_dat->y; 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 int64_t top = slice_dat->bits_ceil;
const double percent = s->tolerance; const double percent = s->tolerance;
const double bottom = top - top*(percent/100.0f); const double bottom = top - top*(percent/100.0f);
...@@ -670,14 +671,13 @@ static int rate_control(AVCodecContext *avctx, void *arg) ...@@ -670,14 +671,13 @@ static int rate_control(AVCodecContext *avctx, void *arg)
bits = count_hq_slice(s, sx, sy, quant); bits = count_hq_slice(s, sx, sy, quant);
range = av_clip(range/2, 1, s->q_ceil); range = av_clip(range/2, 1, s->q_ceil);
if (quant_buf[1] == quant) { if (quant_buf[1] == quant) {
quant = bits_buf[0] < bits ? quant_buf[0] : quant; quant = bits_last < bits ? quant_buf[0] : quant;
bits = bits_buf[0] < bits ? bits_buf[0] : bits; bits = bits_last < bits ? bits_last : bits;
break; break;
} }
quant_buf[1] = quant_buf[0]; quant_buf[1] = quant_buf[0];
quant_buf[0] = quant; quant_buf[0] = quant;
bits_buf[1] = bits_buf[0]; bits_last = bits;
bits_buf[0] = bits;
} }
slice_dat->quant_idx = av_clip(quant, 0, s->q_ceil); slice_dat->quant_idx = av_clip(quant, 0, s->q_ceil);
slice_dat->bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes; slice_dat->bytes = FFALIGN((bits >> 3), s->size_scaler) + 4 + s->prefix_bytes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment