Commit a80b2f34 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

Allow > 64bit FS for large segment sizes

parent 1cff9f2c
......@@ -366,17 +366,18 @@ int ae_decode_end(ae_streamp strm)
#define ASKFS() \
do { \
ASK(1); \
state->fs = 0; \
while (GET(state->fs + 1) == 0) \
while (GET(1) == 0) \
{ \
state->fs++; \
ASK(state->fs + 1); \
DROP(1); \
ASK(1); \
} \
DROP(1); \
} while(0)
#define GETFS() state->fs
#define DROPFS() DROP(state->fs + 1)
#define DROPFS() state->fs = 0;
#define PUT(sample) \
do { \
......
......@@ -223,7 +223,7 @@ int ae_encode_end(ae_streamp strm)
return AE_OK;
}
static inline void emit(encode_state *state, int64_t data, int bits)
static inline void emit(encode_state *state, uint64_t data, int bits)
{
while(bits)
{
......@@ -246,7 +246,15 @@ static inline void emit(encode_state *state, int64_t data, int bits)
static inline void emitfs(encode_state *state, int fs)
{
emit(state, 1, fs + 1);
if (fs < 63)
{
emit(state, 1, fs + 1);
}
else
{
emit(state, 0, fs);
emit(state, 1, 1);
}
}
#ifdef PROFILE
......@@ -337,11 +345,11 @@ int ae_encode(ae_streamp strm, int flush)
state->mode=M_ENCODE_ZERO;
break;
}
/* Pad last output byte with 1 bits
/* Pad last output byte with 0 bits
if user wants to flush, i.e. we got
all input there is.
*/
emit(state, 0xff, state->bitp);
emit(state, 0, state->bitp);
*strm->next_out++ = *state->bp_out;
avail_out--;
total_out++;
......@@ -485,20 +493,16 @@ int ae_encode(ae_streamp strm, int flush)
split_len_min = split_len;
k = j;
#if 0
if (fs_len < this_bs)
{
/* Next can't get better because what we lose
by additional uncompressed bits isn't
compensated by a smaller FS part. */
break;
}
/* if (fs_len < this_bs) */
/* { */
/* /\* Next can't get better because what we lose */
/* by additional uncompressed bits isn't */
/* compensated by a smaller FS part. *\/ */
/* break; */
/* } */
}
else
break;
#else
}
#endif
/* else */
/* break; */
}
/* Count bits for 2nd extension */
......
......@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
strm.bit_per_sample = 16;
strm.block_size = 8;
strm.segment_size = 8;
strm.segment_size = 128;
strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS;
if (ae_decode_init(&strm) != AE_OK)
......
......@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
strm.bit_per_sample = 16;
strm.block_size = 8;
strm.segment_size = 8;
strm.segment_size = 128;
strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS;
if (ae_encode_init(&strm) != AE_OK)
......
......@@ -8,8 +8,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_
strm.bit_per_sample = param->bits_per_pixel;
strm.block_size = param->pixels_per_block;
// strm.segment_size = param->pixels_per_scanline / param->pixels_per_block;
strm.segment_size = 8;
strm.segment_size = param->pixels_per_scanline / param->pixels_per_block;
strm.flags = param->options_mask;
strm.avail_in = sourceLen;
strm.avail_out = *destLen;
......@@ -37,8 +36,7 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, const void *source, siz
strm.bit_per_sample = param->bits_per_pixel;
strm.block_size = param->pixels_per_block;
// strm.segment_size = param->pixels_per_scanline / param->pixels_per_block;
strm.segment_size = 8;
strm.segment_size = param->pixels_per_scanline / param->pixels_per_block;
strm.flags = param->options_mask;
strm.avail_in = sourceLen;
strm.avail_out = *destLen;
......
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