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

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

Issue 1316273002: Updated AAC:Parse() to emit better error logs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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') | media/formats/mp4/aac_unittest.cc » ('J')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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"
wolenetz 2015/09/01 21:22:37 please add a unit test that exposes this log and v
msu.koo 2015/09/11 23:57:23 I understood your intention about this comments, b
wolenetz 2015/09/14 23:17:57 Is it true that Parse() would error first always?
msu.koo 2015/09/15 11:10:19 Done. and ditto'ed below.
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 Extension Sampling Frequency Index with value 0x"
wolenetz 2015/09/01 21:22:37 ditto
msu.koo 2015/09/11 23:57:23 ditto
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 "
wolenetz 2015/09/01 21:22:37 ditto
msu.koo 2015/09/11 23:57:23 ditto
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.");
wolenetz 2015/09/01 21:22:37 ditto
msu.koo 2015/09/11 23:57:23 This line is dead. removed.
wolenetz 2015/09/14 23:17:57 Acknowledged.
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_)
wolenetz 2015/09/01 21:22:37 ditto
msu.koo 2015/09/11 23:57:23 ditto
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 << ", Sampling frequency(Extension): " << extension_frequency_ << "Hz"
152 << ", Channel layout: " << channel_layout_;
153
154 return true;
118 } 155 }
119 156
120 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const { 157 int AAC::GetOutputSamplesPerSecond(bool sbr_in_mimetype) const {
121 if (extension_frequency_ > 0) 158 if (extension_frequency_ > 0)
122 return extension_frequency_; 159 return extension_frequency_;
123 160
124 if (!sbr_in_mimetype) 161 if (!sbr_in_mimetype)
125 return frequency_; 162 return frequency_;
126 163
127 // The following code is written according to ISO 14496 Part 3 Table 1.11 and 164 // 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
241 278
242 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 279 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3
243 } 280 }
244 281
245 return true; 282 return true;
246 } 283 }
247 284
248 } // namespace mp4 285 } // namespace mp4
249 286
250 } // namespace media 287 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/formats/mp4/aac_unittest.cc » ('j') | media/formats/mp4/aac_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698