Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2157)

Side by Side Diff: webrtc/tools/frame_analyzer/video_quality_analysis_unittest.cc

Issue 2529923002: Bug in ExtractFrame API (extracts frames incorrectly) (Closed)
Patch Set: Add missing fclose. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/tools/frame_analyzer/video_quality_analysis.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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];
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 delete[] result_frame;
64 delete[] expected_frame;
65 }
66
41 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) { 67 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) {
42 ResultsContainer result; 68 ResultsContainer result;
43 PrintAnalysisResults(logfile_, "Empty", &result); 69 PrintAnalysisResults(logfile_, "Empty", &result);
44 } 70 }
45 71
46 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) { 72 TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) {
47 ResultsContainer result; 73 ResultsContainer result;
48 result.frames.push_back(AnalysisResult(0, 35.0, 0.9)); 74 result.frames.push_back(AnalysisResult(0, 35.0, 0.9));
49 PrintAnalysisResults(logfile_, "OneFrame", &result); 75 PrintAnalysisResults(logfile_, "OneFrame", &result);
50 } 76 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 stats_file << "frame_0003 0101\n"; 108 stats_file << "frame_0003 0101\n";
83 stats_file << "frame_0004 0106\n"; 109 stats_file << "frame_0004 0106\n";
84 stats_file.close(); 110 stats_file.close();
85 111
86 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename); 112 PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename);
87 } 113 }
88 114
89 115
90 } // namespace test 116 } // namespace test
91 } // namespace webrtc 117 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/tools/frame_analyzer/video_quality_analysis.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698