WebRtcVideoFrame: Support odd resolutions
We currently truncate the resolution of frames to a multiple of 4. This is unnecessary as everything supports odd resolutions now. R=fbarchard@google.com, pbos@webrtc.org, perkj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/43819004 Cr-Commit-Position: refs/heads/master@{#8774} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8774 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -47,12 +47,6 @@ const int kMsCallbackWait = 500;
|
||||
const int kMinHdHeight = 720;
|
||||
const uint32 kTimeout = 5000U;
|
||||
|
||||
void NormalizeVideoSize(int* expected_width, int* expected_height) {
|
||||
// WebRtcVideoFrame truncates the frame size to a multiple of 4.
|
||||
*expected_width = *expected_width & ~3;
|
||||
*expected_height = *expected_height & ~3;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Sets the elapsed time in the video frame to 0.
|
||||
@@ -279,10 +273,7 @@ TEST_F(VideoCapturerTest, ScreencastScaledOddWidth) {
|
||||
cricket::FOURCC_ARGB)));
|
||||
EXPECT_TRUE(capturer_.IsRunning());
|
||||
EXPECT_EQ(0, renderer_.num_rendered_frames());
|
||||
int expected_width = kWidth;
|
||||
int expected_height = kHeight;
|
||||
NormalizeVideoSize(&expected_width, &expected_height);
|
||||
renderer_.SetSize(expected_width, expected_height, 0);
|
||||
renderer_.SetSize(kWidth, kHeight, 0);
|
||||
EXPECT_TRUE(capturer_.CaptureFrame());
|
||||
EXPECT_EQ(1, renderer_.num_rendered_frames());
|
||||
}
|
||||
@@ -314,10 +305,7 @@ TEST_F(VideoCapturerTest, TestRotationPending) {
|
||||
|
||||
// Swap the dimension for the next 2 frames which are rotated by 90 and 270
|
||||
// degree.
|
||||
int expected_width = kHeight;
|
||||
int expected_height = kWidth;
|
||||
NormalizeVideoSize(&expected_width, &expected_height);
|
||||
renderer_.SetSize(expected_width, expected_height, 0);
|
||||
renderer_.SetSize(kHeight, kWidth, 0);
|
||||
|
||||
capturer_.SetRotation(webrtc::kVideoRotation_90);
|
||||
EXPECT_TRUE(capturer_.CaptureFrame());
|
||||
@@ -328,10 +316,7 @@ TEST_F(VideoCapturerTest, TestRotationPending) {
|
||||
EXPECT_EQ(++frame_count, renderer_.num_rendered_frames());
|
||||
|
||||
// Reset the renderer to have corresponding width and height.
|
||||
expected_width = kWidth;
|
||||
expected_height = kHeight;
|
||||
NormalizeVideoSize(&expected_width, &expected_height);
|
||||
renderer_.SetSize(expected_width, expected_height, 0);
|
||||
renderer_.SetSize(kWidth, kHeight, 0);
|
||||
|
||||
capturer_.SetRotation(webrtc::kVideoRotation_180);
|
||||
EXPECT_TRUE(capturer_.CaptureFrame());
|
||||
@@ -360,10 +345,7 @@ TEST_F(VideoCapturerTest, TestRotationApplied) {
|
||||
EXPECT_TRUE(capturer_.IsRunning());
|
||||
EXPECT_EQ(0, renderer_.num_rendered_frames());
|
||||
|
||||
int expected_width = kWidth;
|
||||
int expected_height = kHeight;
|
||||
NormalizeVideoSize(&expected_width, &expected_height);
|
||||
renderer_.SetSize(expected_width, expected_height, 0);
|
||||
renderer_.SetSize(kWidth, kHeight, 0);
|
||||
|
||||
// If the frame's rotation is compensated anywhere in the pipeline, the frame
|
||||
// won't have its original dimension out from capturer. Since the renderer
|
||||
@@ -408,10 +390,7 @@ TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) {
|
||||
cricket::FOURCC_ARGB)));
|
||||
EXPECT_TRUE(capturer_.IsRunning());
|
||||
EXPECT_EQ(0, renderer_.num_rendered_frames());
|
||||
int expected_width = 2050;
|
||||
int expected_height = 1538;
|
||||
NormalizeVideoSize(&expected_width, &expected_height);
|
||||
renderer_.SetSize(expected_width, expected_height, 0);
|
||||
renderer_.SetSize(2050, 1538, 0);
|
||||
EXPECT_TRUE(capturer_.CaptureFrame());
|
||||
EXPECT_EQ(1, renderer_.num_rendered_frames());
|
||||
}
|
||||
|
||||
@@ -987,7 +987,7 @@ class VideoFrameTest : public testing::Test {
|
||||
y, 1, u, 1, v, 1, 0));
|
||||
}
|
||||
|
||||
// Test 5 pixel edge case image I420 buffer rounds down to 4.
|
||||
// Test 5 pixel edge case image.
|
||||
void ConstructI4205Pixel() {
|
||||
T frame;
|
||||
uint8 pixels5x5[5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2];
|
||||
@@ -997,11 +997,11 @@ class VideoFrameTest : public testing::Test {
|
||||
sizeof(pixels5x5), 1, 1, 0, 0,
|
||||
webrtc::kVideoRotation_0));
|
||||
}
|
||||
EXPECT_EQ(4u, frame.GetWidth());
|
||||
EXPECT_EQ(4u, frame.GetHeight());
|
||||
EXPECT_EQ(4, frame.GetYPitch());
|
||||
EXPECT_EQ(2, frame.GetUPitch());
|
||||
EXPECT_EQ(2, frame.GetVPitch());
|
||||
EXPECT_EQ(5u, frame.GetWidth());
|
||||
EXPECT_EQ(5u, frame.GetHeight());
|
||||
EXPECT_EQ(5, frame.GetYPitch());
|
||||
EXPECT_EQ(3, frame.GetUPitch());
|
||||
EXPECT_EQ(3, frame.GetVPitch());
|
||||
}
|
||||
|
||||
// Test 1 pixel edge case image ARGB buffer.
|
||||
|
||||
@@ -232,12 +232,6 @@ bool WebRtcVideoFrame::Reset(uint32 format,
|
||||
// Translate aliases to standard enums (e.g., IYUV -> I420).
|
||||
format = CanonicalFourCC(format);
|
||||
|
||||
// Round display width and height down to multiple of 4, to avoid webrtc
|
||||
// size calculation error on odd sizes.
|
||||
// TODO(Ronghua): Remove this once the webrtc allocator is fixed.
|
||||
dw = (dw > 4) ? (dw & ~3) : dw;
|
||||
dh = (dh > 4) ? (dh & ~3) : dh;
|
||||
|
||||
// Set up a new buffer.
|
||||
// TODO(fbarchard): Support lazy allocation.
|
||||
int new_width = dw;
|
||||
|
||||
@@ -108,16 +108,15 @@ class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
|
||||
EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation());
|
||||
else
|
||||
EXPECT_EQ(frame_rotation, frame.GetRotation());
|
||||
// The size of the new frame should have been cropped to multiple of 4.
|
||||
// If |apply_rotation| and the frame rotation is 90 or 270, width and
|
||||
// height are flipped.
|
||||
if (apply_rotation && (frame_rotation == webrtc::kVideoRotation_90
|
||||
|| frame_rotation == webrtc::kVideoRotation_270)) {
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_width & ~3), frame.GetHeight());
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_height & ~3), frame.GetWidth() );
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_width), frame.GetHeight());
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_height), frame.GetWidth());
|
||||
} else {
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_width & ~3), frame.GetWidth());
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_height & ~3), frame.GetHeight());
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_width), frame.GetWidth());
|
||||
EXPECT_EQ(static_cast<size_t>(cropped_height), frame.GetHeight());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user