diff options
Diffstat (limited to 'libxrdp/xrdp_jpeg_compress.c')
-rw-r--r-- | libxrdp/xrdp_jpeg_compress.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libxrdp/xrdp_jpeg_compress.c b/libxrdp/xrdp_jpeg_compress.c index a41bd1cf..1bb42b8c 100644 --- a/libxrdp/xrdp_jpeg_compress.c +++ b/libxrdp/xrdp_jpeg_compress.c @@ -98,6 +98,67 @@ xrdp_jpeg_compress(void *handle, char *in_data, int width, int height, return height; } +/** + * Compress a rectangular area (aka inner rectangle) inside our + * frame buffer (inp_data) + *****************************************************************************/ + +int APP_CC +xrdp_codec_jpeg_compress(void *handle, + int format, /* input data format */ + char *inp_data, /* input data */ + int width, /* width of inp_data */ + int height, /* height of inp_data */ + int stride, /* inp_data stride, in bytes*/ + int x, /* x loc in inp_data */ + int y, /* y loc in inp_data */ + int cx, /* width of area to compress */ + int cy, /* height of area to compress */ + int quality, /* higher numbers compress less */ + char *out_data, /* dest for jpg image */ + int *io_len /* length of out_data and on return */ + /* len of compressed data */ + ) +{ + tjhandle tj_han; + int error; + int bpp; + char *src_ptr; + + /* + * note: for now we assume that format is always XBGR and ignore format + */ + + if (handle == 0) + { + g_writeln("xrdp_codec_jpeg_compress: handle is nil"); + return height; + } + + tj_han = (tjhandle) handle; + + /* get bytes per pixel */ + bpp = stride / width; + + /* start of inner rect in inp_data */ + src_ptr = inp_data + (y * stride + x * bpp); + + /* compress inner rect */ + error = tjCompress(tj_han, /* opaque handle */ + src_ptr, /* source buf */ + cx, /* width of area to compress */ + stride, /* pitch */ + cy, /* height of area to compress */ + TJPF_XBGR, /* pixel size */ + out_data, /* dest buf */ + io_len, /* inner_buf length & compressed_size */ + TJSAMP_420, /* jpeg sub sample */ + quality, /* jpeg quality */ + 0 /* flags */ + ); + return height; +} + /*****************************************************************************/ void *APP_CC xrdp_jpeg_init(void) |