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 332472 0152356f027f2be2cef08e97082ef21075f8428f
parent 332471 06bab9aac05e886c511e5bf799725f6d3c639d19
child 332473 3db6ca9dc9cd2801fb77225a169984259a5a422d
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrion
bugs1168674
milestone50.0a1
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();
   }