summaryrefslogtreecommitdiff
path: root/lodepng.cpp
diff options
context:
space:
mode:
authorLode <lvandeve@gmail.com>2016-01-25 01:59:41 +0100
committerLode <lvandeve@gmail.com>2016-01-25 01:59:41 +0100
commitb1718cb14f387ff2a4e3d84940abe42d9c241ef8 (patch)
treeb924acff2a223f77f503273b223a24248074bb40 /lodepng.cpp
parent4a02c6f8c55839c08521c538a36284ce9400c3a5 (diff)
code tweaks
Diffstat (limited to 'lodepng.cpp')
-rw-r--r--lodepng.cpp207
1 files changed, 97 insertions, 110 deletions
diff --git a/lodepng.cpp b/lodepng.cpp
index 766fb70..0fca1a9 100644
--- a/lodepng.cpp
+++ b/lodepng.cpp
@@ -251,17 +251,6 @@ static void ucvector_init(ucvector* p)
p->data = NULL;
p->size = p->allocsize = 0;
}
-
-#ifdef LODEPNG_COMPILE_DECODER
-/*resize and give all new elements the value*/
-static unsigned ucvector_resizev(ucvector* p, size_t size, unsigned char value)
-{
- size_t oldsize = p->size, i;
- if(!ucvector_resize(p, size)) return 0;
- for(i = oldsize; i < size; ++i) p->data[i] = value;
- return 1;
-}
-#endif /*LODEPNG_COMPILE_DECODER*/
#endif /*LODEPNG_COMPILE_PNG*/
#ifdef LODEPNG_COMPILE_ZLIB
@@ -1302,21 +1291,17 @@ static void addHuffmanSymbol(size_t* bp, ucvector* compressed, unsigned code, un
given array must be sorted (if no value is smaller, it returns the size of the given array)*/
static size_t searchCodeIndex(const unsigned* array, size_t array_size, size_t value)
{
- /*linear search implementation*/
- /*for(size_t i = 1; i < array_size; ++i) if(array[i] > value) return i - 1;
- return array_size - 1;*/
-
- /*binary search implementation (not that much faster) (precondition: array_size > 0)*/
- size_t left = 1;
+ /*binary search (only small gain over linear). TODO: use CPU log2 instruction for getting symbols instead*/
+ size_t left = 1;
size_t right = array_size - 1;
- while(left <= right)
- {
- size_t mid = (left + right) / 2;
- if(array[mid] <= value) left = mid + 1; /*the value to find is more to the right*/
- else if(array[mid - 1] > value) right = mid - 1; /*the value to find is more to the left*/
- else return mid - 1;
+
+ while(left <= right) {
+ size_t mid = (left + right) >> 1;
+ if (array[mid] >= value) right = mid - 1;
+ else left = mid + 1;
}
- return array_size - 1;
+ if(left >= array_size || array[left] > value) left--;
+ return left;
}
static void addLengthDistance(uivector* values, size_t length, size_t distance)
@@ -1651,10 +1636,10 @@ static unsigned deflateNoCompression(ucvector* out, const unsigned char* data, s
if(datasize - datapos < 65535) LEN = (unsigned)datasize - datapos;
NLEN = 65535 - LEN;
- ucvector_push_back(out, (unsigned char)(LEN % 256));
- ucvector_push_back(out, (unsigned char)(LEN / 256));
- ucvector_push_back(out, (unsigned char)(NLEN % 256));
- ucvector_push_back(out, (unsigned char)(NLEN / 256));
+ ucvector_push_back(out, (unsigned char)(LEN & 255));
+ ucvector_push_back(out, (unsigned char)(LEN >> 8));
+ ucvector_push_back(out, (unsigned char)(NLEN & 255));
+ ucvector_push_back(out, (unsigned char)(NLEN >> 8));
/*Decompressed data*/
for(j = 0; j < 65535 && datapos < datasize; ++j)
@@ -2186,8 +2171,8 @@ unsigned lodepng_zlib_compress(unsigned char** out, size_t* outsize, const unsig
/*ucvector-controlled version of the output buffer, for dynamic array*/
ucvector_init_buffer(&outv, *out, *outsize);
- ucvector_push_back(&outv, (unsigned char)(CMFFLG / 256));
- ucvector_push_back(&outv, (unsigned char)(CMFFLG % 256));
+ ucvector_push_back(&outv, (unsigned char)(CMFFLG >> 8));
+ ucvector_push_back(&outv, (unsigned char)(CMFFLG & 255));
error = deflate(&deflatedata, &deflatesize, in, insize, settings);
@@ -2335,17 +2320,18 @@ static unsigned lodepng_crc32_table[256] = {
};
/*Return the CRC of the bytes buf[0..len-1].*/
-unsigned lodepng_crc32(const unsigned char* buf, size_t len)
+unsigned lodepng_crc32(const unsigned char* data, size_t length)
{
- unsigned c = 0xffffffffL;
- size_t n;
-
- for(n = 0; n < len; ++n)
+ unsigned r = 0xffffffffu;
+ size_t i;
+ for(i = 0; i < length; ++i)
{
- c = lodepng_crc32_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
+ r = lodepng_crc32_table[(r ^ data[i]) & 0xff] ^ (r >> 8);
}
- return c ^ 0xffffffffL;
+ return r ^ 0xffffffffu;
}
+#else /* !LODEPNG_NO_COMPILE_CRC */
+unsigned lodepng_crc32(const unsigned char* data, size_t length);
#endif /* !LODEPNG_NO_COMPILE_CRC */
/* ////////////////////////////////////////////////////////////////////////// */
@@ -3410,25 +3396,26 @@ static void getPixelColorRGBA16(unsigned short* r, unsigned short* g, unsigned s
}
else if(mode->colortype == LCT_RGB)
{
- *r = 256 * in[i * 6 + 0] + in[i * 6 + 1];
- *g = 256 * in[i * 6 + 2] + in[i * 6 + 3];
- *b = 256 * in[i * 6 + 4] + in[i * 6 + 5];
- if(mode->key_defined && 256U * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
- && 256U * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
- && 256U * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
+ *r = 256u * in[i * 6 + 0] + in[i * 6 + 1];
+ *g = 256u * in[i * 6 + 2] + in[i * 6 + 3];
+ *b = 256u * in[i * 6 + 4] + in[i * 6 + 5];
+ if(mode->key_defined
+ && 256u * in[i * 6 + 0] + in[i * 6 + 1] == mode->key_r
+ && 256u * in[i * 6 + 2] + in[i * 6 + 3] == mode->key_g
+ && 256u * in[i * 6 + 4] + in[i * 6 + 5] == mode->key_b) *a = 0;
else *a = 65535;
}
else if(mode->colortype == LCT_GREY_ALPHA)
{
- *r = *g = *b = 256 * in[i * 4 + 0] + in[i * 4 + 1];
- *a = 256 * in[i * 4 + 2] + in[i * 4 + 3];
+ *r = *g = *b = 256u * in[i * 4 + 0] + in[i * 4 + 1];
+ *a = 256u * in[i * 4 + 2] + in[i * 4 + 3];
}
else if(mode->colortype == LCT_RGBA)
{
- *r = 256 * in[i * 8 + 0] + in[i * 8 + 1];
- *g = 256 * in[i * 8 + 2] + in[i * 8 + 3];
- *b = 256 * in[i * 8 + 4] + in[i * 8 + 5];
- *a = 256 * in[i * 8 + 6] + in[i * 8 + 7];
+ *r = 256u * in[i * 8 + 0] + in[i * 8 + 1];
+ *g = 256u * in[i * 8 + 2] + in[i * 8 + 3];
+ *b = 256u * in[i * 8 + 4] + in[i * 8 + 5];
+ *a = 256u * in[i * 8 + 6] + in[i * 8 + 7];
}
}
@@ -3455,7 +3442,8 @@ unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
/*if the user specified output palette but did not give the values, assume
they want the values of the input color type (assuming that one is palette).
Note that we never create a new palette ourselves.*/
- if(palettesize == 0) {
+ if(palettesize == 0)
+ {
palettesize = mode_in->palettesize;
palette = mode_in->palette;
}
@@ -3943,13 +3931,13 @@ static unsigned unfilterScanline(unsigned char* recon, const unsigned char* scan
case 3:
if(precon)
{
- for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i] + precon[i] / 2;
- for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) / 2);
+ for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i] + (precon[i] >> 1);
+ for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + ((recon[i - bytewidth] + precon[i]) >> 1);
}
else
{
for(i = 0; i != bytewidth; ++i) recon[i] = scanline[i];
- for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + recon[i - bytewidth] / 2;
+ for(i = bytewidth; i < length; ++i) recon[i] = scanline[i] + (recon[i - bytewidth] >> 1);
}
break;
case 4:
@@ -4630,13 +4618,13 @@ static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,
/*Adam-7 interlaced: predicted size is the sum of the 7 sub-images sizes*/
const LodePNGColorMode* color = &state->info_png.color;
predict = 0;
- predict += lodepng_get_raw_size_idat((*w + 7) / 8, (*h + 7) / 8, color) + (*h + 7) / 8;
- if(*w > 4) predict += lodepng_get_raw_size_idat((*w + 3) / 8, (*h + 7) / 8, color) + (*h + 7) / 8;
- predict += lodepng_get_raw_size_idat((*w + 3) / 4, (*h + 3) / 8, color) + (*h + 3) / 8;
- if(*w > 2) predict += lodepng_get_raw_size_idat((*w + 1) / 4, (*h + 3) / 4, color) + (*h + 3) / 4;
- predict += lodepng_get_raw_size_idat((*w + 1) / 2, (*h + 1) / 4, color) + (*h + 1) / 4;
- if(*w > 1) predict += lodepng_get_raw_size_idat((*w + 0) / 2, (*h + 1) / 2, color) + (*h + 1) / 2;
- predict += lodepng_get_raw_size_idat((*w + 0) / 1, (*h + 0) / 2, color) + (*h + 0) / 2;
+ predict += lodepng_get_raw_size_idat((*w + 7) >> 3, (*h + 7) >> 3, color) + ((*h + 7) >> 3);
+ if(*w > 4) predict += lodepng_get_raw_size_idat((*w + 3) >> 3, (*h + 7) >> 3, color) + ((*h + 7) >> 3);
+ predict += lodepng_get_raw_size_idat((*w + 3) >> 2, (*h + 3) >> 3, color) + ((*h + 3) >> 3);
+ if(*w > 2) predict += lodepng_get_raw_size_idat((*w + 1) >> 2, (*h + 3) >> 2, color) + ((*h + 3) >> 2);
+ predict += lodepng_get_raw_size_idat((*w + 1) >> 1, (*h + 1) >> 2, color) + ((*h + 1) >> 2);
+ if(*w > 1) predict += lodepng_get_raw_size_idat((*w + 0) >> 1, (*h + 1) >> 1, color) + ((*h + 1) >> 1);
+ predict += lodepng_get_raw_size_idat((*w + 0), (*h + 0) >> 1, color) + ((*h + 0) >> 1);
}
if(!state->error && !ucvector_reserve(&scanlines, predict)) state->error = 83; /*alloc fail*/
if(!state->error)
@@ -4650,11 +4638,10 @@ static void decodeGeneric(unsigned char** out, unsigned* w, unsigned* h,
if(!state->error)
{
size_t outsize = lodepng_get_raw_size(*w, *h, &state->info_png.color);
- ucvector outv;
- ucvector_init(&outv);
- if(!ucvector_resizev(&outv, outsize, 0)) state->error = 83; /*alloc fail*/
- if(!state->error) state->error = postProcessScanlines(outv.data, scanlines.data, *w, *h, &state->info_png);
- *out = outv.data;
+ *out = (unsigned char*)lodepng_malloc(outsize);
+ if(!*out) state->error = 83; /*alloc fail*/
+ for(i = 0; i < outsize; i++) (*out)[i] = 0;
+ if(!state->error) state->error = postProcessScanlines(*out, scanlines.data, *w, *h, &state->info_png);
}
ucvector_cleanup(&scanlines);
}
@@ -4884,20 +4871,20 @@ static unsigned addChunk_tRNS(ucvector* out, const LodePNGColorMode* info)
{
if(info->key_defined)
{
- ucvector_push_back(&tRNS, (unsigned char)(info->key_r / 256));
- ucvector_push_back(&tRNS, (unsigned char)(info->key_r % 256));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
}
}
else if(info->colortype == LCT_RGB)
{
if(info->key_defined)
{
- ucvector_push_back(&tRNS, (unsigned char)(info->key_r / 256));
- ucvector_push_back(&tRNS, (unsigned char)(info->key_r % 256));
- ucvector_push_back(&tRNS, (unsigned char)(info->key_g / 256));
- ucvector_push_back(&tRNS, (unsigned char)(info->key_g % 256));
- ucvector_push_back(&tRNS, (unsigned char)(info->key_b / 256));
- ucvector_push_back(&tRNS, (unsigned char)(info->key_b % 256));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_r >> 8));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_r & 255));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_g >> 8));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_g & 255));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_b >> 8));
+ ucvector_push_back(&tRNS, (unsigned char)(info->key_b & 255));
}
}
@@ -5022,21 +5009,21 @@ static unsigned addChunk_bKGD(ucvector* out, const LodePNGInfo* info)
ucvector_init(&bKGD);
if(info->color.colortype == LCT_GREY || info->color.colortype == LCT_GREY_ALPHA)
{
- ucvector_push_back(&bKGD, (unsigned char)(info->background_r / 256));
- ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_r >> 8));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_r & 255));
}
else if(info->color.colortype == LCT_RGB || info->color.colortype == LCT_RGBA)
{
- ucvector_push_back(&bKGD, (unsigned char)(info->background_r / 256));
- ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256));
- ucvector_push_back(&bKGD, (unsigned char)(info->background_g / 256));
- ucvector_push_back(&bKGD, (unsigned char)(info->background_g % 256));
- ucvector_push_back(&bKGD, (unsigned char)(info->background_b / 256));
- ucvector_push_back(&bKGD, (unsigned char)(info->background_b % 256));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_r >> 8));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_r & 255));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_g >> 8));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_g & 255));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_b >> 8));
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_b & 255));
}
else if(info->color.colortype == LCT_PALETTE)
{
- ucvector_push_back(&bKGD, (unsigned char)(info->background_r % 256)); /*palette index*/
+ ucvector_push_back(&bKGD, (unsigned char)(info->background_r & 255)); /*palette index*/
}
error = addChunk(out, "bKGD", bKGD.data, bKGD.size);
@@ -5050,8 +5037,8 @@ static unsigned addChunk_tIME(ucvector* out, const LodePNGTime* time)
unsigned error = 0;
unsigned char* data = (unsigned char*)lodepng_malloc(7);
if(!data) return 83; /*alloc fail*/
- data[0] = (unsigned char)(time->year / 256);
- data[1] = (unsigned char)(time->year % 256);
+ data[0] = (unsigned char)(time->year >> 8);
+ data[1] = (unsigned char)(time->year & 255);
data[2] = (unsigned char)time->month;
data[3] = (unsigned char)time->day;
data[4] = (unsigned char)time->hour;
@@ -5106,13 +5093,13 @@ static void filterScanline(unsigned char* out, const unsigned char* scanline, co
case 3: /*Average*/
if(prevline)
{
- for(i = 0; i != bytewidth; ++i) out[i] = scanline[i] - prevline[i] / 2;
- for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - ((scanline[i - bytewidth] + prevline[i]) / 2);
+ for(i = 0; i != bytewidth; ++i) out[i] = scanline[i] - (prevline[i] >> 1);
+ for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - ((scanline[i - bytewidth] + prevline[i]) >> 1);
}
else
{
for(i = 0; i != bytewidth; ++i) out[i] = scanline[i];
- for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - scanline[i - bytewidth] / 2;
+ for(i = bytewidth; i < length; ++i) out[i] = scanline[i] - (scanline[i - bytewidth] >> 1);
}
break;
case 4: /*Paeth*/
@@ -5197,14 +5184,14 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
{
/*adaptive filtering*/
size_t sum[5];
- ucvector attempt[5]; /*five filtering attempts, one for each filter type*/
+ unsigned char* attempt[5]; /*five filtering attempts, one for each filter type*/
size_t smallest = 0;
unsigned char type, bestType = 0;
for(type = 0; type != 5; ++type)
{
- ucvector_init(&attempt[type]);
- if(!ucvector_resize(&attempt[type], linebytes)) return 83; /*alloc fail*/
+ attempt[type] = (unsigned char*)lodepng_malloc(linebytes);
+ if(!attempt[type]) return 83; /*alloc fail*/
}
if(!error)
@@ -5214,13 +5201,13 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
/*try the 5 filter types*/
for(type = 0; type != 5; ++type)
{
- filterScanline(attempt[type].data, &in[y * linebytes], prevline, linebytes, bytewidth, type);
+ filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, type);
/*calculate the sum of the result*/
sum[type] = 0;
if(type == 0)
{
- for(x = 0; x != linebytes; ++x) sum[type] += (unsigned char)(attempt[type].data[x]);
+ for(x = 0; x != linebytes; ++x) sum[type] += (unsigned char)(attempt[type][x]);
}
else
{
@@ -5229,7 +5216,7 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
/*For differences, each byte should be treated as signed, values above 127 are negative
(converted to signed char). Filtertype 0 isn't a difference though, so use unsigned there.
This means filtertype 0 is almost never chosen, but that is justified.*/
- unsigned char s = attempt[type].data[x];
+ unsigned char s = attempt[type][x];
sum[type] += s < 128 ? s : (255U - s);
}
}
@@ -5246,24 +5233,24 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
/*now fill the out values*/
out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/
- for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType].data[x];
+ for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType][x];
}
}
- for(type = 0; type != 5; ++type) ucvector_cleanup(&attempt[type]);
+ for(type = 0; type != 5; ++type) lodepng_free(attempt[type]);
}
else if(strategy == LFS_ENTROPY)
{
float sum[5];
- ucvector attempt[5]; /*five filtering attempts, one for each filter type*/
+ unsigned char* attempt[5]; /*five filtering attempts, one for each filter type*/
float smallest = 0;
unsigned type, bestType = 0;
unsigned count[256];
for(type = 0; type != 5; ++type)
{
- ucvector_init(&attempt[type]);
- if(!ucvector_resize(&attempt[type], linebytes)) return 83; /*alloc fail*/
+ attempt[type] = (unsigned char*)lodepng_malloc(linebytes);
+ if(!attempt[type]) return 83; /*alloc fail*/
}
for(y = 0; y != h; ++y)
@@ -5271,9 +5258,9 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
/*try the 5 filter types*/
for(type = 0; type != 5; ++type)
{
- filterScanline(attempt[type].data, &in[y * linebytes], prevline, linebytes, bytewidth, type);
+ filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, type);
for(x = 0; x != 256; ++x) count[x] = 0;
- for(x = 0; x != linebytes; ++x) ++count[attempt[type].data[x]];
+ for(x = 0; x != linebytes; ++x) ++count[attempt[type][x]];
++count[type]; /*the filter type itself is part of the scanline*/
sum[type] = 0;
for(x = 0; x != 256; ++x)
@@ -5293,10 +5280,10 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
/*now fill the out values*/
out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/
- for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType].data[x];
+ for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType][x];
}
- for(type = 0; type != 5; ++type) ucvector_cleanup(&attempt[type]);
+ for(type = 0; type != 5; ++type) lodepng_free(attempt[type]);
}
else if(strategy == LFS_PREDEFINED)
{
@@ -5316,7 +5303,7 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
deflate the scanline after every filter attempt to see which one deflates best.
This is very slow and gives only slightly smaller, sometimes even larger, result*/
size_t size[5];
- ucvector attempt[5]; /*five filtering attempts, one for each filter type*/
+ unsigned char* attempt[5]; /*five filtering attempts, one for each filter type*/
size_t smallest = 0;
unsigned type = 0, bestType = 0;
unsigned char* dummy;
@@ -5332,20 +5319,20 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
zlibsettings.custom_deflate = 0;
for(type = 0; type != 5; ++type)
{
- ucvector_init(&attempt[type]);
- ucvector_resize(&attempt[type], linebytes); /*todo: give error if resize failed*/
+ attempt[type] = (unsigned char*)lodepng_malloc(linebytes);
+ if(!attempt[type]) return 83; /*alloc fail*/
}
for(y = 0; y != h; ++y) /*try the 5 filter types*/
{
for(type = 0; type != 5; ++type)
{
- unsigned testsize = attempt[type].size;
+ unsigned testsize = linebytes;
/*if(testsize > 8) testsize /= 8;*/ /*it already works good enough by testing a part of the row*/
- filterScanline(attempt[type].data, &in[y * linebytes], prevline, linebytes, bytewidth, type);
+ filterScanline(attempt[type], &in[y * linebytes], prevline, linebytes, bytewidth, type);
size[type] = 0;
dummy = 0;
- zlib_compress(&dummy, &size[type], attempt[type].data, testsize, &zlibsettings);
+ zlib_compress(&dummy, &size[type], attempt[type], testsize, &zlibsettings);
lodepng_free(dummy);
/*check if this is smallest size (or if type == 0 it's the first case so always store the values)*/
if(type == 0 || size[type] < smallest)
@@ -5356,9 +5343,9 @@ static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w,
}
prevline = &in[y * linebytes];
out[y * (linebytes + 1)] = bestType; /*the first byte of a scanline will be the filter type*/
- for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType].data[x];
+ for(x = 0; x != linebytes; ++x) out[y * (linebytes + 1) + 1 + x] = attempt[bestType][x];
}
- for(type = 0; type != 5; ++type) ucvector_cleanup(&attempt[type]);
+ for(type = 0; type != 5; ++type) free(attempt[type]);
}
else return 88; /* unknown filter strategy */