Fix T71322: Crash in Audaspace with some video file

Getting upstream audaspace fixes for audio files with more than 8
channels.
This commit is contained in:
Joerg Mueller 2019-11-17 09:02:18 +01:00
parent e385bdb228
commit fb1cbbaf46
Notes: blender-bot 2023-02-14 10:09:24 +01:00
Referenced by issue #71322, Crash in Audaspace with some video file
2 changed files with 13 additions and 9 deletions

View File

@ -1167,7 +1167,8 @@ OpenALDevice::OpenALDevice(DeviceSpecs specs, int buffersize, std::string name)
if((!m_useMC && specs.channels > CHANNELS_STEREO) ||
specs.channels == CHANNELS_STEREO_LFE ||
specs.channels == CHANNELS_SURROUND5)
specs.channels == CHANNELS_SURROUND5 ||
specs.channels > CHANNELS_SURROUND71)
specs.channels = CHANNELS_STEREO;
alGetError();

View File

@ -97,12 +97,15 @@ void ChannelMapperReader::calculateMapping()
for(int i = 0; i < m_source_channels * m_target_channels; i++)
m_mapping[i] = 0;
const Channel* source_channels = CHANNEL_MAPS[m_source_channels - 1];
const Channel* target_channels = CHANNEL_MAPS[m_target_channels - 1];
const Channels source_channel_count = std::min(m_source_channels, CHANNELS_SURROUND71);
const Channels target_channel_count = std::min(m_target_channels, CHANNELS_SURROUND71);
const Channel* source_channels = CHANNEL_MAPS[source_channel_count - 1];
const Channel* target_channels = CHANNEL_MAPS[target_channel_count - 1];
int lfe = -1;
for(int i = 0; i < m_target_channels; i++)
for(int i = 0; i < target_channel_count; i++)
{
if(target_channels[i] == CHANNEL_LFE)
{
@ -111,16 +114,16 @@ void ChannelMapperReader::calculateMapping()
}
}
const float* source_angles = CHANNEL_ANGLES[m_source_channels - 1];
const float* target_angles = CHANNEL_ANGLES[m_target_channels - 1];
const float* source_angles = CHANNEL_ANGLES[source_channel_count - 1];
const float* target_angles = CHANNEL_ANGLES[target_channel_count - 1];
if(m_source_channels == CHANNELS_MONO)
if(source_channel_count == CHANNELS_MONO)
source_angles = &m_mono_angle;
int channel_left, channel_right;
float angle_left, angle_right, angle;
for(int i = 0; i < m_source_channels; i++)
for(int i = 0; i < source_channel_count; i++)
{
if(source_channels[i] == CHANNEL_LFE)
{
@ -134,7 +137,7 @@ void ChannelMapperReader::calculateMapping()
angle_left = -2 * M_PI;
angle_right = 2 * M_PI;
for(int j = 0; j < m_target_channels; j++)
for(int j = 0; j < target_channel_count; j++)
{
if(j == lfe)
continue;