OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/mp4/aac.h" | 5 #include "media/formats/mp4/aac.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/bit_reader.h" | 10 #include "media/base/bit_reader.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 return false; | 31 return false; |
32 | 32 |
33 BitReader reader(&data[0], data.size()); | 33 BitReader reader(&data[0], data.size()); |
34 uint8 extension_type = 0; | 34 uint8 extension_type = 0; |
35 bool ps_present = false; | 35 bool ps_present = false; |
36 uint8 extension_frequency_index = 0xff; | 36 uint8 extension_frequency_index = 0xff; |
37 | 37 |
38 frequency_ = 0; | 38 frequency_ = 0; |
39 extension_frequency_ = 0; | 39 extension_frequency_ = 0; |
40 | 40 |
41 // The following code is written according to ISO 14496 Part 3 Table 1.13 - | 41 // The following code is written according to ISO 14496 Part 3 Table 1.13 - |
wolenetz
2015/09/15 23:53:17
nit: s/14496 Part 3 Table 1.13/14496-3-2009 Table
msu.koo
2015/09/16 08:16:23
Thank you for your comments. I tried to post a new
wolenetz
2015/09/16 19:39:19
It looks to me like you have successfully filed ht
msu.koo
2015/09/17 02:49:26
Oh, I forgot to update this comment :) I filed tha
wolenetz
2015/09/24 19:05:39
The process for obtaining such edit issue permissi
| |
42 // Syntax of AudioSpecificConfig. | 42 // Syntax of AudioSpecificConfig. |
43 | 43 |
44 // Read base configuration | 44 // Read base configuration |
45 RCHECK(reader.ReadBits(5, &profile_)); | 45 RCHECK(reader.ReadBits(5, &profile_)); |
46 RCHECK(reader.ReadBits(4, &frequency_index_)); | 46 RCHECK(reader.ReadBits(4, &frequency_index_)); |
47 if (frequency_index_ == 0xf) | 47 if (frequency_index_ == 0xf) |
48 RCHECK(reader.ReadBits(24, &frequency_)); | 48 RCHECK(reader.ReadBits(24, &frequency_)); |
49 RCHECK(reader.ReadBits(4, &channel_config_)); | 49 RCHECK(reader.ReadBits(4, &channel_config_)); |
50 | 50 |
51 // Read extension configuration. | 51 // Read extension configuration. |
52 if (profile_ == 5 || profile_ == 29) { | 52 if (profile_ == 5 || profile_ == 29) { |
53 ps_present = (profile_ == 29); | 53 ps_present = (profile_ == 29); |
54 extension_type = 5; | 54 extension_type = 5; |
55 RCHECK(reader.ReadBits(4, &extension_frequency_index)); | 55 RCHECK(reader.ReadBits(4, &extension_frequency_index)); |
56 if (extension_frequency_index == 0xf) | 56 if (extension_frequency_index == 0xf) |
57 RCHECK(reader.ReadBits(24, &extension_frequency_)); | 57 RCHECK(reader.ReadBits(24, &extension_frequency_)); |
58 RCHECK(reader.ReadBits(5, &profile_)); | 58 RCHECK(reader.ReadBits(5, &profile_)); |
59 } | 59 } |
60 | 60 |
61 MEDIA_LOG(INFO, media_log) << "Audio codec: mp4a.40." << std::hex | |
62 << static_cast<int>(profile_); | |
63 | |
64 RCHECK(SkipDecoderGASpecificConfig(&reader)); | 61 RCHECK(SkipDecoderGASpecificConfig(&reader)); |
65 RCHECK(SkipErrorSpecificConfig()); | 62 RCHECK(SkipErrorSpecificConfig()); |
66 | 63 |
67 // Read extension configuration again | 64 // Read extension configuration again |
68 // Note: The check for 16 available bits comes from the AAC spec. | 65 // Note: The check for 16 available bits comes from the AAC spec. |
69 if (extension_type != 5 && reader.bits_available() >= 16) { | 66 if (extension_type != 5 && reader.bits_available() >= 16) { |
70 uint16 sync_extension_type; | 67 uint16 sync_extension_type; |
71 uint8 sbr_present_flag; | 68 uint8 sbr_present_flag; |
72 uint8 ps_present_flag; | 69 uint8 ps_present_flag; |
73 | 70 |
(...skipping 15 matching lines...) Expand all Loading... | |
89 RCHECK(reader.ReadBits(1, &ps_present_flag)); | 86 RCHECK(reader.ReadBits(1, &ps_present_flag)); |
90 ps_present = ps_present_flag != 0; | 87 ps_present = ps_present_flag != 0; |
91 } | 88 } |
92 } | 89 } |
93 } | 90 } |
94 } | 91 } |
95 } | 92 } |
96 } | 93 } |
97 | 94 |
98 if (frequency_ == 0) { | 95 if (frequency_ == 0) { |
99 RCHECK(frequency_index_ < kADTSFrequencyTableSize); | 96 if (frequency_index_ >= kADTSFrequencyTableSize) { |
97 MEDIA_LOG(ERROR, media_log) | |
98 << "Sampling Frequency Index(0x" | |
99 << std::hex << static_cast<int>(frequency_index_) | |
100 << ") is not supported. Please see ISO 14496 Part 3 Table 1.18 " | |
101 << "for supported Sampling Frequencies."; | |
102 return false; | |
103 } | |
100 frequency_ = kADTSFrequencyTable[frequency_index_]; | 104 frequency_ = kADTSFrequencyTable[frequency_index_]; |
101 } | 105 } |
102 | 106 |
103 if (extension_frequency_ == 0 && extension_frequency_index != 0xff) { | 107 if (extension_frequency_ == 0 && extension_frequency_index != 0xff) { |
104 RCHECK(extension_frequency_index < kADTSFrequencyTableSize); | 108 if (extension_frequency_index >= kADTSFrequencyTableSize) { |
109 MEDIA_LOG(ERROR, media_log) | |
110 << "Extension Sampling Frequency Index(0x" | |
111 << std::hex << static_cast<int>(extension_frequency_index) | |
112 << ") is not supported. Please see ISO 14496 Part 3 Table 1.18 " | |
113 << "for supported Sampling Frequencies."; | |
114 return false; | |
115 } | |
105 extension_frequency_ = kADTSFrequencyTable[extension_frequency_index]; | 116 extension_frequency_ = kADTSFrequencyTable[extension_frequency_index]; |
106 } | 117 } |
107 | 118 |
108 // When Parametric Stereo is on, mono will be played as stereo. | 119 // When Parametric Stereo is on, mono will be played as stereo. |
109 if (ps_present && channel_config_ == 1) { | 120 if (ps_present && channel_config_ == 1) { |
110 channel_layout_ = CHANNEL_LAYOUT_STEREO; | 121 channel_layout_ = CHANNEL_LAYOUT_STEREO; |
111 } else { | 122 } else { |
112 RCHECK(channel_config_ < kADTSChannelLayoutTableSize); | 123 if (channel_config_ >= kADTSChannelLayoutTableSize) { |
124 MEDIA_LOG(ERROR, media_log) | |
125 << "Channel Configuration(" | |
126 << static_cast<int>(channel_config_) | |
127 << ") is not supported. Please see ISO 14496 Part 3 Table 1.19 " | |
128 << "for supported Channel Configurations."; | |
129 return false; | |
130 } | |
113 channel_layout_ = kADTSChannelLayoutTable[channel_config_]; | 131 channel_layout_ = kADTSChannelLayoutTable[channel_config_]; |
114 } | 132 } |
115 | 133 |
116 return frequency_ != 0 && channel_layout_ != CHANNEL_LAYOUT_NONE && | 134 RCHECK_MEDIA_LOGGED(channel_layout_ != CHANNEL_LAYOUT_NONE, media_log, |
wolenetz
2015/09/15 23:53:17
nit: it looks like this log is also possible to te
msu.koo
2015/09/16 08:16:23
This code block is dead. "|channel_config_| == 0"
wolenetz
2015/09/16 19:39:19
Acknowledged. Since the helper method might change
msu.koo
2015/09/17 02:49:26
Done.
| |
117 profile_ >= 1 && profile_ <= 4; | 135 "Undefined Audio Channel layout with value " |
136 "CHANNEL_LAYOUT_NONE."); | |
137 if (profile_ < 1 || profile_ > 4) { | |
138 MEDIA_LOG(ERROR, media_log) | |
139 << "Audio codec(mp4a.40." << static_cast<int>(profile_) | |
140 << ") is not supported. Please see ISO 14496 Part 3 Table 1.3 " | |
141 << "for Audio Profile Definitions."; | |
142 return false; | |
143 } | |
144 | |
145 MEDIA_LOG(INFO, media_log) | |
146 << "Audio codec: mp4a.40." << static_cast<int>(profile_) | |
147 << ". Sampling frequency: " << frequency_ << "Hz" | |
148 << ". Sampling frequency(Extension): " << extension_frequency_ << "Hz" | |
149 << ". Channel layout: " << channel_layout_ << "."; | |
150 | |
151 return true; | |
118 } | 152 } |
119 | 153 |
120 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const { | 154 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const { |
121 if (extension_frequency_ > 0) | 155 if (extension_frequency_ > 0) |
122 return extension_frequency_; | 156 return extension_frequency_; |
123 | 157 |
124 if (!sbr_in_mimetype) | 158 if (!sbr_in_mimetype) |
125 return frequency_; | 159 return frequency_; |
126 | 160 |
127 // The following code is written according to ISO 14496 Part 3 Table 1.11 and | 161 // The following code is written according to ISO 14496 Part 3 Table 1.11 and |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 275 |
242 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 | 276 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 |
243 } | 277 } |
244 | 278 |
245 return true; | 279 return true; |
246 } | 280 } |
247 | 281 |
248 } // namespace mp4 | 282 } // namespace mp4 |
249 | 283 |
250 } // namespace media | 284 } // namespace media |
OLD | NEW |