VPM: Allow for option to compute the content metrics every nth frame.

Review URL: https://webrtc-codereview.appspot.com/492006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2034 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
marpan@webrtc.org
2012-04-16 15:58:14 +00:00
parent 050f212881
commit 3e2e7038e6
2 changed files with 18 additions and 7 deletions

View File

@ -18,7 +18,8 @@ _id(0),
_contentMetrics(NULL),
_maxFrameRate(0),
_resampledFrame(),
_enableCA(false)
_enableCA(false),
_frameCnt(0)
{
_spatialResampler = new VPMSimpleSpatialResampler();
_ca = new VPMContentAnalysis(true);
@ -49,6 +50,7 @@ VPMFramePreprocessor::Reset()
_contentMetrics = NULL;
_spatialResampler->Reset();
_enableCA = false;
_frameCnt = 0;
}
@ -160,14 +162,19 @@ VPMFramePreprocessor::PreprocessFrame(const VideoFrame* frame, VideoFrame** proc
*processedFrame = &_resampledFrame;
}
// Perform content analysis on the frame to be encoded
// Perform content analysis on the frame to be encoded.
if (_enableCA)
{
if (*processedFrame == NULL) {
_contentMetrics = _ca->ComputeContentMetrics(frame);
} else {
_contentMetrics = _ca->ComputeContentMetrics(&_resampledFrame);
// Compute new metrics every |kSkipFramesCA| frames, starting with
// the first frame.
if (_frameCnt % kSkipFrameCA == 0) {
if (*processedFrame == NULL) {
_contentMetrics = _ca->ComputeContentMetrics(frame);
} else {
_contentMetrics = _ca->ComputeContentMetrics(&_resampledFrame);
}
}
++_frameCnt;
}
return VPM_OK;
}

View File

@ -63,15 +63,19 @@ public:
VideoContentMetrics* ContentMetrics() const;
private:
// The content does not change so much every frame, so to reduce complexity
// we can compute new content metrics every |kSkipFrameCA| frames.
enum { kSkipFrameCA = 2 };
WebRtc_Word32 _id;
VideoContentMetrics* _contentMetrics;
WebRtc_UWord32 _maxFrameRate;
VideoFrame _resampledFrame;
VideoFrame _resampledFrame;
VPMSpatialResampler* _spatialResampler;
VPMContentAnalysis* _ca;
VPMVideoDecimator* _vd;
bool _enableCA;
int _frameCnt;
}; // end of VPMFramePreprocessor class definition