changeset 9775:3fd46320ab12 libavcodec

Take advantage of available input padding to optimize mszh_decomp
author reimar
date Sun, 31 May 2009 11:32:03 +0000
parents 69395e6a4d03
children 18d149e8fc7f
files lcldec.c
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lcldec.c	Sun May 31 10:58:20 2009 +0000
+++ b/lcldec.c	Sun May 31 11:32:03 2009 +0000
@@ -73,7 +73,7 @@
 
 
 /**
- * \param srcptr compressed source buffer, must be padded with at least 4 extra bytes
+ * \param srcptr compressed source buffer, must be padded with at least 5 extra bytes
  * \param destptr must be padded sufficiently for av_memcpy_backptr
  */
 static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize)
@@ -81,16 +81,11 @@
     unsigned char *destptr_bak = destptr;
     unsigned char *destptr_end = destptr + destsize;
     const unsigned char *srcptr_end = srcptr + srclen;
-    unsigned char mask = 0;
-    unsigned char maskbit = 0;
+    unsigned char mask = *srcptr++;
+    unsigned char maskbit = 0x80;
     unsigned int ofs, cnt;
 
     while (srcptr < srcptr_end && destptr < destptr_end) {
-        if (maskbit == 0) {
-            mask = *srcptr++;
-            maskbit = 0x80;
-            continue;
-        }
         if (!(mask & maskbit)) {
             memcpy(destptr, srcptr, 4);
             destptr += 4;
@@ -105,6 +100,10 @@
             destptr += cnt;
         }
         maskbit >>= 1;
+        if (!maskbit) {
+            mask = *srcptr++;
+            maskbit = 0x80;
+        }
     }
 
     return destptr - destptr_bak;