ref: dc7da005d71689106bc5d00e5b4752faa4f3fade
parent: fa94dbda81e457e6ceaae254194cf1ffa70274ae
author: Marco <[email protected]>
date: Tue Jul 14 12:22:10 EDT 2015
Fix to resize logic for 1 pass mode. Proper use/update of resize_state and resize_pending to constrain the total amount of downsizing to be at most one scale down, for now. Change-Id: Id18fc32499f2fbdbec16728dcdc9e4eac09098f0
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3061,17 +3061,17 @@
oxcf->rc_mode == VPX_CBR &&
!cpi->use_svc &&
oxcf->resize_mode == RESIZE_DYNAMIC) {
- if (cpi->resize_state == 1) {
+ if (cpi->resize_pending == 1) {
oxcf->scaled_frame_width =
(cm->width * cpi->resize_scale_num) / cpi->resize_scale_den;
oxcf->scaled_frame_height =
(cm->height * cpi->resize_scale_num) /cpi->resize_scale_den;
- } else if (cpi->resize_state == -1) {
+ } else if (cpi->resize_pending == -1) {
// Go back up to original size.
oxcf->scaled_frame_width = oxcf->width;
oxcf->scaled_frame_height = oxcf->height;
}
- if (cpi->resize_state != 0) {
+ if (cpi->resize_pending != 0) {
// There has been a change in frame size.
vp9_set_size_literal(cpi,
oxcf->scaled_frame_width,
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -1355,9 +1355,11 @@
}
// Trigger the resizing of the next frame if it is scaled.
- cpi->resize_pending =
- rc->next_frame_size_selector != rc->frame_size_selector;
- rc->frame_size_selector = rc->next_frame_size_selector;
+ if (oxcf->pass != 0) {
+ cpi->resize_pending =
+ rc->next_frame_size_selector != rc->frame_size_selector;
+ rc->frame_size_selector = rc->next_frame_size_selector;
+ }
}
void vp9_rc_postencode_update_drop_frame(VP9_COMP *cpi) {
@@ -1632,9 +1634,9 @@
vp9_rc_set_frame_target(cpi, target);
if (cpi->oxcf.resize_mode == RESIZE_DYNAMIC)
- cpi->resize_state = vp9_resize_one_pass_cbr(cpi);
+ cpi->resize_pending = vp9_resize_one_pass_cbr(cpi);
else
- cpi->resize_state = 0;
+ cpi->resize_pending = 0;
}
int vp9_compute_qdelta(const RATE_CONTROL *rc, double qstart, double qtarget,
@@ -1826,9 +1828,11 @@
if (cpi->resize_state == 0 &&
cpi->resize_buffer_underflow > (cpi->resize_count >> 3)) {
resize_now = 1;
+ cpi->resize_state = 1;
} else if (cpi->resize_state == 1 &&
avg_qp < 40 * cpi->rc.worst_quality / 100) {
resize_now = -1;
+ cpi->resize_state = 0;
}
// Reset for next window measurement.
cpi->resize_avg_qp = 0;