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

Side by Side Diff: media/formats/mp2t/es_parser_adts.cc

Issue 2063443002: Return parsed sample frequency of ADTS header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SBR Created 4 years, 6 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
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/mp2t/es_parser_adts.h" 5 #include "media/formats/mp2t/es_parser_adts.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 void EsParserAdts::Flush() { 171 void EsParserAdts::Flush() {
172 } 172 }
173 173
174 void EsParserAdts::ResetInternal() { 174 void EsParserAdts::ResetInternal() {
175 last_audio_decoder_config_ = AudioDecoderConfig(); 175 last_audio_decoder_config_ = AudioDecoderConfig();
176 } 176 }
177 177
178 bool EsParserAdts::UpdateAudioConfiguration(const uint8_t* adts_header) { 178 bool EsParserAdts::UpdateAudioConfiguration(const uint8_t* adts_header) {
179 AudioDecoderConfig audio_decoder_config; 179 AudioDecoderConfig audio_decoder_config;
180 if (!ParseAdtsHeader(adts_header, sbr_in_mimetype_, &audio_decoder_config)) 180 size_t orig_sample_rate = 0;
181 if (!ParseAdtsHeader(adts_header, sbr_in_mimetype_, &audio_decoder_config,
182 &orig_sample_rate))
181 return false; 183 return false;
182 184
183 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { 185 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) {
184 DVLOG(1) << "Sampling frequency: " 186 DVLOG(1) << "Sampling frequency: "
185 << audio_decoder_config.samples_per_second() 187 << audio_decoder_config.samples_per_second()
186 << " SBR=" << sbr_in_mimetype_; 188 << " SBR=" << sbr_in_mimetype_;
187 DVLOG(1) << "Channel layout: " 189 DVLOG(1) << "Channel layout: "
188 << ChannelLayoutToString(audio_decoder_config.channel_layout()); 190 << ChannelLayoutToString(audio_decoder_config.channel_layout());
189 191
190 // For AAC audio with SBR (Spectral Band Replication) the sampling rate is 192 // For AAC audio with SBR (Spectral Band Replication) the sampling rate is
191 // doubled in ParseAdtsHeader above, but AudioTimestampHelper should still 193 // doubled in ParseAdtsHeader above, but AudioTimestampHelper should still
192 // use the original sample rate to compute audio timestamps and durations 194 // use the original sample rate to compute audio timestamps and durations
193 // correctly. 195 // correctly.
194 int samples_per_second = sbr_in_mimetype_ 196
195 ? audio_decoder_config.samples_per_second() / 2
196 : audio_decoder_config.samples_per_second();
197 // Reset the timestamp helper to use a new time scale. 197 // Reset the timestamp helper to use a new time scale.
198 if (audio_timestamp_helper_ && 198 if (audio_timestamp_helper_ &&
199 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { 199 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) {
200 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); 200 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp();
201 audio_timestamp_helper_.reset( 201 audio_timestamp_helper_.reset(new AudioTimestampHelper(orig_sample_rate));
202 new AudioTimestampHelper(samples_per_second));
203 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); 202 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp);
204 } else { 203 } else {
205 audio_timestamp_helper_.reset( 204 audio_timestamp_helper_.reset(new AudioTimestampHelper(orig_sample_rate));
206 new AudioTimestampHelper(samples_per_second));
207 } 205 }
208 // Audio config notification. 206 // Audio config notification.
209 last_audio_decoder_config_ = audio_decoder_config; 207 last_audio_decoder_config_ = audio_decoder_config;
210 new_audio_config_cb_.Run(audio_decoder_config); 208 new_audio_config_cb_.Run(audio_decoder_config);
211 } 209 }
212 210
213 return true; 211 return true;
214 } 212 }
215 213
216 } // namespace mp2t 214 } // namespace mp2t
217 } // namespace media 215 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698