Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 << "Unsupported Sampling Frequency Index with value 0x" | |
| 99 << std::hex << static_cast<int>(frequency_index_) | |
| 100 << ". Please see ISO 14496 Part 3 Table 1.16 " | |
| 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 << "Unsupported Extenson Sampling Frequency Index with value 0x" | |
|
wolenetz
2015/08/31 18:51:49
nit: s/Extenson/Extension/
| |
| 111 << std::hex << static_cast<int>(frequency_index_) | |
| 112 << ". Please see ISO 14496 Part 3 Table 1.16 " | |
| 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 << "Unsupported Channel Configuration with value " | |
| 126 << static_cast<int>(channel_config_) << ". " | |
| 127 << "Please see ISO 14496 Part 3 Table 1.17 " | |
| 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(frequency_ != 0, media_log, |
| 117 profile_ >= 1 && profile_ <= 4; | 135 "Audio frequency is invalid with value 0."); |
| 136 RCHECK_MEDIA_LOGGED(channel_layout_ != CHANNEL_LAYOUT_NONE, media_log, | |
| 137 "Undefined Audio Channel layout with value " | |
| 138 "CHANNEL_LAYOUT_NONE."); | |
| 139 if (profile_ < 1 || profile_ > 4) { | |
| 140 MEDIA_LOG(ERROR, media_log) | |
| 141 << "Audio codec: mp4a.40." << static_cast<int>(profile_) | |
| 142 << " is not supported. " | |
| 143 << "Please see ISO 14496 Part 3 Table 1.3 " | |
| 144 << "for Audio Profile Definitions."; | |
| 145 return false; | |
| 146 } | |
| 147 | |
| 148 MEDIA_LOG(INFO, media_log) | |
| 149 << "Audio codec: mp4a.40." << static_cast<int>(profile_) | |
| 150 << ", Sampling frequency: " << frequency_ << "Hz" | |
| 151 << ", Extension Sampling frequency: " << extension_frequency_ << "Hz" | |
| 152 << ", Channel layout: " << channel_layout_; | |
| 153 return true; | |
| 118 } | 154 } |
| 119 | 155 |
| 120 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const { | 156 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const { |
| 121 if (extension_frequency_ > 0) | 157 if (extension_frequency_ > 0) |
| 122 return extension_frequency_; | 158 return extension_frequency_; |
| 123 | 159 |
| 124 if (!sbr_in_mimetype) | 160 if (!sbr_in_mimetype) |
| 125 return frequency_; | 161 return frequency_; |
| 126 | 162 |
| 127 // 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 Part 3 Table 1.11 and |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 | 277 |
| 242 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 | 278 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 |
| 243 } | 279 } |
| 244 | 280 |
| 245 return true; | 281 return true; |
| 246 } | 282 } |
| 247 | 283 |
| 248 } // namespace mp4 | 284 } // namespace mp4 |
| 249 | 285 |
| 250 } // namespace media | 286 } // namespace media |
| OLD | NEW |