diff tools/lib64fmts.c @ 1839:666b27999570

As the Koala Painter plain RLE compression (without headers and static marker value) is used in various others formats, make the functions generic.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 22 Jun 2018 19:01:23 +0300
parents d02514ceed91
children 8d6bb48f2806
line wrap: on
line diff
--- a/tools/lib64fmts.c	Fri Jun 22 18:21:36 2018 +0300
+++ b/tools/lib64fmts.c	Fri Jun 22 19:01:23 2018 +0300
@@ -23,7 +23,7 @@
 }
 
 
-static int fmtDecodeKoalaPainterPacked(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
+static int fmtDecodeStaticRLEMarkerMode2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
 {
     int res;
     DMGrowBuf mem;
@@ -32,7 +32,7 @@
     cfg.func         = fmt->name;
     cfg.type         = DM_COMP_RLE_MARKER;
     cfg.flags        = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2;
-    cfg.rleMarkerB   = 0xfe;
+    cfg.rleMarkerB   = fmt->size;
 
     if ((res = dmDecodeGenericRLEAlloc(&mem, buf, &cfg)) != DMERR_OK)
         goto out;
@@ -45,7 +45,7 @@
 }
 
 
-static int fmtEncodeKoalaPainterPacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
+static int fmtEncodeStaticRLEMarkerMode2(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
 {
     int res;
     DMGrowBuf tmp;
@@ -59,7 +59,7 @@
     cfg.func         = fmt->name;
     cfg.type         = DM_COMP_RLE_MARKER;
     cfg.flags        = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2;
-    cfg.rleMarkerB   = 0xfe;
+    cfg.rleMarkerB   = fmt->size;
     cfg.rleMinCountB = 3;
     cfg.rleMaxCountB = 255;
     res = dmEncodeGenericRLE(buf, &tmp, &cfg);
@@ -1257,9 +1257,9 @@
     },
 
     {
-        "klp", "Koala Painter (packed)", 0x6000, 0, DM_FMT_RDWR,
+        "klp", "Koala Painter (packed)", 0x6000, 0xfe, DM_FMT_RDWR, // size is abused for RLE marker byte
         fmtProbeKoalaPainterPacked,
-        fmtDecodeKoalaPainterPacked, fmtEncodeKoalaPainterPacked,
+        fmtDecodeStaticRLEMarkerMode2, fmtEncodeStaticRLEMarkerMode2,
         { }, &dmC64CommonFormats[0]
     },