Merge pull request #87 from glyptodon/webp-lossless

GUAC-1305: Support lossless WebP within encoder.
This commit is contained in:
James Muehlner 2015-09-22 12:20:01 -07:00
commit 602285be35
5 changed files with 22 additions and 10 deletions

View File

@ -1340,7 +1340,7 @@ static void __guac_common_surface_flush_to_webp(guac_common_surface* surface) {
/* Send WebP for rect */ /* Send WebP for rect */
guac_client_stream_webp(surface->client, socket, GUAC_COMP_OVER, layer, guac_client_stream_webp(surface->client, socket, GUAC_COMP_OVER, layer,
surface->dirty_rect.x, surface->dirty_rect.y, rect, surface->dirty_rect.x, surface->dirty_rect.y, rect,
GUAC_SURFACE_WEBP_IMAGE_QUALITY); GUAC_SURFACE_WEBP_IMAGE_QUALITY, 0);
cairo_surface_destroy(rect); cairo_surface_destroy(rect);
surface->realized = 1; surface->realized = 1;

View File

@ -425,7 +425,7 @@ void guac_client_stream_jpeg(guac_client* client, guac_socket* socket,
void guac_client_stream_webp(guac_client* client, guac_socket* socket, void guac_client_stream_webp(guac_client* client, guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, int x, int y, guac_composite_mode mode, const guac_layer* layer, int x, int y,
cairo_surface_t* surface, int quality) { cairo_surface_t* surface, int quality, int lossless) {
#ifdef ENABLE_WEBP #ifdef ENABLE_WEBP
/* Allocate new stream for image */ /* Allocate new stream for image */
@ -435,7 +435,7 @@ void guac_client_stream_webp(guac_client* client, guac_socket* socket,
guac_protocol_send_img(socket, stream, mode, layer, "image/webp", x, y); guac_protocol_send_img(socket, stream, mode, layer, "image/webp", x, y);
/* Write WebP data */ /* Write WebP data */
guac_webp_write(socket, stream, surface, quality); guac_webp_write(socket, stream, surface, quality, lossless);
/* Terminate stream */ /* Terminate stream */
guac_protocol_send_end(socket, stream); guac_protocol_send_end(socket, stream);

View File

@ -166,7 +166,7 @@ static int guac_webp_stream_write(const uint8_t* data, size_t data_size,
} }
int guac_webp_write(guac_socket* socket, guac_stream* stream, int guac_webp_write(guac_socket* socket, guac_stream* stream,
cairo_surface_t* surface, int quality) { cairo_surface_t* surface, int quality, int lossless) {
guac_webp_stream_writer writer; guac_webp_stream_writer writer;
WebPPicture picture; WebPPicture picture;
@ -195,7 +195,7 @@ int guac_webp_write(guac_socket* socket, guac_stream* stream,
return -1; return -1;
/* Add additional tuning */ /* Add additional tuning */
config.lossless = 0; config.lossless = lossless;
config.quality = quality; config.quality = quality;
config.thread_level = 1; /* Multi threaded */ config.thread_level = 1; /* Multi threaded */
config.method = 2; /* Compression method (0=fast/larger, 6=slow/smaller) */ config.method = 2; /* Compression method (0=fast/larger, 6=slow/smaller) */

View File

@ -44,12 +44,18 @@
* The Cairo surface to write to the given stream and socket as PNG blobs. * The Cairo surface to write to the given stream and socket as PNG blobs.
* *
* @param quality * @param quality
* The WebP image quality to use. * The WebP image quality to use. For lossy images, larger values indicate
* improving quality at the expense of larger file size. For lossless
* images, this dictates the quality of compression, with larger values
* producing smaller files at the expense of speed.
*
* @param lossless
* Zero for a lossy image, non-zero for lossless.
* *
* @return * @return
* Zero if the encoding operation is successful, non-zero otherwise. * Zero if the encoding operation is successful, non-zero otherwise.
*/ */
int guac_webp_write(guac_socket* socket, guac_stream* stream, int guac_webp_write(guac_socket* socket, guac_stream* stream,
cairo_surface_t* surface, int quality); cairo_surface_t* surface, int quality, int lossless);
#endif #endif

View File

@ -737,12 +737,18 @@ void guac_client_stream_jpeg(guac_client* client, guac_socket* socket,
* A Cairo surface containing the image data to be streamed. * A Cairo surface containing the image data to be streamed.
* *
* @param quality * @param quality
* The WebP image quality, which must be an integer value between 0 and * The WebP image quality, which must be an integer value between 0 and 100
* 100 inclusive. * inclusive. For lossy images, larger values indicate improving quality at
* the expense of larger file size. For lossless images, this dictates the
* quality of compression, with larger values producing smaller files at
* the expense of speed.
*
* @param lossless
* Zero to encode a lossy image, non-zero to encode losslessly.
*/ */
void guac_client_stream_webp(guac_client* client, guac_socket* socket, void guac_client_stream_webp(guac_client* client, guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, int x, int y, guac_composite_mode mode, const guac_layer* layer, int x, int y,
cairo_surface_t* surface, int quality); cairo_surface_t* surface, int quality, int lossless);
/** /**
* Returns whether the given client supports WebP. If the client does not * Returns whether the given client supports WebP. If the client does not