Unify resize and superres denominator constants RESIZE_SCALE_DENOMINATOR and SUPERRES_SCALE_DENOMINATOR were two constants with the same value that did essentially the same thing. This patch merges the two into SCALE_DENOMINATOR for simplicity's sake. Change-Id: I252a9b7f89f10d77bdb0c3cf2d67d31d337afa4b
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index 6526174..bf18271 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -256,12 +256,12 @@ } RANGE_CHECK_HI(cfg, rc_resize_mode, RESIZE_DYNAMIC); - RANGE_CHECK(cfg, rc_resize_numerator, RESIZE_SCALE_DENOMINATOR / 2, - RESIZE_SCALE_DENOMINATOR); + RANGE_CHECK(cfg, rc_resize_numerator, SCALE_DENOMINATOR / 2, + SCALE_DENOMINATOR); #if CONFIG_FRAME_SUPERRES RANGE_CHECK_HI(cfg, rc_superres_mode, SUPERRES_DYNAMIC); - RANGE_CHECK(cfg, rc_superres_numerator, SUPERRES_SCALE_DENOMINATOR / 2, - SUPERRES_SCALE_DENOMINATOR); + RANGE_CHECK(cfg, rc_superres_numerator, SCALE_DENOMINATOR / 2, + SCALE_DENOMINATOR); #endif // CONFIG_FRAME_SUPERRES // AV1 does not support a lower bound on the keyframe interval in @@ -491,14 +491,14 @@ oxcf->resize_mode = (RESIZE_MODE)cfg->rc_resize_mode; oxcf->resize_scale_numerator = (uint8_t)cfg->rc_resize_numerator; if (oxcf->resize_mode == RESIZE_FIXED && - oxcf->resize_scale_numerator == RESIZE_SCALE_DENOMINATOR) + oxcf->resize_scale_numerator == SCALE_DENOMINATOR) oxcf->resize_mode = RESIZE_NONE; #if CONFIG_FRAME_SUPERRES oxcf->superres_mode = (SUPERRES_MODE)cfg->rc_superres_mode; oxcf->superres_scale_numerator = (uint8_t)cfg->rc_superres_numerator; if (oxcf->superres_mode == SUPERRES_FIXED && - oxcf->superres_scale_numerator == SUPERRES_SCALE_DENOMINATOR) + oxcf->superres_scale_numerator == SCALE_DENOMINATOR) oxcf->superres_mode = SUPERRES_NONE; #endif // CONFIG_FRAME_SUPERRES @@ -1583,12 +1583,12 @@ 25, // g_lag_in_frames - 0, // rc_dropframe_thresh - RESIZE_NONE, // rc_resize_mode - RESIZE_SCALE_DENOMINATOR, // rc_resize_numerator + 0, // rc_dropframe_thresh + RESIZE_NONE, // rc_resize_mode + SCALE_DENOMINATOR, // rc_resize_numerator - 0, // rc_superres_mode - SUPERRES_SCALE_DENOMINATOR, // rc_superres_numerator + 0, // rc_superres_mode + SCALE_DENOMINATOR, // rc_superres_numerator AOM_VBR, // rc_end_usage { NULL, 0 }, // rc_twopass_stats_in
diff --git a/av1/common/enums.h b/av1/common/enums.h index 930b365..2e802de 100644 --- a/av1/common/enums.h +++ b/av1/common/enums.h
@@ -546,8 +546,7 @@ } RestorationType; #endif // CONFIG_LOOP_RESTORATION -#define RESIZE_SCALE_DENOMINATOR 16 -#define SUPERRES_SCALE_DENOMINATOR 16 +#define SCALE_DENOMINATOR 16 #if CONFIG_FRAME_SUPERRES #define SUPERRES_SCALE_BITS 3
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c index 8ca06c0..0265861 100644 --- a/av1/common/reconinter.c +++ b/av1/common/reconinter.c
@@ -1041,7 +1041,7 @@ pre = pre_buf->buf + y * pre_buf->stride + x; scaled_mv.row = mv_q4.row; scaled_mv.col = mv_q4.col; - xs = ys = 16; + xs = ys = SCALE_DENOMINATOR; } subpel_x = scaled_mv.col & SUBPEL_MASK; @@ -1146,8 +1146,8 @@ pre[ref] = pre_buf->buf + (y * pre_buf->stride + x); scaled_mv[ref].row = mv_q4.row; scaled_mv[ref].col = mv_q4.col; - subpel_params[ref].xs = 16; - subpel_params[ref].ys = 16; + subpel_params[ref].xs = SCALE_DENOMINATOR; + subpel_params[ref].ys = SCALE_DENOMINATOR; } subpel_params[ref].subpel_x = scaled_mv[ref].col & SUBPEL_MASK; @@ -2983,7 +2983,7 @@ pre = pre_buf->buf + (y * pre_buf->stride + x); scaled_mv.row = mv_q4.row; scaled_mv.col = mv_q4.col; - xs = ys = 16; + xs = ys = SCALE_DENOMINATOR; } subpel_x = scaled_mv.col & SUBPEL_MASK;
diff --git a/av1/common/resize.c b/av1/common/resize.c index 3625263..027bd21 100644 --- a/av1/common/resize.c +++ b/av1/common/resize.c
@@ -882,9 +882,9 @@ } } -void av1_calculate_scaled_size(int *width, int *height, int num, int den) { - *width = *width * num / den; - *height = *height * num / den; +void av1_calculate_scaled_size(int *width, int *height, int num) { + *width = *width * num / SCALE_DENOMINATOR; + *height = *height * num / SCALE_DENOMINATOR; } #if CONFIG_FRAME_SUPERRES
diff --git a/av1/common/resize.h b/av1/common/resize.h index 26c5955..ca2c046 100644 --- a/av1/common/resize.h +++ b/av1/common/resize.h
@@ -79,13 +79,14 @@ YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *scaled); -void av1_calculate_scaled_size(int *width, int *height, int num, int den); +void av1_calculate_scaled_size(int *width, int *height, int num); + #if CONFIG_FRAME_SUPERRES void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool); // Returns 1 if a superres upscaled frame is unscaled and 0 otherwise. static INLINE int av1_superres_unscaled(const AV1_COMMON *cm) { - return (cm->superres_scale_numerator == SUPERRES_SCALE_DENOMINATOR); + return (cm->superres_scale_numerator == SCALE_DENOMINATOR); } #endif // CONFIG_FRAME_SUPERRES
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index fa8c44c..60847ff 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -3087,11 +3087,10 @@ cm->superres_scale_numerator += SUPERRES_SCALE_NUMERATOR_MIN; // Don't edit cm->width or cm->height directly, or the buffers won't get // resized correctly - av1_calculate_scaled_size(width, height, cm->superres_scale_numerator, - SUPERRES_SCALE_DENOMINATOR); + av1_calculate_scaled_size(width, height, cm->superres_scale_numerator); } else { // 1:1 scaling - ie. no scaling, scale not provided - cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR; + cm->superres_scale_numerator = SCALE_DENOMINATOR; } } #endif // CONFIG_FRAME_SUPERRES
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 45247f2..99fc32a 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -4348,7 +4348,7 @@ static void write_superres_scale(const AV1_COMMON *const cm, struct aom_write_bit_buffer *wb) { // First bit is whether to to scale or not - if (cm->superres_scale_numerator == SUPERRES_SCALE_DENOMINATOR) { + if (cm->superres_scale_numerator == SCALE_DENOMINATOR) { aom_wb_write_bit(wb, 0); // no scaling } else { aom_wb_write_bit(wb, 1); // scaling, write scale factor
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index a4473f8..9655823 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -2458,7 +2458,7 @@ av1_loop_filter_init(cm); #if CONFIG_FRAME_SUPERRES - cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR; + cm->superres_scale_numerator = SCALE_DENOMINATOR; cm->superres_upscaled_width = oxcf->width; cm->superres_upscaled_height = oxcf->height; #endif // CONFIG_FRAME_SUPERRES @@ -3849,8 +3849,7 @@ int encode_height = cpi->oxcf.height; uint8_t resize_num = av1_calculate_next_resize_scale(cpi); - av1_calculate_scaled_size(&encode_width, &encode_height, resize_num, - RESIZE_SCALE_DENOMINATOR); + av1_calculate_scaled_size(&encode_width, &encode_height, resize_num); #if CONFIG_FRAME_SUPERRES AV1_COMMON *cm = &cpi->common; @@ -3859,8 +3858,7 @@ cm->superres_scale_numerator = av1_calculate_next_superres_scale(cpi, encode_width, encode_width); av1_calculate_scaled_size(&encode_width, &encode_height, - cm->superres_scale_numerator, - SUPERRES_SCALE_DENOMINATOR); + cm->superres_scale_numerator); #endif // CONFIG_FRAME_SUPERRES set_frame_size(cpi, encode_width, encode_height);
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c index 9cbf1fe..7c1b972 100644 --- a/av1/encoder/ratectrl.c +++ b/av1/encoder/ratectrl.c
@@ -1672,11 +1672,11 @@ uint8_t av1_calculate_next_resize_scale(const AV1_COMP *cpi) { static unsigned int seed = 56789; const AV1EncoderConfig *oxcf = &cpi->oxcf; - if (oxcf->pass == 1) return RESIZE_SCALE_DENOMINATOR; - uint8_t new_num = RESIZE_SCALE_DENOMINATOR; + if (oxcf->pass == 1) return SCALE_DENOMINATOR; + uint8_t new_num = SCALE_DENOMINATOR; switch (oxcf->resize_mode) { - case RESIZE_NONE: new_num = RESIZE_SCALE_DENOMINATOR; break; + case RESIZE_NONE: new_num = SCALE_DENOMINATOR; break; case RESIZE_FIXED: new_num = oxcf->resize_scale_numerator; break; case RESIZE_DYNAMIC: // RESIZE_DYNAMIC: Just random for now. @@ -1693,11 +1693,11 @@ int height) { static unsigned int seed = 34567; const AV1EncoderConfig *oxcf = &cpi->oxcf; - if (oxcf->pass == 1) return SUPERRES_SCALE_DENOMINATOR; - uint8_t new_num = SUPERRES_SCALE_DENOMINATOR; + if (oxcf->pass == 1) return SCALE_DENOMINATOR; + uint8_t new_num = SCALE_DENOMINATOR; switch (oxcf->superres_mode) { - case SUPERRES_NONE: new_num = SUPERRES_SCALE_DENOMINATOR; break; + case SUPERRES_NONE: new_num = SCALE_DENOMINATOR; break; case SUPERRES_FIXED: new_num = oxcf->superres_scale_numerator; break; case SUPERRES_DYNAMIC: // SUPERRES_DYNAMIC: Just random for now. @@ -1707,9 +1707,9 @@ } // Make sure overall reduction is no more than 1/2 of the source size. - if (new_num * width / SUPERRES_SCALE_DENOMINATOR * 2 < oxcf->width || - new_num * height / SUPERRES_SCALE_DENOMINATOR * 2 < oxcf->height) - new_num = SUPERRES_SCALE_DENOMINATOR; + if (new_num * width / SCALE_DENOMINATOR * 2 < oxcf->width || + new_num * height / SCALE_DENOMINATOR * 2 < oxcf->height) + new_num = SCALE_DENOMINATOR; return new_num; }