comparison tools/lib64fmts.c @ 1697:1036b0dcccb5

Refactor DMGrowBuf so that there can be buffers that grow "backwards". This also removes some support functions like the buffer state push/pop.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jun 2018 12:55:17 +0300
parents e7990551c6d6
children a0986cfd6f9d
comparison
equal deleted inserted replaced
1696:cf0fddd4bf52 1697:1036b0dcccb5
144 cfg.rleMaxCountB = 255; 144 cfg.rleMaxCountB = 255;
145 145
146 dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg); 146 dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg);
147 147
148 // Add the header bits 148 // Add the header bits
149 if (!dmGrowBufPut(buf, magicID, strlen(magicID)) || 149 if (!dmGrowBufPut(buf, (Uint8 *) magicID, strlen(magicID)) ||
150 !dmGrowBufPutU8(buf, cfg.rleMarkerB)) 150 !dmGrowBufPutU8(buf, cfg.rleMarkerB))
151 { 151 {
152 res = DMERR_MALLOC; 152 res = DMERR_MALLOC;
153 goto out; 153 goto out;
154 } 154 }
246 cfg.rleMaxCountW = 1024; 246 cfg.rleMaxCountW = 1024;
247 247
248 dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg); 248 dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg);
249 249
250 // Add the header bits 250 // Add the header bits
251 if (!dmGrowBufPut(buf, fmtBDP5MagicID, strlen(fmtBDP5MagicID)) || 251 if (!dmGrowBufPut(buf, (Uint8 *) fmtBDP5MagicID, strlen(fmtBDP5MagicID)) ||
252 !dmGrowBufPutU8(buf, cfg.rleMarkerB) || 252 !dmGrowBufPutU8(buf, cfg.rleMarkerB) ||
253 !dmGrowBufPutU8(buf, cfg.rleMarkerW)) 253 !dmGrowBufPutU8(buf, cfg.rleMarkerW))
254 { 254 {
255 res = DMERR_MALLOC; 255 res = DMERR_MALLOC;
256 goto out; 256 goto out;
610 610
611 611
612 static int fmtEncodeFunPaint2Unpacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) 612 static int fmtEncodeFunPaint2Unpacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt)
613 { 613 {
614 // Add the header bits 614 // Add the header bits
615 if (!dmGrowBufPut(buf, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) || 615 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) ||
616 !dmGrowBufPutU8(buf, 0)) 616 !dmGrowBufPutU8(buf, 0))
617 return DMERR_MALLOC; 617 return DMERR_MALLOC;
618 618
619 return dmC64EncodeGenericBMP(FALSE, buf, img, fmt); 619 return dmC64EncodeGenericBMP(FALSE, buf, img, fmt);
620 } 620 }
637 cfg.rleMaxCountB = 255; 637 cfg.rleMaxCountB = 255;
638 638
639 dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg); 639 dmGenericRLEAnalyze(tmp.data, tmp.len, &cfg);
640 640
641 // Add the header bits 641 // Add the header bits
642 if (!dmGrowBufPut(buf, fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) || 642 if (!dmGrowBufPut(buf, (Uint8 *) fmtFunPaint2MagicID, strlen(fmtFunPaint2MagicID)) ||
643 !dmGrowBufPutU8(buf, cfg.rleMarkerB)) 643 !dmGrowBufPutU8(buf, cfg.rleMarkerB))
644 { 644 {
645 res = DMERR_MALLOC; 645 res = DMERR_MALLOC;
646 goto out; 646 goto out;
647 } 647 }