Skip to content

Commit

Permalink
scale vvenc encoder quality from 0-100 and invert, so that 100 is max…
Browse files Browse the repository at this point in the history
…imum quality
  • Loading branch information
farindk committed Oct 4, 2024
1 parent 8e94574 commit 0a423e9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libheif/plugins/encoder_vvenc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ static void vvenc_init_parameters()
p->version = 2;
p->name = heif_encoder_parameter_name_quality;
p->type = heif_encoder_parameter_type_integer;
p->integer.default_value = 32;
p->integer.default_value = 50;
p->has_default = true;
p->integer.have_minimum_maximum = true;
p->integer.minimum = 0;
p->integer.maximum = 63;
p->integer.maximum = 100;
p->integer.valid_values = NULL;
p->integer.num_valid_values = 0;
d[i++] = p++;
Expand Down Expand Up @@ -438,7 +438,12 @@ static struct heif_error vvenc_encode_image(void* encoder_raw, const struct heif

vvenc_config params;

int ret = vvenc_init_default(&params, encoded_width, encoded_height, 25, 0, encoder->quality, VVENC_MEDIUM);
// invert encoder quality range and scale to 0-63
int encoder_quality = 63 - encoder->quality*63/100;

int ret = vvenc_init_default(&params, encoded_width, encoded_height, 25, 0,
encoder_quality,
VVENC_MEDIUM);
if (ret != VVENC_OK) {
// TODO: cleanup memory

Expand Down

0 comments on commit 0a423e9

Please sign in to comment.