summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2010-03-21 17:30:14 +0200
committerUri Lublin <uril@redhat.com>2010-03-23 15:38:40 +0200
commitced3dd76352a84f6b6621218820d37530aab43b3 (patch)
tree2b8fac167dd5445dd2eda3991b2d5d72e85f91f6
parent273a460eebb3c2fd93978dff4d1fa0e21a858456 (diff)
spice: server: Being more permissive in video identification #575576 (related to #493375)spice-server-0.4.2-6.el6
In 'filter' video streaming mode, use a more permissive threshold for distinguishing 'realistic' streams from 'textaul'/'artificial' streams. The previous threshold classified streams that were scaled on the guest as artificial and thus they were not recoginized as videos.
-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 {