Bug 1288329: [ogg/vorbis] P2. Pass extra information to the decoder so that it can perform proper trimmer. r=gerald,jwwang
☠☠ backed out by 3f66f98ebf11 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 29 Jul 2016 02:19:21 +1000
changeset 349522 a1c4d9b9de328a0ebb68c9540f473b43bedbb22c
parent 349521 a76b6e5597772de7c8cb9d1a68fee0477a907f0b
child 349523 936b73eb37c6469fe8b31bf14965a5f04e25b740
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [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;