Pass entire client structure to tight encoder

tight-png
Andri Yngvason 2019-12-30 17:48:22 +00:00
parent d9f80ad196
commit a0376f2fd4
3 changed files with 17 additions and 21 deletions

View File

@ -1,13 +1,10 @@
#pragma once #pragma once
#include <stdint.h>
#include <unistd.h>
struct nvnc_fb;
struct rfb_pixel_format;
struct pixman_region16;
struct vec; 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, int tight_encode_frame(struct vec* dst, struct nvnc_client* client,
const struct nvnc_fb* src, uint32_t src_fmt, const struct nvnc_fb* fb,
struct pixman_region16* region); struct pixman_region16* region);

View File

@ -853,8 +853,7 @@ void do_client_update_fb(uv_work_t* work)
break; break;
#ifdef ENABLE_TIGHT #ifdef ENABLE_TIGHT
case RFB_ENCODING_TIGHT: case RFB_ENCODING_TIGHT:
tight_encode_frame(&update->frame, &client->pixfmt, fb, tight_encode_frame(&update->frame, client, fb, &update->region);
fb->fourcc_format, &update->region);
break; break;
#endif #endif
case RFB_ENCODING_ZRLE: case RFB_ENCODING_ZRLE:

View File

@ -2,6 +2,8 @@
#include "rfb-proto.h" #include "rfb-proto.h"
#include "vec.h" #include "vec.h"
#include "fb.h" #include "fb.h"
#include "tight.h"
#include "common.h"
#include <pixman.h> #include <pixman.h>
#include <turbojpeg.h> #include <turbojpeg.h>
@ -42,17 +44,16 @@ 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, const struct rfb_pixel_format* dst_fmt, int tight_encode_box(struct vec* dst, struct nvnc_client* client,
const struct nvnc_fb* src, uint32_t src_fmt, const struct nvnc_fb* fb, uint32_t x, uint32_t y,
uint32_t x, uint32_t y, uint32_t stride, uint32_t stride, uint32_t width, uint32_t height)
uint32_t width, uint32_t height)
{ {
unsigned char* buffer = NULL; unsigned char* buffer = NULL;
size_t size = 0; size_t size = 0;
int quality = 50; /* 1 - 100 */ 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) if (tjfmt == TJPF_UNKNOWN)
return -1; return -1;
@ -70,7 +71,7 @@ int tight_encode_box(struct vec* dst, const struct rfb_pixel_format* dst_fmt,
tjhandle handle = tjInitCompress(); 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, tjCompress2(handle, img, width, stride * 4, height, tjfmt, &buffer,
&size, TJSAMP_422, quality, TJFLAG_FASTDCT); &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; return 0;
} }
int tight_encode_frame(struct vec* dst, const struct rfb_pixel_format* dst_fmt, int tight_encode_frame(struct vec* dst, struct nvnc_client* client,
const struct nvnc_fb* src, uint32_t src_fmt, const struct nvnc_fb* fb, struct pixman_region16* region)
struct pixman_region16* region)
{ {
int rc = -1; 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_width = box[i].x2 - x;
int box_height = box[i].y2 - y; int box_height = box[i].y2 - y;
rc = tight_encode_box(dst, dst_fmt, src, src_fmt, x, y, rc = tight_encode_box(dst, client, fb, x, y,
src->width, box_width, box_height); fb->width, box_width, box_height);
if (rc < 0) if (rc < 0)
return -1; return -1;
} }