int y;
int quant_idx;
int bits_ceil;
+ int bits_floor;
int bytes;
} SliceArgs;
/* Rate control stuff */
int slice_max_bytes;
+ int slice_min_bytes;
int q_ceil;
int q_start;
const int sy = slice_dat->y;
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);
+ const int top = slice_dat->bits_ceil;
+ const int bottom = slice_dat->bits_floor;
int bits = count_hq_slice(s, sx, sy, quant);
range -= range & 1; /* Make it an even number */
while ((bits > top) || (bits < bottom)) {
args->x = slice_x;
args->y = slice_y;
args->bits_ceil = s->slice_max_bytes << 3;
+ args->bits_floor = s->slice_min_bytes << 3;
}
}
s->size_scaler <<= 1;
}
+ s->slice_min_bytes = s->slice_max_bytes - s->slice_max_bytes*(s->tolerance/100.0f);
+
ret = ff_alloc_packet2(avctx, avpkt, max_frame_bytes*2, 0);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");