Add offset coordinates to encoders
parent
42b102df0c
commit
8b2c81c3dd
|
@ -42,6 +42,9 @@ struct encoder_impl {
|
|||
struct encoder {
|
||||
struct encoder_impl* impl;
|
||||
|
||||
uint16_t x_pos;
|
||||
uint16_t y_pos;
|
||||
|
||||
void (*on_done)(struct encoder*, struct rcbuf* result);
|
||||
void* userdata;
|
||||
};
|
||||
|
|
|
@ -50,16 +50,19 @@ static inline struct raw_encoder* raw_encoder(struct encoder* encoder)
|
|||
return (struct raw_encoder*)encoder;
|
||||
}
|
||||
|
||||
static int raw_encode_box(struct vec* dst,
|
||||
static int raw_encode_box(struct raw_encoder* self, struct vec* dst,
|
||||
const struct rfb_pixel_format* dst_fmt,
|
||||
const struct nvnc_fb* fb,
|
||||
const struct rfb_pixel_format* src_fmt, int x_start,
|
||||
int y_start, int stride, int width, int height)
|
||||
{
|
||||
uint16_t x_pos = self->encoder.x_pos;
|
||||
uint16_t y_pos = self->encoder.y_pos;
|
||||
|
||||
int rc = -1;
|
||||
|
||||
rc = encode_rect_head(dst, RFB_ENCODING_RAW, x_start, y_start, width,
|
||||
height);
|
||||
rc = encode_rect_head(dst, RFB_ENCODING_RAW, x_pos + x_start,
|
||||
y_pos + y_start, width, height);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -83,7 +86,7 @@ static int raw_encode_box(struct vec* dst,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int raw_encode_frame(struct vec* dst,
|
||||
static int raw_encode_frame(struct raw_encoder* self, struct vec* dst,
|
||||
const struct rfb_pixel_format* dst_fmt, struct nvnc_fb* src,
|
||||
const struct rfb_pixel_format* src_fmt,
|
||||
struct pixman_region16* region)
|
||||
|
@ -115,8 +118,8 @@ static int raw_encode_frame(struct vec* dst,
|
|||
int box_width = box[i].x2 - x;
|
||||
int box_height = box[i].y2 - y;
|
||||
|
||||
rc = raw_encode_box(dst, dst_fmt, src, src_fmt, x, y,
|
||||
src->stride, box_width, box_height);
|
||||
rc = raw_encode_box(self, dst, dst_fmt, src, src_fmt, x, y,
|
||||
src->stride, box_width, box_height);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
}
|
||||
|
@ -145,7 +148,7 @@ static void raw_encoder_do_work(void* obj)
|
|||
rc = rfb_pixfmt_from_fourcc(&src_fmt, nvnc_fb_get_fourcc_format(fb));
|
||||
assert(rc == 0);
|
||||
|
||||
rc = raw_encode_frame(&dst, &self->output_format, fb, &src_fmt,
|
||||
rc = raw_encode_frame(self, &dst, &self->output_format, fb, &src_fmt,
|
||||
&self->current_damage);
|
||||
assert(rc == 0);
|
||||
|
||||
|
|
|
@ -473,13 +473,17 @@ static void tight_finish_tile(struct tight_encoder* self,
|
|||
{
|
||||
struct tight_tile* tile = tight_tile(self, gx, gy);
|
||||
|
||||
uint16_t x_pos = self->encoder.x_pos;
|
||||
uint16_t y_pos = self->encoder.y_pos;
|
||||
|
||||
uint32_t x = gx * TSL;
|
||||
uint32_t y = gy * TSL;
|
||||
|
||||
uint32_t width = tight_tile_width(self, x);
|
||||
uint32_t height = tight_tile_height(self, y);
|
||||
|
||||
encode_rect_head(&self->dst, RFB_ENCODING_TIGHT, x, y, width, height);
|
||||
encode_rect_head(&self->dst, RFB_ENCODING_TIGHT, x_pos + x, y_pos + y,
|
||||
width, height);
|
||||
|
||||
vec_append(&self->dst, &tile->type, sizeof(tile->type));
|
||||
tight_encode_size(&self->dst, tile->size);
|
||||
|
|
21
src/zrle.c
21
src/zrle.c
|
@ -227,7 +227,7 @@ static int zrle_deflate(struct vec* dst, const struct vec* src, z_stream* zs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int zrle_encode_box(struct vec* out,
|
||||
static int zrle_encode_box(struct zrle_encoder* self, struct vec* out,
|
||||
const struct rfb_pixel_format* dst_fmt,
|
||||
const struct nvnc_fb* fb,
|
||||
const struct rfb_pixel_format* src_fmt, int x, int y,
|
||||
|
@ -237,6 +237,9 @@ static int zrle_encode_box(struct vec* out,
|
|||
int bytes_per_cpixel = calc_bytes_per_cpixel(dst_fmt);
|
||||
struct vec in;
|
||||
|
||||
uint16_t x_pos = self->encoder.x_pos;
|
||||
uint16_t y_pos = self->encoder.y_pos;
|
||||
|
||||
uint32_t* tile = malloc(TILE_LENGTH * TILE_LENGTH * 4);
|
||||
if (!tile)
|
||||
goto failure;
|
||||
|
@ -244,7 +247,8 @@ static int zrle_encode_box(struct vec* out,
|
|||
if (vec_init(&in, 1 + bytes_per_cpixel * TILE_LENGTH * TILE_LENGTH) < 0)
|
||||
goto failure;
|
||||
|
||||
r = encode_rect_head(out, RFB_ENCODING_ZRLE, x, y, width, height);
|
||||
r = encode_rect_head(out, RFB_ENCODING_ZRLE, x_pos + x, y_pos + y,
|
||||
width, height);
|
||||
if (r < 0)
|
||||
goto failure;
|
||||
|
||||
|
@ -288,11 +292,10 @@ failure:
|
|||
#undef CHUNK
|
||||
}
|
||||
|
||||
static int zrle_encode_frame(z_stream* zs, struct vec* dst,
|
||||
const struct rfb_pixel_format* dst_fmt,
|
||||
struct nvnc_fb* src,
|
||||
const struct rfb_pixel_format* src_fmt,
|
||||
struct pixman_region16* region)
|
||||
static int zrle_encode_frame(struct zrle_encoder* self, z_stream* zs,
|
||||
struct vec* dst, const struct rfb_pixel_format* dst_fmt,
|
||||
struct nvnc_fb* src, const struct rfb_pixel_format* src_fmt,
|
||||
struct pixman_region16* region)
|
||||
{
|
||||
int rc = -1;
|
||||
|
||||
|
@ -317,7 +320,7 @@ static int zrle_encode_frame(z_stream* zs, struct vec* dst,
|
|||
int box_width = box[i].x2 - x;
|
||||
int box_height = box[i].y2 - y;
|
||||
|
||||
rc = zrle_encode_box(dst, dst_fmt, src, src_fmt, x, y,
|
||||
rc = zrle_encode_box(self, dst, dst_fmt, src, src_fmt, x, y,
|
||||
src->stride, box_width, box_height, zs);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
|
@ -347,7 +350,7 @@ static void zrle_encoder_do_work(void* obj)
|
|||
rc = rfb_pixfmt_from_fourcc(&src_fmt, nvnc_fb_get_fourcc_format(fb));
|
||||
assert(rc == 0);
|
||||
|
||||
rc = zrle_encode_frame(&self->zs, &dst, &self->output_format, fb,
|
||||
rc = zrle_encode_frame(self, &self->zs, &dst, &self->output_format, fb,
|
||||
&src_fmt, &self->current_damage);
|
||||
assert(rc == 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue