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:
parent
7acb65a870
commit
4493db5a3e
@ -266,7 +266,8 @@ public:
|
|||||||
virtual WebRtc_UWord32 DecimatedHeight() const = 0 ;
|
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
|
scaling to a close to target dimension followed by crop/pad
|
||||||
|
|
||||||
\param[in] resamplingMode
|
\param[in] resamplingMode
|
||||||
@ -279,8 +280,8 @@ public:
|
|||||||
Get Processed (decimated) frame
|
Get Processed (decimated) frame
|
||||||
|
|
||||||
\param[in] frame pointer to the video frame.
|
\param[in] frame pointer to the video frame.
|
||||||
|
\param[in] processedFrame pointer (double) to the processed frame. If no
|
||||||
\param[in] processedFrame pointer (double) to the processed frame
|
processing is required, processedFrame will be NULL.
|
||||||
|
|
||||||
\return VPM_OK on success, a negative value on error (see error codes)
|
\return VPM_OK on success, a negative value on error (see error codes)
|
||||||
*/
|
*/
|
||||||
|
@ -152,9 +152,8 @@ VPMFramePreprocessor::PreprocessFrame(const I420VideoFrame& frame,
|
|||||||
return 1; // drop 1 frame
|
return 1; // drop 1 frame
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resizing incoming frame if needed.
|
// Resizing incoming frame if needed. Otherwise, remains NULL.
|
||||||
// Note that we must make a copy of it.
|
// We are not allowed to resample the input frame (must make a copy of it).
|
||||||
// We are not allowed to resample the input frame.
|
|
||||||
*processedFrame = NULL;
|
*processedFrame = NULL;
|
||||||
if (_spatialResampler->ApplyResample(frame.width(), frame.height())) {
|
if (_spatialResampler->ApplyResample(frame.width(), frame.height())) {
|
||||||
WebRtc_Word32 ret = _spatialResampler->ResampleFrame(frame,
|
WebRtc_Word32 ret = _spatialResampler->ResampleFrame(frame,
|
||||||
|
@ -65,12 +65,13 @@ WebRtc_Word32
|
|||||||
VPMSimpleSpatialResampler::ResampleFrame(const I420VideoFrame& inFrame,
|
VPMSimpleSpatialResampler::ResampleFrame(const I420VideoFrame& inFrame,
|
||||||
I420VideoFrame* outFrame)
|
I420VideoFrame* outFrame)
|
||||||
{
|
{
|
||||||
|
// Don't copy if frame remains as is.
|
||||||
if (_resamplingMode == kNoRescaling)
|
if (_resamplingMode == kNoRescaling)
|
||||||
return outFrame->CopyFrame(inFrame);
|
return VPM_OK;
|
||||||
// Check if re-sampling is needed
|
// Check if re-sampling is needed
|
||||||
if ((inFrame.width() == _targetWidth) &&
|
else if ((inFrame.width() == _targetWidth) &&
|
||||||
(inFrame.height() == _targetHeight)) {
|
(inFrame.height() == _targetHeight)) {
|
||||||
return outFrame->CopyFrame(inFrame);
|
return VPM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting scaler
|
// Setting scaler
|
||||||
|
@ -213,20 +213,31 @@ TEST_F(VideoProcessingModuleTest, FrameStats)
|
|||||||
|
|
||||||
TEST_F(VideoProcessingModuleTest, PreprocessorLogic)
|
TEST_F(VideoProcessingModuleTest, PreprocessorLogic)
|
||||||
{
|
{
|
||||||
// Disable temporal sampling
|
// Disable temporal sampling.
|
||||||
|
int resolution = 100;
|
||||||
_vpm->EnableTemporalDecimation(false);
|
_vpm->EnableTemporalDecimation(false);
|
||||||
ASSERT_EQ(VPM_OK, _vpm->SetMaxFrameRate(30));
|
EXPECT_EQ(VPM_OK, _vpm->SetMaxFrameRate(30));
|
||||||
ASSERT_EQ(VPM_OK, _vpm->SetTargetResolution(100, 100, 15));
|
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 15));
|
||||||
// Revert
|
// Revert
|
||||||
_vpm->EnableTemporalDecimation(true);
|
_vpm->EnableTemporalDecimation(true);
|
||||||
ASSERT_EQ(VPM_OK, _vpm->SetTargetResolution(100, 100, 30));
|
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 30));
|
||||||
// Disable spatial sampling
|
// Disable spatial sampling.
|
||||||
_vpm->SetInputFrameResampleMode(kNoRescaling);
|
_vpm->SetInputFrameResampleMode(kNoRescaling);
|
||||||
ASSERT_EQ(VPM_OK, _vpm->SetTargetResolution(100, 100, 30));
|
EXPECT_EQ(VPM_OK, _vpm->SetTargetResolution(resolution, resolution, 30));
|
||||||
I420VideoFrame* outFrame = NULL;
|
I420VideoFrame* outFrame = NULL;
|
||||||
ASSERT_EQ(VPM_OK, _vpm->PreprocessFrame(_videoFrame, &outFrame));
|
// Set rescaling => output frame != NULL.
|
||||||
// No rescaling=> output frame = NULL
|
_vpm->SetInputFrameResampleMode(kFastRescaling);
|
||||||
ASSERT_TRUE(outFrame == NULL);
|
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)
|
TEST_F(VideoProcessingModuleTest, Resampler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user