Bug 1363647 - use current current candidate frame for very short mp3 file. r?gerald
MozReview-Commit-ID: GXSrcXfEfgX
--- a/dom/media/MP3Demuxer.cpp
+++ b/dom/media/MP3Demuxer.cpp
@@ -431,16 +431,20 @@ MP3TrackDemuxer::FindFirstFrame()
while (candidateFrame.Length() && numSuccFrames < MIN_SUCCESSIVE_FRAMES) {
mParser.EndFrameSession();
mOffset = currentFrame.mEnd;
const MediaByteRange prevFrame = currentFrame;
// FindNextFrame() here will only return frames consistent with our candidate frame.
currentFrame = FindNextFrame();
+ if (currentFrame.IsEmpty()) {
+ // EOS or invalid stream.
+ break;
+ }
numSuccFrames += currentFrame.Length() > 0;
// Multiple successive false positives, which wouldn't be caught by the consistency
// checks alone, can be detected by wrong alignment (non-zero gap between frames).
const int64_t frameSeparation = currentFrame.mStart - prevFrame.mEnd;
if (!currentFrame.Length() || frameSeparation != 0) {
MP3LOGV("FindFirst() not enough successive frames detected, "
"rejecting candidate frame: successiveFrames=%d, last "
@@ -453,20 +457,17 @@ MP3TrackDemuxer::FindFirstFrame()
numSuccFrames = candidateFrame.Length() > 0;
currentFrame = candidateFrame;
MP3LOGV("FindFirst() new candidate frame: mOffset=%" PRIu64
" Length()=%" PRIu64,
candidateFrame.mStart, candidateFrame.Length());
}
}
- if (numSuccFrames >= MIN_SUCCESSIVE_FRAMES) {
- MP3LOG("FindFirst() accepting candidate frame: "
- "successiveFrames=%d", numSuccFrames);
- } else {
+ if (candidateFrame.IsEmpty()) {
MP3LOG("FindFirst() no suitable first frame found");
}
return candidateFrame;
}
static bool
VerifyFrameConsistency(const FrameParser::Frame& aFrame1,
const FrameParser::Frame& aFrame2)
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -79,16 +79,17 @@ var gProgressTests = [
// Used by test_played.html
var gPlayedTests = [
{ name:"big-short.wav", type:"audio/x-wav", duration:1.11 },
{ name:"seek-short.ogv", type:"video/ogg", duration:1.03 },
{ name:"seek-short.webm", type:"video/webm", duration:0.23 },
{ name:"gizmo-short.mp4", type:"video/mp4", duration:0.27 },
{ name:"owl-short.mp3", type:"audio/mpeg", duration:0.52 },
+ { name:"very-short.mp3", type:"audio/mpeg", duration:0.07 },
// Disable vbr.mp3 to see if it reduces the error of AUDCLNT_E_CPUUSAGE_EXCEEDED.
// See bug 1110922 comment 26.
//{ name:"vbr.mp3", type:"audio/mpeg", duration:10.0 },
{ name:"bug495794.ogg", type:"audio/ogg", duration:0.3 },
];
// Used by test_mozLoadFrom. Need one test file per decoder backend, plus
// anything for testing clone-specific bugs.
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -601,16 +601,17 @@ support-files =
variable-samplerate.ogg
variable-samplerate.ogg^headers^
variable-samplerate.opus
variable-samplerate.opus^headers^
vbr-head.mp3
vbr-head.mp3^headers^
vbr.mp3
vbr.mp3^headers^
+ very-short.mp3
video-overhang.ogg
video-overhang.ogg^headers^
vp9.webm
vp9.webm^headers^
vp9-short.webm
vp9-short.webm^headers^
vp9cake.webm
vp9cake.webm^headers^
new file mode 100644
index 0000000000000000000000000000000000000000..1d15dcad599ed86e6022d4b02121c6147532e1d2
GIT binary patch
literal 625
zc%1wHdqN5W0T7Xymky-(ftU%13K<$m1^-C~K)Y;w9DQAl^(-xlSk}XwVxpkJw!xQy
z@eIfvZQ3i$3Aug9ga5w;Tp0L2Ffi0NFfed1fSHUy^baVfz`$UCfPsMp7EpRdp=1M~
dJt;~c!!sGc_V6k|>{$Y_#{_6Q3;Cua001>^kURhY