Change: vaq requires parameter. Parameter defines vaq strength ex. 15 == 1.5

This commit is contained in:
Kari Siivonen (TAU) 2020-02-07 19:45:41 +02:00 committed by siivonek
parent bf1b2c1e22
commit be2f420d61
3 changed files with 9 additions and 9 deletions

View file

@ -138,7 +138,7 @@ int kvz_config_init(kvz_config *cfg)
cfg->me_max_steps = (uint32_t)-1;
cfg->vaq = false;
cfg->vaq = 0;
cfg->scaling_list = KVZ_SCALING_LIST_OFF;
@ -1250,7 +1250,7 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
else if (OPT("fast-residual-cost"))
cfg->fast_residual_cost_limit = atoi(value);
else if (OPT("vaq")) {
cfg->vaq = (bool)atobool(value);
cfg->vaq = (int)atoi(value);
}
else if (OPT("max-merge")) {
int max_merge = atoi(value);
@ -1396,6 +1396,11 @@ int kvz_config_validate(const kvz_config *const cfg)
{
int error = 0;
if (cfg->vaq < 0) {
fprintf(stderr, "vaq strength must be positive\n");
error = 1;
}
if (cfg->width <= 0) {
fprintf(stderr, "Input error: width must be positive\n");
error = 1;

View file

@ -133,7 +133,7 @@ static const struct option long_options[] = {
{ "set-qp-in-cu", no_argument, NULL, 0 },
{ "open-gop", no_argument, NULL, 0 },
{ "no-open-gop", no_argument, NULL, 0 },
{ "vaq", no_argument, NULL, 0 },
{ "vaq", required_argument, NULL, 0 },
{ "no-vaq", no_argument, NULL, 0 },
{ "scaling-list", required_argument, NULL, 0 },
{ "max-merge", required_argument, NULL, 0 },

View file

@ -1215,11 +1215,6 @@ static double pixel_var(kvz_pixel * const arr, const uint32_t len) {
return var;
}
// Vaq strength
#ifndef VAQ_STRENGTH
# define VAQ_STRENGTH 1.5
#endif
static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_picture* frame) {
assert(state->type == ENCODER_STATE_TYPE_MAIN);
@ -1235,7 +1230,7 @@ static void encoder_state_init_new_frame(encoder_state_t * const state, kvz_pict
// Variance adaptive quantization
if (cfg->vaq) {
double d = VAQ_STRENGTH; // Empirically decided constant. Affects delta-QP strength
double d = cfg->vaq * 0.1; // Empirically decided constant. Affects delta-QP strength
// Calculate frame pixel variance
uint32_t len = state->tile->frame->width * state->tile->frame->height;