Always enable tight, encoding but allow disabling lossy tight encoding

pull/42/head
Andri Yngvason 2020-07-11 20:16:27 +00:00
parent 497f9adb29
commit 33eda8c5d0
4 changed files with 14 additions and 18 deletions

View File

@ -36,7 +36,7 @@ cc = meson.get_compiler('c')
libm = cc.find_library('m', required: false) libm = cc.find_library('m', required: false)
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
libturbojpeg = dependency('libturbojpeg', required: get_option('tight-encoding')) libturbojpeg = dependency('libturbojpeg', required: get_option('jpeg'))
gnutls = dependency('gnutls', required: get_option('tls')) gnutls = dependency('gnutls', required: get_option('tls'))
zlib = dependency('zlib') zlib = dependency('zlib')
@ -60,6 +60,7 @@ sources = [
'src/rcbuf.c', 'src/rcbuf.c',
'src/stream.c', 'src/stream.c',
'src/display.c', 'src/display.c',
'src/tight.c',
] ]
dependencies = [ dependencies = [
@ -73,8 +74,7 @@ config = configuration_data()
if libturbojpeg.found() if libturbojpeg.found()
dependencies += libturbojpeg dependencies += libturbojpeg
sources += 'src/tight.c' config.set('HAVE_JPEG', true)
config.set('ENABLE_TIGHT', true)
endif endif
if gnutls.found() if gnutls.found()

View File

@ -1,6 +1,6 @@
option('benchmarks', type: 'boolean', value: false, description: 'Build benchmarks') option('benchmarks', type: 'boolean', value: false, description: 'Build benchmarks')
option('examples', type: 'boolean', value: false, description: 'Build examples') option('examples', type: 'boolean', value: false, description: 'Build examples')
option('tight-encoding', type: 'feature', value: 'auto', description: 'Enable Tight encoding') option('jpeg', type: 'feature', value: 'auto', description: 'Enable JPEG compression')
option('tls', type: 'feature', value: 'auto', description: 'Enable encryption & authentication') option('tls', type: 'feature', value: 'auto', description: 'Enable encryption & authentication')
option('x86_64-simd', type: 'string', value: 'sse2', option('x86_64-simd', type: 'string', value: 'sse2',
description: 'Choose SIMD extension for x86_64 release build') description: 'Choose SIMD extension for x86_64 release build')

View File

@ -81,9 +81,7 @@ static void client_close(struct nvnc_client* client)
LIST_REMOVE(client, link); LIST_REMOVE(client, link);
stream_destroy(client->net_stream); stream_destroy(client->net_stream);
#ifdef ENABLE_TIGHT
tight_encoder_destroy(&client->tight_encoder); tight_encoder_destroy(&client->tight_encoder);
#endif
deflateEnd(&client->z_stream); deflateEnd(&client->z_stream);
pixman_region_fini(&client->damage); pixman_region_fini(&client->damage);
free(client); free(client);
@ -730,12 +728,10 @@ static void on_connection(void* obj)
if (rc != Z_OK) if (rc != Z_OK)
goto deflate_failure; goto deflate_failure;
#ifdef ENABLE_TIGHT
int width = server->display->buffer->width; int width = server->display->buffer->width;
int height = server->display->buffer->height; int height = server->display->buffer->height;
if (tight_encoder_init(&client->tight_encoder, width, height) < 0) if (tight_encoder_init(&client->tight_encoder, width, height) < 0)
goto tight_failure; goto tight_failure;
#endif
pixman_region_init(&client->damage); pixman_region_init(&client->damage);
@ -754,13 +750,9 @@ static void on_connection(void* obj)
return; return;
payload_failure: payload_failure:
#ifdef ENABLE_TIGHT
tight_encoder_destroy(&client->tight_encoder); tight_encoder_destroy(&client->tight_encoder);
#endif
pixman_region_fini(&client->damage); pixman_region_fini(&client->damage);
#ifdef ENABLE_TIGHT
tight_failure: tight_failure:
#endif
deflateEnd(&client->z_stream); deflateEnd(&client->z_stream);
deflate_failure: deflate_failure:
stream_destroy(client->net_stream); stream_destroy(client->net_stream);
@ -931,9 +923,7 @@ static enum rfb_encodings choose_frame_encoding(struct nvnc_client* client)
for (size_t i = 0; i < client->n_encodings; ++i) for (size_t i = 0; i < client->n_encodings; ++i)
switch (client->encodings[i]) { switch (client->encodings[i]) {
case RFB_ENCODING_RAW: case RFB_ENCODING_RAW:
#ifdef ENABLE_TIGHT
case RFB_ENCODING_TIGHT: case RFB_ENCODING_TIGHT:
#endif
case RFB_ENCODING_ZRLE: case RFB_ENCODING_ZRLE:
return client->encodings[i]; return client->encodings[i];
default: default:
@ -977,14 +967,12 @@ static void do_client_update_fb(void* work)
raw_encode_frame(&update->frame, &client->pixfmt, fb, raw_encode_frame(&update->frame, &client->pixfmt, fb,
&update->server_fmt, &update->region); &update->server_fmt, &update->region);
break; break;
#ifdef ENABLE_TIGHT
case RFB_ENCODING_TIGHT:; case RFB_ENCODING_TIGHT:;
enum tight_quality quality = client_get_tight_quality(client); enum tight_quality quality = client_get_tight_quality(client);
tight_encode_frame(&client->tight_encoder, &update->frame, tight_encode_frame(&client->tight_encoder, &update->frame,
&client->pixfmt, fb, &update->server_fmt, &client->pixfmt, fb, &update->server_fmt,
&update->region, quality); &update->region, quality);
break; break;
#endif
case RFB_ENCODING_ZRLE: case RFB_ENCODING_ZRLE:
zrle_encode_frame(&client->z_stream, &update->frame, zrle_encode_frame(&client->z_stream, &update->frame,
&client->pixfmt, fb, &update->server_fmt, &client->pixfmt, fb, &update->server_fmt,

View File

@ -21,6 +21,7 @@
#include "vec.h" #include "vec.h"
#include "logging.h" #include "logging.h"
#include "tight.h" #include "tight.h"
#include "config.h"
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -32,8 +33,10 @@
#include <pthread.h> #include <pthread.h>
#include <assert.h> #include <assert.h>
#include <aml.h> #include <aml.h>
#include <turbojpeg.h>
#include <libdrm/drm_fourcc.h> #include <libdrm/drm_fourcc.h>
#ifdef HAVE_JPEG
#include <turbojpeg.h>
#endif
#define UDIV_UP(a, b) (((a) + (b) - 1) / (b)) #define UDIV_UP(a, b) (((a) + (b) - 1) / (b))
@ -277,6 +280,7 @@ static void tight_encode_tile_basic(struct tight_encoder* self,
} }
#ifdef HAVE_JPEG
static enum TJPF tight_get_jpeg_pixfmt(uint32_t fourcc) static enum TJPF tight_get_jpeg_pixfmt(uint32_t fourcc)
{ {
switch (fourcc) { switch (fourcc) {
@ -350,6 +354,7 @@ failure:
return rc; return rc;
} }
#endif /* HAVE_JPEG */
static void tight_encode_tile(struct tight_encoder* self, static void tight_encode_tile(struct tight_encoder* self,
uint32_t gx, uint32_t gy) uint32_t gx, uint32_t gy)
@ -364,6 +369,7 @@ static void tight_encode_tile(struct tight_encoder* self,
tile->size = 0; tile->size = 0;
#ifdef HAVE_JPEG
switch (self->quality) { switch (self->quality) {
case TIGHT_QUALITY_LOSSLESS: case TIGHT_QUALITY_LOSSLESS:
tight_encode_tile_basic(self, tile, x, y, width, height, gx % 4); tight_encode_tile_basic(self, tile, x, y, width, height, gx % 4);
@ -376,7 +382,9 @@ static void tight_encode_tile(struct tight_encoder* self,
case TIGHT_QUALITY_UNSPEC: case TIGHT_QUALITY_UNSPEC:
abort(); abort();
} }
//TODO Jpeg #else
tight_encode_tile_basic(self, tile, x, y, width, height, gx % 4);
#endif
tile->state = TIGHT_TILE_ENCODED; tile->state = TIGHT_TILE_ENCODED;
} }