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/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // of frames, in case fewer than requested were actually decoded. | 371 // of frames, in case fewer than requested were actually decoded. |
372 output = reinterpret_cast<AudioBuffer*>( | 372 output = reinterpret_cast<AudioBuffer*>( |
373 av_buffer_get_opaque(av_frame_->buf[0])); | 373 av_buffer_get_opaque(av_frame_->buf[0])); |
374 | 374 |
375 DCHECK_EQ(ChannelLayoutToChannelCount(config_.channel_layout()), | 375 DCHECK_EQ(ChannelLayoutToChannelCount(config_.channel_layout()), |
376 output->channel_count()); | 376 output->channel_count()); |
377 const int unread_frames = output->frame_count() - av_frame_->nb_samples; | 377 const int unread_frames = output->frame_count() - av_frame_->nb_samples; |
378 DCHECK_GE(unread_frames, 0); | 378 DCHECK_GE(unread_frames, 0); |
379 if (unread_frames > 0) | 379 if (unread_frames > 0) |
380 output->TrimEnd(unread_frames); | 380 output->TrimEnd(unread_frames); |
381 | |
382 av_frame_unref(av_frame_.get()); | 381 av_frame_unref(av_frame_.get()); |
383 } | 382 } |
384 | 383 |
385 // WARNING: |av_frame_| no longer has valid data at this point. | 384 // WARNING: |av_frame_| no longer has valid data at this point. |
386 const int decoded_frames = frame_decoded ? output->frame_count() : 0; | 385 const int decoded_frames = frame_decoded ? output->frame_count() : 0; |
387 if (IsEndOfStream(result, decoded_frames, buffer)) { | 386 if (IsEndOfStream(result, decoded_frames, buffer)) { |
388 DCHECK_EQ(packet.size, 0); | 387 DCHECK_EQ(packet.size, 0); |
389 queued_audio_.push_back(AudioBuffer::CreateEOSBuffer()); | 388 queued_audio_.push_back(AudioBuffer::CreateEOSBuffer()); |
390 } else if (discard_helper_->ProcessBuffers(buffer, output)) { | 389 } else if (discard_helper_->ProcessBuffers(buffer, output)) { |
391 queued_audio_.push_back(output); | 390 queued_audio_.push_back(output); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 | 453 |
455 ResetTimestampState(); | 454 ResetTimestampState(); |
456 return true; | 455 return true; |
457 } | 456 } |
458 | 457 |
459 void FFmpegAudioDecoder::ResetTimestampState() { | 458 void FFmpegAudioDecoder::ResetTimestampState() { |
460 discard_helper_->Reset(config_.codec_delay()); | 459 discard_helper_->Reset(config_.codec_delay()); |
461 } | 460 } |
462 | 461 |
463 } // namespace media | 462 } // namespace media |
OLD | NEW |