OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 // This test doesn't actually verify the output since it's just printed | 11 // This test doesn't actually verify the output since it's just printed |
12 // to stdout by void functions, but it's still useful as it executes the code. | 12 // to stdout by void functions, but it's still useful as it executes the code. |
13 | 13 |
14 #include <stdio.h> | |
15 #include <fstream> | 14 #include <fstream> |
16 #include <string> | 15 #include <string> |
17 | 16 |
18 #include "webrtc/test/gtest.h" | 17 #include "webrtc/test/gtest.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 18 #include "webrtc/test/testsupport/fileutils.h" |
20 #include "webrtc/tools/frame_analyzer/video_quality_analysis.h" | 19 #include "webrtc/tools/frame_analyzer/video_quality_analysis.h" |
21 | 20 |
22 namespace webrtc { | 21 namespace webrtc { |
23 namespace test { | 22 namespace test { |
24 | 23 |
25 // Setup a log file to write the output to instead of stdout because we don't | 24 // Setup a log file to write the output to instead of stdout because we don't |
26 // want those numbers to be picked up as perf numbers. | 25 // want those numbers to be picked up as perf numbers. |
27 class VideoQualityAnalysisTest : public ::testing::Test { | 26 class VideoQualityAnalysisTest : public ::testing::Test { |
28 protected: | 27 protected: |
29 static void SetUpTestCase() { | 28 static void SetUpTestCase() { |
30 std::string log_filename = webrtc::test::OutputPath() + | 29 std::string log_filename = webrtc::test::OutputPath() + |
31 "VideoQualityAnalysisTest.log"; | 30 "VideoQualityAnalysisTest.log"; |
32 logfile_ = fopen(log_filename.c_str(), "w"); | 31 logfile_ = fopen(log_filename.c_str(), "w"); |
33 ASSERT_TRUE(logfile_ != NULL); | 32 ASSERT_TRUE(logfile_ != NULL); |
34 } | 33 } |
35 static void TearDownTestCase() { | 34 static void TearDownTestCase() { |
36 ASSERT_EQ(0, fclose(logfile_)); | 35 ASSERT_EQ(0, fclose(logfile_)); |
37 } | 36 } |
38 static FILE* logfile_; | 37 static FILE* logfile_; |
39 }; | 38 }; |
40 FILE* VideoQualityAnalysisTest::logfile_ = NULL; | 39 FILE* VideoQualityAnalysisTest::logfile_ = NULL; |
41 | 40 |
42 TEST_F(VideoQualityAnalysisTest, MatchExtractedY4mFrame) { | |
43 std::string video_file = | |
44 webrtc::test::ResourcePath("reference_less_video_test_file", "y4m"); | |
45 | |
46 std::string extracted_frame_from_video_file = | |
47 webrtc::test::ResourcePath("video_quality_analysis_frame", "txt"); | |
48 | |
49 int frame_height = 720, frame_width = 1280; | |
50 int frame_number = 2; | |
51 int size = GetI420FrameSize(frame_width, frame_height); | |
52 uint8_t* result_frame = new uint8_t[size]; | |
53 uint8_t* expected_frame = new uint8_t[size]; | |
54 | |
55 FILE* input_file = fopen(extracted_frame_from_video_file.c_str(), "rb"); | |
56 fread(expected_frame, 1, size, input_file); | |
57 | |
58 ExtractFrameFromY4mFile(video_file.c_str(), | |
59 frame_width, frame_height, | |
60 frame_number, result_frame); | |
61 | |
62 EXPECT_EQ(*expected_frame, *result_frame); | |
63 fclose(input_file); | |
64 delete[] result_frame; | |
65 delete[] expected_frame; | |
66 } | |
67 | |
68 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) { | 41 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) { |
69 ResultsContainer result; | 42 ResultsContainer result; |
70 PrintAnalysisResults(logfile_, "Empty", &result); | 43 PrintAnalysisResults(logfile_, "Empty", &result); |
71 } | 44 } |
72 | 45 |
73 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) { | 46 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) { |
74 ResultsContainer result; | 47 ResultsContainer result; |
75 result.frames.push_back(AnalysisResult(0, 35.0, 0.9)); | 48 result.frames.push_back(AnalysisResult(0, 35.0, 0.9)); |
76 PrintAnalysisResults(logfile_, "OneFrame", &result); | 49 PrintAnalysisResults(logfile_, "OneFrame", &result); |
77 } | 50 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 stats_file << "frame_0003 0101\n"; | 82 stats_file << "frame_0003 0101\n"; |
110 stats_file << "frame_0004 0106\n"; | 83 stats_file << "frame_0004 0106\n"; |
111 stats_file.close(); | 84 stats_file.close(); |
112 | 85 |
113 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename); | 86 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename); |
114 } | 87 } |
115 | 88 |
116 | 89 |
117 } // namespace test | 90 } // namespace test |
118 } // namespace webrtc | 91 } // namespace webrtc |
OLD | NEW |