fixed LZ4F_compressFrameBound (dynamic block resize)
authorYann Collet <yann.collet.73@gmail.com>
Tue, 21 Oct 2014 23:36:32 +0000 (00:36 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Tue, 21 Oct 2014 23:36:32 +0000 (00:36 +0100)
lz4frame.c [changed mode: 0644->0755]
programs/frametest.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 93069e0..f7bf242
@@ -234,6 +234,20 @@ size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t* prefere
     size_t streamSize;
 
     if (preferencesPtr!=NULL) prefs = *preferencesPtr;
+    {
+        blockSizeID_t proposedBSID = max64KB;
+        size_t maxBlockSize = 64 KB;
+        while (prefs.frameInfo.blockSizeID > proposedBSID)
+        {
+            if (srcSize <= maxBlockSize)
+            {
+                prefs.frameInfo.blockSizeID = proposedBSID;
+                break;
+            }
+            proposedBSID++;
+            maxBlockSize <<= 2;
+        }
+    }
     prefs.autoFlush = 1;
 
     headerSize = 7;      /* basic header size (no option) including magic number */
old mode 100644 (file)
new mode 100755 (executable)
index 343a8ab..abf0cde
@@ -78,7 +78,7 @@ typedef unsigned long long  U64;
 #define MB *(1U<<20)
 #define GB *(1U<<30)
 
-static const U32 nbTestsDefault = 128 KB;
+static const U32 nbTestsDefault = 256 KB;
 #define COMPRESSIBLE_NOISE_LENGTH (2 MB)
 #define FUZ_COMPRESSIBILITY_DEFAULT 50
 static const U32 prime1 = 2654435761U;
@@ -597,7 +597,12 @@ int main(int argc, char** argv)
                     argument++;
                     displayLevel--;
                     break;
-                case 'i':
+                case 'p': /* pause at the end */
+                    argument++;
+                    pause = 1;
+                    break;
+
+                               case 'i':
                     argument++;
                     nbTests=0;
                     while ((*argument>='0') && (*argument<='9'))
@@ -628,7 +633,7 @@ int main(int argc, char** argv)
                         argument++;
                     }
                     break;
-                case 'p':   /* compressibility % */
+                case 'P':   /* compressibility % */
                     argument++;
                     proba=0;
                     while ((*argument>='0') && (*argument<='9'))
@@ -640,10 +645,6 @@ int main(int argc, char** argv)
                     if (proba<0) proba=0;
                     if (proba>100) proba=100;
                     break;
-                case 'P': /* pause at the end */
-                    argument++;
-                    pause = 1;
-                    break;
                 default:
                     ;
                     return FUZ_usage();