tight: Add method to resize encoder grid

pull/42/head
Andri Yngvason 2020-07-19 16:57:44 +00:00
parent d4a5ed4133
commit 76beec6415
2 changed files with 15 additions and 4 deletions

View File

@ -61,6 +61,9 @@ int tight_encoder_init(struct tight_encoder* self, uint32_t width,
uint32_t height);
void tight_encoder_destroy(struct tight_encoder* self);
int tight_encoder_resize(struct tight_encoder* self, uint32_t width,
uint32_t height);
int tight_encode_frame(struct tight_encoder* self, struct vec* dst,
const struct rfb_pixel_format* dfmt,
const struct nvnc_fb* src,

View File

@ -123,20 +123,28 @@ failure:
return -1;
}
int tight_encoder_init(struct tight_encoder* self, uint32_t width,
int tight_encoder_resize(struct tight_encoder* self, uint32_t width,
uint32_t height)
{
memset(self, 0, sizeof(*self));
self->width = width;
self->height = height;
self->grid_width = UDIV_UP(width, 64);
self->grid_height = UDIV_UP(height, 64);
if (self->grid)
free(self->grid);
self->grid = calloc(self->grid_width * self->grid_height,
sizeof(*self->grid));
if (!self->grid)
return self->grid ? 0 : -1;
}
int tight_encoder_init(struct tight_encoder* self, uint32_t width,
uint32_t height)
{
memset(self, 0, sizeof(*self));
if (tight_encoder_resize(self, width, height) < 0)
return -1;
tight_encoder_init_stream(&self->zs[0]);