*.gcno *.gcda *.gcov gmon.out
check: encode decode test_szcomp
- ./encode -c -b1 -B8 -R128 ../data/example_data > ../data/test.aee
- ./decode -b1 -B8 -R128 ../data/test.aee
+ ./encode -c -b1 -B8 -R128 -J64 ../data/example_data > ../data/test.aee
+ ./decode -b1 -B8 -R128 -J64 ../data/test.aee
diff ../data/test ../data/example_data
- ./encode -c -b1024 -B8 -R128 ../data/example_data > ../data/test.aee
- ./decode -b1024 -B8 -R128 ../data/test.aee
+ ./encode -c -b1024 -B8 -R128 -J64 ../data/example_data > ../data/test.aee
+ ./decode -b1024 -B8 -R128 -J64 ../data/test.aee
diff ../data/test ../data/example_data
./test_szcomp 65536 ../data/example_data_16
-
-
} decode_state;
/* decoding table for the second-extension option */
-static const int second_extension[36][2] = {
+static const int second_extension[92][2] = {
{0, 0},
{1, 1}, {1, 1},
{2, 3}, {2, 3}, {2, 3},
{4, 10}, {4, 10}, {4, 10}, {4, 10}, {4, 10},
{5, 15}, {5, 15}, {5, 15}, {5, 15}, {5, 15}, {5, 15},
{6, 21}, {6, 21}, {6, 21}, {6, 21}, {6, 21}, {6, 21}, {6, 21},
- {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}
+ {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28}, {7, 28},
+ {8, 36}, {8, 36}, {8, 36}, {8, 36}, {8, 36}, {8, 36}, {8, 36}, {8, 36}, {8, 36},
+ {9, 45}, {9, 45}, {9, 45}, {9, 45}, {9, 45}, {9, 45}, {9, 45}, {9, 45}, {9, 45}, {9, 45},
+ {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55}, {10, 55},
+ {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66}, {11, 66},
+ {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}, {12, 78}
};
enum
static inline int m_select_code_option(ae_streamp strm)
{
- int i, k, this_bs, looked_bothways, direction;
+ int i, j, k, this_bs, looked_bothways, direction;
int64_t d, split_len, uncomp_len;
int64_t split_len_min, se_len, fs_len;
encode_state *state = strm->state;
if (state->ref == 0)
fs_len += (state->in_block[0] >> i);
- if (strm->block_size == 16)
- fs_len += (state->in_block[8] >> i)
- + (state->in_block[9] >> i)
- + (state->in_block[10] >> i)
- + (state->in_block[11] >> i)
- + (state->in_block[12] >> i)
- + (state->in_block[13] >> i)
- + (state->in_block[14] >> i)
- + (state->in_block[15] >> i);
+ if (strm->block_size > 8)
+ for (j = 8; j < strm->block_size; j++)
+ fs_len += state->in_block[j] >> i;
split_len = fs_len + this_bs * (i + 1);
/* Decide which option to use */
if (split_len_min < uncomp_len)
{
- if (split_len_min <= se_len)
+ if (split_len_min < se_len)
{
/* Splitting won - the most common case. */
return m_encode_splitting(strm);
/* Some sanity checks */
if (strm->bit_per_sample > 32 || strm->bit_per_sample == 0)
- {
return AE_ERRNO;
- }
+
+ if (strm->block_size != 8
+ && strm->block_size != 16
+ && strm->block_size != 32
+ && strm->block_size != 64)
+ return AE_ERRNO;
+
+ if (strm->rsi > 4096)
+ return AE_ERRNO;
/* Internal state for encoder */
state = (encode_state *) malloc(sizeof(encode_state));
state->in_blklen = 4 * strm->block_size;
if (strm->flags & AE_DATA_MSB)
+ {
state->get_sample = get_msb_32;
+ state->get_block = get_block_msb_32;
+ }
else
state->get_sample = get_lsb_32;
}
if (strm->block_size == 8)
state->get_block = get_block_msb_16_bs_8;
else
- state->get_block = get_block_msb_16_bs_16;
+ state->get_block = get_block_msb_16;
}
else
state->get_sample = get_lsb_16;
if (strm->block_size == 8)
state->get_block = get_block_8_bs_8;
else
- state->get_block = get_block_8_bs_16;
+ state->get_block = get_block_8;
}
if (strm->flags & AE_DATA_SIGNED)
}
/* Largest possible block according to specs */
- state->out_blklen = (5 + 16 * 32) / 8 + 3;
+ state->out_blklen = (5 + 64 * 32) / 8 + 3;
state->out_block = (uint8_t *)malloc(state->out_blklen);
if (state->out_block == NULL)
{
strm->avail_in -= 16;
}
-void get_block_msb_16_bs_16(ae_streamp strm)
+void get_block_msb_16(ae_streamp strm)
{
int i;
int64_t *block = strm->state->in_block;
block[i] = (strm->next_in[2 * i] << 8)
| strm->next_in[2 * i + 1];
}
- strm->next_in += 32;
- strm->total_in += 32;
- strm->avail_in -= 32;
+ strm->next_in += 2 * strm->block_size;
+ strm->total_in += 2 * strm->block_size;
+ strm->avail_in -= 2 * strm->block_size;
+}
+
+void get_block_msb_32(ae_streamp strm)
+{
+ int i;
+ int64_t *block = strm->state->in_block;
+
+ for (i = 0; i < strm->block_size; i++)
+ {
+ block[i] = (strm->next_in[4 * i] << 24)
+ | (strm->next_in[4 * i + 1] << 16)
+ | (strm->next_in[4 * i + 2] << 8)
+ | strm->next_in[4 * i + 3];
+ }
+ strm->next_in += 4 * strm->block_size;
+ strm->total_in += 4 * strm->block_size;
+ strm->avail_in -= 4 * strm->block_size;
}
void get_block_8_bs_8(ae_streamp strm)
strm->avail_in -= 8;
}
-void get_block_8_bs_16(ae_streamp strm)
+void get_block_8(ae_streamp strm)
{
+ int i;
int64_t *block = strm->state->in_block;
- block[0] = strm->next_in[0];
- block[1] = strm->next_in[1];
- block[2] = strm->next_in[2];
- block[3] = strm->next_in[3];
- block[4] = strm->next_in[4];
- block[5] = strm->next_in[5];
- block[6] = strm->next_in[6];
- block[7] = strm->next_in[7];
- block[8] = strm->next_in[8];
- block[9] = strm->next_in[9];
- block[10] = strm->next_in[10];
- block[11] = strm->next_in[11];
- block[12] = strm->next_in[12];
- block[13] = strm->next_in[13];
- block[14] = strm->next_in[14];
- block[15] = strm->next_in[15];
+ for (i = 0; i < strm->block_size; i++)
+ block[i] = strm->next_in[i];
- strm->next_in += 16;
- strm->total_in += 16;
- strm->avail_in -= 16;
+ strm->next_in += strm->block_size;
+ strm->total_in += strm->block_size;
+ strm->avail_in -= strm->block_size;
}
int64_t get_msb_16(ae_streamp);
int64_t get_8(ae_streamp);
+void get_block_msb_32(ae_streamp);
void get_block_msb_16_bs_8(ae_streamp);
-void get_block_msb_16_bs_16(ae_streamp);
+void get_block_msb_16(ae_streamp);
void get_block_8_bs_8(ae_streamp);
-void get_block_8_bs_16(ae_streamp);
+void get_block_8(ae_streamp);
#endif
strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS;
opterr = 0;
- while ((c = getopt (argc, argv, "cb:B:R:")) != -1)
+ while ((c = getopt (argc, argv, "cb:B:J:R:")) != -1)
switch (c)
{
case 'b':
case 'B':
strm.bit_per_sample = atoi(optarg);
break;
+ case 'J':
+ strm.block_size = atoi(optarg);
+ break;
case 'R':
strm.rsi = atoi(optarg);
break;
strm.flags = AE_DATA_MSB | AE_DATA_PREPROCESS;
opterr = 0;
- while ((c = getopt (argc, argv, "cb:B:R:")) != -1)
+ while ((c = getopt (argc, argv, "cb:B:R:J:")) != -1)
switch (c)
{
case 'b':
case 'B':
strm.bit_per_sample = atoi(optarg);
break;
+ case 'J':
+ strm.block_size = atoi(optarg);
+ break;
case 'R':
strm.rsi = atoi(optarg);
break;