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:
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user