From 0a423e963f8b0831a7b6d7aaca99273984291327 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Fri, 4 Oct 2024 22:22:26 +0200 Subject: [PATCH] scale vvenc encoder quality from 0-100 and invert, so that 100 is maximum quality --- libheif/plugins/encoder_vvenc.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libheif/plugins/encoder_vvenc.cc b/libheif/plugins/encoder_vvenc.cc index 6111e604ce..a7eee6a490 100644 --- a/libheif/plugins/encoder_vvenc.cc +++ b/libheif/plugins/encoder_vvenc.cc @@ -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++; @@ -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(¶ms, 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(¶ms, encoded_width, encoded_height, 25, 0, + encoder_quality, + VVENC_MEDIUM); if (ret != VVENC_OK) { // TODO: cleanup memory