Bug 1371290: P1. Use TimeUnit in WMF decoder. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 08 Jun 2017 13:44:46 +0200
changeset 411203 381c3ee3d00e12bec3f9873f17867b0e1c68c914
parent 411202 cc4812a78c235db11fb2de247acec6c6ef1ff09b
child 411204 52586ef104b1740b82d994f4572272ad3ad54d3d
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1371290
milestone55.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 1371290: P1. Use TimeUnit in WMF decoder. r=mattwoodrow Using a float to store the last duration was unwise (as it has only a 24 bits mantissa), luckily it wasn't used except very particular circumstances. MozReview-Commit-ID: BpL8ufQFNeR
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.h
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -673,18 +673,18 @@ WMFVideoMFTManager::Input(MediaRawData* 
 
   RefPtr<IMFSample> inputSample;
   HRESULT hr = mDecoder->CreateInputSample(aSample->Data(),
                                            uint32_t(aSample->Size()),
                                            aSample->mTime.ToMicroseconds(),
                                            &inputSample);
   NS_ENSURE_TRUE(SUCCEEDED(hr) && inputSample != nullptr, hr);
 
-  mLastDuration = aSample->mDuration.ToMicroseconds();
-  mLastTime = aSample->mTime.ToMicroseconds();
+  mLastDuration = aSample->mDuration;
+  mLastTime = aSample->mTime;
   mSamplesCount++;
 
   // Forward sample data to the decoder.
   return mDecoder->Input(inputSample);
 }
 
 class SupportsConfigEvent : public Runnable {
 public:
@@ -731,17 +731,17 @@ WMFVideoMFTManager::CanUseDXVA(IMFMediaT
   MOZ_ASSERT(mDXVA2Manager);
   // SupportsConfig only checks for valid h264 decoders currently.
   if (mStreamType != H264) {
     return true;
   }
 
   // Assume the current samples duration is representative for the
   // entire video.
-  float framerate = 1000000.0 / mLastDuration;
+  float framerate = 1000000.0 / mLastDuration.ToMicroseconds();
 
   // The supports config check must be done on the main thread since we have
   // a crash guard protecting it.
   RefPtr<SupportsConfigEvent> event =
     new SupportsConfigEvent(mDXVA2Manager, aType, framerate);
 
   if (NS_IsMainThread()) {
     event->Run();
@@ -1000,18 +1000,18 @@ WMFVideoMFTManager::Output(int64_t aStre
         return E_FAIL;
       }
       if (wasDraining && sampleCount == 1 && pts == TimeUnit::Zero()) {
         // WMF is unable to calculate a duration if only a single sample
         // was parsed. Additionally, the pts always comes out at 0 under those
         // circumstances.
         // Seeing that we've only fed the decoder a single frame, the pts
         // and duration are known, it's of the last sample.
-        pts = TimeUnit::FromMicroseconds(mLastTime);
-        duration = TimeUnit::FromMicroseconds(mLastDuration);
+        pts = mLastTime;
+        duration = mLastDuration;
       }
       if (mSeekTargetThreshold.isSome()) {
         if ((pts + duration) < mSeekTargetThreshold.ref()) {
           LOG("Dropping video frame which pts is smaller than seek target.");
           // It is necessary to clear the pointer to release the previous output
           // buffer.
           sample = nullptr;
           continue;
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -89,18 +89,18 @@ private:
   const VideoInfo mVideoInfo;
   const nsIntSize mImageSize;
   uint32_t mVideoStride;
 
   RefPtr<layers::ImageContainer> mImageContainer;
   RefPtr<layers::KnowsCompositor> mKnowsCompositor;
   nsAutoPtr<DXVA2Manager> mDXVA2Manager;
 
-  float mLastDuration;
-  int64_t mLastTime = 0;
+  media::TimeUnit mLastDuration;
+  media::TimeUnit mLastTime;
   bool mDraining = false;
   int64_t mSamplesCount = 0;
 
   bool mDXVAEnabled;
   bool mUseHwAccel;
 
   nsCString mDXVAFailureReason;