summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/red_worker.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/server/red_worker.c b/server/red_worker.c
index 773072a..2b7416d 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -761,8 +761,9 @@ typedef struct DrawItem {
typedef enum {
BITMAP_GRADUAL_INVALID,
BITMAP_GRADUAL_NOT_AVAIL,
- BITMAP_GRADUAL_TRUE,
- BITMAP_GRADUAL_FALSE,
+ BITMAP_GRADUAL_LOW,
+ BITMAP_GRADUAL_MEDIUM,
+ BITMAP_GRADUAL_HIGH,
} BitmapGradualType;
struct Drawable {
@@ -980,7 +981,7 @@ static void red_display_release_stream_clip(DisplayChannel* channel, StreamClipI
static int red_display_free_some_independent_glz_drawables(DisplayChannel *channel);
static void red_display_free_glz_drawable(DisplayChannel *channel, RedGlzDrawable *drawable);
static void reset_rate(StreamAgent *stream_agent);
-static int _bitmap_is_gradual(RedWorker *worker, Bitmap *bitmap);
+static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, Bitmap *bitmap);
static inline int _stride_is_extra(Bitmap *bitmap);
#ifdef DUMP_BITMAP
@@ -2750,11 +2751,7 @@ static inline void red_update_copy_graduality(RedWorker* worker, Drawable *drawa
(qxl_image->bitmap.flags & QXL_BITMAP_UNSTABLE)) {
drawable->copy_bitmap_graduality = BITMAP_GRADUAL_NOT_AVAIL;
} else {
- if (_bitmap_is_gradual(worker, &qxl_image->bitmap)) {
- drawable->copy_bitmap_graduality = BITMAP_GRADUAL_TRUE;
- } else {
- drawable->copy_bitmap_graduality = BITMAP_GRADUAL_FALSE;
- }
+ drawable->copy_bitmap_graduality = _get_bitmap_graduality_level(worker, &qxl_image->bitmap);
}
}
@@ -2774,7 +2771,7 @@ static void red_stream_add_frame(RedWorker* worker, Drawable *frame_drawable,
frame_drawable->frames_count = frames_count + 1;
frame_drawable->gradual_frames_count = gradual_frames_count;
- if (frame_drawable->copy_bitmap_graduality != BITMAP_GRADUAL_FALSE) {
+ if (frame_drawable->copy_bitmap_graduality != BITMAP_GRADUAL_LOW) {
if ((frame_drawable->frames_count - last_gradual_frame) >
RED_STREAM_FRAMES_RESET_CONDITION) {
frame_drawable->frames_count = 1;
@@ -5089,11 +5086,16 @@ typedef uint16_t rgb16_pixel_t;
#define RED_BITMAP_UTILS_RGB32
#include "red_bitmap_utils.h"
-#define GRADUAL_SCORE_RGB24_TH -0.03
-#define GRADUAL_SCORE_RGB16_TH 0
+#define GRADUAL_HIGH_RGB24_TH -0.03
+#define GRADUAL_HIGH_RGB16_TH 0
+
+// setting a more permissive threshold for stream identification in order
+// not to miss streams that were artificially scaled on the guest (e.g., full screen view
+// in window media player 12). see red_stream_add_frame
+#define GRADUAL_MEDIUM_SCORE_TH 0.002
// assumes that stride doesn't overflow
-static int _bitmap_is_gradual(RedWorker *worker, Bitmap *bitmap)
+static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, Bitmap *bitmap)
{
long address_delta = worker->dev_info.phys_delta;
double score = 0.0;
@@ -5157,9 +5159,19 @@ static int _bitmap_is_gradual(RedWorker *worker, Bitmap *bitmap)
score /= num_samples;
if (bitmap->format == BITMAP_FMT_16BIT) {
- return (score < GRADUAL_SCORE_RGB16_TH);
+ if (score < GRADUAL_HIGH_RGB16_TH) {
+ return BITMAP_GRADUAL_HIGH;
+ }
+ } else {
+ if (score < GRADUAL_HIGH_RGB24_TH) {
+ return BITMAP_GRADUAL_HIGH;
+ }
+ }
+
+ if (score < GRADUAL_MEDIUM_SCORE_TH) {
+ return BITMAP_GRADUAL_MEDIUM;
} else {
- return (score < GRADUAL_SCORE_RGB24_TH);
+ return BITMAP_GRADUAL_LOW;
}
}
@@ -5535,9 +5547,10 @@ static inline int red_compress_image(DisplayChannel *display_channel,
} else {
if (drawable->copy_bitmap_graduality == BITMAP_GRADUAL_INVALID) {
quic_compress = BITMAP_FMT_IS_RGB[src->format] &&
- _bitmap_is_gradual(display_channel->base.worker, src);
+ (_get_bitmap_graduality_level(display_channel->base.worker, src) ==
+ BITMAP_GRADUAL_HIGH);
} else {
- quic_compress = (drawable->copy_bitmap_graduality == BITMAP_GRADUAL_TRUE);
+ quic_compress = (drawable->copy_bitmap_graduality == BITMAP_GRADUAL_HIGH);
}
}
} else {