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

Side by Side Diff: media/formats/mp4/aac.cc

Issue 1421293009: Update comments about ISO spec on aac parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | media/formats/mp4/aac_unittest.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 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
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 // TODO(msu.koo): Need to update comments after checking which version of 41 // TODO(msu.koo): Need to consider whether ISO 14496-3:2009 needs
42 // ISO 14496-3 this implementation is according to. Also need to reflect 42 // to be reflected instead of ISO 14496-3:2005.
43 // ISO 14496-3:2009 if ISO 14496-3:2005 was reflected here.
44 // https://crbug.com/532281 43 // https://crbug.com/532281
45 44
46 // The following code is written according to ISO 14496 Part 3 Table 1.13 - 45 // The following code is written according to ISO 14496-3:2005 Table 1.13 -
47 // Syntax of AudioSpecificConfig. 46 // Syntax of AudioSpecificConfig.
48 47
49 // Read base configuration 48 // Read base configuration
50 RCHECK(reader.ReadBits(5, &profile_)); 49 RCHECK(reader.ReadBits(5, &profile_));
51 RCHECK(reader.ReadBits(4, &frequency_index_)); 50 RCHECK(reader.ReadBits(4, &frequency_index_));
52 if (frequency_index_ == 0xf) 51 if (frequency_index_ == 0xf)
53 RCHECK(reader.ReadBits(24, &frequency_)); 52 RCHECK(reader.ReadBits(24, &frequency_));
54 RCHECK(reader.ReadBits(4, &channel_config_)); 53 RCHECK(reader.ReadBits(4, &channel_config_));
55 54
56 // Read extension configuration. 55 // Read extension configuration.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return true; 153 return true;
155 } 154 }
156 155
157 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const { 156 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const {
158 if (extension_frequency_ > 0) 157 if (extension_frequency_ > 0)
159 return extension_frequency_; 158 return extension_frequency_;
160 159
161 if (!sbr_in_mimetype) 160 if (!sbr_in_mimetype)
162 return frequency_; 161 return frequency_;
163 162
164 // The following code is written according to ISO 14496 Part 3 Table 1.11 and 163 // The following code is written according to ISO 14496-3:2005 Table 1.11 and
165 // Table 1.22. (Table 1.11 refers to the capping to 48000, Table 1.22 refers 164 // Table 1.22. (Table 1.11 refers to the capping to 48000, Table 1.22 refers
166 // to SBR doubling the AAC sample rate.) 165 // to SBR doubling the AAC sample rate.)
167 // TODO(acolwell) : Extend sample rate cap to 96kHz for Level 5 content. 166 // TODO(acolwell) : Extend sample rate cap to 96kHz for Level 5 content.
168 DCHECK_GT(frequency_, 0); 167 DCHECK_GT(frequency_, 0);
169 return std::min(2 * frequency_, 48000); 168 return std::min(2 * frequency_, 48000);
170 } 169 }
171 170
172 ChannelLayout AAC::GetChannelLayout(bool sbr_in_mimetype) const { 171 ChannelLayout AAC::GetChannelLayout(bool sbr_in_mimetype) const {
173 // Check for implicit signalling of HE-AAC and indicate stereo output 172 // Check for implicit signalling of HE-AAC and indicate stereo output
174 // if the mono channel configuration is signalled. 173 // if the mono channel configuration is signalled.
175 // See ISO-14496-3 Section 1.6.6.1.2 for details about this special casing. 174 // See ISO 14496-3:2005 Section 1.6.5.3 for details about this special casing.
176 if (sbr_in_mimetype && channel_config_ == 1) 175 if (sbr_in_mimetype && channel_config_ == 1)
177 return CHANNEL_LAYOUT_STEREO; 176 return CHANNEL_LAYOUT_STEREO;
178 177
179 return channel_layout_; 178 return channel_layout_;
180 } 179 }
181 180
182 bool AAC::ConvertEsdsToADTS(std::vector<uint8>* buffer) const { 181 bool AAC::ConvertEsdsToADTS(std::vector<uint8>* buffer) const {
183 size_t size = buffer->size() + kADTSHeaderMinSize; 182 size_t size = buffer->size() + kADTSHeaderMinSize;
184 183
185 DCHECK(profile_ >= 1 && profile_ <= 4 && frequency_index_ != 0xf && 184 DCHECK(profile_ >= 1 && profile_ <= 4 && frequency_index_ != 0xf &&
(...skipping 12 matching lines...) Expand all
198 (channel_config_ >> 2); 197 (channel_config_ >> 2);
199 adts[3] = static_cast<uint8>(((channel_config_ & 0x3) << 6) + (size >> 11)); 198 adts[3] = static_cast<uint8>(((channel_config_ & 0x3) << 6) + (size >> 11));
200 adts[4] = static_cast<uint8>((size & 0x7ff) >> 3); 199 adts[4] = static_cast<uint8>((size & 0x7ff) >> 3);
201 adts[5] = ((size & 7) << 5) + 0x1f; 200 adts[5] = ((size & 7) << 5) + 0x1f;
202 adts[6] = 0xfc; 201 adts[6] = 0xfc;
203 202
204 return true; 203 return true;
205 } 204 }
206 205
207 // Currently this function only support GASpecificConfig defined in 206 // Currently this function only support GASpecificConfig defined in
208 // ISO 14496 Part 3 Table 4.1 - Syntax of GASpecificConfig() 207 // ISO 14496-3:2005 Table 4.1 - Syntax of GASpecificConfig()
209 bool AAC::SkipDecoderGASpecificConfig(BitReader* bit_reader) const { 208 bool AAC::SkipDecoderGASpecificConfig(BitReader* bit_reader) const {
210 switch (profile_) { 209 switch (profile_) {
211 case 1: 210 case 1:
212 case 2: 211 case 2:
213 case 3: 212 case 3:
214 case 4: 213 case 4:
215 case 6: 214 case 6:
216 case 7: 215 case 7:
217 case 17: 216 case 17:
218 case 19: 217 case 19:
(...skipping 22 matching lines...) Expand all
241 case 26: 240 case 26:
242 case 27: 241 case 27:
243 return false; 242 return false;
244 default: 243 default:
245 break; 244 break;
246 } 245 }
247 246
248 return true; 247 return true;
249 } 248 }
250 249
251 // The following code is written according to ISO 14496 part 3 Table 4.1 - 250 // The following code is written according to ISO 14496-3:2005 Table 4.1 -
252 // GASpecificConfig. 251 // GASpecificConfig.
253 bool AAC::SkipGASpecificConfig(BitReader* bit_reader) const { 252 bool AAC::SkipGASpecificConfig(BitReader* bit_reader) const {
254 uint8 extension_flag = 0; 253 uint8 extension_flag = 0;
255 uint8 depends_on_core_coder; 254 uint8 depends_on_core_coder;
256 uint16 dummy; 255 uint16 dummy;
257 256
258 RCHECK(bit_reader->ReadBits(1, &dummy)); // frameLengthFlag 257 RCHECK(bit_reader->ReadBits(1, &dummy)); // frameLengthFlag
259 RCHECK(bit_reader->ReadBits(1, &depends_on_core_coder)); 258 RCHECK(bit_reader->ReadBits(1, &depends_on_core_coder));
260 if (depends_on_core_coder == 1) 259 if (depends_on_core_coder == 1)
261 RCHECK(bit_reader->ReadBits(14, &dummy)); // coreCoderDelay 260 RCHECK(bit_reader->ReadBits(14, &dummy)); // coreCoderDelay
(...skipping 16 matching lines...) Expand all
278 277
279 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 278 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3
280 } 279 }
281 280
282 return true; 281 return true;
283 } 282 }
284 283
285 } // namespace mp4 284 } // namespace mp4
286 285
287 } // namespace media 286 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/formats/mp4/aac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698