cricket::VideoAdapter: Drop frames before spending time converting/scaling, not after.
In VideoCapturer::OnFrameCaptured, we currently convert cricket::CapturedFrame to cricket::VideoFrame and then send that to VideoAdapter::AdaptFrame. AdaptFrame may then decide to drop the frame. It would be faster to drop the frame before converting to cricket::VideoFrame. This CL refactors VideoAdapter with a new function AdaptFrameResolution that takes captured resolution as input and output adapted resolution, or 0x0 if the frame should be dropped. Using that function, frames can be dropped before any conversion takes place. R=fbarchard@google.com, perkj@webrtc.org, tommi@webrtc.org Committed: https://code.google.com/p/webrtc/source/detail?r=7702 Committed: https://code.google.com/p/webrtc/source/detail?r=7707 Review URL: https://webrtc-codereview.appspot.com/29949004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7721 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -292,6 +292,52 @@ TEST_F(VideoAdapterTest, AdaptFramerateOntheFly) {
|
||||
EXPECT_GT(listener_->GetStats().dropped_frames, 0);
|
||||
}
|
||||
|
||||
// Set a very high output pixel resolution. Expect no resolution change.
|
||||
TEST_F(VideoAdapterTest, AdaptFrameResolutionHighLimit) {
|
||||
adapter_->SetOutputNumPixels(INT_MAX);
|
||||
VideoFormat adapted_format = adapter_->AdaptFrameResolution(
|
||||
capture_format_.width, capture_format_.height);
|
||||
EXPECT_EQ(capture_format_.width, adapted_format.width);
|
||||
EXPECT_EQ(capture_format_.height, adapted_format.height);
|
||||
|
||||
adapter_->SetOutputNumPixels(987654321);
|
||||
adapted_format = capture_format_,
|
||||
adapter_->AdaptFrameResolution(capture_format_.width, capture_format_.height);
|
||||
EXPECT_EQ(capture_format_.width, adapted_format.width);
|
||||
EXPECT_EQ(capture_format_.height, adapted_format.height);
|
||||
}
|
||||
|
||||
// Adapt the frame resolution to be the same as capture resolution. Expect no
|
||||
// resolution change.
|
||||
TEST_F(VideoAdapterTest, AdaptFrameResolutionIdentical) {
|
||||
adapter_->SetOutputFormat(capture_format_);
|
||||
const VideoFormat adapted_format = adapter_->AdaptFrameResolution(
|
||||
capture_format_.width, capture_format_.height);
|
||||
EXPECT_EQ(capture_format_.width, adapted_format.width);
|
||||
EXPECT_EQ(capture_format_.height, adapted_format.height);
|
||||
}
|
||||
|
||||
// Adapt the frame resolution to be a quarter of the capture resolution. Expect
|
||||
// resolution change.
|
||||
TEST_F(VideoAdapterTest, AdaptFrameResolutionQuarter) {
|
||||
VideoFormat request_format = capture_format_;
|
||||
request_format.width /= 2;
|
||||
request_format.height /= 2;
|
||||
adapter_->SetOutputFormat(request_format);
|
||||
const VideoFormat adapted_format = adapter_->AdaptFrameResolution(
|
||||
request_format.width, request_format.height);
|
||||
EXPECT_EQ(request_format.width, adapted_format.width);
|
||||
EXPECT_EQ(request_format.height, adapted_format.height);
|
||||
}
|
||||
|
||||
// Adapt the pixel resolution to 0. Expect frame drop.
|
||||
TEST_F(VideoAdapterTest, AdaptFrameResolutionDrop) {
|
||||
adapter_->SetOutputNumPixels(0);
|
||||
EXPECT_TRUE(
|
||||
adapter_->AdaptFrameResolution(capture_format_.width,
|
||||
capture_format_.height).IsSize0x0());
|
||||
}
|
||||
|
||||
// Adapt the frame resolution to be a quarter of the capture resolution at the
|
||||
// beginning. Expect resolution change.
|
||||
TEST_F(VideoAdapterTest, AdaptResolution) {
|
||||
|
||||
Reference in New Issue
Block a user