| 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/formats/mp4/rcheck.h" | 11 #include "media/formats/mp4/rcheck.h" |
| 12 #include "media/formats/mpeg/adts_constants.h" | 12 #include "media/formats/mpeg/adts_constants.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 namespace mp4 { | 15 namespace mp4 { |
| 16 | 16 |
| 17 AAC::AAC() | 17 AAC::AAC() |
| 18 : profile_(0), frequency_index_(0), channel_config_(0), frequency_(0), | 18 : profile_(0), frequency_index_(0), channel_config_(0), frequency_(0), |
| 19 extension_frequency_(0), channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED) { | 19 extension_frequency_(0), channel_layout_(CHANNEL_LAYOUT_UNSUPPORTED) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 AAC::~AAC() { | 22 AAC::~AAC() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool AAC::Parse(const std::vector<uint8>& data, const LogCB& log_cb) { | 25 bool AAC::Parse(const std::vector<uint8>& data, |
| 26 const scoped_refptr<MediaLog>& media_log) { |
| 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 |
| 60 MEDIA_LOG(INFO, log_cb) << "Audio codec: mp4a.40." << std::hex | 61 MEDIA_LOG(INFO, media_log) << "Audio codec: mp4a.40." << std::hex |
| 61 << static_cast<int>(profile_); | 62 << static_cast<int>(profile_); |
| 62 | 63 |
| 63 RCHECK(SkipDecoderGASpecificConfig(&reader)); | 64 RCHECK(SkipDecoderGASpecificConfig(&reader)); |
| 64 RCHECK(SkipErrorSpecificConfig()); | 65 RCHECK(SkipErrorSpecificConfig()); |
| 65 | 66 |
| 66 // Read extension configuration again | 67 // Read extension configuration again |
| 67 // 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. |
| 68 if (extension_type != 5 && reader.bits_available() >= 16) { | 69 if (extension_type != 5 && reader.bits_available() >= 16) { |
| 69 uint16 sync_extension_type; | 70 uint16 sync_extension_type; |
| 70 uint8 sbr_present_flag; | 71 uint8 sbr_present_flag; |
| 71 uint8 ps_present_flag; | 72 uint8 ps_present_flag; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 241 |
| 241 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 | 242 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 |
| 242 } | 243 } |
| 243 | 244 |
| 244 return true; | 245 return true; |
| 245 } | 246 } |
| 246 | 247 |
| 247 } // namespace mp4 | 248 } // namespace mp4 |
| 248 | 249 |
| 249 } // namespace media | 250 } // namespace media |
| OLD | NEW |