Mercurial > hg > dmlib
diff tools/lib64gfx.c @ 2606:92909caccc9e
Rename various compression related internal constants.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 25 Nov 2023 15:56:18 +0200 |
parents | d3bdaaae624f |
children | 8315e713c35e |
line wrap: on
line diff
--- a/tools/lib64gfx.c Sat Nov 25 06:06:18 2023 +0200 +++ b/tools/lib64gfx.c Sat Nov 25 15:56:18 2023 +0200 @@ -301,7 +301,7 @@ // According to compression type .. switch (cfg->type) { - case DM_COMP_RLE_MARKER: + case DM_COMP_TYPE_RLE_MARKER: { size_t selected = 0, smallest = buf->len; @@ -310,18 +310,18 @@ for (size_t n = 0; n < DM_STAT_MAX; n++) if (stats[n] < smallest) { - switch (cfg->flags & DM_RLE_RUNS_MASK) + switch (cfg->flags & DM_COMP_RLE_RUNS_MASK) { - case DM_RLE_BYTE_RUNS | DM_RLE_WORD_RUNS: + case DM_COMP_RLE_BYTE_RUNS | DM_COMP_RLE_WORD_RUNS: cfg->rleMarkerW = selected; cfg->rleMarkerB = selected = n; break; - case DM_RLE_BYTE_RUNS: + case DM_COMP_RLE_BYTE_RUNS: cfg->rleMarkerB = selected = n; break; - case DM_RLE_WORD_RUNS: + case DM_COMP_RLE_WORD_RUNS: cfg->rleMarkerW = selected = n; break; } @@ -330,7 +330,7 @@ } break; - case DM_COMP_RLE_MASK: + case DM_COMP_TYPE_RLE_MASK: cfg->rleMarkerMask = 0xC0; cfg->rleMarkerBits = 0xC0; cfg->rleCountMask = 0x3f; @@ -346,13 +346,13 @@ void dmSetupRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg) { - if (src != NULL && (cfg->flags & DM_RLE_BACKWARDS_INPUT)) + if (src != NULL && (cfg->flags & DM_COMP_INPUT_BACKWARDS)) { src->offs = src->len; src->backwards = true; } - if (dst != NULL && (cfg->flags & DM_RLE_BACKWARDS_OUTPUT)) + if (dst != NULL && (cfg->flags & DM_COMP_OUTPUT_BACKWARDS)) { dst->backwards = true; dst->offs = dst->size; @@ -384,15 +384,15 @@ if (dst != NULL) { - if (cfg->flags & DM_RLE_BACKWARDS_OUTPUT) + if (cfg->flags & DM_COMP_OUTPUT_BACKWARDS) { memmove(dst->data, dst->data + dst->offs, dst->len); dst->offs = 0; } - switch (cfg->flags & DM_OUT_CROP_MASK) + switch (cfg->flags & DM_COMP_OUTPUT_CROP_MASK) { - case DM_OUT_CROP_END: + case DM_COMP_OUTPUT_CROP_END: if (cfg->cropOutLen < dst->len) { memmove(dst->data, dst->data + dst->len - cfg->cropOutLen, cfg->cropOutLen); @@ -400,7 +400,7 @@ } break; - case DM_OUT_CROP_START: + case DM_COMP_OUTPUT_CROP_START: if (cfg->cropOutLen <= dst->len) dst->len = cfg->cropOutLen; break; @@ -448,10 +448,10 @@ { unsigned int count = 1; - if (cfg->type == DM_COMP_RLE_MARKER) + if (cfg->type == DM_COMP_TYPE_RLE_MARKER) { // A simple marker byte RLE variant: [Marker] [count] [data] - if ((cfg->flags & DM_RLE_BYTE_RUNS) && data == cfg->rleMarkerB) + if ((cfg->flags & DM_COMP_RLE_BYTE_RUNS) && data == cfg->rleMarkerB) { if (!dmGrowBufGetU8(&src, &tmp1)) { @@ -477,24 +477,24 @@ cfg->func); goto out; } - switch (cfg->flags & DM_RLE_ORDER_MASK) + switch (cfg->flags & DM_COMP_RLE_ORDER_MASK) { - case DM_RLE_ORDER_1: + case DM_COMP_RLE_ORDER_1: count = tmp1; data = tmp2; break; - case DM_RLE_ORDER_2: + case DM_COMP_RLE_ORDER_2: count = tmp2; data = tmp1; break; } - if (count == 0 && (cfg->flags & DM_RLE_ZERO_COUNT_MAX)) + if (count == 0 && (cfg->flags & DM_COMP_RLE_ZERO_COUNT_MAX)) count = 256; } else - if ((cfg->flags & DM_RLE_WORD_RUNS) && data == cfg->rleMarkerW) + if ((cfg->flags & DM_COMP_RLE_WORD_RUNS) && data == cfg->rleMarkerW) { if (!dmGrowBufGetU8(&src, &tmp1) || !dmGrowBufGetU8(&src, &tmp2) || @@ -505,25 +505,25 @@ cfg->func); goto out; } - switch (cfg->flags & DM_RLE_ORDER_MASK) + switch (cfg->flags & DM_COMP_RLE_ORDER_MASK) { - case DM_RLE_ORDER_1: + case DM_COMP_RLE_ORDER_1: count = (tmp2 << 8) | tmp1; data = tmp3; break; - case DM_RLE_ORDER_2: + case DM_COMP_RLE_ORDER_2: data = tmp1; count = (tmp3 << 8) | tmp2; break; } - if (count == 0 && (cfg->flags & DM_RLE_ZERO_COUNT_MAX)) + if (count == 0 && (cfg->flags & DM_COMP_RLE_ZERO_COUNT_MAX)) count = 65536; } } else - if (cfg->type == DM_COMP_RLE_MASK) + if (cfg->type == DM_COMP_TYPE_RLE_MASK) { // Mask marker RLE: usually high bit(s) of byte mark RLE sequence // and the lower bits contain the count: [Mask + count] [data] @@ -571,25 +571,25 @@ switch (cfg->type) { - case DM_COMP_RLE_MARKER: - if ((cfg->flags & DM_RLE_WORD_RUNS) && + case DM_COMP_TYPE_RLE_MARKER: + if ((cfg->flags & DM_COMP_RLE_WORD_RUNS) && (count >= cfg->rleMinCountW || data == cfg->rleMarkerW)) { - if (count == 65536 && (cfg->flags & DM_RLE_ZERO_COUNT_MAX)) + if (count == 65536 && (cfg->flags & DM_COMP_RLE_ZERO_COUNT_MAX)) count = 0; if (!dmGrowBufPutU8(dst, cfg->rleMarkerW)) goto out; - switch (cfg->flags & DM_RLE_ORDER_MASK) + switch (cfg->flags & DM_COMP_RLE_ORDER_MASK) { - case DM_RLE_ORDER_1: + case DM_COMP_RLE_ORDER_1: if (!dmGrowBufPutU16LE(dst, count) || !dmGrowBufPutU8(dst, data)) goto out; break; - case DM_RLE_ORDER_2: + case DM_COMP_RLE_ORDER_2: if (!dmGrowBufPutU8(dst, data) || !dmGrowBufPutU16LE(dst, count)) goto out; @@ -597,24 +597,24 @@ } } else - if ((cfg->flags & DM_RLE_BYTE_RUNS) && + if ((cfg->flags & DM_COMP_RLE_BYTE_RUNS) && (count >= cfg->rleMinCountB || data == cfg->rleMarkerB)) { - if (count == 256 && (cfg->flags & DM_RLE_ZERO_COUNT_MAX)) + if (count == 256 && (cfg->flags & DM_COMP_RLE_ZERO_COUNT_MAX)) count = 0; if (!dmGrowBufPutU8(dst, cfg->rleMarkerB)) goto out; - switch (cfg->flags & DM_RLE_ORDER_MASK) + switch (cfg->flags & DM_COMP_RLE_ORDER_MASK) { - case DM_RLE_ORDER_1: + case DM_COMP_RLE_ORDER_1: if (!dmGrowBufPutU8(dst, count) || !dmGrowBufPutU8(dst, data)) goto out; break; - case DM_RLE_ORDER_2: + case DM_COMP_RLE_ORDER_2: if (!dmGrowBufPutU8(dst, data) || !dmGrowBufPutU8(dst, count)) goto out; @@ -625,7 +625,7 @@ copyOnly = true; break; - case DM_COMP_RLE_MASK: + case DM_COMP_TYPE_RLE_MASK: if (count >= cfg->rleMinCountB || (data & cfg->rleMarkerMask) == cfg->rleMarkerBits) { // Mask marker RLE: usually high bit(s) of byte mark RLE sequence @@ -668,8 +668,8 @@ // If new data byte is different, or we exceed the rleMaxCount // for the active runs mode(s) .. then encode the run. if ((data != prev && prev != -1) || - ((cfg->flags & DM_RLE_WORD_RUNS) && count >= cfg->rleMaxCountW) || - (((cfg->flags & DM_RLE_RUNS_MASK) == DM_RLE_BYTE_RUNS) && count >= cfg->rleMaxCountB)) + ((cfg->flags & DM_COMP_RLE_WORD_RUNS) && count >= cfg->rleMaxCountW) || + (((cfg->flags & DM_COMP_RLE_RUNS_MASK) == DM_COMP_RLE_BYTE_RUNS) && count >= cfg->rleMaxCountB)) { if ((res = dmEncodeGenericRLESequence(dst, prev, count, cfg)) != DMERR_OK) goto out;