tight: Prepare for "basic" encoding method
parent
999c1ef255
commit
cfb2abfc58
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "neatvnc.h"
|
#include "neatvnc.h"
|
||||||
#include "miniz.h"
|
#include "miniz.h"
|
||||||
|
#include "tight.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef ENABLE_TLS
|
#ifdef ENABLE_TLS
|
||||||
|
@ -71,6 +72,7 @@ struct nvnc_client {
|
||||||
bool is_updating;
|
bool is_updating;
|
||||||
nvnc_client_fn cleanup_fn;
|
nvnc_client_fn cleanup_fn;
|
||||||
z_stream z_stream;
|
z_stream z_stream;
|
||||||
|
struct tight_encoder tight_encoder;
|
||||||
size_t buffer_index;
|
size_t buffer_index;
|
||||||
size_t buffer_len;
|
size_t buffer_len;
|
||||||
uint8_t msg_buffer[MSG_BUFFER_SIZE];
|
uint8_t msg_buffer[MSG_BUFFER_SIZE];
|
||||||
|
|
|
@ -16,11 +16,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "miniz.h"
|
||||||
|
|
||||||
struct vec;
|
struct vec;
|
||||||
struct nvnc_client;
|
struct nvnc_client;
|
||||||
struct nvnc_fb;
|
struct nvnc_fb;
|
||||||
struct pixman_region16;
|
struct pixman_region16;
|
||||||
|
|
||||||
int tight_encode_frame(struct vec* dst, struct nvnc_client* client,
|
struct tight_encoder {
|
||||||
|
z_stream zs[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
int tight_encoder_init(struct tight_encoder*);
|
||||||
|
void tight_encoder_destroy(struct tight_encoder*);
|
||||||
|
|
||||||
|
int tight_encode_frame(struct tight_encoder* self, struct vec* dst,
|
||||||
const struct nvnc_fb* fb,
|
const struct nvnc_fb* fb,
|
||||||
struct pixman_region16* region);
|
struct pixman_region16* region);
|
||||||
|
|
10
src/server.c
10
src/server.c
|
@ -77,6 +77,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);
|
||||||
|
tight_encoder_destroy(&client->tight_encoder);
|
||||||
deflateEnd(&client->z_stream);
|
deflateEnd(&client->z_stream);
|
||||||
pixman_region_fini(&client->damage);
|
pixman_region_fini(&client->damage);
|
||||||
free(client);
|
free(client);
|
||||||
|
@ -708,6 +709,9 @@ static void on_connection(void* obj)
|
||||||
if (rc != Z_OK)
|
if (rc != Z_OK)
|
||||||
goto deflate_failure;
|
goto deflate_failure;
|
||||||
|
|
||||||
|
if (tight_encoder_init(&client->tight_encoder) < 0)
|
||||||
|
goto tight_failure;
|
||||||
|
|
||||||
pixman_region_init(&client->damage);
|
pixman_region_init(&client->damage);
|
||||||
|
|
||||||
struct rcbuf* payload = rcbuf_from_string(RFB_VERSION_MESSAGE);
|
struct rcbuf* payload = rcbuf_from_string(RFB_VERSION_MESSAGE);
|
||||||
|
@ -725,6 +729,9 @@ static void on_connection(void* obj)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
payload_failure:
|
payload_failure:
|
||||||
|
tight_encoder_destroy(&client->tight_encoder);
|
||||||
|
pixman_region_fini(&client->damage);
|
||||||
|
tight_failure:
|
||||||
deflateEnd(&client->z_stream);
|
deflateEnd(&client->z_stream);
|
||||||
deflate_failure:
|
deflate_failure:
|
||||||
stream_destroy(client->net_stream);
|
stream_destroy(client->net_stream);
|
||||||
|
@ -859,7 +866,8 @@ void do_client_update_fb(void* work)
|
||||||
break;
|
break;
|
||||||
#ifdef ENABLE_TIGHT
|
#ifdef ENABLE_TIGHT
|
||||||
case RFB_ENCODING_TIGHT:
|
case RFB_ENCODING_TIGHT:
|
||||||
tight_encode_frame(&update->frame, client, fb, &update->region);
|
tight_encode_frame(&client->tight_encoder, &update->frame, fb,
|
||||||
|
&update->region);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case RFB_ENCODING_ZRLE:
|
case RFB_ENCODING_ZRLE:
|
||||||
|
|
24
src/tight.c
24
src/tight.c
|
@ -35,6 +35,17 @@
|
||||||
|
|
||||||
#define TIGHT_MAX_WIDTH 2048
|
#define TIGHT_MAX_WIDTH 2048
|
||||||
|
|
||||||
|
int tight_encoder_init(struct tight_encoder* self)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tight_encoder_destroy(struct tight_encoder* self)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
enum TJPF get_jpeg_pixfmt(uint32_t fourcc)
|
enum TJPF get_jpeg_pixfmt(uint32_t fourcc)
|
||||||
{
|
{
|
||||||
switch (fourcc) {
|
switch (fourcc) {
|
||||||
|
@ -64,7 +75,7 @@ static void tight_encode_size(struct vec* dst, size_t size)
|
||||||
vec_fast_append_8(dst, (size >> 14) & 0x7f);
|
vec_fast_append_8(dst, (size >> 14) & 0x7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tight_encode_box(struct vec* dst, struct nvnc_client* client,
|
int tight_encode_box_jpeg(struct tight_encoder* self, struct vec* dst,
|
||||||
const struct nvnc_fb* fb, uint32_t x, uint32_t y,
|
const struct nvnc_fb* fb, uint32_t x, uint32_t y,
|
||||||
uint32_t stride, uint32_t width, uint32_t height)
|
uint32_t stride, uint32_t width, uint32_t height)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +128,14 @@ compress_failure:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tight_encode_frame(struct vec* dst, struct nvnc_client* client,
|
int tight_encode_box(struct tight_encoder* self, struct vec* dst,
|
||||||
|
const struct nvnc_fb* fb, uint32_t x, uint32_t y,
|
||||||
|
uint32_t stride, uint32_t width, uint32_t height)
|
||||||
|
{
|
||||||
|
return tight_encode_box_jpeg(self, dst, fb, x, y, stride, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
int tight_encode_frame(struct tight_encoder* self, struct vec* dst,
|
||||||
const struct nvnc_fb* fb, struct pixman_region16* region)
|
const struct nvnc_fb* fb, struct pixman_region16* region)
|
||||||
{
|
{
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
@ -148,7 +166,7 @@ int tight_encode_frame(struct vec* dst, struct nvnc_client* client,
|
||||||
int w = MIN(TIGHT_MAX_WIDTH, box_width);
|
int w = MIN(TIGHT_MAX_WIDTH, box_width);
|
||||||
box_width -= w;
|
box_width -= w;
|
||||||
|
|
||||||
rc = tight_encode_box(dst, client, fb, x, y, fb->width,
|
rc = tight_encode_box(self, dst, fb, x, y, fb->width,
|
||||||
w, box_height);
|
w, box_height);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue