summaryrefslogtreecommitdiff
path: root/modules/video_processing/main
diff options
context:
space:
mode:
authormikhal@webrtc.org <mikhal@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2012-12-13 18:25:36 +0000
committermikhal@webrtc.org <mikhal@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2012-12-13 18:25:36 +0000
commitb8f8c5e113f2a4ac84a2f3b302c76c1e6ace9ff1 (patch)
tree71a9d19c608c60ea13d3a7f4b9844946b10fe512 /modules/video_processing/main
parent4f92005c526c3224903a6a8e6fd3d73215b8f715 (diff)
downloadwebrtc-b8f8c5e113f2a4ac84a2f3b302c76c1e6ace9ff1.tar.gz
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/webrtc@3284 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'modules/video_processing/main')
-rw-r--r--modules/video_processing/main/interface/video_processing.h7
-rw-r--r--modules/video_processing/main/source/frame_preprocessor.cc5
-rw-r--r--modules/video_processing/main/source/spatial_resampler.cc7
-rw-r--r--modules/video_processing/main/test/unit_test/unit_test.cc31
4 files changed, 31 insertions, 19 deletions
diff --git a/modules/video_processing/main/interface/video_processing.h b/modules/video_processing/main/interface/video_processing.h
index fbee00d9..1aaade3c 100644
--- a/modules/video_processing/main/interface/video_processing.h
+++ b/modules/video_processing/main/interface/video_processing.h
@@ -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)
*/
diff --git a/modules/video_processing/main/source/frame_preprocessor.cc b/modules/video_processing/main/source/frame_preprocessor.cc
index 58805416..4b342cef 100644
--- a/modules/video_processing/main/source/frame_preprocessor.cc
+++ b/modules/video_processing/main/source/frame_preprocessor.cc
@@ -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,
diff --git a/modules/video_processing/main/source/spatial_resampler.cc b/modules/video_processing/main/source/spatial_resampler.cc
index 5f1359fa..207260e4 100644
--- a/modules/video_processing/main/source/spatial_resampler.cc
+++ b/modules/video_processing/main/source/spatial_resampler.cc
@@ -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
diff --git a/modules/video_processing/main/test/unit_test/unit_test.cc b/modules/video_processing/main/test/unit_test/unit_test.cc
index c29808a7..e4775fc0 100644
--- a/modules/video_processing/main/test/unit_test/unit_test.cc
+++ b/modules/video_processing/main/test/unit_test/unit_test.cc
@@ -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)