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 <string.h> | 5 #include <string.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "media/base/stream_parser_buffer.h" | 8 #include "media/base/stream_parser_buffer.h" |
9 #include "media/mp4/avc.h" | 9 #include "media/mp4/avc.h" |
10 #include "media/mp4/box_definitions.h" | 10 #include "media/mp4/box_definitions.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "testing/gtest/include/gtest/gtest-param-test.h" | 12 #include "testing/gtest/include/gtest/gtest-param-test.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 namespace mp4 { | 15 namespace mp4 { |
16 | 16 |
17 static const uint8 kNALU1[] = { 0x01, 0x02, 0x03 }; | 17 static const uint8 kNALU1[] = { 0x01, 0x02, 0x03 }; |
18 static const uint8 kNALU2[] = { 0x04, 0x05, 0x06, 0x07 }; | 18 static const uint8 kNALU2[] = { 0x04, 0x05, 0x06, 0x07 }; |
19 static const uint8 kExpected[] = { | 19 static const uint8 kExpected[] = { |
20 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, | 20 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, |
21 0x00, 0x00, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07 }; | 21 0x00, 0x00, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07 }; |
22 | 22 |
23 static const uint8 kExpectedParamSets[] = { | 23 static const uint8 kExpectedParamSets[] = { |
24 0x00, 0x00, 0x00, 0x01, 0x67, 0x12, | 24 0x00, 0x00, 0x00, 0x01, 0x67, 0x12, |
25 0x00, 0x00, 0x00, 0x01, 0x67, 0x34, | 25 0x00, 0x00, 0x00, 0x01, 0x67, 0x34, |
26 0x00, 0x00, 0x00, 0x01, 0x68, 0x56, 0x78, 0x9a}; | 26 0x00, 0x00, 0x00, 0x01, 0x68, 0x56, 0x78}; |
27 | 27 |
28 class AVCConversionTest : public testing::TestWithParam<int> { | 28 class AVCConversionTest : public testing::TestWithParam<int> { |
29 protected: | 29 protected: |
30 void MakeInputForLength(int length_size, std::vector<uint8>* buf) { | 30 void MakeInputForLength(int length_size, std::vector<uint8>* buf) { |
31 buf->clear(); | 31 buf->clear(); |
32 for (int i = 1; i < length_size; i++) | 32 for (int i = 1; i < length_size; i++) |
33 buf->push_back(0); | 33 buf->push_back(0); |
34 buf->push_back(sizeof(kNALU1)); | 34 buf->push_back(sizeof(kNALU1)); |
35 buf->insert(buf->end(), kNALU1, kNALU1 + sizeof(kNALU1)); | 35 buf->insert(buf->end(), kNALU1, kNALU1 + sizeof(kNALU1)); |
36 | 36 |
(...skipping 29 matching lines...) Expand all Loading... |
66 TEST_P(AVCConversionTest, ParseEmpty) { | 66 TEST_P(AVCConversionTest, ParseEmpty) { |
67 std::vector<uint8> buf; | 67 std::vector<uint8> buf; |
68 EXPECT_TRUE(AVC::ConvertToAnnexB(GetParam(), &buf)); | 68 EXPECT_TRUE(AVC::ConvertToAnnexB(GetParam(), &buf)); |
69 EXPECT_EQ(0u, buf.size()); | 69 EXPECT_EQ(0u, buf.size()); |
70 } | 70 } |
71 | 71 |
72 INSTANTIATE_TEST_CASE_P(AVCConversionTestValues, | 72 INSTANTIATE_TEST_CASE_P(AVCConversionTestValues, |
73 AVCConversionTest, | 73 AVCConversionTest, |
74 ::testing::Values(1, 2, 4)); | 74 ::testing::Values(1, 2, 4)); |
75 | 75 |
76 TEST(AVC, InsertParameterSetsTest) { | 76 TEST_F(AVCConversionTest, ConvertParameterSets) { |
77 AVCDecoderConfigurationRecord avc_config; | 77 AVCDecoderConfigurationRecord avc_config; |
78 avc_config.sps_list.resize(2); | 78 avc_config.sps_list.resize(2); |
79 avc_config.sps_list[0].push_back(0x67); | 79 avc_config.sps_list[0].push_back(0x67); |
80 avc_config.sps_list[0].push_back(0x12); | 80 avc_config.sps_list[0].push_back(0x12); |
81 avc_config.sps_list[1].push_back(0x67); | 81 avc_config.sps_list[1].push_back(0x67); |
82 avc_config.sps_list[1].push_back(0x34); | 82 avc_config.sps_list[1].push_back(0x34); |
83 avc_config.pps_list.resize(1); | 83 avc_config.pps_list.resize(1); |
84 avc_config.pps_list[0].push_back(0x68); | 84 avc_config.pps_list[0].push_back(0x68); |
85 avc_config.pps_list[0].push_back(0x56); | 85 avc_config.pps_list[0].push_back(0x56); |
86 avc_config.pps_list[0].push_back(0x78); | 86 avc_config.pps_list[0].push_back(0x78); |
87 | 87 |
88 std::vector<uint8> buf; | 88 std::vector<uint8> buf; |
89 buf.push_back(0x9a); | 89 EXPECT_TRUE(AVC::ConvertParameterSets(avc_config, &buf)); |
90 EXPECT_TRUE(AVC::InsertParameterSets(avc_config, &buf)); | |
91 EXPECT_EQ(0, memcmp(kExpectedParamSets, &buf[0], | 90 EXPECT_EQ(0, memcmp(kExpectedParamSets, &buf[0], |
92 sizeof(kExpectedParamSets))); | 91 sizeof(kExpectedParamSets))); |
93 } | 92 } |
94 | 93 |
95 } // namespace mp4 | 94 } // namespace mp4 |
96 } // namespace media | 95 } // namespace media |
OLD | NEW |