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" |
| 11 #include "media/base/media_log.h" |
11 #include "media/formats/mp4/rcheck.h" | 12 #include "media/formats/mp4/rcheck.h" |
12 #include "media/formats/mpeg/adts_constants.h" | 13 #include "media/formats/mpeg/adts_constants.h" |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 namespace mp4 { | 16 namespace mp4 { |
16 | 17 |
17 AAC::AAC() | 18 AAC::AAC() |
18 : profile_(0), frequency_index_(0), channel_config_(0), frequency_(0), | 19 : profile_(0), frequency_index_(0), channel_config_(0), frequency_(0), |
19 extension_frequency_(0), channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED) { | 20 extension_frequency_(0), channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED) { |
20 } | 21 } |
21 | 22 |
22 AAC::~AAC() { | 23 AAC::~AAC() { |
23 } | 24 } |
24 | 25 |
25 bool AAC::Parse(const std::vector<uint8>& data) { | 26 bool AAC::Parse(const std::vector<uint8>& data, const LogCB& log_cb) { |
26 #if defined(OS_ANDROID) | 27 #if defined(OS_ANDROID) |
27 codec_specific_data_ = data; | 28 codec_specific_data_ = data; |
28 #endif | 29 #endif |
29 if (data.empty()) | 30 if (data.empty()) |
30 return false; | 31 return false; |
31 | 32 |
32 BitReader reader(&data[0], data.size()); | 33 BitReader reader(&data[0], data.size()); |
33 uint8 extension_type = 0; | 34 uint8 extension_type = 0; |
34 bool ps_present = false; | 35 bool ps_present = false; |
35 uint8 extension_frequency_index = 0xff; | 36 uint8 extension_frequency_index = 0xff; |
(...skipping 14 matching lines...) Expand all Loading... |
50 // Read extension configuration. | 51 // Read extension configuration. |
51 if (profile_ == 5 || profile_ == 29) { | 52 if (profile_ == 5 || profile_ == 29) { |
52 ps_present = (profile_ == 29); | 53 ps_present = (profile_ == 29); |
53 extension_type = 5; | 54 extension_type = 5; |
54 RCHECK(reader.ReadBits(4, &extension_frequency_index)); | 55 RCHECK(reader.ReadBits(4, &extension_frequency_index)); |
55 if (extension_frequency_index == 0xf) | 56 if (extension_frequency_index == 0xf) |
56 RCHECK(reader.ReadBits(24, &extension_frequency_)); | 57 RCHECK(reader.ReadBits(24, &extension_frequency_)); |
57 RCHECK(reader.ReadBits(5, &profile_)); | 58 RCHECK(reader.ReadBits(5, &profile_)); |
58 } | 59 } |
59 | 60 |
| 61 MEDIA_LOG(log_cb) << "Audio codec: mp4a.40." |
| 62 << std::hex << static_cast<int>(profile_); |
| 63 |
60 RCHECK(SkipDecoderGASpecificConfig(&reader)); | 64 RCHECK(SkipDecoderGASpecificConfig(&reader)); |
61 RCHECK(SkipErrorSpecificConfig()); | 65 RCHECK(SkipErrorSpecificConfig()); |
62 | 66 |
63 // Read extension configuration again | 67 // Read extension configuration again |
64 // Note: The check for 16 available bits comes from the AAC spec. | 68 // Note: The check for 16 available bits comes from the AAC spec. |
65 if (extension_type != 5 && reader.bits_available() >= 16) { | 69 if (extension_type != 5 && reader.bits_available() >= 16) { |
66 uint16 sync_extension_type; | 70 uint16 sync_extension_type; |
67 uint8 sbr_present_flag; | 71 uint8 sbr_present_flag; |
68 uint8 ps_present_flag; | 72 uint8 ps_present_flag; |
69 | 73 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 241 |
238 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 | 242 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 |
239 } | 243 } |
240 | 244 |
241 return true; | 245 return true; |
242 } | 246 } |
243 | 247 |
244 } // namespace mp4 | 248 } // namespace mp4 |
245 | 249 |
246 } // namespace media | 250 } // namespace media |
OLD | NEW |