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
--- 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;