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
This commit is contained in:
Fergus Simpson 2017-06-14 23:13:12 -07:00
Родитель 315f5784dd
Коммит bfbf6a5983
9 изменённых файлов: 37 добавлений и 40 удалений

Просмотреть файл

@ -256,12 +256,12 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
}
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 @@ static aom_codec_err_t set_encoder_config(
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 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
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

Просмотреть файл

@ -546,8 +546,7 @@ typedef enum {
} 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

Просмотреть файл

@ -1041,7 +1041,7 @@ void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd, int plane,
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 @@ void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd, int plane,
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 @@ static void build_inter_predictors_single_buf(MACROBLOCKD *xd, int plane,
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;

Просмотреть файл

@ -882,9 +882,9 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
}
}
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

Просмотреть файл

@ -79,13 +79,14 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
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

Просмотреть файл

@ -3087,11 +3087,10 @@ static void setup_superres(AV1_COMMON *const cm, struct aom_read_bit_buffer *rb,
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

Просмотреть файл

@ -4348,7 +4348,7 @@ static void write_render_size(const AV1_COMMON *cm,
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

Просмотреть файл

@ -2458,7 +2458,7 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
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 @@ static void setup_frame_size(AV1_COMP *cpi) {
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 @@ static void setup_frame_size(AV1_COMP *cpi) {
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);

Просмотреть файл

@ -1672,11 +1672,11 @@ static unsigned int lcg_rand16(unsigned int *state) {
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 @@ uint8_t av1_calculate_next_superres_scale(const AV1_COMP *cpi, int width,
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 @@ uint8_t av1_calculate_next_superres_scale(const AV1_COMP *cpi, int width,
}
// 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;
}