You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/09/26 12:46:16 UTC

[1/2] guacamole-server git commit: GUACAMOLE-632: Dynamically scale JPEG/WebP quality depending on measured processing lag.

Repository: guacamole-server
Updated Branches:
  refs/heads/master 43db1965e -> 2d6ce1a5f


GUACAMOLE-632: Dynamically scale JPEG/WebP quality depending on measured processing lag.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/45e8503e
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/45e8503e
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/45e8503e

Branch: refs/heads/master
Commit: 45e8503ead5aa90ee8f53ddf43257c019069653d
Parents: 54fda21
Author: Michael Jumper <mj...@apache.org>
Authored: Tue May 17 20:49:51 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Sep 25 13:28:21 2018 -0700

----------------------------------------------------------------------
 src/common/surface.c | 48 +++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/45e8503e/src/common/surface.c
----------------------------------------------------------------------
diff --git a/src/common/surface.c b/src/common/surface.c
index 8c690b7..c31dfbf 100644
--- a/src/common/surface.c
+++ b/src/common/surface.c
@@ -79,13 +79,6 @@
 #endif
 
 /**
- * The JPEG image quality ('quantization') setting to use. Range 0-100 where
- * 100 is the highest quality/largest file size, and 0 is the lowest
- * quality/smallest file size.
- */
-#define GUAC_SURFACE_JPEG_IMAGE_QUALITY 90
-
-/**
  * The framerate which, if exceeded, indicates that JPEG is preferred.
  */
 #define GUAC_COMMON_SURFACE_JPEG_FRAMERATE 3
@@ -97,13 +90,6 @@
 #define GUAC_SURFACE_JPEG_MIN_BITMAP_SIZE 4096
 
 /**
- * The WebP image quality ('quantization') setting to use. Range 0-100 where
- * 100 is the highest quality/largest file size, and 0 is the lowest
- * quality/smallest file size.
- */
-#define GUAC_SURFACE_WEBP_IMAGE_QUALITY 90
-
-/**
  * The JPEG compression min block size. This defines the optimal rectangle block
  * size factor for JPEG compression. Usually 8x8 would suffice, but use 16 to
  * reduce the occurrence of ringing artifacts further.
@@ -1667,6 +1653,36 @@ static void __guac_common_surface_flush_to_png(guac_common_surface* surface,
 }
 
 /**
+ * Returns an appropriate quality between 0 and 100 for lossy encoding
+ * depending on the current processing lag calculated for the given client.
+ *
+ * @param client
+ *     The client for which the lossy quality is being calculated.
+ *
+ * @return
+ *     A value between 0 and 100 inclusive which seems appropriate for the
+ *     client based on lag measurements.
+ */
+static int guac_common_surface_suggest_quality(guac_client* client) {
+
+    int lag = guac_client_get_processing_lag(client);
+
+    /* Scale quality linearly from 90 to 30 as lag varies from 20ms to 80ms */
+    int quality = 90 - (lag - 20);
+
+    /* Do not exceed 90 for quality */
+    if (quality > 90)
+        return 90;
+
+    /* Do not go below 30 for quality */
+    if (quality < 30)
+        return 30;
+
+    return quality;
+
+}
+
+/**
  * Flushes the bitmap update currently described by the dirty rectangle within
  * the given surface directly via an "img" instruction as JPEG data. The
  * resulting instructions will be sent over the socket associated with the
@@ -1702,7 +1718,7 @@ static void __guac_common_surface_flush_to_jpeg(guac_common_surface* surface) {
         /* Send JPEG for rect */
         guac_client_stream_jpeg(surface->client, socket, GUAC_COMP_OVER, layer,
                 surface->dirty_rect.x, surface->dirty_rect.y, rect,
-                GUAC_SURFACE_JPEG_IMAGE_QUALITY);
+                guac_common_surface_suggest_quality(surface->client));
 
         cairo_surface_destroy(rect);
         surface->realized = 1;
@@ -1764,7 +1780,7 @@ static void __guac_common_surface_flush_to_webp(guac_common_surface* surface,
         /* Send WebP for rect */
         guac_client_stream_webp(surface->client, socket, GUAC_COMP_OVER, layer,
                 surface->dirty_rect.x, surface->dirty_rect.y, rect,
-                GUAC_SURFACE_WEBP_IMAGE_QUALITY, 0);
+                guac_common_surface_suggest_quality(surface->client), 0);
 
         cairo_surface_destroy(rect);
         surface->realized = 1;


[2/2] guacamole-server git commit: GUACAMOLE-632: Merge dynamic JPEG/WebP quality scaling.

Posted by vn...@apache.org.
GUACAMOLE-632: Merge dynamic JPEG/WebP quality scaling.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/2d6ce1a5
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/2d6ce1a5
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/2d6ce1a5

Branch: refs/heads/master
Commit: 2d6ce1a5fd7d1cdb0f5fd921e89abd55af3f320a
Parents: 43db196 45e8503
Author: Nick Couchman <vn...@apache.org>
Authored: Wed Sep 26 08:45:32 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Wed Sep 26 08:45:32 2018 -0400

----------------------------------------------------------------------
 src/common/surface.c | 48 +++++++++++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------