tight: Limit rectangle max width according to spec

pull/30/head
Andri Yngvason 2020-04-02 21:26:12 +00:00
parent 1724797a27
commit 999c1ef255
1 changed files with 14 additions and 4 deletions

View File

@ -25,6 +25,7 @@
#include <pixman.h> #include <pixman.h>
#include <turbojpeg.h> #include <turbojpeg.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/param.h>
#include <libdrm/drm_fourcc.h> #include <libdrm/drm_fourcc.h>
#define TIGHT_FILL 0x80 #define TIGHT_FILL 0x80
@ -32,6 +33,8 @@
#define TIGHT_PNG 0xA0 #define TIGHT_PNG 0xA0
#define TIGHT_BASIC 0x00 #define TIGHT_BASIC 0x00
#define TIGHT_MAX_WIDTH 2048
enum TJPF get_jpeg_pixfmt(uint32_t fourcc) enum TJPF get_jpeg_pixfmt(uint32_t fourcc)
{ {
switch (fourcc) { switch (fourcc) {
@ -141,10 +144,17 @@ int tight_encode_frame(struct vec* dst, struct nvnc_client* client,
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, client, fb, x, y, while (box_width > 0) {
fb->width, box_width, box_height); int w = MIN(TIGHT_MAX_WIDTH, box_width);
box_width -= w;
rc = tight_encode_box(dst, client, fb, x, y, fb->width,
w, box_height);
if (rc < 0) if (rc < 0)
return -1; return -1;
x += w;
}
} }
return 0; return 0;