OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
11 #include "webrtc/video_frame.h" | |
12 | |
13 #include <math.h> | 11 #include <math.h> |
14 #include <string.h> | 12 #include <string.h> |
15 | 13 |
16 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webrtc/base/bind.h" | 15 #include "webrtc/base/bind.h" |
18 #include "webrtc/base/scoped_ptr.h" | 16 #include "webrtc/base/scoped_ptr.h" |
19 #include "webrtc/test/fake_texture_frame.h" | 17 #include "webrtc/test/fake_texture_frame.h" |
| 18 #include "webrtc/video_frame.h" |
20 | 19 |
21 namespace webrtc { | 20 namespace webrtc { |
22 | 21 |
23 bool EqualPlane(const uint8_t* data1, | 22 bool EqualPlane(const uint8_t* data1, |
24 const uint8_t* data2, | 23 const uint8_t* data2, |
25 int stride, | 24 int stride, |
26 int width, | 25 int width, |
27 int height); | 26 int height); |
28 bool EqualFrames(const VideoFrame& frame1, const VideoFrame& frame2); | 27 bool EqualFrames(const VideoFrame& frame1, const VideoFrame& frame2); |
29 int ExpectedSize(int plane_stride, int image_height, PlaneType type); | 28 int ExpectedSize(int plane_stride, int image_height, PlaneType type); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 frame2.set_rotation(kVideoRotation_90); | 166 frame2.set_rotation(kVideoRotation_90); |
168 | 167 |
169 EXPECT_NE(frame2.timestamp(), frame1.timestamp()); | 168 EXPECT_NE(frame2.timestamp(), frame1.timestamp()); |
170 EXPECT_NE(frame2.ntp_time_ms(), frame1.ntp_time_ms()); | 169 EXPECT_NE(frame2.ntp_time_ms(), frame1.ntp_time_ms()); |
171 EXPECT_NE(frame2.render_time_ms(), frame1.render_time_ms()); | 170 EXPECT_NE(frame2.render_time_ms(), frame1.render_time_ms()); |
172 EXPECT_NE(frame2.rotation(), frame1.rotation()); | 171 EXPECT_NE(frame2.rotation(), frame1.rotation()); |
173 } | 172 } |
174 | 173 |
175 TEST(TestVideoFrame, Reset) { | 174 TEST(TestVideoFrame, Reset) { |
176 VideoFrame frame; | 175 VideoFrame frame; |
177 ASSERT_TRUE(frame.CreateEmptyFrame(5, 5, 5, 5, 5) == 0); | 176 ASSERT_EQ(frame.CreateEmptyFrame(5, 5, 5, 5, 5), 0); |
178 frame.set_ntp_time_ms(1); | 177 frame.set_ntp_time_ms(1); |
179 frame.set_timestamp(2); | 178 frame.set_timestamp(2); |
180 frame.set_render_time_ms(3); | 179 frame.set_render_time_ms(3); |
181 ASSERT_TRUE(frame.video_frame_buffer() != NULL); | 180 ASSERT_TRUE(frame.video_frame_buffer() != NULL); |
182 | 181 |
183 frame.Reset(); | 182 frame.Reset(); |
184 EXPECT_EQ(0u, frame.ntp_time_ms()); | 183 EXPECT_EQ(0u, frame.ntp_time_ms()); |
185 EXPECT_EQ(0u, frame.render_time_ms()); | 184 EXPECT_EQ(0u, frame.render_time_ms()); |
186 EXPECT_EQ(0u, frame.timestamp()); | 185 EXPECT_EQ(0u, frame.timestamp()); |
187 EXPECT_TRUE(frame.video_frame_buffer() == NULL); | 186 EXPECT_TRUE(frame.video_frame_buffer() == NULL); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 int ExpectedSize(int plane_stride, int image_height, PlaneType type) { | 295 int ExpectedSize(int plane_stride, int image_height, PlaneType type) { |
297 if (type == kYPlane) { | 296 if (type == kYPlane) { |
298 return (plane_stride * image_height); | 297 return (plane_stride * image_height); |
299 } else { | 298 } else { |
300 int half_height = (image_height + 1) / 2; | 299 int half_height = (image_height + 1) / 2; |
301 return (plane_stride * half_height); | 300 return (plane_stride * half_height); |
302 } | 301 } |
303 } | 302 } |
304 | 303 |
305 } // namespace webrtc | 304 } // namespace webrtc |
OLD | NEW |