mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1289668 - Refactor FrameStatistics writers to use Data struct - r=kamidphish
Decoders now use FrameStatisticsData to gather data for their frame-related notifications. This will ease introducing new members later on. MozReview-Commit-ID: DWdOSPX3JM --HG-- extra : rebase_source : a3e05f34353a397d1c82b3f4d935c0864f90556e
This commit is contained in:
parent
16ceda9794
commit
7bea2e1262
@ -10,6 +10,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/StateMirroring.h"
|
||||
|
||||
#include "FrameStatistics.h"
|
||||
#include "MediaEventSource.h"
|
||||
#include "MediaInfo.h"
|
||||
#include "nsISupports.h"
|
||||
@ -57,8 +58,7 @@ public:
|
||||
// Increments the parsed, decoded and dropped frame counters by the passed in
|
||||
// counts.
|
||||
// Can be called on any thread.
|
||||
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
|
||||
uint32_t aDropped) = 0;
|
||||
virtual void NotifyDecodedFrames(const FrameStatisticsData& aStats) = 0;
|
||||
|
||||
virtual AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() { return nullptr; };
|
||||
|
||||
@ -99,15 +99,15 @@ public:
|
||||
class AutoNotifyDecoded {
|
||||
public:
|
||||
explicit AutoNotifyDecoded(AbstractMediaDecoder* aDecoder)
|
||||
: mParsed(0), mDecoded(0), mDropped(0), mDecoder(aDecoder) {}
|
||||
: mDecoder(aDecoder)
|
||||
{}
|
||||
~AutoNotifyDecoded() {
|
||||
if (mDecoder) {
|
||||
mDecoder->NotifyDecodedFrames(mParsed, mDecoded, mDropped);
|
||||
mDecoder->NotifyDecodedFrames(mStats);
|
||||
}
|
||||
}
|
||||
uint32_t mParsed;
|
||||
uint32_t mDecoded;
|
||||
uint32_t mDropped;
|
||||
|
||||
FrameStatisticsData mStats;
|
||||
|
||||
private:
|
||||
AbstractMediaDecoder* mDecoder;
|
||||
|
@ -7,6 +7,8 @@
|
||||
#ifndef FrameStatistics_h_
|
||||
#define FrameStatistics_h_
|
||||
|
||||
#include "mozilla/ReentrantMonitor.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct FrameStatisticsData
|
||||
@ -26,6 +28,22 @@ struct FrameStatisticsData
|
||||
// Number of frames that have been skipped because they have missed their
|
||||
// composition deadline.
|
||||
uint64_t mDroppedFrames = 0;
|
||||
|
||||
FrameStatisticsData() = default;
|
||||
FrameStatisticsData(uint64_t aParsed, uint64_t aDecoded, uint64_t aDropped)
|
||||
: mParsedFrames(aParsed)
|
||||
, mDecodedFrames(aDecoded)
|
||||
, mDroppedFrames(aDropped)
|
||||
{}
|
||||
|
||||
void
|
||||
Accumulate(const FrameStatisticsData& aStats)
|
||||
{
|
||||
mParsedFrames += aStats.mParsedFrames;
|
||||
mDecodedFrames += aStats.mDecodedFrames;
|
||||
mPresentedFrames += aStats.mPresentedFrames;
|
||||
mDroppedFrames += aStats.mDroppedFrames;
|
||||
}
|
||||
};
|
||||
|
||||
// Frame decoding/painting related performance counters.
|
||||
@ -82,16 +100,10 @@ public:
|
||||
|
||||
// Increments the parsed and decoded frame counters by the passed in counts.
|
||||
// Can be called on any thread.
|
||||
void NotifyDecodedFrames(uint64_t aParsed, uint64_t aDecoded,
|
||||
uint64_t aDropped)
|
||||
void NotifyDecodedFrames(const FrameStatisticsData& aStats)
|
||||
{
|
||||
if (aParsed == 0 && aDecoded == 0 && aDropped == 0) {
|
||||
return;
|
||||
}
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
mFrameStatisticsData.mParsedFrames += aParsed;
|
||||
mFrameStatisticsData.mDecodedFrames += aDecoded;
|
||||
mFrameStatisticsData.mDroppedFrames += aDropped;
|
||||
mFrameStatisticsData.Accumulate(aStats);
|
||||
}
|
||||
|
||||
// Increments the presented frame counters.
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "AbstractMediaDecoder.h"
|
||||
#include "FrameStatistics.h"
|
||||
#include "MediaDecoderOwner.h"
|
||||
#include "MediaEventSource.h"
|
||||
#include "MediaMetadataManager.h"
|
||||
@ -484,10 +483,9 @@ private:
|
||||
|
||||
// Increments the parsed and decoded frame counters by the passed in counts.
|
||||
// Can be called on any thread.
|
||||
virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
|
||||
uint32_t aDropped) override
|
||||
virtual void NotifyDecodedFrames(const FrameStatisticsData& aStats) override
|
||||
{
|
||||
GetFrameStatistics().NotifyDecodedFrames(aParsed, aDecoded, aDropped);
|
||||
GetFrameStatistics().NotifyDecodedFrames(aStats);
|
||||
}
|
||||
|
||||
void UpdateReadyState()
|
||||
|
@ -1015,7 +1015,7 @@ MediaFormatReader::HandleDemuxedSamples(TrackType aTrack,
|
||||
decoder.mNumSamplesInput++;
|
||||
decoder.mSizeOfQueue++;
|
||||
if (aTrack == TrackInfo::kVideoTrack) {
|
||||
aA.mParsed++;
|
||||
aA.mStats.mParsedFrames++;
|
||||
}
|
||||
|
||||
if (mDemuxOnly) {
|
||||
@ -1192,7 +1192,7 @@ MediaFormatReader::Update(TrackType aTrack)
|
||||
if (aTrack == TrackType::kVideoTrack) {
|
||||
uint64_t delta =
|
||||
decoder.mNumSamplesOutputTotal - mLastReportedNumDecodedFrames;
|
||||
a.mDecoded = static_cast<uint32_t>(delta);
|
||||
a.mStats.mDecodedFrames = static_cast<uint32_t>(delta);
|
||||
mLastReportedNumDecodedFrames = decoder.mNumSamplesOutputTotal;
|
||||
nsCString error;
|
||||
mVideo.mIsHardwareAccelerated =
|
||||
@ -1491,7 +1491,7 @@ MediaFormatReader::DropDecodedSamples(TrackType aTrack)
|
||||
decoder.mOutput.Clear();
|
||||
decoder.mSizeOfQueue -= lengthDecodedQueue;
|
||||
if (aTrack == TrackInfo::kVideoTrack && mDecoder) {
|
||||
mDecoder->NotifyDecodedFrames(0, 0, lengthDecodedQueue);
|
||||
mDecoder->NotifyDecodedFrames({ 0, 0, lengthDecodedQueue });
|
||||
}
|
||||
}
|
||||
|
||||
@ -1527,7 +1527,7 @@ MediaFormatReader::VideoSkipReset(uint32_t aSkipped)
|
||||
DropDecodedSamples(TrackInfo::kVideoTrack);
|
||||
// Report the pending frames as dropped.
|
||||
if (mDecoder) {
|
||||
mDecoder->NotifyDecodedFrames(0, 0, SizeOfVideoQueueInFrames());
|
||||
mDecoder->NotifyDecodedFrames({ 0, 0, SizeOfVideoQueueInFrames() });
|
||||
}
|
||||
|
||||
// Cancel any pending demux request and pending demuxed samples.
|
||||
@ -1535,7 +1535,7 @@ MediaFormatReader::VideoSkipReset(uint32_t aSkipped)
|
||||
Reset(TrackType::kVideoTrack);
|
||||
|
||||
if (mDecoder) {
|
||||
mDecoder->NotifyDecodedFrames(aSkipped, 0, aSkipped);
|
||||
mDecoder->NotifyDecodedFrames({ aSkipped, 0, aSkipped });
|
||||
}
|
||||
|
||||
mVideo.mNumSamplesSkippedTotal += aSkipped;
|
||||
|
@ -155,8 +155,8 @@ bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// when a frame is a keyframe.
|
||||
#if 0
|
||||
if (!frame.mKeyFrame) {
|
||||
++a.mParsed;
|
||||
++a.mDropped;
|
||||
++a.mStats.mParsedFrames;
|
||||
++a.mStats.mDroppedFrames;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
@ -244,9 +244,9 @@ bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
if (!v) {
|
||||
return false;
|
||||
}
|
||||
a.mParsed++;
|
||||
a.mDecoded++;
|
||||
NS_ASSERTION(a.mDecoded <= a.mParsed, "Expect to decode fewer frames than parsed in AndroidMedia...");
|
||||
a.mStats.mParsedFrames++;
|
||||
a.mStats.mDecodedFrames++;
|
||||
NS_ASSERTION(a.mStats.mDecodedFrames <= a.mStats.mParsedFrames, "Expect to decode fewer frames than parsed in AndroidMedia...");
|
||||
|
||||
// Since MPAPI doesn't give us the end time of frames, we keep one frame
|
||||
// buffered in AndroidMediaReader and push it into the queue as soon
|
||||
|
@ -406,7 +406,7 @@ VideoSink::UpdateRenderedVideoFrames()
|
||||
}
|
||||
++framesRemoved;
|
||||
if (!currentFrame->As<VideoData>()->mSentToCompositor) {
|
||||
mFrameStats.NotifyDecodedFrames(0, 0, 1);
|
||||
mFrameStats.NotifyDecodedFrames({ 0, 0, 1 });
|
||||
VSINK_LOG_V("discarding video frame mTime=%lld clock_time=%lld",
|
||||
currentFrame->mTime, clockTime);
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ bool OggReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
}
|
||||
nsAutoRef<ogg_packet> autoRelease(packet);
|
||||
|
||||
a.mParsed++;
|
||||
a.mStats.mParsedFrames++;
|
||||
NS_ASSERTION(packet && packet->granulepos != -1,
|
||||
"Must know first packet's granulepos");
|
||||
bool eos = packet->e_o_s;
|
||||
@ -931,7 +931,7 @@ bool OggReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
{
|
||||
aKeyframeSkip = false;
|
||||
nsresult res = DecodeTheora(packet, aTimeThreshold);
|
||||
a.mDecoded++;
|
||||
a.mStats.mDecodedFrames++;
|
||||
if (NS_FAILED(res)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
continue;
|
||||
}
|
||||
|
||||
a.mParsed++;
|
||||
a.mStats.mParsedFrames++;
|
||||
if (frame.mShouldSkip && mSkipCount < MAX_DROPPED_FRAMES) {
|
||||
mSkipCount++;
|
||||
continue;
|
||||
@ -434,8 +434,8 @@ bool MediaOmxReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
return false;
|
||||
}
|
||||
|
||||
a.mDecoded++;
|
||||
NS_ASSERTION(a.mDecoded <= a.mParsed, "Expect to decode fewer frames than parsed in OMX decoder...");
|
||||
a.mStats.mDecodedFrames++;
|
||||
NS_ASSERTION(a.mStats.mDecodedFrames <= a.mStats.mParsedFrames, "Expect to decode fewer frames than parsed in OMX decoder...");
|
||||
|
||||
mVideoQueue.Push(v);
|
||||
|
||||
|
@ -156,7 +156,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
return false;
|
||||
}
|
||||
|
||||
a.mParsed++;
|
||||
a.mStats.mParsedFrames++;
|
||||
|
||||
if (currentFrameTime >= aTimeThreshold)
|
||||
break;
|
||||
@ -200,7 +200,7 @@ bool RawReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
|
||||
mVideoQueue.Push(v);
|
||||
mCurrentFrame++;
|
||||
a.mDecoded++;
|
||||
a.mStats.mDecodedFrames++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ BufferDecoder::GetResource() const
|
||||
}
|
||||
|
||||
void
|
||||
BufferDecoder::NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
|
||||
uint32_t aDropped)
|
||||
BufferDecoder::NotifyDecodedFrames(const FrameStatisticsData& aStats)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
@ -33,8 +33,7 @@ public:
|
||||
|
||||
MediaResource* GetResource() const final override;
|
||||
|
||||
void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
|
||||
uint32_t aDropped) final override;
|
||||
void NotifyDecodedFrames(const FrameStatisticsData& aStats) final override;
|
||||
|
||||
VideoFrameContainer* GetVideoFrameContainer() final override;
|
||||
layers::ImageContainer* GetImageContainer() final override;
|
||||
|
Loading…
Reference in New Issue
Block a user