From: jackychen Date: Wed, 28 Oct 2015 19:30:45 +0000 (-0700) Subject: VP9_resizing: add limitation to the downsacling resolution. X-Git-Tag: v1.6.0~598^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dba2d5b3f3e80e8bdeca4af77d0b8632bf471e77;p=libvpx VP9_resizing: add limitation to the downsacling resolution. Width and height of downscaling resolution should not be lower than min_width and min_height which can be set as needed, both are 180 for now. Change-Id: I34d06704ea51affbdd814246e22ee8d41d991f00 --- diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index d70068570..9905d9e78 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1835,6 +1835,9 @@ int vp9_resize_one_pass_cbr(VP9_COMP *cpi) { RESIZE_ACTION resize_action = NO_RESIZE; int avg_qp_thr1 = 70; int avg_qp_thr2 = 50; + int min_width = 180; + int min_height = 180; + int down_size_on = 1; cpi->resize_scale_num = 1; cpi->resize_scale_den = 1; // Don't resize on key frame; reset the counters on key frame. @@ -1843,6 +1846,21 @@ int vp9_resize_one_pass_cbr(VP9_COMP *cpi) { cpi->resize_count = 0; return 0; } + // Check current frame reslution to avoid generating frames smaller than + // the minimum resolution. + if (ONEHALFONLY_RESIZE) { + if ((cm->width >> 1) < min_width || (cm->height >> 1) < min_height) + down_size_on = 0; + } else { + if (cpi->resize_state == ORIG && + (cm->width * 3 / 4 < min_width || + cm->height * 3 / 4 < min_height)) + return 0; + else if (cpi->resize_state == THREE_QUARTER && + ((cpi->oxcf.width >> 1) < min_width || + (cpi->oxcf.height >> 1) < min_height)) + down_size_on = 0; + } #if CONFIG_VP9_TEMPORAL_DENOISING // If denoiser is on, apply a smaller qp threshold. @@ -1869,7 +1887,7 @@ int vp9_resize_one_pass_cbr(VP9_COMP *cpi) { // down state, i.e. 1/2 or 3/4 of original resolution. // Currently, use a flag to turn 3/4 resizing feature on/off. if (cpi->resize_buffer_underflow > (cpi->resize_count >> 2)) { - if (cpi->resize_state == THREE_QUARTER) { + if (cpi->resize_state == THREE_QUARTER && down_size_on) { resize_action = DOWN_ONEHALF; cpi->resize_state = ONE_HALF; } else if (cpi->resize_state == ORIG) {