| Index: trunk/src/media/filters/opus_audio_decoder.cc
|
| ===================================================================
|
| --- trunk/src/media/filters/opus_audio_decoder.cc (revision 264802)
|
| +++ trunk/src/media/filters/opus_audio_decoder.cc (working copy)
|
| @@ -253,6 +253,7 @@
|
| opus_decoder_(NULL),
|
| last_input_timestamp_(kNoTimestamp()),
|
| frames_to_discard_(0),
|
| + frame_delay_at_start_(0),
|
| start_input_timestamp_(kNoTimestamp()) {}
|
|
|
| void OpusAudioDecoder::Initialize(const AudioDecoderConfig& config,
|
| @@ -336,7 +337,7 @@
|
| start_input_timestamp_ = input->timestamp();
|
| if (last_input_timestamp_ == kNoTimestamp() &&
|
| input->timestamp() == start_input_timestamp_) {
|
| - frames_to_discard_ = config_.codec_delay();
|
| + frames_to_discard_ = frame_delay_at_start_;
|
| }
|
|
|
| last_input_timestamp_ = input->timestamp();
|
| @@ -390,13 +391,17 @@
|
| &opus_extra_data))
|
| return false;
|
|
|
| - if (config_.codec_delay() <= 0) {
|
| + // Convert from seconds to samples.
|
| + timestamp_offset_ = config_.codec_delay();
|
| + frame_delay_at_start_ = TimeDeltaToAudioFrames(config_.codec_delay(),
|
| + config_.samples_per_second());
|
| + if (timestamp_offset_ <= base::TimeDelta() || frame_delay_at_start_ < 0) {
|
| DLOG(ERROR) << "Invalid file. Incorrect value for codec delay: "
|
| - << config_.codec_delay();
|
| + << config_.codec_delay().InMicroseconds();
|
| return false;
|
| }
|
|
|
| - if (config_.codec_delay() != opus_extra_data.skip_samples) {
|
| + if (frame_delay_at_start_ != opus_extra_data.skip_samples) {
|
| DLOG(ERROR) << "Invalid file. Codec Delay in container does not match the "
|
| << "value in Opus Extra Data.";
|
| return false;
|
| @@ -491,12 +496,7 @@
|
| if (output_timestamp_helper_->base_timestamp() == kNoTimestamp() &&
|
| !input->end_of_stream()) {
|
| DCHECK(input->timestamp() != kNoTimestamp());
|
| - // Adjust the timestamp helper so the base timestamp is corrected for frames
|
| - // dropped due to codec delay.
|
| output_timestamp_helper_->SetBaseTimestamp(input->timestamp());
|
| - output_timestamp_helper_->SetBaseTimestamp(
|
| - input->timestamp() -
|
| - output_timestamp_helper_->GetFrameDuration(config_.codec_delay()));
|
| }
|
|
|
| // Trim off any extraneous allocation.
|
| @@ -529,7 +529,8 @@
|
| }
|
|
|
| // Assign timestamp and duration to the buffer.
|
| - output_buffer->get()->set_timestamp(output_timestamp_helper_->GetTimestamp());
|
| + output_buffer->get()->set_timestamp(
|
| + output_timestamp_helper_->GetTimestamp() - timestamp_offset_);
|
| output_buffer->get()->set_duration(
|
| output_timestamp_helper_->GetFrameDuration(frames_to_output));
|
| output_timestamp_helper_->AddFrames(frames_decoded);
|
|
|