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,