comparison 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
comparison
equal deleted inserted replaced
1838:d02514ceed91 1839:666b27999570
21 21
22 return DM_PROBE_SCORE_FALSE; 22 return DM_PROBE_SCORE_FALSE;
23 } 23 }
24 24
25 25
26 static int fmtDecodeKoalaPainterPacked(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) 26 static int fmtDecodeStaticRLEMarkerMode2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt)
27 { 27 {
28 int res; 28 int res;
29 DMGrowBuf mem; 29 DMGrowBuf mem;
30 DMCompParams cfg; 30 DMCompParams cfg;
31 31
32 cfg.func = fmt->name; 32 cfg.func = fmt->name;
33 cfg.type = DM_COMP_RLE_MARKER; 33 cfg.type = DM_COMP_RLE_MARKER;
34 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2; 34 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2;
35 cfg.rleMarkerB = 0xfe; 35 cfg.rleMarkerB = fmt->size;
36 36
37 if ((res = dmDecodeGenericRLEAlloc(&mem, buf, &cfg)) != DMERR_OK) 37 if ((res = dmDecodeGenericRLEAlloc(&mem, buf, &cfg)) != DMERR_OK)
38 goto out; 38 goto out;
39 39
40 res = dmC64DecodeGenericBMP(img, &mem, fmt); 40 res = dmC64DecodeGenericBMP(img, &mem, fmt);
43 dmGrowBufFree(&mem); 43 dmGrowBufFree(&mem);
44 return res; 44 return res;
45 } 45 }
46 46
47 47
48 static int fmtEncodeKoalaPainterPacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) 48 static int fmtEncodeStaticRLEMarkerMode2(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
49 { 49 {
50 int res; 50 int res;
51 DMGrowBuf tmp; 51 DMGrowBuf tmp;
52 DMCompParams cfg; 52 DMCompParams cfg;
53 53
57 57
58 // And now RLE compress the data to the existing buffer 58 // And now RLE compress the data to the existing buffer
59 cfg.func = fmt->name; 59 cfg.func = fmt->name;
60 cfg.type = DM_COMP_RLE_MARKER; 60 cfg.type = DM_COMP_RLE_MARKER;
61 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2; 61 cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_2;
62 cfg.rleMarkerB = 0xfe; 62 cfg.rleMarkerB = fmt->size;
63 cfg.rleMinCountB = 3; 63 cfg.rleMinCountB = 3;
64 cfg.rleMaxCountB = 255; 64 cfg.rleMaxCountB = 255;
65 res = dmEncodeGenericRLE(buf, &tmp, &cfg); 65 res = dmEncodeGenericRLE(buf, &tmp, &cfg);
66 66
67 out: 67 out:
1255 NULL, NULL, 1255 NULL, NULL,
1256 { }, &dmC64CommonFormats[0] 1256 { }, &dmC64CommonFormats[0]
1257 }, 1257 },
1258 1258
1259 { 1259 {
1260 "klp", "Koala Painter (packed)", 0x6000, 0, DM_FMT_RDWR, 1260 "klp", "Koala Painter (packed)", 0x6000, 0xfe, DM_FMT_RDWR, // size is abused for RLE marker byte
1261 fmtProbeKoalaPainterPacked, 1261 fmtProbeKoalaPainterPacked,
1262 fmtDecodeKoalaPainterPacked, fmtEncodeKoalaPainterPacked, 1262 fmtDecodeStaticRLEMarkerMode2, fmtEncodeStaticRLEMarkerMode2,
1263 { }, &dmC64CommonFormats[0] 1263 { }, &dmC64CommonFormats[0]
1264 }, 1264 },
1265 1265
1266 { 1266 {
1267 "aas", "Advanced Art Studio (unpacked)", 0x2000, 10018, DM_FMT_RDWR, 1267 "aas", "Advanced Art Studio (unpacked)", 0x2000, 10018, DM_FMT_RDWR,