# HG changeset patch # User Matti Hamalainen # Date 1647780613 -7200 # Node ID 317d2f4b322c79e977a2898701eb538a41480632 # Parent e716a2f18da0ac6678d0acf8d59e6bfd805ecbf7 Reorder some format specific probe functions etc. diff -r e716a2f18da0 -r 317d2f4b322c tools/lib64fmts.c --- a/tools/lib64fmts.c Sat Mar 12 02:42:31 2022 +0200 +++ b/tools/lib64fmts.c Sun Mar 20 14:50:13 2022 +0200 @@ -1374,6 +1374,42 @@ } +#define XX2_MIN_SIZE 4000 +#define XX2_WIDTH_CH 40 +#define XX2_HEIGHT_CH 10 +#define XX2_SIZE (XX2_WIDTH_CH * XX2_HEIGHT_CH) +#define XX2_BSIZE (XX2_SIZE * 8) + + +static int fmtProbeFormatXX2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) +{ + if (buf->len >= XX2_MIN_SIZE && + buf->len <= XX2_MIN_SIZE + 8 && + dmCompareAddr16(buf, 0, fmt->addr)) + return DM_PROBE_SCORE_MAYBE; + + return DM_PROBE_SCORE_FALSE; +} + + +static int fmtDecodeFormatXX2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) +{ + int res; + DMGrowBuf tmp; + + // If there is only data for less than XX2_MIN_SIZE bytes, + // allocate a buffer of that size and copy data there. + // Otherwise allocate len bytes. + if (dmGrowBufCopy(&tmp, buf, buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE - buf->len : 0) == NULL) + return DMERR_MALLOC; + + tmp.len = tmp.size; + res = dmC64DecodeGenericBMP(img, &tmp, fmt); + dmGrowBufFree(&tmp); + return res; +} + + static const Uint8 fmtFormatXX3_MagicID_1[] = { 0x01, 0x08, 0x0B, 0x08, 0xF0, 0x02, 0x9E, 0x32, @@ -1442,42 +1478,6 @@ } -#define XX2_MIN_SIZE 4000 -#define XX2_WIDTH_CH 40 -#define XX2_HEIGHT_CH 10 -#define XX2_SIZE (XX2_WIDTH_CH * XX2_HEIGHT_CH) -#define XX2_BSIZE (XX2_SIZE * 8) - - -static int fmtProbeFormatXX2(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) -{ - if (buf->len >= XX2_MIN_SIZE && - buf->len <= XX2_MIN_SIZE + 8 && - dmCompareAddr16(buf, 0, fmt->addr)) - return DM_PROBE_SCORE_MAYBE; - - return DM_PROBE_SCORE_FALSE; -} - - -static int fmtDecodeFormatXX2(DMC64Image *img, const DMGrowBuf *buf, const DMC64ImageFormat *fmt) -{ - int res; - DMGrowBuf tmp; - - // If there is only data for less than XX2_MIN_SIZE bytes, - // allocate a buffer of that size and copy data there. - // Otherwise allocate len bytes. - if (dmGrowBufCopy(&tmp, buf, buf->len < XX2_MIN_SIZE ? XX2_MIN_SIZE - buf->len : 0) == NULL) - return DMERR_MALLOC; - - tmp.len = tmp.size; - res = dmC64DecodeGenericBMP(img, &tmp, fmt); - dmGrowBufFree(&tmp); - return res; -} - - static int fmtProbeCosmosDesignsHiresManager(const DMGrowBuf *buf, const DMC64ImageFormat *fmt) { if (buf->len > 32 && dmCompareAddr16(buf, 0, fmt->addr))