Commit 855c5d3d authored by Mathis Rosenhauer's avatar Mathis Rosenhauer Committed by Thomas Jahns

Working 3 byte datatype support.

parent 394c480f
......@@ -84,6 +84,15 @@ static void put_msb_32(ae_streamp strm, int64_t data)
strm->total_out += 4;
}
static void put_msb_24(ae_streamp strm, int64_t data)
{
*strm->next_out++ = data >> 16;
*strm->next_out++ = data >> 8;
*strm->next_out++ = data;
strm->avail_out -= 3;
strm->total_out += 3;
}
static void put_msb_16(ae_streamp strm, int64_t data)
{
*strm->next_out++ = data >> 8;
......@@ -102,6 +111,15 @@ static void put_lsb_32(ae_streamp strm, int64_t data)
strm->total_out += 4;
}
static void put_lsb_24(ae_streamp strm, int64_t data)
{
*strm->next_out++ = data;
*strm->next_out++ = data >> 8;
*strm->next_out++ = data >> 16;
strm->avail_out -= 3;
strm->total_out += 3;
}
static void put_lsb_16(ae_streamp strm, int64_t data)
{
*strm->next_out++ = data;
......@@ -278,13 +296,26 @@ int ae_decode_init(ae_streamp strm)
if (strm->bit_per_sample > 16)
{
state->byte_per_sample = 4;
state->id_len = 5;
state->out_blklen = strm->block_size * 4;
if (strm->flags & AE_DATA_MSB)
state->put_sample = put_msb_32;
if (strm->bit_per_sample <= 24 && strm->flags & AE_DATA_3BYTE)
{
state->byte_per_sample = 3;
if (strm->flags & AE_DATA_MSB)
state->put_sample = put_msb_24;
else
state->put_sample = put_lsb_24;
}
else
state->put_sample = put_lsb_32;
{
state->byte_per_sample = 4;
if (strm->flags & AE_DATA_MSB)
state->put_sample = put_msb_32;
else
state->put_sample = put_lsb_32;
}
state->out_blklen = strm->block_size
* state->byte_per_sample;
}
else if (strm->bit_per_sample > 8)
{
......
......@@ -687,31 +687,30 @@ int ae_encode_init(ae_streamp strm)
if (strm->bit_per_sample > 16)
{
/* 32 bit settings */
/* 24/32 input bit settings */
state->id_len = 5;
state->block_len = 4 * strm->block_size;
if (strm->flags & AE_DATA_MSB)
if (strm->bit_per_sample <= 24 && strm->flags & AE_DATA_3BYTE)
{
if (strm->bit_per_sample == 24
&& strm->flags & AE_DATA_3BYTE)
state->block_len = 3 * strm->block_size;
if (strm->flags & AE_DATA_MSB)
{
state->get_sample = get_msb_24;
state->get_block = get_block_funcs_msb_24[bsi];
}
else
{
state->get_sample = get_msb_32;
state->get_block = get_block_funcs_msb_32[bsi];
state->get_sample = get_lsb_24;
state->get_block = get_block_funcs_lsb_24[bsi];
}
}
else
{
if (strm->bit_per_sample == 24
&& strm->flags & AE_DATA_3BYTE)
state->block_len = 4 * strm->block_size;
if (strm->flags & AE_DATA_MSB)
{
state->get_sample = get_lsb_24;
state->get_block = get_block_funcs_lsb_24[bsi];
state->get_sample = get_msb_32;
state->get_block = get_block_funcs_msb_32[bsi];
}
else
{
......
......@@ -218,10 +218,10 @@ uint32_t get_msb_32(ae_streamp strm)
for (i = 0; i < strm->rsi; i++) \
for (j = 0; j < BS; j++) \
block[i * BS + j] = \
(uint32_t)strm->next_in[4 * (i * BS + j)] \
| ((uint32_t)strm->next_in[4 * (i * BS + j) + 1] \
(uint32_t)strm->next_in[3 * (i * BS + j)] \
| ((uint32_t)strm->next_in[3 * (i * BS + j) + 1] \
<< 8) \
| ((uint32_t)strm->next_in[4 * (i * BS + j) + 2] \
| ((uint32_t)strm->next_in[3 * (i * BS + j) + 2] \
<< 16); \
\
strm->next_in += 3 * BS * strm->rsi; \
......@@ -238,11 +238,11 @@ uint32_t get_msb_32(ae_streamp strm)
for (i = 0; i < strm->rsi; i++) \
for (j = 0; j < BS; j++) \
block[i * BS + j] = \
((uint32_t)strm->next_in[4 * (i * BS + j)] \
((uint32_t)strm->next_in[3 * (i * BS + j)] \
<< 16) \
| ((uint32_t)strm->next_in[4 * (i * BS + j) + 1] \
| ((uint32_t)strm->next_in[3 * (i * BS + j) + 1] \
<< 8) \
| (uint32_t)strm->next_in[4 * (i * BS + j) + 2]; \
| (uint32_t)strm->next_in[3 * (i * BS + j) + 2]; \
\
strm->next_in += 3 * BS * strm->rsi; \
strm->total_in += 3 * BS * strm->rsi; \
......
......@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
strm.flags = AE_DATA_PREPROCESS;
opterr = 0;
while ((c = getopt (argc, argv, "Mscb:B:J:R:")) != -1)
while ((c = getopt (argc, argv, "3Mscb:B:J:R:")) != -1)
switch (c)
{
case 'b':
......@@ -51,6 +51,9 @@ int main(int argc, char *argv[])
case 'M':
strm.flags |= AE_DATA_MSB;
break;
case '3':
strm.flags |= AE_DATA_3BYTE;
break;
case '?':
if (optopt == 'b')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
......@@ -75,6 +78,18 @@ int main(int argc, char *argv[])
exit(-1);
}
if (strm.bit_per_sample > 16)
{
if (strm.bit_per_sample <= 24 && strm.flags & AE_DATA_3BYTE)
chunk *= 3;
else
chunk *= 4;
}
else if (strm.bit_per_sample > 8)
{
chunk *= 2;
}
in = (uint8_t *)malloc(chunk);
out = (uint8_t *)malloc(chunk);
if (in == NULL || out == NULL)
......
......@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
strm.flags = AE_DATA_PREPROCESS;
opterr = 0;
while ((c = getopt (argc, argv, "Mscb:B:R:J:")) != -1)
while ((c = getopt (argc, argv, "3Mscb:B:R:J:")) != -1)
switch (c)
{
case 'b':
......@@ -51,6 +51,9 @@ int main(int argc, char *argv[])
case 'M':
strm.flags |= AE_DATA_MSB;
break;
case '3':
strm.flags |= AE_DATA_3BYTE;
break;
case '?':
if (optopt == 'b')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
......@@ -75,6 +78,18 @@ int main(int argc, char *argv[])
exit(-1);
}
if (strm.bit_per_sample > 16)
{
if (strm.bit_per_sample <= 24 && strm.flags & AE_DATA_3BYTE)
chunk *= 3;
else
chunk *= 4;
}
else if (strm.bit_per_sample > 8)
{
chunk *= 2;
}
out = (uint8_t *)malloc(chunk);
in = (uint8_t *)malloc(chunk);
......
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