Bug 1301226 - Handle odd WAV chunk lengths - r=cpearce
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 07 Nov 2016 16:31:39 +1100
changeset 321576 c7a47678290a380324b9bc9704b21c9f3c116af3
parent 321575 cea9d0937e3bf55318cbbf6be0ab67dd82cd1e29
child 321577 4a1847c6164f36f770d18adae40b6f582030c2a6
push id83647
push userkwierso@gmail.com
push dateTue, 08 Nov 2016 22:08:41 +0000
treeherdermozilla-inbound@1d0b02250149 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1301226
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301226 - Handle odd WAV chunk lengths - r=cpearce 'fmt ' and 'LIST' chunks could theoretically (but unlikely) have an odd length, in which case the following chunk will start at the next even offset. Added test case. MozReview-Commit-ID: DkpBTaUqnf8
dom/media/test/bug1301226-odd.wav
dom/media/test/bug1301226-odd.wav^headers^
dom/media/test/manifest.js
dom/media/test/mochitest.ini
dom/media/wave/WaveDemuxer.cpp
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dd2df4e4dd7bca8695c7c95f838d7f02050ebfa0
GIT binary patch
literal 244
zc$^)Ly$ZrW5QH}-f;OVHjraf|DHK~l4-Q1Zgjfe8on7#$d^(Zj$PeS}-N5bcH+yq;
zYYccE$KqVQ>di_-0%}``oIWBGS(03Amakdu)!b}m@`bYUUG4U9dWh2`;ruM?Qj^$9
zC?k4|6cBJyI+sXhOm=ht=N<JT|06JPJL0TVL|+e-^HrGFVoKWb)!<2whMuE3b`3)E
U&?f=9=kTM`vFm-d-e2$i0XsW>=l}o!
new file mode 100644
--- /dev/null
+++ b/dom/media/test/bug1301226-odd.wav^headers^
@@ -0,0 +1,1 @@
+Cache-Control: no-store
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -162,16 +162,18 @@ var gPlayTests = [
   // 24-bit samples
   { name:"wavedata_s24.wav", type:"audio/x-wav", duration:1.0 },
   // aLaw compressed wave file
   { name:"wavedata_alaw.wav", type:"audio/x-wav", duration:1.0 },
   // uLaw compressed wave file
   { name:"wavedata_ulaw.wav", type:"audio/x-wav", duration:1.0 },
   // Data length 0xFFFFFFFF
   { name:"bug1301226.wav", type:"audio/x-wav", duration:0.003673 },
+  // Data length 0xFFFFFFFF and odd chunk lengths.
+  { name:"bug1301226-odd.wav", type:"audio/x-wav", duration:0.003673 },
 
   // Ogg stream without eof marker
   { name:"bug461281.ogg", type:"application/ogg", duration:2.208 },
 
   // oggz-chop stream
   { name:"bug482461.ogv", type:"video/ogg", duration:4.34 },
   // Theora only oggz-chop stream
   { name:"bug482461-theora.ogv", type:"video/ogg", duration:4.138 },
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -388,16 +388,18 @@ support-files =
   bug603918.webm^headers^
   bug604067.webm
   bug604067.webm^headers^
   bug883173.vtt
   bug1066943.webm
   bug1066943.webm^headers^
   bug1301226.wav
   bug1301226.wav^headers^
+  bug1301226-odd.wav
+  bug1301226-odd.wav^headers^
   can_play_type_dash.js
   can_play_type_ogg.js
   can_play_type_wave.js
   can_play_type_webm.js
   cancellable_request.sjs
   chain.ogg
   chain.ogg^headers^
   chain.ogv
--- a/dom/media/wave/WaveDemuxer.cpp
+++ b/dom/media/wave/WaveDemuxer.cpp
@@ -128,18 +128,21 @@ WAVTrackDemuxer::Init()
       }
     } else if (aChunkName == DATA_CODE) {
       mDataLength = aChunkSize;
       if (mFirstChunkOffset != mOffset) {
         mFirstChunkOffset = mOffset;
       }
       break;
     } else {
+      mOffset += aChunkSize; // Skip other irrelevant chunks.
+    }
+    if (mOffset & 1) {
       // Wave files are 2-byte aligned so we need to round up
-      mOffset += (aChunkSize + 1) & ~1; // Skip other irrelevant chunks.
+      mOffset += 1;
     }
     mHeaderParser.Reset();
   }
 
   if (mDataLength > StreamLength() - mFirstChunkOffset) {
     mDataLength = StreamLength() - mFirstChunkOffset;
   }