vpm: removing unnecessary memcpy

TEST=trybots

BUG=1128

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3284 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2012-12-13 18:25:36 +00:00
parent 7acb65a870
commit 4493db5a3e
4 changed files with 31 additions and 19 deletions

View File

@ -266,7 +266,8 @@ public:
virtual WebRtc_UWord32 DecimatedHeight() const = 0 ;
/**
Set the spatial resampling settings of the VPM: The resampler may either be disabled or one of the following:
Set the spatial resampling settings of the VPM: The resampler may either be
disabled or one of the following:
scaling to a close to target dimension followed by crop/pad
\param[in] resamplingMode
@ -279,8 +280,8 @@ public:
Get Processed (decimated) frame
\param[in] frame pointer to the video frame.
\param[in] processedFrame pointer (double) to the processed frame
\param[in] processedFrame pointer (double) to the processed frame. If no
processing is required, processedFrame will be NULL.
\return VPM_OK on success, a negative value on error (see error codes)
*/

View File

@ -152,9 +152,8 @@ VPMFramePreprocessor::PreprocessFrame(const I420VideoFrame& frame,
return 1; // drop 1 frame
}
// Resizing incoming frame if needed.
// Note that we must make a copy of it.
// We are not allowed to resample the input frame.
// Resizing incoming frame if needed. Otherwise, remains NULL.
// We are not allowed to resample the input frame (must make a copy of it).
*processedFrame = NULL;
if (_spatialResampler->ApplyResample(frame.width(), frame.height())) {
WebRtc_Word32 ret = _spatialResampler->ResampleFrame(frame,

View File

@ -65,12 +65,13 @@ WebRtc_Word32
VPMSimpleSpatialResampler::ResampleFrame(const I420VideoFrame& inFrame,
I420VideoFrame* outFrame)
{
// Don't copy if frame remains as is.
if (_resamplingMode == kNoRescaling)
return outFrame->CopyFrame(inFrame);
return VPM_OK;
// Check if re-sampling is needed
if ((inFrame.width() == _targetWidth) &&
else if ((inFrame.width() == _targetWidth) &&
(inFrame.height() == _targetHeight)) {
return outFrame->CopyFrame(inFrame);
return VPM_OK;
}
// Setting scaler

View File

@ -213,20 +213,31 @@ TEST_F(VideoProcessingModuleTest, FrameStats)
TEST_F(VideoProcessingModuleTest, PreprocessorLogic)
{
// Disable temporal sampling
// Disable temporal sampling.
int resolution = 100;
_vpm->EnableTemporalDecimation(false);
ASSERT_EQ(VPM_OK, _vpm->SetMaxFrameRate(30));
ASSERT_EQ(VPM_OK, _vpm->SetTargetResolution(100, 100, 15));
EXPECT_EQ(VPM_OK, _vpm->SetMaxFrameRate(30));
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 15));
// Revert
_vpm->EnableTemporalDecimation(true);
ASSERT_EQ(VPM_OK, _vpm->SetTargetResolution(100, 100, 30));
// Disable spatial sampling
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 30));
// Disable spatial sampling.
_vpm->SetInputFrameResampleMode(kNoRescaling);
ASSERT_EQ(VPM_OK, _vpm->SetTargetResolution(100, 100, 30));
I420VideoFrame *outFrame = NULL;
ASSERT_EQ(VPM_OK, _vpm->PreprocessFrame(_videoFrame, &outFrame));
// No rescaling=> output frame = NULL
ASSERT_TRUE(outFrame == NULL);
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 30));
I420VideoFrame* outFrame = NULL;
// Set rescaling => output frame != NULL.
_vpm->SetInputFrameResampleMode(kFastRescaling);
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 30));
EXPECT_EQ(VPM_OK, _vpm->PreprocessFrame(_videoFrame, &outFrame));
EXPECT_FALSE(outFrame == NULL);
if (outFrame) {
EXPECT_EQ(resolution, outFrame->width());
EXPECT_EQ(resolution, outFrame->height());
}
// No rescaling=> output frame = NULL.
_vpm->SetInputFrameResampleMode(kNoRescaling);
EXPECT_EQ(VPM_OK, _vpm->PreprocessFrame(_videoFrame, &outFrame));
EXPECT_TRUE(outFrame == NULL);
}
TEST_F(VideoProcessingModuleTest, Resampler)