Mercurial > hg > dmlib
diff tools/lib64gfx.h @ 1650:9233da9de92c
Refactor RLE encoding a bit, and add support for 16bit run counts and make things more configurable.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 30 May 2018 03:25:34 +0300 |
parents | 948d6fda722d |
children | 7555c8803529 |
line wrap: on
line diff
--- a/tools/lib64gfx.h Wed May 30 01:29:09 2018 +0300 +++ b/tools/lib64gfx.h Wed May 30 03:25:34 2018 +0300 @@ -204,17 +204,34 @@ // -// Compression types +// Compression types and flags // -#define DM_COMP_RLE_MARKER1 1 -#define DM_COMP_RLE_MARKER2 2 -#define DM_COMP_RLE_MASK 3 +enum +{ + DM_COMP_RLE_MARKER = 1, // RLE with a separate marker byte + DM_COMP_RLE_MASK = 2, // RLE that has marker bits and lower part acts as run length +}; + +enum +{ + DM_RLE_8BIT_RUNS = 0x0001, // Uses one-byte runs + DM_RLE_16BIT_RUNS = 0x0002, // Uses two-byte runs + DM_RLE_RUNS_MASK = 0x000f, + + 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, +}; typedef struct { int type; - Uint8 rleMarker, rleMask1, rleMask2, rleMinCount, rleMaxCount; + int flags; + Uint8 + rleMarker1, rleMarker2, + rleMask1, rleMask2, + rleMinCount, rleMaxCount; } DMCompParams; @@ -267,7 +284,7 @@ int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt); int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt); -void dmGenericRLEAnalyze(const DMGrowBuf *buf, Uint8 *rleMarker, const int rleType); +void dmGenericRLEAnalyze(const Uint8 *buf, const size_t len, 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);