OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/filters/ffmpeg_audio_decoder.h" | 5 #include "media/filters/ffmpeg_audio_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 if (last_input_timestamp_ == kNoTimestamp()) { | 193 if (last_input_timestamp_ == kNoTimestamp()) { |
194 if (is_vorbis && (input->GetTimestamp() < base::TimeDelta())) { | 194 if (is_vorbis && (input->GetTimestamp() < base::TimeDelta())) { |
195 // Dropping frames for negative timestamps as outlined in section A.2 | 195 // Dropping frames for negative timestamps as outlined in section A.2 |
196 // in the Vorbis spec. http://xiph.org/vorbis/doc/Vorbis_I_spec.html | 196 // in the Vorbis spec. http://xiph.org/vorbis/doc/Vorbis_I_spec.html |
197 int frames_to_drop = floor( | 197 int frames_to_drop = floor( |
198 0.5 + -input->GetTimestamp().InSecondsF() * samples_per_second_); | 198 0.5 + -input->GetTimestamp().InSecondsF() * samples_per_second_); |
199 output_bytes_to_drop_ = bytes_per_frame_ * frames_to_drop; | 199 output_bytes_to_drop_ = bytes_per_frame_ * frames_to_drop; |
200 } else { | 200 } else { |
201 last_input_timestamp_ = input->GetTimestamp(); | 201 last_input_timestamp_ = input->GetTimestamp(); |
202 } | 202 } |
203 } else if (input->GetTimestamp() < last_input_timestamp_) { | 203 } else if (input->GetTimestamp() != kNoTimestamp()) { |
204 base::TimeDelta diff = input->GetTimestamp() - last_input_timestamp_; | 204 if (input->GetTimestamp() < last_input_timestamp_) { |
205 DVLOG(1) << "Input timestamps are not monotonically increasing! " | 205 base::TimeDelta diff = input->GetTimestamp() - last_input_timestamp_; |
206 << " ts " << input->GetTimestamp().InMicroseconds() << " us" | 206 DVLOG(1) << "Input timestamps are not monotonically increasing! " |
207 << " diff " << diff.InMicroseconds() << " us"; | 207 << " ts " << input->GetTimestamp().InMicroseconds() << " us" |
208 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); | 208 << " diff " << diff.InMicroseconds() << " us"; |
209 return; | 209 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); |
| 210 return; |
| 211 } |
| 212 |
| 213 last_input_timestamp_ = input->GetTimestamp(); |
210 } | 214 } |
211 } | 215 } |
212 | 216 |
213 AVPacket packet; | 217 AVPacket packet; |
214 av_init_packet(&packet); | 218 av_init_packet(&packet); |
215 packet.data = const_cast<uint8*>(input->GetData()); | 219 packet.data = const_cast<uint8*>(input->GetData()); |
216 packet.size = input->GetDataSize(); | 220 packet.size = input->GetDataSize(); |
217 | 221 |
218 PipelineStatistics statistics; | 222 PipelineStatistics statistics; |
219 statistics.audio_bytes_decoded = input->GetDataSize(); | 223 statistics.audio_bytes_decoded = input->GetDataSize(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 &FFmpegAudioDecoder::DoDecodeBuffer, this, status, buffer)); | 332 &FFmpegAudioDecoder::DoDecodeBuffer, this, status, buffer)); |
329 } | 333 } |
330 | 334 |
331 base::TimeDelta FFmpegAudioDecoder::GetNextOutputTimestamp() const { | 335 base::TimeDelta FFmpegAudioDecoder::GetNextOutputTimestamp() const { |
332 DCHECK(output_timestamp_base_ != kNoTimestamp()); | 336 DCHECK(output_timestamp_base_ != kNoTimestamp()); |
333 double decoded_us = (total_frames_decoded_ / samples_per_second_) * | 337 double decoded_us = (total_frames_decoded_ / samples_per_second_) * |
334 base::Time::kMicrosecondsPerSecond; | 338 base::Time::kMicrosecondsPerSecond; |
335 return output_timestamp_base_ + base::TimeDelta::FromMicroseconds(decoded_us); | 339 return output_timestamp_base_ + base::TimeDelta::FromMicroseconds(decoded_us); |
336 } | 340 } |
337 } // namespace media | 341 } // namespace media |
OLD | NEW |