diff options
author | rfelker <rfelker@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-03-29 18:14:24 +0000 |
---|---|---|
committer | rfelker <rfelker@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-03-29 18:14:24 +0000 |
commit | df40cefb1fe48211c7718d575da900724feafd81 (patch) | |
tree | 12bbcc546badd706766863af095cf34837340f64 /libfaad2 | |
parent | 9a873224f674d879546eae9febf5c4292b8de61f (diff) | |
download | mpv-df40cefb1fe48211c7718d575da900724feafd81.tar.bz2 mpv-df40cefb1fe48211c7718d575da900724feafd81.tar.xz |
usable downmixing for fixed point mode (take 2, previous patch reversed immediately on account of 1000l error :)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15021 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libfaad2')
-rw-r--r-- | libfaad2/output.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/libfaad2/output.c b/libfaad2/output.c index 6594582bbd..6169e636d1 100644 --- a/libfaad2/output.c +++ b/libfaad2/output.c @@ -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, +void* output_to_PCM_sux(NeAACDecHandle hDecoder, real_t **input, void *sample_buffer, uint8_t channels, uint16_t frame_len, uint8_t format) { @@ -554,4 +554,51 @@ 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; + int i; + int16_t *short_sample_buffer = (int16_t*)sample_buffer; + real_t *ch0 = input[hDecoder->internal_channel[0]]; + real_t *ch1 = input[hDecoder->internal_channel[1]]; + real_t *ch2 = input[hDecoder->internal_channel[2]]; + real_t *ch3 = input[hDecoder->internal_channel[3]]; + real_t *ch4 = input[hDecoder->internal_channel[4]]; + + if (format != FAAD_FMT_16BIT) + return output_to_PCM_sux(hDecoder, input, sample_buffer, channels, frame_len, format); + + if (hDecoder->downMatrix) { + for(i = 0; i < frame_len; i++) + { + int32_t tmp; + tmp = (ch1[i] + ((ch0[i]+ch3[i])<<1) + (ch0[i]+ch3[i]) + (1<<(REAL_BITS+2))) >> (REAL_BITS+3); + 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]) + (1<<(REAL_BITS+2))) >> (REAL_BITS+3); + 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_t tmp = input[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 |