From eba49ebd1c672c35fc8ab74cb7d41c6568927010 Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 29 Jul 2016 02:19:21 +1000 Subject: [PATCH] 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 --HG-- extra : rebase_source : 3aa215576fe77357dd9a484626c0e5759aeedb3c --- dom/media/MediaData.cpp | 1 + dom/media/MediaData.h | 4 ++++ dom/media/ogg/OggCodecState.cpp | 1 + dom/media/platforms/agnostic/VorbisDecoder.cpp | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dom/media/MediaData.cpp b/dom/media/MediaData.cpp index 2f845812b590..a698ac9ea8db 100644 --- a/dom/media/MediaData.cpp +++ b/dom/media/MediaData.cpp @@ -512,6 +512,7 @@ MediaRawData::Clone() const s->mExtraData = mExtraData; s->mCryptoInternal = mCryptoInternal; s->mTrackInfo = mTrackInfo; + s->mEOS = mEOS; if (!s->mBuffer.Append(mBuffer.Data(), mBuffer.Length())) { return nullptr; } diff --git a/dom/media/MediaData.h b/dom/media/MediaData.h index def3f54d656c..d3869b8d1e80 100644 --- a/dom/media/MediaData.h +++ b/dom/media/MediaData.h @@ -656,6 +656,10 @@ public: const CryptoSample& mCrypto; RefPtr mExtraData; + // Used by the Vorbis decoder and Ogg demuxer. + // Indicates that this is the last packet of the stream. + bool mEOS = false; + RefPtr mTrackInfo; // Return a deep copy or nullptr if out of memory. diff --git a/dom/media/ogg/OggCodecState.cpp b/dom/media/ogg/OggCodecState.cpp index 719e321c378c..221f6f9fa75a 100644 --- a/dom/media/ogg/OggCodecState.cpp +++ b/dom/media/ogg/OggCodecState.cpp @@ -247,6 +247,7 @@ OggCodecState::PacketOutAsMediaRawData() sample->mTime = end_tstamp - duration; sample->mDuration = duration; sample->mKeyframe = IsKeyframe(packet); + sample->mEOS = packet->e_o_s; ReleasePacket(packet); diff --git a/dom/media/platforms/agnostic/VorbisDecoder.cpp b/dom/media/platforms/agnostic/VorbisDecoder.cpp index 161965dbc0f3..7b240100d06f 100644 --- a/dom/media/platforms/agnostic/VorbisDecoder.cpp +++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp @@ -167,7 +167,8 @@ VorbisDataDecoder::DoDecode(MediaRawData* aSample) 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;