From ebe0beb40048c90a8128cf81678bd2c250973a1e Mon Sep 17 00:00:00 2001 From: Johns Date: Sat, 21 Apr 2012 16:45:56 +0200 Subject: [PATCH] Add upmix from 5 to 6 channels. --- audio.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/audio.c b/audio.c index 84e2748..efc7ef0 100644 --- a/audio.c +++ b/audio.c @@ -535,6 +535,30 @@ static void AudioSurround2Stereo(const int16_t * in, int in_chan, int frames, } } +/** +** Upmix @a in_chan channels to @a out_chan. +** +** @param in input sample buffer +** @param in_chan nr. of input channels +** @param frames number of frames in sample buffer +** @param out output sample buffer +** @param out_chan nr. of output channels +*/ +static void AudioUpmix(const int16_t * in, int in_chan, int frames, + int16_t * out, int out_chan) +{ + while (frames--) { + int i; + + for (i = 0; i < in_chan; ++i) { // copy existing channels + *out++ = *in++; + } + for (; i < out_chan; ++i) { // silents missing channels + *out++ = 0; + } + } +} + /** ** Resample ffmpeg sample format to hardware format. ** @@ -572,6 +596,9 @@ static void AudioResample(const int16_t * in, int in_chan, int frames, case 8 * 8 + 2: AudioSurround2Stereo(in, in_chan, frames, out); break; + case 5 * 8 + 6: + AudioUpmix(in, in_chan, frames, out, out_chan); + break; default: Error("audio: unsupported %d -> %d channels resample\n", in_chan,