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> | |
14 #include <fstream> | 15 #include <fstream> |
15 #include <string> | 16 #include <string> |
16 | 17 |
17 #include "webrtc/test/gtest.h" | 18 #include "webrtc/test/gtest.h" |
18 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
19 #include "webrtc/tools/frame_analyzer/video_quality_analysis.h" | 20 #include "webrtc/tools/frame_analyzer/video_quality_analysis.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 namespace test { | 23 namespace test { |
23 | 24 |
24 // Setup a log file to write the output to instead of stdout because we don't | 25 // Setup a log file to write the output to instead of stdout because we don't |
25 // want those numbers to be picked up as perf numbers. | 26 // want those numbers to be picked up as perf numbers. |
26 class VideoQualityAnalysisTest : public ::testing::Test { | 27 class VideoQualityAnalysisTest : public ::testing::Test { |
27 protected: | 28 protected: |
28 static void SetUpTestCase() { | 29 static void SetUpTestCase() { |
29 std::string log_filename = webrtc::test::OutputPath() + | 30 std::string log_filename = webrtc::test::OutputPath() + |
30 "VideoQualityAnalysisTest.log"; | 31 "VideoQualityAnalysisTest.log"; |
31 logfile_ = fopen(log_filename.c_str(), "w"); | 32 logfile_ = fopen(log_filename.c_str(), "w"); |
32 ASSERT_TRUE(logfile_ != NULL); | 33 ASSERT_TRUE(logfile_ != NULL); |
33 } | 34 } |
34 static void TearDownTestCase() { | 35 static void TearDownTestCase() { |
35 ASSERT_EQ(0, fclose(logfile_)); | 36 ASSERT_EQ(0, fclose(logfile_)); |
36 } | 37 } |
37 static FILE* logfile_; | 38 static FILE* logfile_; |
38 }; | 39 }; |
39 FILE* VideoQualityAnalysisTest::logfile_ = NULL; | 40 FILE* VideoQualityAnalysisTest::logfile_ = NULL; |
40 | 41 |
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]; | |
phoglund
2016/11/25 14:39:07
These leak. I think you can allocate these guys on
| |
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 } | |
64 | |
41 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) { | 65 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) { |
42 ResultsContainer result; | 66 ResultsContainer result; |
43 PrintAnalysisResults(logfile_, "Empty", &result); | 67 PrintAnalysisResults(logfile_, "Empty", &result); |
44 } | 68 } |
45 | 69 |
46 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) { | 70 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) { |
47 ResultsContainer result; | 71 ResultsContainer result; |
48 result.frames.push_back(AnalysisResult(0, 35.0, 0.9)); | 72 result.frames.push_back(AnalysisResult(0, 35.0, 0.9)); |
49 PrintAnalysisResults(logfile_, "OneFrame", &result); | 73 PrintAnalysisResults(logfile_, "OneFrame", &result); |
50 } | 74 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 stats_file << "frame_0003 0101\n"; | 106 stats_file << "frame_0003 0101\n"; |
83 stats_file << "frame_0004 0106\n"; | 107 stats_file << "frame_0004 0106\n"; |
84 stats_file.close(); | 108 stats_file.close(); |
85 | 109 |
86 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename); | 110 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename); |
87 } | 111 } |
88 | 112 |
89 | 113 |
90 } // namespace test | 114 } // namespace test |
91 } // namespace webrtc | 115 } // namespace webrtc |
OLD | NEW |