Backed out 3 changesets (bug 1431810) for failing test_bug1431810_opus_downmix_to_mono.html on Windows

Backed out changeset a01c1941a829 (bug 1431810)
Backed out changeset 43eb1c01c67f (bug 1431810)
Backed out changeset 3fe9d85d684a (bug 1431810)
This commit is contained in:
Gurzau Raul 2018-03-26 12:09:42 +03:00
parent c8c4816b4f
commit 1368521911
9 changed files with 7 additions and 172 deletions

View File

@ -162,19 +162,6 @@ 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)
{

View File

@ -158,10 +158,6 @@ 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

View File

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

View File

@ -95,17 +95,6 @@ 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;

View File

@ -607,8 +607,6 @@ support-files =
test-7-6.1.opus^headers^
test-8-7.1.opus
test-8-7.1.opus^headers^
test-stereo-phase-inversion-180.opus
test-stereo-phase-inversion-180.opus^headers^
variable-channel.ogg
variable-channel.ogg^headers^
variable-channel.opus
@ -1275,5 +1273,3 @@ tags = hls
# We could skip the test in that case as we cannot play 2 video at a time.
skip-if = toolkit != 'android' || android_version < '18'
tags = hls
[test_bug1431810_opus_downmix_to_mono.html]

View File

@ -1 +0,0 @@
Cache-Control: no-store

View File

@ -1,137 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Media test: disable phase inversion in opus decoder</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<audio preload=none id="a" controls></audio>
<audio preload=none id="b" controls></audio>
<script class="testbody" type="text/javascript">
/*
This test makes use of an (stereo) opus file with phase inversion of 180 degrees (right = -left => right + left = 0).
Firstly, the phase inversion is verified on a normal stereo playback.
Secondly, mono playback is forced which results in the phase inversion being disabled (Bug 1431810).
*/
SimpleTest.waitForExplicitFinish();
function areChannelsInverted(b1, b2) {
for (var i = 0; i < b1.length; i++) {
if (Math.abs(b1[i] + b2[i]) > 9e-3) {
return false;
}
}
return true;
}
function areChannelsEqual(b1, b2) {
for (var i = 0; i < b1.length; i++) {
if (Math.abs(b1[i] - b2[i]) > 9e-3) {
return false;
}
}
return true;
}
function isSilent(b) {
for (var i = 0; i < b.length; i++) {
if (b[i] != 0.0) {
return false;
}
}
return true;
}
function mediaElementWithPhaseInversion(audioContext, mediaElement, success) {
let audio_source = audioContext.createMediaElementSource(mediaElement);
let script_processor = audioContext.createScriptProcessor();
audio_source.connect(script_processor);
mediaElement.onplay = () => {
script_processor.onaudioprocess = (e) => {
let right = e.inputBuffer.getChannelData(0);
let left = e.inputBuffer.getChannelData(1);
// This is leading or trailing silence
// produced by ScriptProcessor.
if (isSilent(right) && isSilent(left)) {
return;
}
ok(areChannelsInverted(right, left), "Channels must be inverted");
}
}
mediaElement.onended = () => {
ok(true, "End of file.");
mediaElement.onended = null;
script_processor.onaudioprocess = null;
success();
}
mediaElement.src = "test-stereo-phase-inversion-180.opus";
// Normal playback channels will by inverted
mediaElement.play();
}
function mediaElementWithPhaseInversionDisabled(audioContext, mediaElement, success) {
let audio_source = audioContext.createMediaElementSource(mediaElement);
let script_processor = audioContext.createScriptProcessor();
audio_source.connect(script_processor);
mediaElement.onplay = () => {
script_processor.onaudioprocess = (e) => {
let right = e.inputBuffer.getChannelData(0);
let left = e.inputBuffer.getChannelData(1);
// This is leading or trailing silence
// produced by ScriptProcessor.
if (isSilent(right) && isSilent(left)) {
return;
}
ok(!areChannelsInverted(right, left), "Channels must not be inverted");
ok(areChannelsEqual(right, left), "Channels must be equal");
}
}
mediaElement.onended = () => {
ok(true, "End of file.");
mediaElement.onended = null;
script_processor.onaudioprocess = null;
success();
}
mediaElement.src = "test-stereo-phase-inversion-180.opus";
// Downmix to mono will force to disable opus phase inversion
SpecialPowers.pushPrefEnv({"set": [["accessibility.monoaudio.enable", true]]})
.then(() => {
mediaElement.play();
});
}
let ac = new AudioContext();
function testPhaseInversion(mediaElement) {
return new Promise((accept, reject) => {
mediaElementWithPhaseInversion(ac, a, accept);
});
}
function testPhaseInversionDisabled(mediaElement) {
return new Promise((accept, reject) => {
mediaElementWithPhaseInversionDisabled(ac, b, accept);
});
}
// Start testing
testPhaseInversion(a)
.then( () => testPhaseInversionDisabled(b) )
.then( () => SimpleTest.finish() )
</script>
</pre>
</body>
</html>

View File

@ -13,7 +13,7 @@
var count = 20;
function isSilent(b) {
for (var i = 0; i < b.length; i++) {
for (var i = 0; i < b.length; b++) {
if (b[i] != 0.0) {
return false;
}