Commit 5c932b03 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

Faster decoding if buffer space available

parent d991d495
......@@ -13,9 +13,12 @@ clean:
rm -f mytest ../data/ae_out $(objects)
test: mytest
./mytest < ../data/example_data.szip > ../data/ae_out
./mytest 1 1 < ../data/example_data.szip > ../data/ae_out
diff ../data/ae_out ../data/example_data
./mytest 9478 16384 < ../data/example_data.szip > ../data/ae_out
diff ../data/ae_out ../data/example_data
vtest: mytest
valgrind -v ./mytest < example_data.szip > ae_out
diff ae_out example_data
valgrind -v ./mytest < ../data/example_data.szip > ../data/ae_out
diff ../data/ae_out ../data/example_data
......@@ -7,7 +7,7 @@ struct internal_state;
typedef struct _ae_stream
{
uint8_t *next_in;
const uint8_t *next_in;
size_t avail_in; /* number of bytes available at next_in */
size_t total_in; /* total number of input bytes read so far */
......
This diff is collapsed.
......@@ -15,9 +15,20 @@ int main(int argc, char *argv[])
uint8_t *in;
uint32_t *out;
size_t total_out;
int chunk_in, chunk_out;
chunk_in = CHUNK_IN;
chunk_out = CHUNK_OUT;
if (argc == 3)
{
chunk_in = atoi(argv[1]);
chunk_out = atoi(argv[2]);
}
fprintf(stderr, "chunk_in: %i\nchunk_out: %i\n", chunk_in, chunk_out);
in = (uint8_t *)malloc(ALL_IN);
out = (uint32_t *)malloc(CHUNK_OUT * sizeof(uint32_t));
out = (uint32_t *)malloc(chunk_out * sizeof(uint32_t));
if (in == NULL || out == NULL)
return 1;
......@@ -38,9 +49,9 @@ int main(int argc, char *argv[])
return 1;
strm.next_in = in;
strm.avail_in = CHUNK_IN;
strm.avail_in = chunk_in;
strm.next_out = out;
strm.avail_out = CHUNK_OUT;
strm.avail_out = chunk_out;
todo = 1;
total_out = 0;
......@@ -52,17 +63,17 @@ int main(int argc, char *argv[])
fprintf(stderr, "error is %i\n", status);
return 1;
}
fprintf(stderr, "avail in %li total in %li avail out %li total out %lx\n", strm.avail_in, strm.total_in, strm.avail_out, strm.total_out);
// fprintf(stderr, "avail in %li total in %li avail out %li total out %lx\n", strm.avail_in, strm.total_in, strm.avail_out, strm.total_out);
if (strm.avail_in == 0 && strm.total_in < ALL_IN)
{
in += CHUNK_IN;
in += chunk_in;
strm.next_in = in;
if (ALL_IN - strm.total_in < CHUNK_IN)
if (ALL_IN - strm.total_in < chunk_in)
strm.avail_in = ALL_IN - strm.total_in;
else
strm.avail_in = CHUNK_IN;
strm.avail_in = chunk_in;
todo = 1;
}
......@@ -74,7 +85,7 @@ int main(int argc, char *argv[])
}
total_out = strm.total_out;
strm.next_out = out;
strm.avail_out = CHUNK_OUT;
strm.avail_out = chunk_out;
todo = 1;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment