| OLD | NEW |
| 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" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/files/memory_mapped_file.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "content/common/gpu/media/h264_parser.h" | 11 #include "content/common/gpu/media/h264_parser.h" |
| 12 | 12 |
| 13 using content::H264Parser; | 13 using content::H264Parser; |
| 14 using content::H264NALU; | 14 using content::H264NALU; |
| 15 | 15 |
| 16 const base::FilePath::CharType* test_stream_filename = | 16 const base::FilePath::CharType* test_stream_filename = |
| 17 FILE_PATH_LITERAL("content/common/gpu/testdata/test-25fps.h264"); | 17 FILE_PATH_LITERAL("content/common/gpu/testdata/test-25fps.h264"); |
| 18 // Number of NALUs in the stream to be parsed. | 18 // Number of NALUs in the stream to be parsed. |
| 19 int num_nalus = 759; | 19 int num_nalus = 759; |
| 20 | 20 |
| 21 TEST(H264ParserTest, StreamFileParsing) { | 21 TEST(H264ParserTest, StreamFileParsing) { |
| 22 base::FilePath fp(test_stream_filename); | 22 base::FilePath fp(test_stream_filename); |
| 23 file_util::MemoryMappedFile stream; | 23 base::MemoryMappedFile stream; |
| 24 CHECK(stream.Initialize(fp)) << "Couldn't open stream file: " | 24 CHECK(stream.Initialize(fp)) << "Couldn't open stream file: " |
| 25 << test_stream_filename; | 25 << test_stream_filename; |
| 26 DVLOG(1) << "Parsing file: " << test_stream_filename; | 26 DVLOG(1) << "Parsing file: " << test_stream_filename; |
| 27 | 27 |
| 28 H264Parser parser; | 28 H264Parser parser; |
| 29 parser.SetStream(stream.data(), stream.length()); | 29 parser.SetStream(stream.data(), stream.length()); |
| 30 | 30 |
| 31 // Parse until the end of stream/unsupported stream/error in stream is found. | 31 // Parse until the end of stream/unsupported stream/error in stream is found. |
| 32 int num_parsed_nalus = 0; | 32 int num_parsed_nalus = 0; |
| 33 while (true) { | 33 while (true) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 test_stream_filename = it->second.c_str(); | 84 test_stream_filename = it->second.c_str(); |
| 85 } else if (it->first == "num_nalus") { | 85 } else if (it->first == "num_nalus") { |
| 86 CHECK(base::StringToInt(it->second, &num_nalus)); | 86 CHECK(base::StringToInt(it->second, &num_nalus)); |
| 87 } else { | 87 } else { |
| 88 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 88 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 return RUN_ALL_TESTS(); | 92 return RUN_ALL_TESTS(); |
| 93 } | 93 } |
| OLD | NEW |