Bug 1288329: [ogg/vorbis] P2. Pass extra information to the decoder so that it can perform proper trimmer. r=gerald,jwwang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 29 Jul 2016 02:19:21 +1000
changeset 347503 b1f32a906af2f3aaaf653d804f83ddf0f5884e31
parent 347502 725b6c6ff7f6eb46b19efc2136e29f2b329ba294
child 347504 f9dec37d375c018a587eb20a6ec958fa3d4c28e9
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)
reviewersgerald, jwwang
bugs1288329
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 1288329: [ogg/vorbis] P2. Pass extra information to the decoder so that it can perform proper trimmer. r=gerald,jwwang The OggReader always passed a complete ogg_packet to the vorbis decoder, ensuring that the right number of frames was be returned. In the conversion to the new architecture, this information got lost making the vorbis decoder always return more frames than normal on the last packet. MozReview-Commit-ID: HYHxqXfYntJ
dom/media/MediaData.cpp
dom/media/MediaData.h
dom/media/ogg/OggCodecState.cpp
dom/media/platforms/agnostic/VorbisDecoder.cpp
--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -507,16 +507,17 @@ MediaRawData::Clone() const
   s->mTimecode = mTimecode;
   s->mTime = mTime;
   s->mDuration = mDuration;
   s->mOffset = mOffset;
   s->mKeyframe = mKeyframe;
   s->mExtraData = mExtraData;
   s->mCryptoInternal = mCryptoInternal;
   s->mTrackInfo = mTrackInfo;
+  s->mEOS = mEOS;
   if (!s->mBuffer.Append(mBuffer.Data(), mBuffer.Length())) {
     return nullptr;
   }
   return s.forget();
 }
 
 MediaRawData::~MediaRawData()
 {
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -651,16 +651,20 @@ public:
   size_t ComputedSizeOfIncludingThis() const
   {
     return sizeof(*this) + mBuffer.ComputedSizeOfExcludingThis();
   }
 
   const CryptoSample& mCrypto;
   RefPtr<MediaByteBuffer> mExtraData;
 
+  // Used by the Vorbis decoder and Ogg demuxer.
+  // Indicates that this is the last packet of the stream.
+  bool mEOS = false;
+
   RefPtr<SharedTrackInfo> mTrackInfo;
 
   // Return a deep copy or nullptr if out of memory.
   virtual already_AddRefed<MediaRawData> Clone() const;
   // Create a MediaRawDataWriter for this MediaRawData. The caller must
   // delete the writer once done. The writer is not thread-safe.
   virtual MediaRawDataWriter* CreateWriter();
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
--- a/dom/media/ogg/OggCodecState.cpp
+++ b/dom/media/ogg/OggCodecState.cpp
@@ -242,16 +242,17 @@ OggCodecState::PacketOutAsMediaRawData()
 
   int64_t duration = PacketDuration(packet);
   NS_ASSERTION(duration >= 0, "duration invalid");
 
   sample->mTimecode = packet->granulepos;
   sample->mTime = end_tstamp - duration;
   sample->mDuration = duration;
   sample->mKeyframe = IsKeyframe(packet);
+  sample->mEOS = packet->e_o_s;
 
   ReleasePacket(packet);
 
   return sample;
 }
 
 nsresult
 OggCodecState::PageIn(ogg_page* aPage)
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp
+++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp
@@ -162,17 +162,18 @@ VorbisDataDecoder::DoDecode(MediaRawData
   MOZ_ASSERT(mPacketCount >= 3);
 
   if (!mLastFrameTime || mLastFrameTime.ref() != aSample->mTime) {
     // We are starting a new block.
     mFrames = 0;
     mLastFrameTime = Some(aSample->mTime);
   }
 
-  ogg_packet pkt = InitVorbisPacket(aData, aLength, false, false, -1, mPacketCount++);
+  ogg_packet pkt = InitVorbisPacket(aData, aLength, false, aSample->mEOS,
+                                    aSample->mTimecode, mPacketCount++);
 
   if (vorbis_synthesis(&mVorbisBlock, &pkt) != 0) {
     return -1;
   }
 
   if (vorbis_synthesis_blockin(&mVorbisDsp,
                                &mVorbisBlock) != 0) {
     return -1;