[Spice-commits] 7 commits - common/lz_compress_tmpl.c common/lz_decompress_tmpl.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 7 15:27:33 UTC 2020


 common/lz_compress_tmpl.c   |    5 -----
 common/lz_decompress_tmpl.c |   35 ++++++++++++++++-------------------
 2 files changed, 16 insertions(+), 24 deletions(-)

New commits:
commit ea864c70d92be5465ad4a7d12b956935f5dc5c81
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Nov 16 10:40:39 2019 +0000

    lz_compress: Cleanup unused macros
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_compress_tmpl.c b/common/lz_compress_tmpl.c
index 1d4eb81..c3a7202 100644
--- a/common/lz_compress_tmpl.c
+++ b/common/lz_compress_tmpl.c
@@ -507,16 +507,11 @@ static void FNAME(compress)(Encoder *encoder)
 #undef PIXEL
 #undef ENCODE_PIXEL
 #undef SAME_PIXEL
-#undef LZ_READU16
 #undef HASH_FUNC
-#undef BYTES_TO_16
-#undef HASH_FUNC_16
 #undef GET_rgb
-#undef GET_CODE
 #undef LZ_PLT
 #undef LZ_RGB_ALPHA
 #undef LZ_RGB16
 #undef LZ_RGB24
 #undef LZ_RGB32
 #undef LZ_A8
-#undef HASH_FUNC2
commit d5d1d5b0bfad44dc043b309809f23a5a589036d9
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 10 17:08:41 2019 +0100

    lz_decompress: Read "ctrl" inside loop
    
    Remove code duplication
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index 3f7a386..099f3dd 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -223,9 +223,9 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
 {
     OUT_PIXEL    *op = out_buf;
     OUT_PIXEL    *const op_limit = out_buf + size;
-    uint32_t ctrl = decode(encoder);
 
     for (;;) {
+        uint32_t ctrl = decode(encoder);
 
         if (ctrl >= MAX_COPY) { // reference (dictionary/RLE)
             /* retrieving the reference and the match length */
@@ -305,7 +305,6 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
         if (LZ_UNEXPECT_CONDITIONAL(op >= op_limit)) {
             break;
         }
-        ctrl = decode(encoder);
     }
 
     return (op - out_buf);
commit a446b5b27b0b59e01114864710fc6b19583a15ed
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 10 17:08:18 2019 +0100

    lz_decompress: Move variable declaration in nested scope
    
    No need to compute these variable always, only if we have
    a reference to a previous sequence.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index 7e74d83..3f7a386 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -226,13 +226,14 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
     uint32_t ctrl = decode(encoder);
 
     for (;;) {
-        const OUT_PIXEL *ref = op;
-        uint32_t len = ctrl >> 5;
-        uint32_t ofs = (ctrl & 31) << 8; // 5 MSb of distance
 
         if (ctrl >= MAX_COPY) { // reference (dictionary/RLE)
             /* retrieving the reference and the match length */
 
+            const OUT_PIXEL *ref = op;
+            uint32_t len = ctrl >> 5;
+            uint32_t ofs = (ctrl & 31) << 8; // 5 MSb of distance
+
             uint8_t code;
             len--;
             //ref -= ofs;
commit 08fafdbb33104b79eed937ec17eade4c41a0a8bc
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 10 17:07:44 2019 +0100

    lz_decompress: Reindented comment
    
    Just space changes
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index c393616..7e74d83 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -50,10 +50,10 @@
 
 /*
     For each output pixel type the following macros are defined:
-    OUT_PIXEL                      - the output pixel type
-    COPY_PIXEL(p, out)              - assigns the pixel to the place pointed by out and increases
-                                      out. Used in RLE. Need special handling because in alpha we
-                                      copy only the pad byte.
+    OUT_PIXEL                     - the output pixel type
+    COPY_PIXEL(p, out)            - assigns the pixel to the place pointed by out and increases
+                                    out. Used in RLE. Need special handling because in alpha we
+                                    copy only the pad byte.
     COPY_REF_PIXEL(ref, out)      - copies the pixel pointed by ref to the pixel pointed by out.
                                     Increases ref and out.
     COPY_COMP_PIXEL(encoder, out) - copies pixel from the compressed buffer to the decompressed
commit 6595de58a285c5ed61110cd15026963e7633473c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 10 17:06:47 2019 +0100

    lz_decompress: Simplify loop
    
    The loop is always executed once so use a do {} while construct
    to avoid the repetition.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index 4713e31..c393616 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -294,14 +294,11 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
         } else { // copy
             ctrl++; // copy count is biased by 1
             spice_assert(op + CAST_PLT_DISTANCE(ctrl) <= op_limit);
-            COPY_COMP_PIXEL(encoder, op);
 
-            spice_assert(op <= op_limit);
-
-            for (--ctrl; ctrl; ctrl--) {
+            do {
                 COPY_COMP_PIXEL(encoder, op);
                 spice_extra_assert(op <= op_limit);
-            }
+            } while(--ctrl);
         }
 
         if (LZ_UNEXPECT_CONDITIONAL(op >= op_limit)) {
commit 109f6a4802b25642ec21ca06b0ee8c737f6b8d0c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 10 17:06:01 2019 +0100

    lz_decompress: Do not execute nested checks
    
    Boundaries checks already done some lines above, no needs
    to repeat for each pixel.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index 9ac139f..4713e31 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -283,12 +283,12 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
                 const OUT_PIXEL b = *ref;
                 for (; len; --len) {
                     COPY_PIXEL(b, op);
-                    spice_assert(op <= op_limit);
+                    spice_extra_assert(op <= op_limit);
                 }
             } else {
                 for (; len; --len) {
                     COPY_REF_PIXEL(ref, op);
-                    spice_assert(op <= op_limit);
+                    spice_extra_assert(op <= op_limit);
                 }
             }
         } else { // copy
@@ -300,7 +300,7 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
 
             for (--ctrl; ctrl; ctrl--) {
                 COPY_COMP_PIXEL(encoder, op);
-                spice_assert(op <= op_limit);
+                spice_extra_assert(op <= op_limit);
             }
         }
 
commit ac4763bd89c8106814020d87d2a08b17549557ef
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Fri May 10 17:04:47 2019 +0100

    lz_decompress: Constify some variable
    
    Make clear they are not supposed to be changed.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Francesco Giudici <fgiudici at redhat.com>

diff --git a/common/lz_decompress_tmpl.c b/common/lz_decompress_tmpl.c
index 462513f..9ac139f 100644
--- a/common/lz_decompress_tmpl.c
+++ b/common/lz_decompress_tmpl.c
@@ -222,7 +222,7 @@
 static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
 {
     OUT_PIXEL    *op = out_buf;
-    OUT_PIXEL    *op_limit = out_buf + size;
+    OUT_PIXEL    *const op_limit = out_buf + size;
     uint32_t ctrl = decode(encoder);
 
     for (;;) {
@@ -280,7 +280,7 @@ static size_t FNAME(decompress)(Encoder *encoder, OUT_PIXEL *out_buf, int size)
                                           //       because the number of pixel copied is larger
                                           //       then one...
                 /* optimize copy for a run */
-                OUT_PIXEL b = *ref;
+                const OUT_PIXEL b = *ref;
                 for (; len; --len) {
                     COPY_PIXEL(b, op);
                     spice_assert(op <= op_limit);


More information about the Spice-commits mailing list