diff --git a/meson.build b/meson.build index 72bc7b1..5263094 100644 --- a/meson.build +++ b/meson.build @@ -36,7 +36,7 @@ cc = meson.get_compiler('c') libm = cc.find_library('m', required: false) 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')) zlib = dependency('zlib') @@ -60,6 +60,7 @@ sources = [ 'src/rcbuf.c', 'src/stream.c', 'src/display.c', + 'src/tight.c', ] dependencies = [ @@ -73,8 +74,7 @@ config = configuration_data() if libturbojpeg.found() dependencies += libturbojpeg - sources += 'src/tight.c' - config.set('ENABLE_TIGHT', true) + config.set('HAVE_JPEG', true) endif if gnutls.found() diff --git a/meson_options.txt b/meson_options.txt index 1c2eff6..f2e80f4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,6 +1,6 @@ option('benchmarks', type: 'boolean', value: false, description: 'Build benchmarks') 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('x86_64-simd', type: 'string', value: 'sse2', description: 'Choose SIMD extension for x86_64 release build') diff --git a/src/server.c b/src/server.c index dd286fd..332786f 100644 --- a/src/server.c +++ b/src/server.c @@ -81,9 +81,7 @@ static void client_close(struct nvnc_client* client) LIST_REMOVE(client, link); stream_destroy(client->net_stream); -#ifdef ENABLE_TIGHT tight_encoder_destroy(&client->tight_encoder); -#endif deflateEnd(&client->z_stream); pixman_region_fini(&client->damage); free(client); @@ -730,12 +728,10 @@ static void on_connection(void* obj) if (rc != Z_OK) goto deflate_failure; -#ifdef ENABLE_TIGHT int width = server->display->buffer->width; int height = server->display->buffer->height; if (tight_encoder_init(&client->tight_encoder, width, height) < 0) goto tight_failure; -#endif pixman_region_init(&client->damage); @@ -754,13 +750,9 @@ static void on_connection(void* obj) return; payload_failure: -#ifdef ENABLE_TIGHT tight_encoder_destroy(&client->tight_encoder); -#endif pixman_region_fini(&client->damage); -#ifdef ENABLE_TIGHT tight_failure: -#endif deflateEnd(&client->z_stream); deflate_failure: 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) switch (client->encodings[i]) { case RFB_ENCODING_RAW: -#ifdef ENABLE_TIGHT case RFB_ENCODING_TIGHT: -#endif case RFB_ENCODING_ZRLE: return client->encodings[i]; default: @@ -977,14 +967,12 @@ static void do_client_update_fb(void* work) raw_encode_frame(&update->frame, &client->pixfmt, fb, &update->server_fmt, &update->region); break; -#ifdef ENABLE_TIGHT case RFB_ENCODING_TIGHT:; enum tight_quality quality = client_get_tight_quality(client); tight_encode_frame(&client->tight_encoder, &update->frame, &client->pixfmt, fb, &update->server_fmt, &update->region, quality); break; -#endif case RFB_ENCODING_ZRLE: zrle_encode_frame(&client->z_stream, &update->frame, &client->pixfmt, fb, &update->server_fmt, diff --git a/src/tight.c b/src/tight.c index a20bc75..952b892 100644 --- a/src/tight.c +++ b/src/tight.c @@ -21,6 +21,7 @@ #include "vec.h" #include "logging.h" #include "tight.h" +#include "config.h" #include #include @@ -32,8 +33,10 @@ #include #include #include -#include #include +#ifdef HAVE_JPEG +#include +#endif #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) { switch (fourcc) { @@ -350,6 +354,7 @@ failure: return rc; } +#endif /* HAVE_JPEG */ static void tight_encode_tile(struct tight_encoder* self, uint32_t gx, uint32_t gy) @@ -364,6 +369,7 @@ static void tight_encode_tile(struct tight_encoder* self, tile->size = 0; +#ifdef HAVE_JPEG switch (self->quality) { case TIGHT_QUALITY_LOSSLESS: 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: abort(); } - //TODO Jpeg +#else + tight_encode_tile_basic(self, tile, x, y, width, height, gx % 4); +#endif tile->state = TIGHT_TILE_ENCODED; }