diff tools/lib64fmts.c @ 1660:7555c8803529

More work on improving the generic RLE decoder/encoder.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 May 2018 17:05:19 +0300
parents 4b528da326da
children dc3fbd130db7
line wrap: on
line diff
--- a/tools/lib64fmts.c	Wed May 30 14:45:14 2018 +0300
+++ b/tools/lib64fmts.c	Wed May 30 17:05:19 2018 +0300
@@ -52,8 +52,8 @@
     DMCompParams cfg;
 
     cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_2;
-    cfg.rleMarker1  = 0xfe;
+    cfg.flags       = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2;
+    cfg.rleMarkerB  = 0xfe;
     if ((res = dmDecodeGenericRLEAlloc(&mem, buf, buf + len, &cfg)) != DMERR_OK)
         goto out;
 
@@ -76,11 +76,11 @@
         goto out;
 
     // And now RLE compress the data to the existing buffer
-    cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_2;
-    cfg.rleMarker1  = 0xfe;
-    cfg.rleMinCount = 3;
-    cfg.rleMaxCount = 255;
+    cfg.type         = DM_COMP_RLE_MARKER;
+    cfg.flags        = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2;
+    cfg.rleMarkerB   = 0xfe;
+    cfg.rleMinCountB = 3;
+    cfg.rleMaxCountB = 255;
     res = dmEncodeGenericRLE(buf, tmp.data, tmp.data + tmp.len, &cfg);
 
 out:
@@ -113,8 +113,8 @@
     DMCompParams cfg;
 
     cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_1;
-    cfg.rleMarker1  = buf[0x0d];
+    cfg.flags       = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMarkerB  = buf[0x0d];
 
     if ((res = dmDecodeGenericRLEAlloc(&mem, buf + 0x0e, buf + len, &cfg)) != DMERR_OK)
         goto out;
@@ -140,14 +140,14 @@
 
     // Analyze and setup RLE
     dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg);
-    cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_1;
-    cfg.rleMinCount = 3;
-    cfg.rleMaxCount = 255;
+    cfg.type         = DM_COMP_RLE_MARKER;
+    cfg.flags        = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMinCountB = 3;
+    cfg.rleMaxCountB = 255;
 
     // Add the header bits
     if (!dmGrowBufPut(buf, magicID, strlen(magicID)) ||
-        !dmGrowBufPutU8(buf, cfg.rleMarker1))
+        !dmGrowBufPutU8(buf, cfg.rleMarkerB))
     {
         res = DMERR_MALLOC;
         goto out;
@@ -212,9 +212,9 @@
     DMCompParams cfg;
 
     cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_16BIT_RUNS | DM_RLE_ORDER_1;
-    cfg.rleMarker1  = buf[8];
-    cfg.rleMarker2  = buf[9];
+    cfg.flags       = DM_RLE_BYTE_RUNS | DM_RLE_WORD_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMarkerB  = buf[8];
+    cfg.rleMarkerW  = buf[9];
 
     if ((res = dmDecodeGenericRLEAlloc(&mem, buf + 10, buf + len, &cfg)) != DMERR_OK)
         goto out;
@@ -280,8 +280,8 @@
 
     // Now do an RLE decode on the enlarged buffer
     cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_1;
-    cfg.rleMarker1  = 0xC2;
+    cfg.flags       = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMarkerB  = 0xC2;
 
     if ((res = dmDecodeGenericRLEAlloc(&mem, tmp.data, tmp.data + tmp.len, &cfg)) != DMERR_OK)
         goto out;
@@ -307,11 +307,11 @@
         goto out;
 
     // And now RLE compress the data to the existing buffer
-    cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_1;
-    cfg.rleMarker1  = 0xC2;
-    cfg.rleMinCount = 3;
-    cfg.rleMaxCount = 255;
+    cfg.type         = DM_COMP_RLE_MARKER;
+    cfg.flags        = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMarkerB   = 0xC2;
+    cfg.rleMinCountB = 3;
+    cfg.rleMaxCountB = 255;
 
     res = dmEncodeGenericRLE(buf, tmp.data, tmp.data + tmp.len, &cfg);
 
@@ -548,8 +548,8 @@
         DMCompParams cfg;
 
         cfg.type        = DM_COMP_RLE_MARKER;
-        cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_1;
-        cfg.rleMarker1  = buf[15];
+        cfg.flags       = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
+        cfg.rleMarkerB  = buf[15];
 
         if ((res = dmDecodeGenericRLEAlloc(
             &mem, buf + FUNPAINT2_HEADER_SIZE, buf + len, &cfg)) == DMERR_OK)
@@ -589,14 +589,14 @@
 
     // Analyze and setup RLE
     dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg);
-    cfg.type        = DM_COMP_RLE_MARKER;
-    cfg.flags       = DM_RLE_8BIT_RUNS | DM_RLE_ORDER_1;
-    cfg.rleMinCount = 3;
-    cfg.rleMaxCount = 255;
+    cfg.type         = DM_COMP_RLE_MARKER;
+    cfg.flags        = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1;
+    cfg.rleMinCountB = 3;
+    cfg.rleMaxCountB = 255;
 
     // Add the header bits
     if (!dmGrowBufPut(buf, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) ||
-        !dmGrowBufPutU8(buf, cfg.rleMarker1))
+        !dmGrowBufPutU8(buf, cfg.rleMarkerB))
     {
         res = DMERR_MALLOC;
         goto out;