зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500238 correct mono-to-stereo panning at centre position r=padenot
and re-use input buffer instead of copying. Depends on D9211 Differential Revision: https://phabricator.services.mozilla.com/D9212 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6e306581c2
Коммит
ad45a8d475
|
@ -46,7 +46,7 @@ public:
|
||||||
using AudioChunk::SizeOfExcludingThisIfUnshared;
|
using AudioChunk::SizeOfExcludingThisIfUnshared;
|
||||||
using AudioChunk::SizeOfExcludingThis;
|
using AudioChunk::SizeOfExcludingThis;
|
||||||
// mDuration is not exposed. Use GetDuration().
|
// mDuration is not exposed. Use GetDuration().
|
||||||
// mBuffer is not exposed. Use SetBuffer().
|
// mBuffer is not exposed. Use Get/SetBuffer().
|
||||||
using AudioChunk::mChannelData;
|
using AudioChunk::mChannelData;
|
||||||
using AudioChunk::mVolume;
|
using AudioChunk::mVolume;
|
||||||
using AudioChunk::mBufferFormat;
|
using AudioChunk::mBufferFormat;
|
||||||
|
@ -74,6 +74,7 @@ public:
|
||||||
return static_cast<float*>(const_cast<void*>(mChannelData[aChannel]));
|
return static_cast<float*>(const_cast<void*>(mChannelData[aChannel]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThreadSharedObject* GetBuffer() const { return mBuffer; }
|
||||||
void SetBuffer(ThreadSharedObject* aNewBuffer);
|
void SetBuffer(ThreadSharedObject* aNewBuffer);
|
||||||
void SetNull(StreamTime aDuration) {
|
void SetNull(StreamTime aDuration) {
|
||||||
MOZ_ASSERT(aDuration == WEBAUDIO_BLOCK_SIZE);
|
MOZ_ASSERT(aDuration == WEBAUDIO_BLOCK_SIZE);
|
||||||
|
|
|
@ -462,9 +462,6 @@ PannerNodeEngine::EqualPowerPanningFunction(const AudioBlock& aInput,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The output of this node is always stereo, no matter what the inputs are.
|
|
||||||
aOutput->AllocateChannels(2);
|
|
||||||
|
|
||||||
ComputeAzimuthAndElevation(position, azimuth, elevation);
|
ComputeAzimuthAndElevation(position, azimuth, elevation);
|
||||||
coneGain = ComputeConeGain(position, orientation);
|
coneGain = ComputeConeGain(position, orientation);
|
||||||
|
|
||||||
|
@ -508,9 +505,6 @@ PannerNodeEngine::EqualPowerPanningFunction(const AudioBlock& aInput,
|
||||||
float orientationY[WEBAUDIO_BLOCK_SIZE];
|
float orientationY[WEBAUDIO_BLOCK_SIZE];
|
||||||
float orientationZ[WEBAUDIO_BLOCK_SIZE];
|
float orientationZ[WEBAUDIO_BLOCK_SIZE];
|
||||||
|
|
||||||
// The output of this node is always stereo, no matter what the inputs are.
|
|
||||||
aOutput->AllocateChannels(2);
|
|
||||||
|
|
||||||
if (!mPositionX.HasSimpleValue()) {
|
if (!mPositionX.HasSimpleValue()) {
|
||||||
mPositionX.GetValuesAtTime(tick, positionX, WEBAUDIO_BLOCK_SIZE);
|
mPositionX.GetValuesAtTime(tick, positionX, WEBAUDIO_BLOCK_SIZE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -52,6 +52,8 @@ template<typename T, typename U>
|
||||||
void ApplyStereoPanning(const AudioBlock& aInput, AudioBlock* aOutput,
|
void ApplyStereoPanning(const AudioBlock& aInput, AudioBlock* aOutput,
|
||||||
T aGainL, T aGainR, U aOnLeft)
|
T aGainL, T aGainR, U aOnLeft)
|
||||||
{
|
{
|
||||||
|
aOutput->AllocateChannels(2);
|
||||||
|
|
||||||
if (aInput.ChannelCount() == 1) {
|
if (aInput.ChannelCount() == 1) {
|
||||||
GainMonoToStereo(aInput, aOutput, aGainL, aGainR);
|
GainMonoToStereo(aInput, aOutput, aGainL, aGainR);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -92,16 +92,18 @@ public:
|
||||||
void UpmixToStereoIfNeeded(const AudioBlock& aInput, AudioBlock* aOutput)
|
void UpmixToStereoIfNeeded(const AudioBlock& aInput, AudioBlock* aOutput)
|
||||||
{
|
{
|
||||||
if (aInput.ChannelCount() == 2) {
|
if (aInput.ChannelCount() == 2) {
|
||||||
const float* inputL = static_cast<const float*>(aInput.mChannelData[0]);
|
*aOutput = aInput;
|
||||||
const float* inputR = static_cast<const float*>(aInput.mChannelData[1]);
|
|
||||||
float* outputL = aOutput->ChannelFloatsForWrite(0);
|
|
||||||
float* outputR = aOutput->ChannelFloatsForWrite(1);
|
|
||||||
|
|
||||||
AudioBlockCopyChannelWithScale(inputL, aInput.mVolume, outputL);
|
|
||||||
AudioBlockCopyChannelWithScale(inputR, aInput.mVolume, outputR);
|
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(aInput.ChannelCount() == 1);
|
MOZ_ASSERT(aInput.ChannelCount() == 1);
|
||||||
GainMonoToStereo(aInput, aOutput, aInput.mVolume, aInput.mVolume);
|
aOutput->SetBuffer(aInput.GetBuffer());
|
||||||
|
aOutput->mChannelData.SetLength(2);
|
||||||
|
for (uint32_t i = 0; i < 2; ++i) {
|
||||||
|
aOutput->mChannelData[i] = aInput.ChannelData<float>()[0];
|
||||||
|
}
|
||||||
|
// 1/sqrt(2) multiplier is because StereoPanner up-mixing differs from
|
||||||
|
// input up-mixing.
|
||||||
|
aOutput->mVolume = M_SQRT1_2 * aInput.mVolume;
|
||||||
|
aOutput->mBufferFormat = AUDIO_FORMAT_FLOAT32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +121,6 @@ public:
|
||||||
// If input is silent, so is the output
|
// If input is silent, so is the output
|
||||||
aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
|
aOutput->SetNull(WEBAUDIO_BLOCK_SIZE);
|
||||||
} else if (mPan.HasSimpleValue()) {
|
} else if (mPan.HasSimpleValue()) {
|
||||||
aOutput->AllocateChannels(2);
|
|
||||||
float panning = mPan.GetValue();
|
float panning = mPan.GetValue();
|
||||||
// If the panning is 0.0, we can simply copy the input to the
|
// If the panning is 0.0, we can simply copy the input to the
|
||||||
// output with gain applied, up-mixing to stereo if needed.
|
// output with gain applied, up-mixing to stereo if needed.
|
||||||
|
@ -138,7 +139,6 @@ public:
|
||||||
panning <= 0);
|
panning <= 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
aOutput->AllocateChannels(2);
|
|
||||||
float computedGain[2*WEBAUDIO_BLOCK_SIZE + 4];
|
float computedGain[2*WEBAUDIO_BLOCK_SIZE + 4];
|
||||||
bool onLeft[WEBAUDIO_BLOCK_SIZE];
|
bool onLeft[WEBAUDIO_BLOCK_SIZE];
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче