1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/files/memory_mapped_file.h"
6 #include "base/logging.h"
7 #include "media/base/test_data_util.h"
8 #include "media/filters/ivf_parser.h"
9 #include "media/filters/vp8_parser.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(Vp8ParserTest
, StreamFileParsing
) {
15 base::FilePath file_path
= GetTestDataFilePath("test-25fps.vp8");
16 base::MemoryMappedFile stream
;
17 ASSERT_TRUE(stream
.Initialize(file_path
))
18 << "Couldn't open stream file: " << file_path
.MaybeAsASCII();
21 IvfFileHeader ivf_file_header
= {};
23 ivf_parser
.Initialize(stream
.data(), stream
.length(), &ivf_file_header
));
24 ASSERT_EQ(ivf_file_header
.fourcc
, 0x30385056u
); // VP80
27 IvfFrameHeader ivf_frame_header
= {};
28 size_t num_parsed_frames
= 0;
30 // Parse until the end of stream/unsupported stream/error in stream is found.
31 const uint8_t* payload
= nullptr;
32 while (ivf_parser
.ParseNextFrame(&ivf_frame_header
, &payload
)) {
36 vp8_parser
.ParseFrame(payload
, ivf_frame_header
.frame_size
, &fhdr
));
41 DVLOG(1) << "Number of successfully parsed frames before EOS: "
44 EXPECT_EQ(ivf_file_header
.num_frames
, num_parsed_frames
);