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 "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/common_video/libyuv/include/scaler.h" | 15 #include "webrtc/common_video/libyuv/include/scaler.h" |
16 #include "webrtc/system_wrappers/include/tick_util.h" | 16 #include "webrtc/system_wrappers/include/tick_util.h" |
17 #include "webrtc/test/testsupport/fileutils.h" | 17 #include "webrtc/test/testsupport/fileutils.h" |
18 #include "webrtc/test/testsupport/gtest_disable.h" | |
19 | 18 |
20 namespace webrtc { | 19 namespace webrtc { |
21 | 20 |
22 class TestScaler : public ::testing::Test { | 21 class TestScaler : public ::testing::Test { |
23 protected: | 22 protected: |
24 TestScaler(); | 23 TestScaler(); |
25 virtual void SetUp(); | 24 virtual void SetUp(); |
26 virtual void TearDown(); | 25 virtual void TearDown(); |
27 | 26 |
28 void ScaleSequence(ScaleMethod method, | 27 void ScaleSequence(ScaleMethod method, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 width_, half_width_, half_width_); | 107 width_, half_width_, half_width_); |
109 EXPECT_EQ(0, test_scaler_.Scale(test_frame_, &test_frame2)); | 108 EXPECT_EQ(0, test_scaler_.Scale(test_frame_, &test_frame2)); |
110 EXPECT_GT(width_ * height_, test_frame2.allocated_size(kYPlane)); | 109 EXPECT_GT(width_ * height_, test_frame2.allocated_size(kYPlane)); |
111 EXPECT_GT(size_uv_, test_frame2.allocated_size(kUPlane)); | 110 EXPECT_GT(size_uv_, test_frame2.allocated_size(kUPlane)); |
112 EXPECT_GT(size_uv_, test_frame2.allocated_size(kVPlane)); | 111 EXPECT_GT(size_uv_, test_frame2.allocated_size(kVPlane)); |
113 EXPECT_EQ(half_width_, test_frame2.width()); | 112 EXPECT_EQ(half_width_, test_frame2.width()); |
114 EXPECT_EQ(half_height_, test_frame2.height()); | 113 EXPECT_EQ(half_height_, test_frame2.height()); |
115 } | 114 } |
116 | 115 |
117 // TODO(mikhal): Converge the test into one function that accepts the method. | 116 // TODO(mikhal): Converge the test into one function that accepts the method. |
118 TEST_F(TestScaler, DISABLED_ON_ANDROID(PointScaleTest)) { | 117 #if defined(WEBRTC_ANDROID) |
| 118 TEST_F(TestScaler, DISABLED_PointScaleTest) { |
| 119 #else |
| 120 TEST_F(TestScaler, PointScaleTest) { |
| 121 #endif |
119 double avg_psnr; | 122 double avg_psnr; |
120 FILE* source_file2; | 123 FILE* source_file2; |
121 ScaleMethod method = kScalePoint; | 124 ScaleMethod method = kScalePoint; |
122 std::string out_name = webrtc::test::OutputPath() + | 125 std::string out_name = webrtc::test::OutputPath() + |
123 "LibYuvTest_PointScale_176_144.yuv"; | 126 "LibYuvTest_PointScale_176_144.yuv"; |
124 ScaleSequence(method, | 127 ScaleSequence(method, |
125 source_file_, out_name, | 128 source_file_, out_name, |
126 width_, height_, | 129 width_, height_, |
127 half_width_, half_height_); | 130 half_width_, half_height_); |
128 // Upsample back up and check PSNR. | 131 // Upsample back up and check PSNR. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 352, 288); | 178 352, 288); |
176 avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); | 179 avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); |
177 printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " | 180 printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " |
178 "original size: %f \n", width_, height_, 282, 231, avg_psnr); | 181 "original size: %f \n", width_, height_, 282, 231, avg_psnr); |
179 // Average PSNR for lower bound in assert is ~0.1dB lower than the actual | 182 // Average PSNR for lower bound in assert is ~0.1dB lower than the actual |
180 // average PSNR under same conditions. | 183 // average PSNR under same conditions. |
181 ASSERT_GT(avg_psnr, 25.8); | 184 ASSERT_GT(avg_psnr, 25.8); |
182 ASSERT_EQ(0, fclose(source_file2)); | 185 ASSERT_EQ(0, fclose(source_file2)); |
183 } | 186 } |
184 | 187 |
185 TEST_F(TestScaler, DISABLED_ON_ANDROID(BiLinearScaleTest)) { | 188 #if defined(WEBRTC_ANDROID) |
| 189 TEST_F(TestScaler, DISABLED_BiLinearScaleTest) { |
| 190 #else |
| 191 TEST_F(TestScaler, BiLinearScaleTest) { |
| 192 #endif |
186 double avg_psnr; | 193 double avg_psnr; |
187 FILE* source_file2; | 194 FILE* source_file2; |
188 ScaleMethod method = kScaleBilinear; | 195 ScaleMethod method = kScaleBilinear; |
189 std::string out_name = webrtc::test::OutputPath() + | 196 std::string out_name = webrtc::test::OutputPath() + |
190 "LibYuvTest_BilinearScale_176_144.yuv"; | 197 "LibYuvTest_BilinearScale_176_144.yuv"; |
191 ScaleSequence(method, | 198 ScaleSequence(method, |
192 source_file_, out_name, | 199 source_file_, out_name, |
193 width_, height_, | 200 width_, height_, |
194 width_ / 2, height_ / 2); | 201 width_ / 2, height_ / 2); |
195 // Up-sample back up and check PSNR. | 202 // Up-sample back up and check PSNR. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 width_, height_, | 234 width_, height_, |
228 300, 200); | 235 300, 200); |
229 out_name = webrtc::test::OutputPath() + | 236 out_name = webrtc::test::OutputPath() + |
230 "LibYuvTest_BilinearScale_400_300.yuv"; | 237 "LibYuvTest_BilinearScale_400_300.yuv"; |
231 ScaleSequence(method, | 238 ScaleSequence(method, |
232 source_file_, out_name, | 239 source_file_, out_name, |
233 width_, height_, | 240 width_, height_, |
234 400, 300); | 241 400, 300); |
235 } | 242 } |
236 | 243 |
237 TEST_F(TestScaler, DISABLED_ON_ANDROID(BoxScaleTest)) { | 244 #if defined(WEBRTC_ANDROID) |
| 245 TEST_F(TestScaler, DISABLED_BoxScaleTest) { |
| 246 #else |
| 247 TEST_F(TestScaler, BoxScaleTest) { |
| 248 #endif |
238 double avg_psnr; | 249 double avg_psnr; |
239 FILE* source_file2; | 250 FILE* source_file2; |
240 ScaleMethod method = kScaleBox; | 251 ScaleMethod method = kScaleBox; |
241 std::string out_name = webrtc::test::OutputPath() + | 252 std::string out_name = webrtc::test::OutputPath() + |
242 "LibYuvTest_BoxScale_176_144.yuv"; | 253 "LibYuvTest_BoxScale_176_144.yuv"; |
243 ScaleSequence(method, | 254 ScaleSequence(method, |
244 source_file_, out_name, | 255 source_file_, out_name, |
245 width_, height_, | 256 width_, height_, |
246 width_ / 2, height_ / 2); | 257 width_ / 2, height_ / 2); |
247 // Up-sample back up and check PSNR. | 258 // Up-sample back up and check PSNR. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 if (frame_count) { | 383 if (frame_count) { |
373 printf("Scaling[%d %d] => [%d %d]: ", | 384 printf("Scaling[%d %d] => [%d %d]: ", |
374 src_width, src_height, dst_width, dst_height); | 385 src_width, src_height, dst_width, dst_height); |
375 printf("Average time per frame[ms]: %.2lf\n", | 386 printf("Average time per frame[ms]: %.2lf\n", |
376 (static_cast<double>(total_clock) / frame_count)); | 387 (static_cast<double>(total_clock) / frame_count)); |
377 } | 388 } |
378 ASSERT_EQ(0, fclose(output_file)); | 389 ASSERT_EQ(0, fclose(output_file)); |
379 } | 390 } |
380 | 391 |
381 } // namespace webrtc | 392 } // namespace webrtc |
OLD | NEW |