server: Use requested quality for tight encoding

tight-encoder-v2
Andri Yngvason 2020-07-09 13:35:45 +00:00
parent 72c7474a72
commit c5be1ecd22
1 changed files with 19 additions and 3 deletions

View File

@ -943,6 +943,22 @@ static enum rfb_encodings choose_frame_encoding(struct nvnc_client* client)
return RFB_ENCODING_RAW; return RFB_ENCODING_RAW;
} }
static enum tight_quality client_get_tight_quality(struct nvnc_client* client)
{
if (client->pixfmt.bits_per_pixel != 16 &&
client->pixfmt.bits_per_pixel != 32)
return TIGHT_QUALITY_LOSSLESS;
for (size_t i = 0; i < client->n_encodings; ++i)
switch (client->encodings[i]) {
case RFB_ENCODING_JPEG_HIGHQ: return TIGHT_QUALITY_HIGH;
case RFB_ENCODING_JPEG_LOWQ: return TIGHT_QUALITY_LOW;
default:;
}
return TIGHT_QUALITY_LOSSLESS;
}
static void do_client_update_fb(void* work) static void do_client_update_fb(void* work)
{ {
struct fb_update_work* update = aml_get_userdata(work); struct fb_update_work* update = aml_get_userdata(work);
@ -962,11 +978,11 @@ static void do_client_update_fb(void* work)
&update->server_fmt, &update->region); &update->server_fmt, &update->region);
break; break;
#ifdef ENABLE_TIGHT #ifdef ENABLE_TIGHT
case RFB_ENCODING_TIGHT: case RFB_ENCODING_TIGHT:;
// TODO: Use the right quality enum tight_quality quality = client_get_tight_quality(client);
tight_encode_frame_v2(&client->tight_encoder, &update->frame, tight_encode_frame_v2(&client->tight_encoder, &update->frame,
&client->pixfmt, fb, &update->server_fmt, &client->pixfmt, fb, &update->server_fmt,
&update->region, TIGHT_QUALITY_HIGH); &update->region, quality);
break; break;
#endif #endif
case RFB_ENCODING_ZRLE: case RFB_ENCODING_ZRLE: