Chromium Code Reviews| Index: media/filters/vp8_parser_unittest.cc |
| diff --git a/media/filters/vp8_parser_unittest.cc b/media/filters/vp8_parser_unittest.cc |
| index 39a2a801032e7d6cb2f459199b611321ae1effc2..c28e240bc8092d08c0154577ffa42b025a80e2cf 100644 |
| --- a/media/filters/vp8_parser_unittest.cc |
| +++ b/media/filters/vp8_parser_unittest.cc |
| @@ -2,12 +2,10 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "base/command_line.h" |
| #include "base/files/memory_mapped_file.h" |
| #include "base/logging.h" |
| -#include "base/strings/string_number_conversions.h" |
| -#include "base/sys_byteorder.h" |
| #include "media/base/test_data_util.h" |
| +#include "media/filters/ivf_parser.h" |
| #include "media/filters/vp8_parser.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -22,31 +20,23 @@ TEST(Vp8ParserTest, StreamFileParsing) { |
| ASSERT_TRUE(stream.Initialize(file_path)) |
| << "Couldn't open stream file: " << file_path.MaybeAsASCII(); |
| - Vp8Parser parser; |
| + IvfParser ivf_parser; |
| + IvfFileHeader ivf_file_header; |
|
wuchengli
2015/07/30 06:26:13
memset to 0
kcwu
2015/07/30 11:52:52
Done.
|
| + ASSERT_TRUE( |
| + ivf_parser.Initialize(stream.data(), stream.length(), &ivf_file_header)); |
| + ASSERT_EQ(ivf_file_header.fourcc, 0x30385056u); // VP80 |
|
wuchengli
2015/07/30 06:26:13
Make 0x30385056 a constant and share it with video
kcwu
2015/07/30 11:52:52
Where do you suggest to put these fourcc values?
|
| - // Parse until the end of stream/unsupported stream/error in stream is found. |
| + Vp8Parser vp8_parser; |
| + IvfFrameHeader ivf_frame_header; |
|
wuchengli
2015/07/30 06:26:13
memset to 0
kcwu
2015/07/30 11:52:52
Done.
|
| int num_parsed_frames = 0; |
| - const uint8_t* stream_ptr = stream.data(); |
| - size_t bytes_left = stream.length(); |
| - // Skip IVF file header. |
| - const size_t kIvfStreamHeaderLen = 32; |
| - CHECK_GE(bytes_left, kIvfStreamHeaderLen); |
| - stream_ptr += kIvfStreamHeaderLen; |
| - bytes_left -= kIvfStreamHeaderLen; |
| - |
| - const size_t kIvfFrameHeaderLen = 12; |
| - while (bytes_left > kIvfFrameHeaderLen) { |
| + |
| + // Parse until the end of stream/unsupported stream/error in stream is found. |
| + while (ivf_parser.ParseNextFrame(&ivf_frame_header)) { |
| Vp8FrameHeader fhdr; |
| - uint32_t frame_size = |
| - base::ByteSwapToLE32(*reinterpret_cast<const uint32_t*>(stream_ptr)); |
| - // Skip IVF frame header. |
| - stream_ptr += kIvfFrameHeaderLen; |
| - bytes_left -= kIvfFrameHeaderLen; |
| - ASSERT_TRUE(parser.ParseFrame(stream_ptr, frame_size, &fhdr)); |
| + ASSERT_TRUE(vp8_parser.ParseFrame(ivf_frame_header.data, |
| + ivf_frame_header.data_size, &fhdr)); |
| - stream_ptr += frame_size; |
| - bytes_left -= frame_size; |
| ++num_parsed_frames; |
| } |