From 4619f234e5d4f0bd8c21a0e1f6c9c5b1441e621c Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Thu, 16 Nov 2023 15:42:32 -0800 Subject: [PATCH] Try not calling begin() until after setting up avail_in and _out --- compression.cpp | 3 --- tile.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compression.cpp b/compression.cpp index 6792332f..4506afc1 100644 --- a/compression.cpp +++ b/compression.cpp @@ -20,9 +20,6 @@ void decompressor::begin() { fprintf(stderr, "initialize decompression: %d %s\n", d, zs.msg); exit(EXIT_IMPOSSIBLE); } - - zs.avail_out = 0; - zs.avail_in = 0; } int decompressor::fread(void *p, size_t size, size_t nmemb, std::atomic *geompos) { diff --git a/tile.cpp b/tile.cpp index d94b1493..2844d2c0 100644 --- a/tile.cpp +++ b/tile.cpp @@ -1974,10 +1974,9 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch if (geoms->within) { geoms->end(geompos_in); } - - geoms->begin(); } + printf("fseek to %lld\n", (long long) geoms->fp); if (fseek(geoms->fp, og, SEEK_SET) != 0) { perror("fseek geom"); exit(EXIT_SEEK); @@ -1986,6 +1985,10 @@ long long write_tile(decompressor *geoms, std::atomic *geompos_in, ch *geompos_in = og; geoms->zs.avail_in = 0; geoms->zs.avail_out = 0; + + if (compressed_input) { + geoms->begin(); + } } int prefilter_write = -1, prefilter_read = -1;