Commit 1af9cda5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

AES3: decode to native endian

(and revert earlier accidental changes)
parent ca4846fe
......@@ -157,52 +157,64 @@ static block_t *Decode( decoder_t *p_dec, block_t **pp_block )
p_block->i_buffer -= AES3_HEADER_LEN;
p_block->p_buffer += AES3_HEADER_LEN;
#ifdef WORDS_BIGENGIAN
# define LOB 2
# define HIB 0
#else
# define LOB 0
# define HIB 2
#endif
#define MIB 1
if( i_bits == 24 )
{
uint32_t *p_out = p_aout_buffer->p_buffer;
uint8_t *p_out = p_aout_buffer->p_buffer;
while( p_block->i_buffer / 7 )
{
p_out[0] = reverse[p_block->p_buffer[0]];
p_out[1] = reverse[p_block->p_buffer[1]];
p_out[2] = reverse[p_block->p_buffer[2]];
p_out[3] = (reverse[p_block->p_buffer[3]] >> 4)
| ((reverse[p_block->p_buffer[4]] << 4) & 0xf0);
p_out[4] = (reverse[p_block->p_buffer[4]] >> 4)
| ((reverse[p_block->p_buffer[5]] << 4) & 0xf0);
p_out[5] = (reverse[p_block->p_buffer[5]] >> 4)
| ((reverse[p_block->p_buffer[6]] << 4) & 0xf0);
p_out[LOB] = reverse[p_block->p_buffer[0]];
p_out[MIB] = reverse[p_block->p_buffer[1]];
p_out[HIB] = reverse[p_block->p_buffer[2]];
p_out += 3;
p_out[LOB] = (reverse[p_block->p_buffer[3]] >> 4)
| ((reverse[p_block->p_buffer[4]] << 4) & 0xf0);
p_out[MIB] = (reverse[p_block->p_buffer[4]] >> 4)
| ((reverse[p_block->p_buffer[5]] << 4) & 0xf0);
p_out[HIB] = (reverse[p_block->p_buffer[5]] >> 4)
| ((reverse[p_block->p_buffer[6]] << 4) & 0xf0);
p_out += 3;
p_block->i_buffer -= 7;
p_block->p_buffer += 7;
p_out += 6;
}
}
else if( i_bits == 20 )
{
uint32_t *p_out = p_aout_buffer->p_buffer;
uint8_t *p_out = p_aout_buffer->p_buffer;
while( p_block->i_buffer / 6 )
{
p_out[0] = ((reverse[p_block->p_buffer[0]] << 4) & 0xf0);
p_out[1] = (reverse[p_block->p_buffer[0]] >> 4)
| ((reverse[p_block->p_buffer[1]] << 4) & 0xf0);
p_out[2] = (reverse[p_block->p_buffer[1]] >> 4)
| ((reverse[p_block->p_buffer[2]] << 4) & 0xf0);
p_out[3] = ((reverse[p_block->p_buffer[3]] << 4) & 0xf0);
p_out[4] = (reverse[p_block->p_buffer[3]] >> 4)
| ((reverse[p_block->p_buffer[4]] << 4) & 0xf0);
p_out[5] = (reverse[p_block->p_buffer[4]] >> 4)
| ((reverse[p_block->p_buffer[5]] << 4) & 0xf0);
p_out[LOB] = ((reverse[p_block->p_buffer[0]] << 4) & 0xf0);
p_out[MIB] = (reverse[p_block->p_buffer[0]] >> 4)
| ((reverse[p_block->p_buffer[1]] << 4) & 0xf0);
p_out[HIB] = (reverse[p_block->p_buffer[1]] >> 4)
| ((reverse[p_block->p_buffer[2]] << 4) & 0xf0);
p_out += 3;
p_out[LOB] = ((reverse[p_block->p_buffer[3]] << 4) & 0xf0);
p_out[MIB] = (reverse[p_block->p_buffer[3]] >> 4)
| ((reverse[p_block->p_buffer[4]] << 4) & 0xf0);
p_out[HIB] = (reverse[p_block->p_buffer[4]] >> 4)
| ((reverse[p_block->p_buffer[5]] << 4) & 0xf0);
p_out += 3;
p_block->i_buffer -= 6;
p_block->p_buffer += 6;
p_out += 6;
}
}
#undef HIB
#define HIB (!(LOB))
else
{
uint8_t *p_out = p_aout_buffer->p_buffer;
......@@ -211,17 +223,18 @@ static block_t *Decode( decoder_t *p_dec, block_t **pp_block )
while( p_block->i_buffer / 5 )
{
p_out[0] = reverse[p_block->p_buffer[0]];
p_out[1] = reverse[p_block->p_buffer[1]];
p_out[LOB] = reverse[p_block->p_buffer[0]];
p_out[HIB] = reverse[p_block->p_buffer[1]];
p_out += 2;
p_out[2] = (reverse[p_block->p_buffer[2]] >> 4)
| ((reverse[p_block->p_buffer[3]] << 4) & 0xf0);
p_out[3] = (reverse[p_block->p_buffer[3]] >> 4)
| ((reverse[p_block->p_buffer[4]] << 4) & 0xf0);
p_out[LOB] = (reverse[p_block->p_buffer[2]] >> 4)
| ((reverse[p_block->p_buffer[3]] << 4) & 0xf0);
p_out[HIB] = (reverse[p_block->p_buffer[3]] >> 4)
| ((reverse[p_block->p_buffer[4]] << 4) & 0xf0);
p_out += 2;
p_block->i_buffer -= 5;
p_block->p_buffer += 5;
p_out += 4;
}
}
......@@ -372,8 +385,9 @@ static block_t *Parse( decoder_t *p_dec, int *pi_frame_length, int *pi_bits,
}
else
{
p_dec->fmt_out.i_codec = i_bits == 16 ? VLC_CODEC_S16N : VLC_CODEC_S32N;
p_dec->fmt_out.audio.i_bitspersample = i_bits == 16 ? 16 : 32;
p_dec->fmt_out.i_codec = i_bits == 16 ? VLC_CODEC_S16N
: VLC_CODEC_S24N;
p_dec->fmt_out.audio.i_bitspersample = i_bits == 16 ? 16 : 24;
}
p_dec->fmt_out.audio.i_channels = i_channels;
......
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