Bug 1703812 - Part 14 - Test seamless looping of compressed audio files. r=alwu

Open doesn't loop seamlessly at the minute.

Differential Revision: https://phabricator.services.mozilla.com/D168277
This commit is contained in:
Paul Adenot 2023-05-24 13:18:33 +00:00
parent 3f2efc7e35
commit f02eeee71b
9 changed files with 70 additions and 28 deletions

View File

@ -2126,6 +2126,19 @@ var gEMENonMSEFailTests = [
},
];
// Test files that are supposed to loop seamlessly when played back.
var gSeamlessLoopingTests = [
// MP4 files dont't loop seamlessly yet, the seeking logic seeks to 0, not the
// actual first packet, resulting in incorrect decoding.
// See bug 1817989
// { name: "sin-441-1s-44100-fdk_aac.mp4", type: "audio/mp4" },
// { name: "sin-441-1s-44100-afconvert.mp4", type: "audio/mp4" },
// { name: "sin-441-1s-44100.ogg", type: "audio/vorbis" },
// { name: "sin-441-1s-44100.opus", type: "audio/opus" },
{ name: "sin-441-1s-44100-lame.mp3", type: "audio/mpeg" },
{ name: "sin-441-1s-44100.flac", type: "audio/flac" },
];
// These are files that are used for video decode suspend in
// background tabs tests.
var gDecodeSuspendTests = [

View File

@ -641,21 +641,36 @@ support-files =
seek_support.js
seekLies.sjs
seek_with_sound.ogg^headers^
short-aac-encrypted-audio.mp4
short-aac-encrypted-audio.mp4^headers^
short-audio-fragmented-cenc-without-pssh.mp4
short-audio-fragmented-cenc-without-pssh.mp4^headers^
short-cenc.mp4
short-video.ogv
short.mp4
short.mp4.gz
short.mp4^headers^
# source file generated with:
# > sox -V -r 44100 -n -b 16 -c 1 sin-441-1s-44100.wav synth 1 sin 441 vol -5dB
# then encoded:
# ffmpeg -i sin-441-1s-44100.wav sin-441-1s-44100-libfdk_aac.mp4
sin-441-1s-44100-fdk_aac.mp4
# afconvert -s 3 -f mp4f -d aac sin-4411-1s-441100.wav
sin-441-1s-44100-afconvert.mp4
# ffmpeg -i sin-441-1s-44100.wav sin-441-1s-44100-libfdk_lame.mp3
sin-441-1s-44100-lame.mp3
# ffmpeg -i sin-441-1s-44100.wav sin-441-1s-44100.ogg
sin-441-1s-44100.ogg
# ffmpeg -i sin-441-1s-44100.wav sin-441-1s-44100.opus
sin-441-1s-44100.opus
# ffmpeg -i sin-441-1s-44100.wav sin-441-1s-44100.flac
sin-441-1s-44100.flac
sine.webm
sine.webm^headers^
sintel-short-clearkey-subsample-encrypted-audio.webm
sintel-short-clearkey-subsample-encrypted-audio.webm^headers^
sintel-short-clearkey-subsample-encrypted-video.webm
sintel-short-clearkey-subsample-encrypted-video.webm^headers^
short.mp4
short.mp4.gz
short.mp4^headers^
short-aac-encrypted-audio.mp4
short-aac-encrypted-audio.mp4^headers^
short-audio-fragmented-cenc-without-pssh.mp4
short-audio-fragmented-cenc-without-pssh.mp4^headers^
short-video.ogv
short-video.ogv^headers^
short-vp9-encrypted-video.mp4
short-vp9-encrypted-video.mp4^headers^

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,9 +1,9 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html>
<head>
<title>Test for seamless loop of HTMLAudioElements</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
@ -22,19 +22,34 @@ SimpleTest.waitForExplicitFinish();
var DEBUG = true;
var LOOPING_COUNT = 0;
var MAX_LOOPING_COUNT = 10;
var TONE_FREQUENCY = 440;
// Test files are at 44100Hz, files are one second long, and contain therefore
// 100 periods
var TONE_FREQUENCY = 441;
(async function testSeamlesslooping() {
info(`- create looping audio element -`);
let audio = createAudioElement();
let wavFileURL = {
name: URL.createObjectURL(new Blob([createSrcBuffer()], { type: 'audio/wav'
})),
type: "audio/wav"
};
info(`- start audio and analyze audio wave data to ensure looping audio without any silence or noise -`);
await playAudioAndStartAnalyzingWaveData(audio);
let testURLs = gSeamlessLoopingTests.splice(0)
testURLs.push(wavFileURL);
for (let testFile of testURLs) {
LOOPING_COUNT = 0;
info(`- create looping audio element ${testFile.name}`);
let audio = createAudioElement(testFile.name);
info(`- test seamless looping multiples times -`);
for (LOOPING_COUNT = 0; LOOPING_COUNT < MAX_LOOPING_COUNT; LOOPING_COUNT++) {
await once(audio, "seeked");
info(`- the round ${LOOPING_COUNT} of the seamless looping succeeds -`);
info(`- start audio and analyze audio wave data to ensure looping audio without any silence or noise -`);
await playAudioAndStartAnalyzingWaveData(audio);
info(`- test seamless looping multiples times -`);
for (LOOPING_COUNT = 0; LOOPING_COUNT < MAX_LOOPING_COUNT; LOOPING_COUNT++) {
await once(audio, "seeked");
info(`- the round ${LOOPING_COUNT} of the seamless looping succeeds -`);
}
window.audio.remove();
window.ac.close();
}
info(`- end of seamless looping test -`);
@ -96,11 +111,10 @@ function createSrcBuffer() {
return buf;
}
function createAudioElement() {
function createAudioElement(url) {
/* global audio */
window.audio = document.createElement("audio");
audio.src = URL.createObjectURL(new Blob([createSrcBuffer()],
{ type: 'audio/wav' }));
audio.src = url;
audio.controls = true;
audio.loop = true;
document.body.appendChild(audio);
@ -167,19 +181,19 @@ function createAudioWaveAnalyser(source) {
let fftSize = 2 * buf.length;
// first find a peak where we expect one.
let binIndexTone = 1 + Math.round(TONE_FREQUENCY * fftSize / ctxSampleRate);
ok(buf[binIndexTone] > -25,
`Could not find a peak: ${buf[binIndexTone]} db at ${TONE_FREQUENCY}Hz`);
ok(buf[binIndexTone] > -35,
`Could not find a peak: ${buf[binIndexTone]} db at ${TONE_FREQUENCY}Hz
(${source.src})`);
// check that the energy some octaves higher is very low.
let binIndexOutsidePeak = 1 + Math.round(TONE_FREQUENCY * 4 * buf.length / ctxSampleRate);
ok(buf[binIndexOutsidePeak] < -110,
`Found unexpected high frequency content: ${buf[binIndexOutsidePeak]}db at ${TONE_FREQUENCY * 4}Hz`);
ok(buf[binIndexOutsidePeak] < -84,
`Found unexpected high frequency content: ${buf[binIndexOutsidePeak]}db
at ${TONE_FREQUENCY * 4}Hz (${source.src})`);
}
analyser.notifyAnalysis();
}
</script>
</pre>
</body>
</html>