Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: webrtc/media/engine/webrtcvideoframefactory_unittest.cc

Issue 1960073002: New method CreateScaledFrame in the VideoFrameFactory interface. Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 // Reset the frame first so it's exclusive hence we could go through the 86 // Reset the frame first so it's exclusive hence we could go through the
87 // StretchToFrame code path in CreateAliasedFrame. 87 // StretchToFrame code path in CreateAliasedFrame.
88 frame.reset(); 88 frame.reset();
89 frame.reset(factory.CreateAliasedFrame( 89 frame.reset(factory.CreateAliasedFrame(
90 &captured_frame, new_width, new_height, new_width / 2, new_height / 2)); 90 &captured_frame, new_width, new_height, new_width / 2, new_height / 2));
91 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2, 91 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2,
92 new_height / 2, apply_rotation); 92 new_height / 2, apply_rotation);
93 } 93 }
94 94
95 void TestCreateScaledFrame(bool apply_rotation) {
96 cricket::VideoFrameFactory& factory = factory_;
97 factory.SetApplyRotation(apply_rotation);
98 InitFrame(webrtc::kVideoRotation_270);
99 const cricket::CapturedFrame& captured_frame = get_captured_frame();
100 // Create the new frame from the CapturedFrame.
101 std::unique_ptr<cricket::VideoFrame> frame;
102 int new_width = captured_frame.width / 2;
103 int new_height = captured_frame.height / 2;
104 frame = factory.CreateScaledFrame(&captured_frame, new_width, new_height);
105 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width, new_height,
106 apply_rotation);
107
108 frame = factory.CreateScaledFrame(&captured_frame,
109 new_width / 2, new_height / 2);
110 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2,
111 new_height / 2, apply_rotation);
112 }
95 const cricket::CapturedFrame& get_captured_frame() { return captured_frame_; } 113 const cricket::CapturedFrame& get_captured_frame() { return captured_frame_; }
96 114
97 private: 115 private:
98 cricket::CapturedFrame captured_frame_; 116 cricket::CapturedFrame captured_frame_;
99 std::unique_ptr<uint8_t[]> captured_frame_buffer_; 117 std::unique_ptr<uint8_t[]> captured_frame_buffer_;
100 cricket::WebRtcVideoFrameFactory factory_; 118 cricket::WebRtcVideoFrameFactory factory_;
101 }; 119 };
102 120
103 TEST_F(WebRtcVideoFrameFactoryTest, NoApplyRotation) { 121 TEST_F(WebRtcVideoFrameFactoryTest, CreateAliasedFrameNoApplyRotation) {
104 TestCreateAliasedFrame(false); 122 TestCreateAliasedFrame(false);
105 } 123 }
106 124
107 TEST_F(WebRtcVideoFrameFactoryTest, ApplyRotation) { 125 TEST_F(WebRtcVideoFrameFactoryTest, CreateAliasedFrameApplyRotation) {
108 TestCreateAliasedFrame(true); 126 TestCreateAliasedFrame(true);
109 } 127 }
128
129 TEST_F(WebRtcVideoFrameFactoryTest, CreateScaledFrameNoApplyRotation) {
130 TestCreateScaledFrame(false);
131 }
132
133 TEST_F(WebRtcVideoFrameFactoryTest, CreateScaledFrameApplyRotation) {
134 TestCreateScaledFrame(true);
135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698