Add upmix from 5 to 6 channels.

This commit is contained in:
Johns 2012-04-21 16:45:56 +02:00
parent 93ddd26a4a
commit ebe0beb400

27
audio.c
View File

@ -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. ** 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: case 8 * 8 + 2:
AudioSurround2Stereo(in, in_chan, frames, out); AudioSurround2Stereo(in, in_chan, frames, out);
break; break;
case 5 * 8 + 6:
AudioUpmix(in, in_chan, frames, out, out_chan);
break;
default: default:
Error("audio: unsupported %d -> %d channels resample\n", in_chan, Error("audio: unsupported %d -> %d channels resample\n", in_chan,