Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: media/mp4/aac_unittest.cc

Issue 13648007: Fix channel layout reporting for implicit signalling of AAC parametric stereo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/mp4/aac.cc ('k') | media/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/mp4/aac.h" 5 #include "media/mp4/aac.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace media { 9 namespace media {
10 10
11 namespace mp4 { 11 namespace mp4 {
12 12
13 TEST(AACTest, BasicProfileTest) { 13 TEST(AACTest, BasicProfileTest) {
14 AAC aac; 14 AAC aac;
15 uint8 buffer[] = {0x12, 0x10}; 15 uint8 buffer[] = {0x12, 0x10};
16 std::vector<uint8> data; 16 std::vector<uint8> data;
17 17
18 data.assign(buffer, buffer + sizeof(buffer)); 18 data.assign(buffer, buffer + sizeof(buffer));
19 19
20 EXPECT_TRUE(aac.Parse(data)); 20 EXPECT_TRUE(aac.Parse(data));
21 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 44100); 21 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 44100);
22 EXPECT_EQ(aac.channel_layout(), CHANNEL_LAYOUT_STEREO); 22 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO);
23 } 23 }
24 24
25 TEST(AACTest, ExtensionTest) { 25 TEST(AACTest, ExtensionTest) {
26 AAC aac; 26 AAC aac;
27 uint8 buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80}; 27 uint8 buffer[] = {0x13, 0x08, 0x56, 0xe5, 0x9d, 0x48, 0x80};
28 std::vector<uint8> data; 28 std::vector<uint8> data;
29 29
30 data.assign(buffer, buffer + sizeof(buffer)); 30 data.assign(buffer, buffer + sizeof(buffer));
31 31
32 EXPECT_TRUE(aac.Parse(data)); 32 EXPECT_TRUE(aac.Parse(data));
33 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000); 33 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000);
34 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000); 34 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
35 EXPECT_EQ(aac.channel_layout(), CHANNEL_LAYOUT_STEREO); 35 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO);
36 } 36 }
37 37
38 TEST(AACTest, TestImplicitSBR) { 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, TestImplicitSBR_ChannelConfig0) {
43 AAC aac;
44 uint8 buffer[] = {0x13, 0x08};
45 std::vector<uint8> data;
46
47 data.assign(buffer, buffer + sizeof(buffer));
48
49 EXPECT_TRUE(aac.Parse(data));
50
51 // Test w/o implict SBR.
52 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000);
53 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_MONO);
54
55 // Test implicit SBR.
56 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
57 EXPECT_EQ(aac.GetChannelLayout(true), CHANNEL_LAYOUT_STEREO);
58 }
59
60 // Tests implicit SBR with a stereo channel config.
61 TEST(AACTest, TestImplicitSBR_ChannelConfig1) {
39 AAC aac; 62 AAC aac;
40 uint8 buffer[] = {0x13, 0x10}; 63 uint8 buffer[] = {0x13, 0x10};
41 std::vector<uint8> data; 64 std::vector<uint8> data;
42 65
43 data.assign(buffer, buffer + sizeof(buffer)); 66 data.assign(buffer, buffer + sizeof(buffer));
44 67
45 EXPECT_TRUE(aac.Parse(data)); 68 EXPECT_TRUE(aac.Parse(data));
69
70 // Test w/o implict SBR.
46 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000); 71 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 24000);
72 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_STEREO);
73
74 // Test implicit SBR.
47 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000); 75 EXPECT_EQ(aac.GetOutputSamplesPerSecond(true), 48000);
48 EXPECT_EQ(aac.channel_layout(), CHANNEL_LAYOUT_STEREO); 76 EXPECT_EQ(aac.GetChannelLayout(true), CHANNEL_LAYOUT_STEREO);
49 } 77 }
50 78
51 TEST(AACTest, SixChannelTest) { 79 TEST(AACTest, SixChannelTest) {
52 AAC aac; 80 AAC aac;
53 uint8 buffer[] = {0x11, 0xb0}; 81 uint8 buffer[] = {0x11, 0xb0};
54 std::vector<uint8> data; 82 std::vector<uint8> data;
55 83
56 data.assign(buffer, buffer + sizeof(buffer)); 84 data.assign(buffer, buffer + sizeof(buffer));
57 85
58 EXPECT_TRUE(aac.Parse(data)); 86 EXPECT_TRUE(aac.Parse(data));
59 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000); 87 EXPECT_EQ(aac.GetOutputSamplesPerSecond(false), 48000);
60 EXPECT_EQ(aac.channel_layout(), CHANNEL_LAYOUT_5_1); 88 EXPECT_EQ(aac.GetChannelLayout(false), CHANNEL_LAYOUT_5_1);
61 } 89 }
62 90
63 TEST(AACTest, DataTooShortTest) { 91 TEST(AACTest, DataTooShortTest) {
64 AAC aac; 92 AAC aac;
65 std::vector<uint8> data; 93 std::vector<uint8> data;
66 94
67 EXPECT_FALSE(aac.Parse(data)); 95 EXPECT_FALSE(aac.Parse(data));
68 96
69 data.push_back(0x12); 97 data.push_back(0x12);
70 EXPECT_FALSE(aac.Parse(data)); 98 EXPECT_FALSE(aac.Parse(data));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 137
110 EXPECT_FALSE(aac.Parse(data)); 138 EXPECT_FALSE(aac.Parse(data));
111 139
112 data[1] = 0x08; 140 data[1] = 0x08;
113 EXPECT_TRUE(aac.Parse(data)); 141 EXPECT_TRUE(aac.Parse(data));
114 } 142 }
115 143
116 } // namespace mp4 144 } // namespace mp4
117 145
118 } // namespace media 146 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/aac.cc ('k') | media/mp4/mp4_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698