Bug 1168674: [ogg] P4. Skip over header packets when seeking close to the start. r=brion+1012
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 21 Jul 2016 17:56:01 +1000
changeset 347438 0152356f027f2be2cef08e97082ef21075f8428f
parent 347437 06bab9aac05e886c511e5bf799725f6d3c639d19
child 347439 3db6ca9dc9cd2801fb77225a169984259a5a422d
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrion
bugs1168674
milestone50.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 1168674: [ogg] P4. Skip over header packets when seeking close to the start. r=brion+1012 MozReview-Commit-ID: F0Ezo0yfOyo
dom/media/ogg/OggDemuxer.cpp
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -857,21 +857,33 @@ OggDemuxer::GetCrypto()
 {
   return nullptr;
 }
 
 RefPtr<MediaRawData>
 OggDemuxer::GetNextPacket(TrackInfo::TrackType aType)
 {
   OggCodecState* state = GetTrackCodecState(aType);
-  DemuxUntilPacketAvailable(state);
+  ogg_packet* packet = nullptr;
+
+  do {
+    if (packet) {
+      OggCodecState::ReleasePacket(state->PacketOut());
+    }
+    DemuxUntilPacketAvailable(state);
+
+    packet = state->PacketPeek();
+  } while (packet && state->IsHeader(packet));
+
+  if (!packet) {
+    return nullptr;
+  }
 
   // Check the eos state in case we need to look for chained streams.
-  ogg_packet* packet = state->PacketPeek();
-  bool eos = packet && packet->e_o_s;
+  bool eos = packet->e_o_s;
 
   RefPtr<MediaRawData> data = state->PacketOutAsMediaRawData();;
 
   if (eos) {
     // We've encountered an end of bitstream packet; check for a chained
     // bitstream following this one.
     ReadOggChain();
   }