diff tools/lib64gfx.h @ 1707:a0986cfd6f9d

More consistently use DMGrowBuf in the lib64gfx APIs, and implement "backwards" RLE decoding and encoding (optionally regards input/output). Not tested very much yet, there may be bugs.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jun 2018 21:58:10 +0300
parents 1741717b1ae5
children 2b592df78943
line wrap: on
line diff
--- a/tools/lib64gfx.h	Tue Jun 05 19:57:08 2018 +0300
+++ b/tools/lib64gfx.h	Tue Jun 05 21:58:10 2018 +0300
@@ -175,7 +175,7 @@
     int    bank;
     size_t size;
 
-    BOOL   (*decFunction)(DMC64Image *img, const struct _DMC64EncDecOp *op, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt);
+    BOOL   (*decFunction)(DMC64Image *img, const struct _DMC64EncDecOp *op, const DMGrowBuf *buf, const DMC64ImageFormat *fmt);
     BOOL   (*encFunction)(const struct _DMC64EncDecOp *op, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);
 } DMC64EncDecOp;
 
@@ -199,7 +199,7 @@
 
     int  (*probe)(const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt);
 
-    int  (*decode)(DMC64Image *img, const Uint8 *buf, const size_t len, const struct _DMC64ImageFormat *fmt);
+    int  (*decode)(DMC64Image *img, const DMGrowBuf *buf, const struct _DMC64ImageFormat *fmt);
     int  (*encode)(DMGrowBuf *buf, const DMC64Image *img, const struct _DMC64ImageFormat *fmt);
 
     int  (*convertFrom)(DMImage *, const DMC64Image *, const struct _DMC64ImageFormat *fmt);
@@ -229,6 +229,9 @@
     DM_RLE_ORDER_1          = 0x0000, // Order: <marker>, <count/run length>, <data>
     DM_RLE_ORDER_2          = 0x0010, // Order: <marker>, <data>, <count/run length>
     DM_RLE_ORDER_MASK       = 0x00f0,
+
+    DM_RLE_BACKWARDS_INPUT  = 0x1000,
+    DM_RLE_BACKWARDS_OUTPUT = 0x2000,
 };
 
 
@@ -246,7 +249,7 @@
         rleMarkerMask,       // Mask bits for marker: data & rleMarkerMask == rleMarkerBits
         rleCountMask;        // Mask bits for length: count = data & rleCountMask
 
-    int
+    unsigned int
         // Minimum and maximum run lengths
         rleMinCountB,
         rleMinCountW,
@@ -292,25 +295,25 @@
 
 int       dmC64ProbeBMP(const Uint8 *buf, const size_t len, const DMC64ImageFormat **fmt);
 
-int       dmC64DecodeGenericBMP(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt);
+int       dmC64DecodeGenericBMP(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt);
 int       dmC64EncodeGenericBMP(const BOOL allocate, DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);
 
 int       dmC64ConvertBMP2Image(DMImage **pdst, const DMC64Image *src, const DMC64ImageFormat *fmt);
 int       dmC64ConvertImage2BMP(DMC64Image **pdst, const DMImage *src, const DMC64ImageFormat *fmt);
 
-int       dmC64DecodeBMP(DMC64Image **img, const Uint8 *buf, const size_t len, const size_t probeOffs, const size_t loadOffs, const DMC64ImageFormat **fmt, const DMC64ImageFormat *forced);
+int       dmC64DecodeBMP(DMC64Image **img, const DMGrowBuf *buf, const size_t probeOffs, const size_t loadOffs, const DMC64ImageFormat **fmt, const DMC64ImageFormat *forced);
 int       dmC64EncodeBMP(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt);
 
 int       dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt);
 int       dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt);
 
-void      dmGenericRLEAnalyze(const Uint8 *buf, const size_t len, DMCompParams *cfg);
+void      dmGenericRLEAnalyze(const DMGrowBuf *buf, DMCompParams *cfg);
 
-int       dmDecodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg);
-int       dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg);
+int       dmDecodeGenericRLE(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg);
+int       dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg);
 
-int       dmEncodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg);
-int       dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg);
+int       dmEncodeGenericRLE(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg);
+int       dmEncodeGenericRLEAlloc(DMGrowBuf *dst, const DMGrowBuf *src, const DMCompParams *cfg);
 
 
 //