[vlc-commits] AES3: decode to native endian
Rémi Denis-Courmont
git at videolan.org
Thu Nov 22 22:26:17 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov 22 23:25:33 2012 +0200| [1af9cda50cea036c94a98f4507dab30ac3607c2e] | committer: Rémi Denis-Courmont
AES3: decode to native endian
(and revert earlier accidental changes)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1af9cda50cea036c94a98f4507dab30ac3607c2e
---
modules/codec/aes3.c | 82 +++++++++++++++++++++++++++++---------------------
1 file changed, 48 insertions(+), 34 deletions(-)
diff --git a/modules/codec/aes3.c b/modules/codec/aes3.c
index 33af926..d59ba48 100644
--- a/modules/codec/aes3.c
+++ b/modules/codec/aes3.c
@@ -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;
More information about the vlc-commits
mailing list