[Spice-commits] 2 commits - server/mjpeg_encoder.c server/tests

Yonit Halperin yhalperi at kemper.freedesktop.org
Tue May 15 22:57:34 PDT 2012


 server/mjpeg_encoder.c                |   10 ++++++++--
 server/tests/test_display_streaming.c |   11 ++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

New commits:
commit dd0d4959bb14c377c99c092de24ec3a26de8ec7d
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Tue May 15 09:33:14 2012 +0300

    server/tests: test_display_streaming - test wide sized frames
    
    Before, we tested only higher frames, while wider frames would have
    triggered a bug in mjpeg_encoder, when spice is linked with libjpeg and
    not libjpeg-turbo.

diff --git a/server/tests/test_display_streaming.c b/server/tests/test_display_streaming.c
index f395800..c2acd49 100644
--- a/server/tests/test_display_streaming.c
+++ b/server/tests/test_display_streaming.c
@@ -49,7 +49,7 @@ void create_overlay(Command *command , int width, int height)
  * Upon the OVERLAY_FRAME-th, a drawable is created on top of a part of the stream,
  * and from then on, all the stream frames has a clipping that keeps this drawable
  * visible, and in addition a clipping_factor is subtracted from the right limit of their clipping.
- * If sized=TRUE, a higher frame than the original stream height is created every SIZED_INTERVAL.
+ * If sized=TRUE, a higher and wider frame than the original stream is created every SIZED_INTERVAL.
  * The sized frames can be distinguished by a change in the color of the top and bottom limits of the
  * surface.
  */
@@ -58,7 +58,8 @@ void create_clipped_frame(Command *command, int clipping_factor)
     static int count = 0;
     CommandDrawBitmap *cmd = &command->bitmap;
     int max_height = test_get_height();
-    int width = test_get_width();
+    int max_width = test_get_width();
+    int width;
     int height;
     int cur_line, end_line;
     uint32_t *dst;
@@ -75,11 +76,12 @@ void create_clipped_frame(Command *command, int clipping_factor)
     cmd->surface_id = 0;
 
     cmd->bbox.left = 0;
-    cmd->bbox.right = width;
+    cmd->bbox.right = max_width - 50;
     assert(max_height > 600);
     cmd->bbox.top = 50;
     cmd->bbox.bottom = max_height - 50;
     height = cmd->bbox.bottom  - cmd->bbox.top;
+    width = cmd->bbox.right - cmd->bbox.left;
     cur_line = (height/30)*(count % 30);
     end_line = cur_line + (height/30);
     if (end_line >= height || height - end_line < 8) {
@@ -90,7 +92,10 @@ void create_clipped_frame(Command *command, int clipping_factor)
 
         cmd->bbox.top = 0;
         cmd->bbox.bottom = max_height;
+        cmd->bbox.left = 0;
+        cmd->bbox.right = max_width;
         height = max_height;
+        width = max_width;
         cur_line += 50;
         end_line += 50;
     }
commit d0a57ac22becf162148c11cc30b89f34bc4120bf
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Mon May 14 15:17:54 2012 +0300

    server/mjpeg_encoder: realloc encoder->row, when a wider frame is given
    
    Fix crashes when there are sized wider frames in the stream, and we are
    linked with libjpeg.
    
    Related : rhbz#813826
    Resolves: rhbz#820669

diff --git a/server/mjpeg_encoder.c b/server/mjpeg_encoder.c
index 6bb2f69..b812ba0 100644
--- a/server/mjpeg_encoder.c
+++ b/server/mjpeg_encoder.c
@@ -26,6 +26,7 @@
 
 struct MJpegEncoder {
     uint8_t *row;
+    uint32_t row_size;
     int first_frame;
     int quality;
 
@@ -196,6 +197,8 @@ int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
 {
     encoder->cinfo.in_color_space   = JCS_RGB;
     encoder->cinfo.input_components = 3;
+    encoder->pixel_converter = NULL;
+
     switch (format) {
     case SPICE_BITMAP_FMT_32BIT:
     case SPICE_BITMAP_FMT_RGBA:
@@ -224,13 +227,16 @@ int mjpeg_encoder_start_frame(MJpegEncoder *encoder, SpiceBitmapFmt format,
         return FALSE;
     }
 
-    if ((encoder->pixel_converter != NULL) && (encoder->row == NULL)) {
+    if (encoder->pixel_converter != NULL) {
         unsigned int stride = width * 3;
         /* check for integer overflow */
         if (stride < width) {
             return FALSE;
         }
-        encoder->row = spice_malloc(stride);
+        if (encoder->row_size < stride) {
+            encoder->row = spice_realloc(encoder->row, stride);
+            encoder->row_size = stride;
+        }
     }
 
     spice_jpeg_mem_dest(&encoder->cinfo, dest, dest_len);


More information about the Spice-commits mailing list