forked from mia/Aegisub
Converting audio provider didn't know about channel count during bitdepth and samplerate conversion and intermixed samples from channels and more, resulting in garbage output. Fixes #726.
Originally committed to SVN as r2933.
This commit is contained in:
parent
863d89ba4f
commit
44e17e9e11
1 changed files with 6 additions and 6 deletions
|
@ -135,17 +135,17 @@ void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t co
|
||||||
short *last = NULL;
|
short *last = NULL;
|
||||||
|
|
||||||
// Read audio
|
// Read audio
|
||||||
buffer1 = new short[fullSize];
|
buffer1 = new short[fullSize * channels];
|
||||||
source->GetAudio(buffer1,start/sampleMult,srcCount);
|
source->GetAudio(buffer1,start/sampleMult,srcCount);
|
||||||
|
|
||||||
// Convert from 8-bit to 16-bit
|
// Convert from 8-bit to 16-bit
|
||||||
if (srcBps == 1) {
|
if (srcBps == 1) {
|
||||||
if (sampleMult == 1) {
|
if (sampleMult == 1) {
|
||||||
Make16Bit((const char*)buffer1,(short*)destination,srcCount);
|
Make16Bit((const char*)buffer1,(short*)destination,srcCount * channels);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buffer2 = new short[fullSize];
|
buffer2 = new short[fullSize * channels];
|
||||||
Make16Bit((const char*)buffer1,buffer2,srcCount);
|
Make16Bit((const char*)buffer1,buffer2,srcCount * channels);
|
||||||
last = buffer2;
|
last = buffer2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t co
|
||||||
|
|
||||||
// Convert sample rate
|
// Convert sample rate
|
||||||
if (sampleMult != 1) {
|
if (sampleMult != 1) {
|
||||||
ChangeSampleRate(last,(short*)destination,count);
|
ChangeSampleRate(last,(short*)destination,count * channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] buffer1;
|
delete [] buffer1;
|
||||||
|
@ -167,7 +167,7 @@ void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t co
|
||||||
AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) {
|
AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) {
|
||||||
AudioProvider *provider = source_provider;
|
AudioProvider *provider = source_provider;
|
||||||
if (provider->GetBytesPerSample() != 2 || provider->GetSampleRate() < 32000)
|
if (provider->GetBytesPerSample() != 2 || provider->GetSampleRate() < 32000)
|
||||||
provider = new ConvertAudioProvider(source_provider);
|
provider = new ConvertAudioProvider(provider);
|
||||||
|
|
||||||
if (provider->GetChannels() != 1)
|
if (provider->GetChannels() != 1)
|
||||||
provider = new DownmixingAudioProvider(provider);
|
provider = new DownmixingAudioProvider(provider);
|
||||||
|
|
Loading…
Reference in a new issue