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

Side by Side Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 251893002: Support start trimming post-decoding. Use it with FFmpegDemuxer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 422 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
423 DLOG(ERROR) << "Could not initialize audio decoder: " 423 DLOG(ERROR) << "Could not initialize audio decoder: "
424 << codec_context_->codec_id; 424 << codec_context_->codec_id;
425 ReleaseFFmpegResources(); 425 ReleaseFFmpegResources();
426 state_ = kUninitialized; 426 state_ = kUninitialized;
427 return false; 427 return false;
428 } 428 }
429 429
430 // Success! 430 // Success!
431 av_frame_.reset(av_frame_alloc()); 431 av_frame_.reset(av_frame_alloc());
432 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second())); 432 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(),
433 config_.codec_delay()));
433 av_sample_format_ = codec_context_->sample_fmt; 434 av_sample_format_ = codec_context_->sample_fmt;
434 435
435 if (codec_context_->channels != 436 if (codec_context_->channels !=
436 ChannelLayoutToChannelCount(config_.channel_layout())) { 437 ChannelLayoutToChannelCount(config_.channel_layout())) {
437 DLOG(ERROR) << "Audio configuration specified " 438 DLOG(ERROR) << "Audio configuration specified "
438 << ChannelLayoutToChannelCount(config_.channel_layout()) 439 << ChannelLayoutToChannelCount(config_.channel_layout())
439 << " channels, but FFmpeg thinks the file contains " 440 << " channels, but FFmpeg thinks the file contains "
440 << codec_context_->channels << " channels"; 441 << codec_context_->channels << " channels";
441 ReleaseFFmpegResources(); 442 ReleaseFFmpegResources();
442 state_ = kUninitialized; 443 state_ = kUninitialized;
443 return false; 444 return false;
444 } 445 }
445 446
446 ResetTimestampState(); 447 ResetTimestampState();
447 return true; 448 return true;
448 } 449 }
449 450
450 void FFmpegAudioDecoder::ResetTimestampState() { 451 void FFmpegAudioDecoder::ResetTimestampState() {
451 discard_helper_->Reset(config_.codec_delay()); 452 discard_helper_->Reset(config_.codec_delay());
452 } 453 }
453 454
454 } // namespace media 455 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698