From a0376f2fd4ccdb8dc6570628eaf8a0377896536a Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Mon, 30 Dec 2019 17:48:22 +0000 Subject: [PATCH] Pass entire client structure to tight encoder --- include/tight.h | 13 +++++-------- src/server.c | 3 +-- src/tight.c | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/include/tight.h b/include/tight.h index 82ca009..870bd7e 100644 --- a/include/tight.h +++ b/include/tight.h @@ -1,13 +1,10 @@ #pragma once -#include -#include - -struct nvnc_fb; -struct rfb_pixel_format; -struct pixman_region16; struct vec; +struct nvnc_client; +struct nvnc_fb; +struct pixman_region16; -int tight_encode_frame(struct vec* dst, const struct rfb_pixel_format* dst_fmt, - const struct nvnc_fb* src, uint32_t src_fmt, +int tight_encode_frame(struct vec* dst, struct nvnc_client* client, + const struct nvnc_fb* fb, struct pixman_region16* region); diff --git a/src/server.c b/src/server.c index a6ad2ba..9f29b7f 100644 --- a/src/server.c +++ b/src/server.c @@ -853,8 +853,7 @@ void do_client_update_fb(uv_work_t* work) break; #ifdef ENABLE_TIGHT case RFB_ENCODING_TIGHT: - tight_encode_frame(&update->frame, &client->pixfmt, fb, - fb->fourcc_format, &update->region); + tight_encode_frame(&update->frame, client, fb, &update->region); break; #endif case RFB_ENCODING_ZRLE: diff --git a/src/tight.c b/src/tight.c index 75f0e8a..b5f571d 100644 --- a/src/tight.c +++ b/src/tight.c @@ -2,6 +2,8 @@ #include "rfb-proto.h" #include "vec.h" #include "fb.h" +#include "tight.h" +#include "common.h" #include #include @@ -42,17 +44,16 @@ static void tight_encode_size(struct vec* dst, size_t size) vec_fast_append_8(dst, (size >> 14) & 0x7f); } -int tight_encode_box(struct vec* dst, const struct rfb_pixel_format* dst_fmt, - const struct nvnc_fb* src, uint32_t src_fmt, - uint32_t x, uint32_t y, uint32_t stride, - uint32_t width, uint32_t height) +int tight_encode_box(struct vec* dst, struct nvnc_client* client, + const struct nvnc_fb* fb, uint32_t x, uint32_t y, + uint32_t stride, uint32_t width, uint32_t height) { unsigned char* buffer = NULL; size_t size = 0; int quality = 50; /* 1 - 100 */ - enum TJPF tjfmt = get_jpeg_pixfmt(src_fmt); + enum TJPF tjfmt = get_jpeg_pixfmt(fb->fourcc_format); if (tjfmt == TJPF_UNKNOWN) return -1; @@ -70,7 +71,7 @@ int tight_encode_box(struct vec* dst, const struct rfb_pixel_format* dst_fmt, tjhandle handle = tjInitCompress(); - void* img = (uint32_t*)src->addr + x + y * stride; + void* img = (uint32_t*)fb->addr + x + y * stride; tjCompress2(handle, img, width, stride * 4, height, tjfmt, &buffer, &size, TJSAMP_422, quality, TJFLAG_FASTDCT); @@ -87,9 +88,8 @@ int tight_encode_box(struct vec* dst, const struct rfb_pixel_format* dst_fmt, return 0; } -int tight_encode_frame(struct vec* dst, const struct rfb_pixel_format* dst_fmt, - const struct nvnc_fb* src, uint32_t src_fmt, - struct pixman_region16* region) +int tight_encode_frame(struct vec* dst, struct nvnc_client* client, + const struct nvnc_fb* fb, struct pixman_region16* region) { int rc = -1; @@ -115,8 +115,8 @@ int tight_encode_frame(struct vec* dst, const struct rfb_pixel_format* dst_fmt, int box_width = box[i].x2 - x; int box_height = box[i].y2 - y; - rc = tight_encode_box(dst, dst_fmt, src, src_fmt, x, y, - src->width, box_width, box_height); + rc = tight_encode_box(dst, client, fb, x, y, + fb->width, box_width, box_height); if (rc < 0) return -1; }