scaling: Add kf numerator for resize and superres
Adds a separate scale numerator for resize and superres scaling on keyframes. They will only use this factor in their respective FIXED modes. Change-Id: I4ef9a5760a5423ec632d644e6c7fec674bbb46f4
This commit is contained in:
Родитель
6d99b21b79
Коммит
87cf61b11e
|
@ -380,6 +380,14 @@ typedef struct aom_codec_enc_cfg {
|
|||
*/
|
||||
unsigned int rc_resize_numerator;
|
||||
|
||||
/*!\brief Keyframe resize numerator.
|
||||
*
|
||||
* The numerator for resize to use, assuming 16 as the denominator.
|
||||
*
|
||||
* Valid numerators are 8 - 16 for now.
|
||||
*/
|
||||
unsigned int rc_resize_kf_numerator;
|
||||
|
||||
/*!\brief Frame super-resolution scaling mode.
|
||||
*
|
||||
* Similar to spatial resampling, frame super-resolution integrates
|
||||
|
@ -403,6 +411,16 @@ typedef struct aom_codec_enc_cfg {
|
|||
*/
|
||||
unsigned int rc_superres_numerator;
|
||||
|
||||
/*!\brief Keyframe super-resolution numerator.
|
||||
*
|
||||
* The numerator for superres to use. If fixed it will only change if the
|
||||
* cumulative scale change over resizing and superres is greater than 1/2;
|
||||
* this forces superres to reduce scaling.
|
||||
*
|
||||
* Valid numerators are 8 - 16 for now.
|
||||
*/
|
||||
unsigned int rc_superres_kf_numerator;
|
||||
|
||||
/*!\brief Rate control algorithm to use.
|
||||
*
|
||||
* Indicates whether the end usage of this stream is to be streamed over
|
||||
|
|
|
@ -258,10 +258,14 @@ 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, SCALE_DENOMINATOR / 2,
|
||||
SCALE_DENOMINATOR);
|
||||
RANGE_CHECK(cfg, rc_resize_kf_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, SCALE_DENOMINATOR / 2,
|
||||
SCALE_DENOMINATOR);
|
||||
RANGE_CHECK(cfg, rc_superres_kf_numerator, SCALE_DENOMINATOR / 2,
|
||||
SCALE_DENOMINATOR);
|
||||
#endif // CONFIG_FRAME_SUPERRES
|
||||
|
||||
// AV1 does not support a lower bound on the keyframe interval in
|
||||
|
@ -490,15 +494,19 @@ 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;
|
||||
oxcf->resize_kf_scale_numerator = (uint8_t)cfg->rc_resize_kf_numerator;
|
||||
if (oxcf->resize_mode == RESIZE_FIXED &&
|
||||
oxcf->resize_scale_numerator == SCALE_DENOMINATOR)
|
||||
oxcf->resize_scale_numerator == SCALE_DENOMINATOR &&
|
||||
oxcf->resize_kf_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;
|
||||
oxcf->superres_kf_scale_numerator = (uint8_t)cfg->rc_superres_kf_numerator;
|
||||
if (oxcf->superres_mode == SUPERRES_FIXED &&
|
||||
oxcf->superres_scale_numerator == SCALE_DENOMINATOR)
|
||||
oxcf->superres_scale_numerator == SCALE_DENOMINATOR &&
|
||||
oxcf->superres_kf_scale_numerator == SCALE_DENOMINATOR)
|
||||
oxcf->superres_mode = SUPERRES_NONE;
|
||||
#endif // CONFIG_FRAME_SUPERRES
|
||||
|
||||
|
@ -1586,9 +1594,11 @@ static aom_codec_enc_cfg_map_t encoder_usage_cfg_map[] = {
|
|||
0, // rc_dropframe_thresh
|
||||
RESIZE_NONE, // rc_resize_mode
|
||||
SCALE_DENOMINATOR, // rc_resize_numerator
|
||||
SCALE_DENOMINATOR, // rc_resize_kf_numerator
|
||||
|
||||
0, // rc_superres_mode
|
||||
SCALE_DENOMINATOR, // rc_superres_numerator
|
||||
SCALE_DENOMINATOR, // rc_superres_kf_numerator
|
||||
|
||||
AOM_VBR, // rc_end_usage
|
||||
{ NULL, 0 }, // rc_twopass_stats_in
|
||||
|
|
|
@ -306,6 +306,7 @@ typedef struct AV1Common {
|
|||
#if CONFIG_FRAME_SUPERRES
|
||||
// The numerator of the superres scale; the denominator is fixed.
|
||||
uint8_t superres_scale_numerator;
|
||||
uint8_t superres_kf_scale_numerator;
|
||||
int superres_upscaled_width;
|
||||
int superres_upscaled_height;
|
||||
#endif // CONFIG_FRAME_SUPERRES
|
||||
|
|
|
@ -213,11 +213,13 @@ typedef struct AV1EncoderConfig {
|
|||
// Internal frame size scaling.
|
||||
RESIZE_MODE resize_mode;
|
||||
uint8_t resize_scale_numerator;
|
||||
uint8_t resize_kf_scale_numerator;
|
||||
|
||||
#if CONFIG_FRAME_SUPERRES
|
||||
// Frame Super-Resolution size scaling.
|
||||
SUPERRES_MODE superres_mode;
|
||||
uint8_t superres_scale_numerator;
|
||||
uint8_t superres_kf_scale_numerator;
|
||||
#endif // CONFIG_FRAME_SUPERRES
|
||||
|
||||
// Enable feature to reduce the frame quantization every x frames.
|
||||
|
|
|
@ -1677,7 +1677,12 @@ uint8_t av1_calculate_next_resize_scale(const AV1_COMP *cpi) {
|
|||
|
||||
switch (oxcf->resize_mode) {
|
||||
case RESIZE_NONE: new_num = SCALE_DENOMINATOR; break;
|
||||
case RESIZE_FIXED: new_num = oxcf->resize_scale_numerator; break;
|
||||
case RESIZE_FIXED:
|
||||
if (cpi->common.frame_type == KEY_FRAME)
|
||||
new_num = oxcf->resize_kf_scale_numerator;
|
||||
else
|
||||
new_num = oxcf->resize_scale_numerator;
|
||||
break;
|
||||
case RESIZE_DYNAMIC:
|
||||
// RESIZE_DYNAMIC: Just random for now.
|
||||
new_num = lcg_rand16(&seed) % 4 + 13;
|
||||
|
@ -1698,7 +1703,12 @@ uint8_t av1_calculate_next_superres_scale(const AV1_COMP *cpi, int width,
|
|||
|
||||
switch (oxcf->superres_mode) {
|
||||
case SUPERRES_NONE: new_num = SCALE_DENOMINATOR; break;
|
||||
case SUPERRES_FIXED: new_num = oxcf->superres_scale_numerator; break;
|
||||
case SUPERRES_FIXED:
|
||||
if (cpi->common.frame_type == KEY_FRAME)
|
||||
new_num = oxcf->superres_kf_scale_numerator;
|
||||
else
|
||||
new_num = oxcf->superres_scale_numerator;
|
||||
break;
|
||||
case SUPERRES_DYNAMIC:
|
||||
// SUPERRES_DYNAMIC: Just random for now.
|
||||
new_num = lcg_rand16(&seed) % 9 + 8;
|
||||
|
|
Загрузка…
Ссылка в новой задаче