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

Side by Side Diff: media/filters/h264_parser_unittest.cc

Issue 119153002: Move H264Parser and H264BitReader to media/filters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/h264_parser.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h"
6
7 #include "base/command_line.h" 5 #include "base/command_line.h"
8 #include "base/files/memory_mapped_file.h" 6 #include "base/files/memory_mapped_file.h"
9 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
11 #include "content/common/gpu/media/h264_parser.h" 10 #include "media/base/test_data_util.h"
11 #include "media/filters/h264_parser.h"
12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using content::H264Parser; 14 namespace media {
14 using content::H264NALU;
15
16 const base::FilePath::CharType* test_stream_filename =
17 FILE_PATH_LITERAL("content/common/gpu/testdata/test-25fps.h264");
18 // Number of NALUs in the stream to be parsed.
19 int num_nalus = 759;
20 15
21 TEST(H264ParserTest, StreamFileParsing) { 16 TEST(H264ParserTest, StreamFileParsing) {
22 base::FilePath fp(test_stream_filename); 17 base::FilePath file_path = GetTestDataFilePath("test-25fps.h264");
18 // Number of NALUs in the test stream to be parsed.
19 int num_nalus = 759;
20
23 base::MemoryMappedFile stream; 21 base::MemoryMappedFile stream;
24 CHECK(stream.Initialize(fp)) << "Couldn't open stream file: " 22 ASSERT_TRUE(stream.Initialize(file_path))
25 << test_stream_filename; 23 << "Couldn't open stream file: " << file_path.MaybeAsASCII();
26 DVLOG(1) << "Parsing file: " << test_stream_filename;
27 24
28 H264Parser parser; 25 H264Parser parser;
29 parser.SetStream(stream.data(), stream.length()); 26 parser.SetStream(stream.data(), stream.length());
30 27
31 // Parse until the end of stream/unsupported stream/error in stream is found. 28 // Parse until the end of stream/unsupported stream/error in stream is found.
32 int num_parsed_nalus = 0; 29 int num_parsed_nalus = 0;
33 while (true) { 30 while (true) {
34 content::H264SliceHeader shdr; 31 media::H264SliceHeader shdr;
35 content::H264SEIMessage sei_msg; 32 media::H264SEIMessage sei_msg;
36 H264NALU nalu; 33 H264NALU nalu;
37 H264Parser::Result res = parser.AdvanceToNextNALU(&nalu); 34 H264Parser::Result res = parser.AdvanceToNextNALU(&nalu);
38 if (res == H264Parser::kEOStream) { 35 if (res == H264Parser::kEOStream) {
39 DVLOG(1) << "Number of successfully parsed NALUs before EOS: " 36 DVLOG(1) << "Number of successfully parsed NALUs before EOS: "
40 << num_parsed_nalus; 37 << num_parsed_nalus;
41 ASSERT_EQ(num_nalus, num_parsed_nalus); 38 ASSERT_EQ(num_nalus, num_parsed_nalus);
42 return; 39 return;
43 } 40 }
44 ASSERT_EQ(res, H264Parser::kOk); 41 ASSERT_EQ(res, H264Parser::kOk);
45 42
(...skipping 19 matching lines...) Expand all
65 break; 62 break;
66 63
67 default: 64 default:
68 // Skip unsupported NALU. 65 // Skip unsupported NALU.
69 DVLOG(4) << "Skipping unsupported NALU"; 66 DVLOG(4) << "Skipping unsupported NALU";
70 break; 67 break;
71 } 68 }
72 } 69 }
73 } 70 }
74 71
75 int main(int argc, char **argv) { 72 } // namespace media
76 ::testing::InitGoogleTest(&argc, argv);
77 CommandLine::Init(argc, argv);
78
79 const CommandLine::SwitchMap& switches =
80 CommandLine::ForCurrentProcess()->GetSwitches();
81 for (CommandLine::SwitchMap::const_iterator it = switches.begin();
82 it != switches.end(); ++it) {
83 if (it->first == "test_stream") {
84 test_stream_filename = it->second.c_str();
85 } else if (it->first == "num_nalus") {
86 CHECK(base::StringToInt(it->second, &num_nalus));
87 } else {
88 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second;
89 }
90 }
91
92 return RUN_ALL_TESTS();
93 }
OLDNEW
« no previous file with comments | « media/filters/h264_parser.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698