cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / media / mp4 / aac_unittest.cc
blobd9ce22db3fee23e05e2c0e2d426f7cedae331c97
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
3 // found in the LICENSE file.
5 #include "media/mp4/aac.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace media {
11 namespace mp4 {
13 TEST(AACTest, BasicProfileTest) {
14 AAC aac;
15 uint8 buffer[] = {0x12, 0x10};
16 std::vector<uint8> data;
18 data.assign(buffer, buffer + sizeof(buffer));
20 EXPECT_TRUE(aac.Parse(data));
21 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 44100);
22 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO);
25 TEST(AACTest, ExtensionTest) {
26 AAC aac;
27 uint8 buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80};
28 std::vector<uint8> data;
30 data.assign(buffer, buffer + sizeof(buffer));
32 EXPECT_TRUE(aac.Parse(data));
33 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000);
34 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
35 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO);
38 // Test implicit SBR with mono channel config.
39 // Mono channel layout should only be reported if SBR is not
40 // specified. Otherwise stereo should be reported.
41 // See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing.
42 TEST(AACTest, ImplicitSBR_ChannelConfig0) {
43 AAC aac;
44 uint8 buffer[] = {0x13, 0x08};
45 std::vector<uint8> data;
47 data.assign(buffer, buffer + sizeof(buffer));
49 EXPECT_TRUE(aac.Parse(data));
51 // Test w/o implict SBR.
52 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000);
53 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_MONO);
55 // Test implicit SBR.
56 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
57 EXPECT_EQ(aac.GetChannelLayout(true), CHANNEL_LAYOUT_STEREO);
60 // Tests implicit SBR with a stereo channel config.
61 TEST(AACTest, ImplicitSBR_ChannelConfig1) {
62 AAC aac;
63 uint8 buffer[] = {0x13, 0x10};
64 std::vector<uint8> data;
66 data.assign(buffer, buffer + sizeof(buffer));
68 EXPECT_TRUE(aac.Parse(data));
70 // Test w/o implict SBR.
71 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000);
72 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO);
74 // Test implicit SBR.
75 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
76 EXPECT_EQ(aac.GetChannelLayout(true), CHANNEL_LAYOUT_STEREO);
79 TEST(AACTest, SixChannelTest) {
80 AAC aac;
81 uint8 buffer[] = {0x11, 0xb0};
82 std::vector<uint8> data;
84 data.assign(buffer, buffer + sizeof(buffer));
86 EXPECT_TRUE(aac.Parse(data));
87 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000);
88 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_5_1);
91 TEST(AACTest, DataTooShortTest) {
92 AAC aac;
93 std::vector<uint8> data;
95 EXPECT_FALSE(aac.Parse(data));
97 data.push_back(0x12);
98 EXPECT_FALSE(aac.Parse(data));
101 TEST(AACTest, IncorrectProfileTest) {
102 AAC aac;
103 uint8 buffer[] = {0x0, 0x08};
104 std::vector<uint8> data;
106 data.assign(buffer, buffer + sizeof(buffer));
108 EXPECT_FALSE(aac.Parse(data));
110 data[0] = 0x08;
111 EXPECT_TRUE(aac.Parse(data));
113 data[0] = 0x28;
114 EXPECT_FALSE(aac.Parse(data));
117 TEST(AACTest, IncorrectFrequencyTest) {
118 AAC aac;
119 uint8 buffer[] = {0x0f, 0x88};
120 std::vector<uint8> data;
122 data.assign(buffer, buffer + sizeof(buffer));
124 EXPECT_FALSE(aac.Parse(data));
126 data[0] = 0x0e;
127 data[1] = 0x08;
128 EXPECT_TRUE(aac.Parse(data));
131 TEST(AACTest, IncorrectChannelTest) {
132 AAC aac;
133 uint8 buffer[] = {0x0e, 0x00};
134 std::vector<uint8> data;
136 data.assign(buffer, buffer + sizeof(buffer));
138 EXPECT_FALSE(aac.Parse(data));
140 data[1] = 0x08;
141 EXPECT_TRUE(aac.Parse(data));
144 } // namespace mp4
146 } // namespace media