diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2006-06-17 20:43:57 +0000 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2006-06-17 20:43:57 +0000 |
commit | 985a492cbbee8d10fb169220f3f112422471adbd (patch) | |
tree | acc68cac10c3e19c128377a7b074946443ceb2c5 /src/libfaad/output.c | |
parent | 43f5d8a9a218359bf1df78f9fafa814113bc4e83 (diff) | |
download | xine-lib-985a492cbbee8d10fb169220f3f112422471adbd.tar.gz xine-lib-985a492cbbee8d10fb169220f3f112422471adbd.tar.bz2 |
Add patch for faad 5.1 support, sent by Darren Salt on mailing list.
CVS patchset: 8050
CVS date: 2006/06/17 20:43:57
Diffstat (limited to 'src/libfaad/output.c')
-rw-r--r-- | src/libfaad/output.c | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/src/libfaad/output.c b/src/libfaad/output.c index 8a005c87e..cf02505c6 100644 --- a/src/libfaad/output.c +++ b/src/libfaad/output.c @@ -22,7 +22,7 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: output.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: output.c,v 1.8 2006/06/17 20:43:57 dgp85 Exp $ **/ #include "common.h" @@ -463,7 +463,7 @@ static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample } } -void* output_to_PCM(NeAACDecHandle hDecoder, +static void* output_to_PCM_orig(NeAACDecHandle hDecoder, real_t **input, void *sample_buffer, uint8_t channels, uint16_t frame_len, uint8_t format) { @@ -554,4 +554,56 @@ void* output_to_PCM(NeAACDecHandle hDecoder, return sample_buffer; } +void *output_to_PCM(NeAACDecHandle hDecoder, + real_t **input, void *sample_buffer, uint8_t channels, + uint16_t frame_len, uint8_t format) +{ + int ch, i; + int16_t *short_sample_buffer; + real_t *ch0, *ch1, *ch2, *ch3, *ch4; + + if (format != FAAD_FMT_16BIT) + return output_to_PCM_orig(hDecoder, input, sample_buffer, channels, frame_len, format); + + short_sample_buffer = (int16_t *)sample_buffer; + ch0 = input[hDecoder->internal_channel[0]]; + ch1 = input[hDecoder->internal_channel[1]]; + ch2 = input[hDecoder->internal_channel[2]]; + ch3 = input[hDecoder->internal_channel[3]]; + ch4 = input[hDecoder->internal_channel[4]]; + + if (hDecoder->downMatrix) + { + for (i = 0; i < frame_len; ++i) + { + int32_t tmp = (ch1[i] + ((ch0[i] + ch3[i]) >> 1) + ((ch0[i] + ch3[i]) >> 2) + (1 << (REAL_BITS))) >> (REAL_BITS + 1); + if ((tmp + 0x8000) & ~0xffff) + tmp = ~(tmp >> 31) - 0x8000; + short_sample_buffer[0] = tmp; + tmp = (ch2[i] + ((ch0[i] + ch4[i]) >> 1) + ((ch0[i] + ch4[i]) >> 2) + (1 << (REAL_BITS))) >> (REAL_BITS + 1); + if ((tmp + 0x8000) & ~0xffff) + tmp = ~(tmp >> 31) - 0x8000; + short_sample_buffer[1] = tmp; + short_sample_buffer += channels; + } + return sample_buffer; + } + + /* Copy output to a standard PCM buffer */ + for (i = 0; i < frame_len; ++i) + { + for (ch = 0; ch < channels; ++ch) + { + int32 tmp = input[hDecoder->internal_channel[ch]][i]; + tmp += (1 << (REAL_BITS - 1)); + tmp >>= REAL_BITS; + if ((tmp + 0x8000) & ~0xffff) + tmp = ~(tmp >> 31) - 0x8000; + *(short_sample_buffer++) = tmp; + } + } + + return sample_buffer; +} + #endif |