Mercurial > hg > dmlib
comparison 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 |
comparison
equal
deleted
inserted
replaced
1649:dbdff3d50a4e | 1650:9233da9de92c |
---|---|
202 const DMC64EncDecOpList encdecOps, *encdecOpsRef; | 202 const DMC64EncDecOpList encdecOps, *encdecOpsRef; |
203 } DMC64ImageFormat; | 203 } DMC64ImageFormat; |
204 | 204 |
205 | 205 |
206 // | 206 // |
207 // Compression types | 207 // Compression types and flags |
208 // | 208 // |
209 #define DM_COMP_RLE_MARKER1 1 | 209 enum |
210 #define DM_COMP_RLE_MARKER2 2 | 210 { |
211 #define DM_COMP_RLE_MASK 3 | 211 DM_COMP_RLE_MARKER = 1, // RLE with a separate marker byte |
212 DM_COMP_RLE_MASK = 2, // RLE that has marker bits and lower part acts as run length | |
213 }; | |
214 | |
215 enum | |
216 { | |
217 DM_RLE_8BIT_RUNS = 0x0001, // Uses one-byte runs | |
218 DM_RLE_16BIT_RUNS = 0x0002, // Uses two-byte runs | |
219 DM_RLE_RUNS_MASK = 0x000f, | |
220 | |
221 DM_RLE_ORDER_1 = 0x0000, // Order: <marker>, <count/run length>, <data> | |
222 DM_RLE_ORDER_2 = 0x0010, // Order: <marker>, <data>, <count/run length> | |
223 DM_RLE_ORDER_MASK = 0x00f0, | |
224 }; | |
212 | 225 |
213 | 226 |
214 typedef struct | 227 typedef struct |
215 { | 228 { |
216 int type; | 229 int type; |
217 Uint8 rleMarker, rleMask1, rleMask2, rleMinCount, rleMaxCount; | 230 int flags; |
231 Uint8 | |
232 rleMarker1, rleMarker2, | |
233 rleMask1, rleMask2, | |
234 rleMinCount, rleMaxCount; | |
218 } DMCompParams; | 235 } DMCompParams; |
219 | 236 |
220 | 237 |
221 // | 238 // |
222 // Global variables | 239 // Global variables |
265 int dmC64EncodeBMP(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt); | 282 int dmC64EncodeBMP(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt); |
266 | 283 |
267 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt); | 284 int dmC64ConvertGenericBMP2Image(DMImage *dst, const DMC64Image *src, const DMC64ImageFormat *fmt); |
268 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt); | 285 int dmC64ConvertGenericImage2BMP(DMC64Image *dst, const DMImage *src, const DMC64ImageFormat *fmt); |
269 | 286 |
270 void dmGenericRLEAnalyze(const DMGrowBuf *buf, Uint8 *rleMarker, const int rleType); | 287 void dmGenericRLEAnalyze(const Uint8 *buf, const size_t len, DMCompParams *cfg); |
271 | 288 |
272 int dmDecodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg); | 289 int dmDecodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg); |
273 int dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg); | 290 int dmDecodeGenericRLEAlloc(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg); |
274 | 291 |
275 int dmEncodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg); | 292 int dmEncodeGenericRLE(DMGrowBuf *dst, const Uint8 *src, const Uint8 *srcEnd, const DMCompParams *cfg); |