Commit 29e40a65 authored by Debargha Mukherjee's avatar Debargha Mukherjee
Browse files

Unify and clean up resize arguments

Unifies the command line arguments for resize and superes.
Removes resize arguments that are currently unused.

Change-Id: I1362dffceb8257cee539f92679d1e8d79df08e66
parent c4e78942
...@@ -363,44 +363,22 @@ typedef struct aom_codec_enc_cfg { ...@@ -363,44 +363,22 @@ typedef struct aom_codec_enc_cfg {
*/ */
unsigned int rc_dropframe_thresh; unsigned int rc_dropframe_thresh;
/*!\brief Enable/disable spatial resampling, if supported by the codec. /*!\brief Mode for spatial resampling, if supported by the codec.
* *
* Spatial resampling allows the codec to compress a lower resolution * Spatial resampling allows the codec to compress a lower resolution
* version of the frame, which is then upscaled by the encoder to the * version of the frame, which is then upscaled by the decoder to the
* correct presentation resolution. This increases visual quality at * correct presentation resolution. This increases visual quality at
* low data rates, at the expense of CPU time on the encoder/decoder. * low data rates, at the expense of CPU time on the encoder/decoder.
*/ */
unsigned int rc_resize_allowed; unsigned int rc_resize_mode;
/*!\brief Internal coded frame width. /*!\brief Frame resize numerator.
* *
* If spatial resampling is enabled this specifies the width of the * The numerator for resize to use, assuming 16 as the denominator.
* encoded frame.
*/
unsigned int rc_scaled_width;
/*!\brief Internal coded frame height.
*
* If spatial resampling is enabled this specifies the height of the
* encoded frame.
*/
unsigned int rc_scaled_height;
/*!\brief Spatial resampling up watermark.
* *
* This threshold is described as a percentage of the target data buffer. * Valid numerators are 8 - 16 for now.
* When the data buffer rises above this percentage of fullness, the
* encoder will step up to a higher resolution version of the frame.
*/
unsigned int rc_resize_up_thresh;
/*!\brief Spatial resampling down watermark.
*
* This threshold is described as a percentage of the target data buffer.
* When the data buffer falls below this percentage of fullness, the
* encoder will step down to a lower resolution version of the frame.
*/ */
unsigned int rc_resize_down_thresh; unsigned int rc_resize_numerator;
/*!\brief Frame super-resolution scaling mode. /*!\brief Frame super-resolution scaling mode.
* *
......
...@@ -271,16 +271,10 @@ static const arg_def_t *global_args[] = { ...@@ -271,16 +271,10 @@ static const arg_def_t *global_args[] = {
static const arg_def_t dropframe_thresh = static const arg_def_t dropframe_thresh =
ARG_DEF(NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)"); ARG_DEF(NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)");
static const arg_def_t resize_allowed = static const arg_def_t resize_mode =
ARG_DEF(NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)"); ARG_DEF(NULL, "resize-mode", 1, "Frame resize mode");
static const arg_def_t resize_width = static const arg_def_t resize_numerator =
ARG_DEF(NULL, "resize-width", 1, "Width of encoded frame"); ARG_DEF(NULL, "resize-numerator", 1, "Frame resize numerator");
static const arg_def_t resize_height =
ARG_DEF(NULL, "resize-height", 1, "Height of encoded frame");
static const arg_def_t resize_up_thresh =
ARG_DEF(NULL, "resize-up", 1, "Upscale threshold (buf %)");
static const arg_def_t resize_down_thresh =
ARG_DEF(NULL, "resize-down", 1, "Downscale threshold (buf %)");
static const struct arg_enum_list end_usage_enum[] = { { "vbr", AOM_VBR }, static const struct arg_enum_list end_usage_enum[] = { { "vbr", AOM_VBR },
{ "cbr", AOM_CBR }, { "cbr", AOM_CBR },
{ "cq", AOM_CQ }, { "cq", AOM_CQ },
...@@ -310,9 +304,8 @@ static const arg_def_t buf_initial_sz = ...@@ -310,9 +304,8 @@ static const arg_def_t buf_initial_sz =
ARG_DEF(NULL, "buf-initial-sz", 1, "Client initial buffer size (ms)"); ARG_DEF(NULL, "buf-initial-sz", 1, "Client initial buffer size (ms)");
static const arg_def_t buf_optimal_sz = static const arg_def_t buf_optimal_sz =
ARG_DEF(NULL, "buf-optimal-sz", 1, "Client optimal buffer size (ms)"); ARG_DEF(NULL, "buf-optimal-sz", 1, "Client optimal buffer size (ms)");
static const arg_def_t *rc_args[] = { &dropframe_thresh, &resize_allowed, static const arg_def_t *rc_args[] = { &dropframe_thresh, &resize_mode,
&resize_width, &resize_height, &resize_numerator,
&resize_up_thresh, &resize_down_thresh,
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
&superres_mode, &superres_numerator, &superres_mode, &superres_numerator,
#endif // CONFIG_FRAME_SUPERRES #endif // CONFIG_FRAME_SUPERRES
...@@ -1012,16 +1005,10 @@ static int parse_stream_params(struct AvxEncoderConfig *global, ...@@ -1012,16 +1005,10 @@ static int parse_stream_params(struct AvxEncoderConfig *global,
config->cfg.g_lag_in_frames = arg_parse_uint(&arg); config->cfg.g_lag_in_frames = arg_parse_uint(&arg);
} else if (arg_match(&arg, &dropframe_thresh, argi)) { } else if (arg_match(&arg, &dropframe_thresh, argi)) {
config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg); config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_allowed, argi)) { } else if (arg_match(&arg, &resize_mode, argi)) {
config->cfg.rc_resize_allowed = arg_parse_uint(&arg); config->cfg.rc_resize_mode = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_width, argi)) { } else if (arg_match(&arg, &resize_numerator, argi)) {
config->cfg.rc_scaled_width = arg_parse_uint(&arg); config->cfg.rc_resize_numerator = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_height, argi)) {
config->cfg.rc_scaled_height = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_up_thresh, argi)) {
config->cfg.rc_resize_up_thresh = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_down_thresh, argi)) {
config->cfg.rc_resize_down_thresh = arg_parse_uint(&arg);
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
} else if (arg_match(&arg, &superres_mode, argi)) { } else if (arg_match(&arg, &superres_mode, argi)) {
config->cfg.rc_superres_mode = arg_parse_uint(&arg); config->cfg.rc_superres_mode = arg_parse_uint(&arg);
...@@ -1233,11 +1220,8 @@ static void show_stream_config(struct stream_state *stream, ...@@ -1233,11 +1220,8 @@ static void show_stream_config(struct stream_state *stream,
SHOW(g_pass); SHOW(g_pass);
SHOW(g_lag_in_frames); SHOW(g_lag_in_frames);
SHOW(rc_dropframe_thresh); SHOW(rc_dropframe_thresh);
SHOW(rc_resize_allowed); SHOW(rc_resize_mode);
SHOW(rc_scaled_width); SHOW(rc_resize_numerator);
SHOW(rc_scaled_height);
SHOW(rc_resize_up_thresh);
SHOW(rc_resize_down_thresh);
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
SHOW(rc_superres_mode); SHOW(rc_superres_mode);
SHOW(rc_superres_numerator); SHOW(rc_superres_numerator);
......
...@@ -243,10 +243,7 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, ...@@ -243,10 +243,7 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100); RANGE_CHECK_HI(cfg, rc_overshoot_pct, 100);
RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100);
RANGE_CHECK(cfg, kf_mode, AOM_KF_DISABLED, AOM_KF_AUTO); RANGE_CHECK(cfg, kf_mode, AOM_KF_DISABLED, AOM_KF_AUTO);
RANGE_CHECK_BOOL(cfg, rc_resize_allowed);
RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100);
RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100);
RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
RANGE_CHECK(cfg, g_pass, AOM_RC_ONE_PASS, AOM_RC_LAST_PASS); RANGE_CHECK(cfg, g_pass, AOM_RC_ONE_PASS, AOM_RC_LAST_PASS);
RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1); RANGE_CHECK_HI(extra_cfg, min_gf_interval, MAX_LAG_BUFFERS - 1);
RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1); RANGE_CHECK_HI(extra_cfg, max_gf_interval, MAX_LAG_BUFFERS - 1);
...@@ -258,11 +255,9 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx, ...@@ -258,11 +255,9 @@ static aom_codec_err_t validate_config(aom_codec_alg_priv_t *ctx,
(MAX_LAG_BUFFERS - 1)); (MAX_LAG_BUFFERS - 1));
} }
if (cfg->rc_resize_allowed == 1) { RANGE_CHECK_HI(cfg, rc_resize_mode, RESIZE_DYNAMIC);
RANGE_CHECK_HI(cfg, rc_scaled_width, cfg->g_w); RANGE_CHECK(cfg, rc_resize_numerator, RESIZE_SCALE_DENOMINATOR / 2,
RANGE_CHECK_HI(cfg, rc_scaled_height, cfg->g_h); RESIZE_SCALE_DENOMINATOR);
}
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
RANGE_CHECK_HI(cfg, rc_superres_mode, SUPERRES_DYNAMIC); RANGE_CHECK_HI(cfg, rc_superres_mode, SUPERRES_DYNAMIC);
RANGE_CHECK(cfg, rc_superres_numerator, SUPERRES_SCALE_DENOMINATOR / 2, RANGE_CHECK(cfg, rc_superres_numerator, SUPERRES_SCALE_DENOMINATOR / 2,
...@@ -493,22 +488,11 @@ static aom_codec_err_t set_encoder_config( ...@@ -493,22 +488,11 @@ static aom_codec_err_t set_encoder_config(
oxcf->under_shoot_pct = cfg->rc_undershoot_pct; oxcf->under_shoot_pct = cfg->rc_undershoot_pct;
oxcf->over_shoot_pct = cfg->rc_overshoot_pct; oxcf->over_shoot_pct = cfg->rc_overshoot_pct;
oxcf->scaled_frame_width = cfg->rc_scaled_width; oxcf->resize_mode = (RESIZE_MODE)cfg->rc_resize_mode;
oxcf->scaled_frame_height = cfg->rc_scaled_height; oxcf->resize_scale_numerator = (uint8_t)cfg->rc_resize_numerator;
if (cfg->rc_resize_allowed == 1) { if (oxcf->resize_mode == RESIZE_FIXED &&
oxcf->resize_mode = oxcf->resize_scale_numerator == RESIZE_SCALE_DENOMINATOR)
(oxcf->scaled_frame_width == 0 || oxcf->scaled_frame_height == 0)
? RESIZE_DYNAMIC
: RESIZE_FIXED;
} else {
oxcf->resize_mode = RESIZE_NONE; oxcf->resize_mode = RESIZE_NONE;
}
// Initialize to input resolution if not specified.
if (oxcf->resize_mode != RESIZE_FIXED) {
oxcf->scaled_frame_width = oxcf->width;
oxcf->scaled_frame_height = oxcf->height;
}
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
oxcf->superres_mode = (SUPERRES_MODE)cfg->rc_superres_mode; oxcf->superres_mode = (SUPERRES_MODE)cfg->rc_superres_mode;
...@@ -1599,12 +1583,9 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { ...@@ -1599,12 +1583,9 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
25, // g_lag_in_frames 25, // g_lag_in_frames
0, // rc_dropframe_thresh 0, // rc_dropframe_thresh
0, // rc_resize_allowed RESIZE_NONE, // rc_resize_mode
0, // rc_scaled_width RESIZE_SCALE_DENOMINATOR, // rc_resize_numerator
0, // rc_scaled_height
60, // rc_resize_down_thresold
30, // rc_resize_up_thresold
0, // rc_superres_mode 0, // rc_superres_mode
SUPERRES_SCALE_DENOMINATOR, // rc_superres_numerator SUPERRES_SCALE_DENOMINATOR, // rc_superres_numerator
......
...@@ -546,7 +546,9 @@ typedef enum { ...@@ -546,7 +546,9 @@ typedef enum {
} RestorationType; } RestorationType;
#endif // CONFIG_LOOP_RESTORATION #endif // CONFIG_LOOP_RESTORATION
#define RESIZE_SCALE_DENOMINATOR 16
#define SUPERRES_SCALE_DENOMINATOR 16 #define SUPERRES_SCALE_DENOMINATOR 16
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
#define SUPERRES_SCALE_BITS 3 #define SUPERRES_SCALE_BITS 3
#define SUPERRES_SCALE_NUMERATOR_MIN 8 #define SUPERRES_SCALE_NUMERATOR_MIN 8
......
...@@ -882,13 +882,12 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm, ...@@ -882,13 +882,12 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
} }
} }
#if CONFIG_FRAME_SUPERRES void av1_calculate_scaled_size(int *width, int *height, int num, int den) {
void av1_calculate_superres_size(const AV1_COMMON *cm, int *width, *width = *width * num / den;
int *height) { *height = *height * num / den;
*width = *width * cm->superres_scale_numerator / SUPERRES_SCALE_DENOMINATOR;
*height = *height * cm->superres_scale_numerator / SUPERRES_SCALE_DENOMINATOR;
} }
#if CONFIG_FRAME_SUPERRES
// TODO(afergs): Look for in-place upscaling // TODO(afergs): Look for in-place upscaling
// TODO(afergs): aom_ vs av1_ functions? Which can I use? // TODO(afergs): aom_ vs av1_ functions? Which can I use?
// Upscale decoded image. // Upscale decoded image.
......
...@@ -79,12 +79,8 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm, ...@@ -79,12 +79,8 @@ YV12_BUFFER_CONFIG *av1_scale_if_required(AV1_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled, YV12_BUFFER_CONFIG *unscaled,
YV12_BUFFER_CONFIG *scaled); YV12_BUFFER_CONFIG *scaled);
void av1_calculate_scaled_size(int *width, int *height, int num, int den);
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
// This is the size after superress scaling, which could be 1:1.
// Superres scaling happens after regular downscaling.
// TODO(afergs): Limit overall reduction to 1/2 of the original size
void av1_calculate_superres_size(const AV1_COMMON *cm, int *width, int *height);
void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool); void av1_superres_upscale(AV1_COMMON *cm, BufferPool *const pool);
// Returns 1 if a superres upscaled frame is unscaled and 0 otherwise. // Returns 1 if a superres upscaled frame is unscaled and 0 otherwise.
......
...@@ -3078,7 +3078,8 @@ static void setup_superres(AV1_COMMON *const cm, struct aom_read_bit_buffer *rb, ...@@ -3078,7 +3078,8 @@ static void setup_superres(AV1_COMMON *const cm, struct aom_read_bit_buffer *rb,
cm->superres_scale_numerator += SUPERRES_SCALE_NUMERATOR_MIN; cm->superres_scale_numerator += SUPERRES_SCALE_NUMERATOR_MIN;
// Don't edit cm->width or cm->height directly, or the buffers won't get // Don't edit cm->width or cm->height directly, or the buffers won't get
// resized correctly // resized correctly
av1_calculate_superres_size(cm, width, height); av1_calculate_scaled_size(width, height, cm->superres_scale_numerator,
SUPERRES_SCALE_DENOMINATOR);
} else { } else {
// 1:1 scaling - ie. no scaling, scale not provided // 1:1 scaling - ie. no scaling, scale not provided
cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR; cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
......
...@@ -2459,8 +2459,8 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf, ...@@ -2459,8 +2459,8 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
av1_loop_filter_init(cm); av1_loop_filter_init(cm);
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR; cm->superres_scale_numerator = SUPERRES_SCALE_DENOMINATOR;
cm->superres_upscaled_width = oxcf->scaled_frame_width; cm->superres_upscaled_width = oxcf->width;
cm->superres_upscaled_height = oxcf->scaled_frame_height; cm->superres_upscaled_height = oxcf->height;
#endif // CONFIG_FRAME_SUPERRES #endif // CONFIG_FRAME_SUPERRES
#if CONFIG_LOOP_RESTORATION #if CONFIG_LOOP_RESTORATION
av1_loop_restoration_precal(); av1_loop_restoration_precal();
...@@ -3845,21 +3845,22 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) { ...@@ -3845,21 +3845,22 @@ static void set_frame_size(AV1_COMP *cpi, int width, int height) {
} }
static void setup_frame_size(AV1_COMP *cpi) { static void setup_frame_size(AV1_COMP *cpi) {
int encode_width; int encode_width = cpi->oxcf.width;
int encode_height; int encode_height = cpi->oxcf.height;
av1_calculate_next_scaled_size(cpi, &encode_width, &encode_height); uint8_t resize_num = av1_calculate_next_resize_scale(cpi);
printf("encode size: %dx%d ", encode_width, encode_height); av1_calculate_scaled_size(&encode_width, &encode_height, resize_num,
RESIZE_SCALE_DENOMINATOR);
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
AV1_COMMON *cm = &cpi->common; AV1_COMMON *cm = &cpi->common;
cm->superres_upscaled_width = encode_width; cm->superres_upscaled_width = encode_width;
cm->superres_upscaled_height = encode_height; cm->superres_upscaled_height = encode_height;
cm->superres_scale_numerator = (uint8_t)av1_calculate_next_superres_scale( cm->superres_scale_numerator =
cpi, encode_width, encode_width); av1_calculate_next_superres_scale(cpi, encode_width, encode_width);
av1_calculate_superres_size(cm, &encode_width, &encode_height); av1_calculate_scaled_size(&encode_width, &encode_height,
// printf("Resize/superres %d x %d -> %d x %d\n", encode_width, encode_height, cm->superres_scale_numerator,
// cm->superres_upscaled_width, cm->superres_upscaled_height); SUPERRES_SCALE_DENOMINATOR);
printf("superres numerator: %02d ", cm->superres_scale_numerator); printf("superres numerator: %02d ", cm->superres_scale_numerator);
#endif // CONFIG_FRAME_SUPERRES #endif // CONFIG_FRAME_SUPERRES
printf("Final encode size: %dx%d\n", encode_width, encode_height); printf("Final encode size: %dx%d\n", encode_width, encode_height);
......
...@@ -129,7 +129,7 @@ typedef enum { ...@@ -129,7 +129,7 @@ typedef enum {
RESIZE_NONE = 0, // No frame resizing allowed. RESIZE_NONE = 0, // No frame resizing allowed.
RESIZE_FIXED = 1, // All frames are coded at the specified dimension. RESIZE_FIXED = 1, // All frames are coded at the specified dimension.
RESIZE_DYNAMIC = 2 // Coded size of each frame is determined by the codec. RESIZE_DYNAMIC = 2 // Coded size of each frame is determined by the codec.
} RESIZE_TYPE; } RESIZE_MODE;
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
typedef enum { typedef enum {
SUPERRES_NONE = 0, SUPERRES_NONE = 0,
...@@ -207,9 +207,8 @@ typedef struct AV1EncoderConfig { ...@@ -207,9 +207,8 @@ typedef struct AV1EncoderConfig {
unsigned int disable_tempmv; unsigned int disable_tempmv;
#endif #endif
// Internal frame size scaling. // Internal frame size scaling.
RESIZE_TYPE resize_mode; RESIZE_MODE resize_mode;
int scaled_frame_width; uint8_t resize_scale_numerator;
int scaled_frame_height;
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
// Frame Super-Resolution size scaling. // Frame Super-Resolution size scaling.
......
...@@ -1669,44 +1669,35 @@ static unsigned int lcg_rand16(unsigned int *state) { ...@@ -1669,44 +1669,35 @@ static unsigned int lcg_rand16(unsigned int *state) {
return *state / 65536 % 32768; return *state / 65536 % 32768;
} }
void av1_calculate_next_scaled_size(AV1_COMP *cpi, int *width, int *height) { uint8_t av1_calculate_next_resize_scale(const AV1_COMP *cpi) {
static unsigned int seed = 56789; static unsigned int seed = 56789;
AV1EncoderConfig *oxcf = &cpi->oxcf; const AV1EncoderConfig *oxcf = &cpi->oxcf;
// TODO(afergs): Get width from frame instead? if (oxcf->pass == 1) return RESIZE_SCALE_DENOMINATOR;
*width = oxcf->width; uint8_t new_num = RESIZE_SCALE_DENOMINATOR;
*height = oxcf->height;
if (oxcf->pass == 1) return; switch (oxcf->resize_mode) {
case RESIZE_NONE: new_num = RESIZE_SCALE_DENOMINATOR; break;
if (oxcf->resize_mode == RESIZE_FIXED) { case RESIZE_FIXED: new_num = oxcf->resize_scale_numerator; break;
*width = oxcf->scaled_frame_width; case RESIZE_DYNAMIC:
*height = oxcf->scaled_frame_height; // RESIZE_DYNAMIC: Just random for now.
return; new_num = lcg_rand16(&seed) % 4 + 13;
} break;
if (oxcf->resize_mode == RESIZE_DYNAMIC) { default: assert(0);
// NOTE: RESIZE_DYNAMIC defaults to random now.
if (oxcf->pass == 2 || oxcf->pass == 0) {
int scale_num = lcg_rand16(&seed) % 4 + 13;
int scale_den = 16;
if (!(cpi->oxcf.width * scale_num / scale_den * 2 < oxcf->width ||
cpi->oxcf.height * scale_num / scale_den * 2 < oxcf->height)) {
*width = cpi->oxcf.width * scale_num / scale_den;
*height = cpi->oxcf.height * scale_num / scale_den;
}
}
} }
return new_num;
} }
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
// TODO(afergs): Rename av1_rc_update_superres_scale(...)? // TODO(afergs): Rename av1_rc_update_superres_scale(...)?
int av1_calculate_next_superres_scale(const AV1_COMP *cpi, int width, uint8_t av1_calculate_next_superres_scale(const AV1_COMP *cpi, int width,
int height) { int height) {
static unsigned int seed = 34567; static unsigned int seed = 34567;
const AV1EncoderConfig *oxcf = &cpi->oxcf; const AV1EncoderConfig *oxcf = &cpi->oxcf;
if (oxcf->pass == 1) return SUPERRES_SCALE_DENOMINATOR; if (oxcf->pass == 1) return SUPERRES_SCALE_DENOMINATOR;
uint8_t new_num = cpi->common.superres_scale_numerator; uint8_t new_num = SUPERRES_SCALE_DENOMINATOR;
switch (oxcf->superres_mode) { switch (oxcf->superres_mode) {
case SUPERRES_NONE: return SUPERRES_SCALE_DENOMINATOR; break; case SUPERRES_NONE: new_num = SUPERRES_SCALE_DENOMINATOR; break;
case SUPERRES_FIXED: new_num = oxcf->superres_scale_numerator; break; case SUPERRES_FIXED: new_num = oxcf->superres_scale_numerator; break;
case SUPERRES_DYNAMIC: case SUPERRES_DYNAMIC:
// SUPERRES_DYNAMIC: Just random for now. // SUPERRES_DYNAMIC: Just random for now.
......
...@@ -256,11 +256,10 @@ void av1_set_target_rate(struct AV1_COMP *cpi); ...@@ -256,11 +256,10 @@ void av1_set_target_rate(struct AV1_COMP *cpi);
int av1_resize_one_pass_cbr(struct AV1_COMP *cpi); int av1_resize_one_pass_cbr(struct AV1_COMP *cpi);
void av1_calculate_next_scaled_size(struct AV1_COMP *cpi, int *width, uint8_t av1_calculate_next_resize_scale(const struct AV1_COMP *cpi);
int *height);
#if CONFIG_FRAME_SUPERRES #if CONFIG_FRAME_SUPERRES
int av1_calculate_next_superres_scale(const struct AV1_COMP *cpi, int width, uint8_t av1_calculate_next_superres_scale(const struct AV1_COMP *cpi, int width,
int height); int height);
#endif // CONFIG_FRAME_SUPERRES #endif // CONFIG_FRAME_SUPERRES
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
...@@ -108,7 +108,7 @@ TEST_P(ActiveMapRefreshTest, Test) { ...@@ -108,7 +108,7 @@ TEST_P(ActiveMapRefreshTest, Test) {
cfg_.g_lag_in_frames = 0; cfg_.g_lag_in_frames = 0;
cfg_.g_profile = 1; cfg_.g_profile = 1;
cfg_.rc_target_bitrate = 600; cfg_.rc_target_bitrate = 600;
cfg_.rc_resize_allowed = 0; cfg_.rc_resize_mode = 0;
cfg_.rc_min_quantizer = 8; cfg_.rc_min_quantizer = 8;
cfg_.rc_max_quantizer = 30; cfg_.rc_max_quantizer = 30;
cfg_.g_pass = AOM_RC_ONE_PASS; cfg_.g_pass = AOM_RC_ONE_PASS;
......
...@@ -73,7 +73,7 @@ class ActiveMapTest ...@@ -73,7 +73,7 @@ class ActiveMapTest
// Validate that this non multiple of 64 wide clip encodes // Validate that this non multiple of 64 wide clip encodes
cfg_.g_lag_in_frames = 0; cfg_.g_lag_in_frames = 0;
cfg_.rc_target_bitrate = 400; cfg_.rc_target_bitrate = 400;
cfg_.rc_resize_allowed = 0; cfg_.rc_resize_mode = 0;
cfg_.g_pass = AOM_RC_ONE_PASS; cfg_.g_pass = AOM_RC_ONE_PASS;
cfg_.rc_end_usage = AOM_CBR; cfg_.rc_end_usage = AOM_CBR;
cfg_.kf_max_dist = 90000; cfg_.kf_max_dist = 90000;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment