Bug 1431810 - Disable Opus phase inversion on stereo to mono downmix. r=rillian

MozReview-Commit-ID: 5eaSPQzUu9o

--HG--
extra : rebase_source : 126d9faa2824d29fc73cf040b033ca585dfdbcee
This commit is contained in:
Alex Chronopoulos 2018-03-15 18:28:14 +02:00
Родитель 32b3e12eb0
Коммит 851a3ee589
4 изменённых файлов: 29 добавлений и 6 удалений

Просмотреть файл

@ -167,6 +167,19 @@ void DownmixStereoToMono(mozilla::AudioDataValue* aBuffer,
}
}
uint32_t DecideAudioPlaybackChannels(const AudioInfo& info)
{
if (MediaPrefs::MonoAudio()) {
return 1;
}
if (MediaPrefs::AudioSinkForceStereo()) {
return 2;
}
return info.mChannels;
}
bool
IsVideoContentType(const nsCString& aContentType)
{

Просмотреть файл

@ -158,6 +158,10 @@ ScaleDisplayByAspectRatio(gfx::IntSize& aDisplay, float aAspectRatio);
void DownmixStereoToMono(mozilla::AudioDataValue* aBuffer,
uint32_t aFrames);
// Decide the number of playback channels according to the
// given AudioInfo and the prefs that are being set.
uint32_t DecideAudioPlaybackChannels(const AudioInfo& info);
bool IsVideoContentType(const nsCString& aContentType);
// Returns true if it's safe to use aPicture as the picture to be

Просмотреть файл

@ -64,12 +64,7 @@ AudioSink::AudioSink(AbstractThread* aThread,
}
MOZ_DIAGNOSTIC_ASSERT(mOutputRate, "output rate can't be 0.");
bool monoAudioEnabled = MediaPrefs::MonoAudio();
mOutputChannels =
monoAudioEnabled
? 1
: (MediaPrefs::AudioSinkForceStereo() ? 2 : mInfo.mChannels);
mOutputChannels = DecideAudioPlaybackChannels(mInfo);
}
AudioSink::~AudioSink()

Просмотреть файл

@ -95,6 +95,17 @@ OpusDataDecoder::Init()
mOpusParser->mCoupledStreams,
mMappingTable.Elements(),
&r);
// Opus has a special feature for stereo coding where it represent wide
// stereo channels by 180-degree out of phase. This improves quality, but
// needs to be disabled when the output is downmixed to mono. Playback number
// of channels are set in AudioSink, using the same method
// `DecideAudioPlaybackChannels()`, and triggers downmix if needed.
if (mOpusDecoder && mOpusParser->mChannels == 2 &&
DecideAudioPlaybackChannels(mInfo) == 1) {
opus_multistream_decoder_ctl(mOpusDecoder, OPUS_SET_PHASE_INVERSION_DISABLED(1));
}
mSkip = mOpusParser->mPreSkip;
mPaddingDiscarded = false;