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 <math.h> | 11 #include <math.h> |
12 #include <string.h> | 12 #include <string.h> |
13 | 13 |
| 14 #include <memory> |
| 15 |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/common_video/libyuv/include/scaler.h" | 17 #include "webrtc/common_video/libyuv/include/scaler.h" |
16 #include "webrtc/system_wrappers/include/tick_util.h" | 18 #include "webrtc/system_wrappers/include/tick_util.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
18 | 20 |
19 namespace webrtc { | 21 namespace webrtc { |
20 | 22 |
21 class TestScaler : public ::testing::Test { | 23 class TestScaler : public ::testing::Test { |
22 protected: | 24 protected: |
23 TestScaler(); | 25 TestScaler(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 EXPECT_EQ(-1, test_scaler_.Scale(null_src_frame, &test_frame_)); | 93 EXPECT_EQ(-1, test_scaler_.Scale(null_src_frame, &test_frame_)); |
92 } | 94 } |
93 | 95 |
94 TEST_F(TestScaler, ScaleSendingBufferTooSmall) { | 96 TEST_F(TestScaler, ScaleSendingBufferTooSmall) { |
95 // Sending a buffer which is too small (should reallocate and update size) | 97 // Sending a buffer which is too small (should reallocate and update size) |
96 EXPECT_EQ(0, test_scaler_.Set(width_, height_, | 98 EXPECT_EQ(0, test_scaler_.Set(width_, height_, |
97 half_width_, half_height_, | 99 half_width_, half_height_, |
98 kI420, kI420, | 100 kI420, kI420, |
99 kScalePoint)); | 101 kScalePoint)); |
100 VideoFrame test_frame2; | 102 VideoFrame test_frame2; |
101 rtc::scoped_ptr<uint8_t[]> orig_buffer(new uint8_t[frame_length_]); | 103 std::unique_ptr<uint8_t[]> orig_buffer(new uint8_t[frame_length_]); |
102 EXPECT_GT(fread(orig_buffer.get(), 1, frame_length_, source_file_), 0U); | 104 EXPECT_GT(fread(orig_buffer.get(), 1, frame_length_, source_file_), 0U); |
103 test_frame_.CreateFrame(orig_buffer.get(), | 105 test_frame_.CreateFrame(orig_buffer.get(), |
104 orig_buffer.get() + size_y_, | 106 orig_buffer.get() + size_y_, |
105 orig_buffer.get() + size_y_ + size_uv_, | 107 orig_buffer.get() + size_y_ + size_uv_, |
106 width_, height_, | 108 width_, height_, |
107 width_, half_width_, half_width_, | 109 width_, half_width_, half_width_, |
108 kVideoRotation_0); | 110 kVideoRotation_0); |
109 EXPECT_EQ(0, test_scaler_.Scale(test_frame_, &test_frame2)); | 111 EXPECT_EQ(0, test_scaler_.Scale(test_frame_, &test_frame2)); |
110 EXPECT_GT(width_ * height_, test_frame2.allocated_size(kYPlane)); | 112 EXPECT_GT(width_ * height_, test_frame2.allocated_size(kYPlane)); |
111 EXPECT_GT(size_uv_, test_frame2.allocated_size(kUPlane)); | 113 EXPECT_GT(size_uv_, test_frame2.allocated_size(kUPlane)); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 ASSERT_TRUE(output_file != NULL); | 353 ASSERT_TRUE(output_file != NULL); |
352 | 354 |
353 rewind(source_file); | 355 rewind(source_file); |
354 | 356 |
355 VideoFrame input_frame; | 357 VideoFrame input_frame; |
356 VideoFrame output_frame; | 358 VideoFrame output_frame; |
357 int64_t start_clock, total_clock; | 359 int64_t start_clock, total_clock; |
358 total_clock = 0; | 360 total_clock = 0; |
359 int frame_count = 0; | 361 int frame_count = 0; |
360 size_t src_required_size = CalcBufferSize(kI420, src_width, src_height); | 362 size_t src_required_size = CalcBufferSize(kI420, src_width, src_height); |
361 rtc::scoped_ptr<uint8_t[]> frame_buffer(new uint8_t[src_required_size]); | 363 std::unique_ptr<uint8_t[]> frame_buffer(new uint8_t[src_required_size]); |
362 int size_y = src_width * src_height; | 364 int size_y = src_width * src_height; |
363 int size_uv = ((src_width + 1) / 2) * ((src_height + 1) / 2); | 365 int size_uv = ((src_width + 1) / 2) * ((src_height + 1) / 2); |
364 | 366 |
365 // Running through entire sequence. | 367 // Running through entire sequence. |
366 while (feof(source_file) == 0) { | 368 while (feof(source_file) == 0) { |
367 if (fread(frame_buffer.get(), 1, src_required_size, source_file) != | 369 if (fread(frame_buffer.get(), 1, src_required_size, source_file) != |
368 src_required_size) | 370 src_required_size) |
369 break; | 371 break; |
370 | 372 |
371 input_frame.CreateFrame(frame_buffer.get(), | 373 input_frame.CreateFrame(frame_buffer.get(), |
(...skipping 16 matching lines...) Expand all Loading... |
388 if (frame_count) { | 390 if (frame_count) { |
389 printf("Scaling[%d %d] => [%d %d]: ", | 391 printf("Scaling[%d %d] => [%d %d]: ", |
390 src_width, src_height, dst_width, dst_height); | 392 src_width, src_height, dst_width, dst_height); |
391 printf("Average time per frame[ms]: %.2lf\n", | 393 printf("Average time per frame[ms]: %.2lf\n", |
392 (static_cast<double>(total_clock) / frame_count)); | 394 (static_cast<double>(total_clock) / frame_count)); |
393 } | 395 } |
394 ASSERT_EQ(0, fclose(output_file)); | 396 ASSERT_EQ(0, fclose(output_file)); |
395 } | 397 } |
396 | 398 |
397 } // namespace webrtc | 399 } // namespace webrtc |
OLD | NEW |