Bug 1240201: [opus] P2. Properly determine sample duration and time in webm demuxer. r=kinetik
☠☠ backed out by 8381cc4aa935 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 22 Jan 2016 00:36:06 +1100
changeset 280931 b06a049cafb789e5f7b4d20be64b1c745173a86c
parent 280930 69b695ad6d43bfa2344161b31102e56d8a27ec19
child 280932 97503acd6658d4fecf1638d6a3ae3a1d9e0b2eaf
push id70626
push userjyavenard@mozilla.com
push dateThu, 21 Jan 2016 13:43:17 +0000
treeherdermozilla-inbound@b06a049cafb7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1240201
milestone46.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 1240201: [opus] P2. Properly determine sample duration and time in webm demuxer. r=kinetik
dom/media/webm/WebMDemuxer.cpp
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -24,16 +24,18 @@
 
 #include <algorithm>
 #include <stdint.h>
 
 #define VPX_DONT_DEFINE_STDINT_TYPES
 #include "vpx/vp8dx.h"
 #include "vpx/vpx_decoder.h"
 
+#include <opus/opus.h>
+
 #define WEBM_DEBUG(arg, ...) MOZ_LOG(gWebMDemuxerLog, mozilla::LogLevel::Debug, ("WebMDemuxer(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
 using namespace gfx;
 
 LazyLogModule gWebMDemuxerLog("WebMDemuxer");
 LazyLogModule gNesteggLog("Nestegg");
@@ -568,16 +570,27 @@ WebMDemuxer::GetNextPacket(TrackInfo::Tr
           int nsamples = mVorbisCounter.GetNumSamples(data, length);
           if (nsamples < 0) {
             return false;
           }
           duration =
             FramesToTimeUnit(nsamples, mInfo.mAudio.mRate).ToMicroseconds();
           break;
         }
+        case NESTEGG_CODEC_OPUS:
+        {
+          int nsamples =
+            opus_packet_get_nb_samples(data, length, mInfo.mAudio.mRate);
+          if (nsamples < 0) {
+            return false;
+          }
+          duration =
+            FramesToTimeUnit(nsamples, mInfo.mAudio.mRate).ToMicroseconds();
+          break;
+        }
         default:
           break;
       }
     } else if (aType == TrackInfo::kVideoTrack) {
       vpx_codec_stream_info_t si;
       PodZero(&si);
       si.sz = sizeof(si);
       switch (mVideoCodec) {
@@ -601,17 +614,18 @@ WebMDemuxer::GetNextPacket(TrackInfo::Tr
     sample->mKeyframe = isKeyframe;
     if (discardPadding) {
       uint8_t c[8];
       BigEndian::writeInt64(&c[0], discardPadding);
       sample->mExtraData = new MediaByteBuffer;
       sample->mExtraData->AppendElements(&c[0], 8);
     }
     aSamples->Push(sample);
-    if (mAudioCodec == NESTEGG_CODEC_VORBIS) {
+    if (mAudioCodec == NESTEGG_CODEC_VORBIS ||
+        mAudioCodec == NESTEGG_CODEC_OPUS) {
       tstamp += duration;
     }
   }
   return true;
 }
 
 RefPtr<NesteggPacketHolder>
 WebMDemuxer::NextPacket(TrackInfo::TrackType aType)