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

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

Issue 1260193005: Fix incorrect opus seek preroll and flaky pre-skip removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 5 years, 4 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 (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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const scoped_refptr<MediaLog>& media_log) 129 const scoped_refptr<MediaLog>& media_log)
130 : task_runner_(task_runner), 130 : task_runner_(task_runner),
131 state_(kUninitialized), 131 state_(kUninitialized),
132 av_sample_format_(0), 132 av_sample_format_(0),
133 media_log_(media_log) { 133 media_log_(media_log) {
134 } 134 }
135 135
136 FFmpegAudioDecoder::~FFmpegAudioDecoder() { 136 FFmpegAudioDecoder::~FFmpegAudioDecoder() {
137 DCHECK(task_runner_->BelongsToCurrentThread()); 137 DCHECK(task_runner_->BelongsToCurrentThread());
138 138
139 if (state_ != kUninitialized) { 139 if (state_ != kUninitialized)
140 ReleaseFFmpegResources(); 140 ReleaseFFmpegResources();
141 ResetTimestampState();
142 }
143 } 141 }
144 142
145 std::string FFmpegAudioDecoder::GetDisplayName() const { 143 std::string FFmpegAudioDecoder::GetDisplayName() const {
146 return "FFmpegAudioDecoder"; 144 return "FFmpegAudioDecoder";
147 } 145 }
148 146
149 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config, 147 void FFmpegAudioDecoder::Initialize(const AudioDecoderConfig& config,
150 const InitCB& init_cb, 148 const InitCB& init_cb,
151 const OutputCB& output_cb) { 149 const OutputCB& output_cb) {
152 DCHECK(task_runner_->BelongsToCurrentThread()); 150 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 362 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
365 DLOG(ERROR) << "Could not initialize audio decoder: " 363 DLOG(ERROR) << "Could not initialize audio decoder: "
366 << codec_context_->codec_id; 364 << codec_context_->codec_id;
367 ReleaseFFmpegResources(); 365 ReleaseFFmpegResources();
368 state_ = kUninitialized; 366 state_ = kUninitialized;
369 return false; 367 return false;
370 } 368 }
371 369
372 // Success! 370 // Success!
373 av_frame_.reset(av_frame_alloc()); 371 av_frame_.reset(av_frame_alloc());
374 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(), 372 discard_helper_.reset(new AudioDiscardHelper(config_.samples_per_second(),
chcunningham 2015/07/31 19:48:44 Move this into ResetTimestampState like you did fo
DaleCurtis 2015/08/03 22:49:53 Done.
375 config_.codec_delay())); 373 config_.codec_delay()));
376 av_sample_format_ = codec_context_->sample_fmt; 374 av_sample_format_ = codec_context_->sample_fmt;
377 375
378 if (codec_context_->channels != 376 if (codec_context_->channels !=
379 ChannelLayoutToChannelCount(config_.channel_layout())) { 377 ChannelLayoutToChannelCount(config_.channel_layout())) {
380 DLOG(ERROR) << "Audio configuration specified " 378 DLOG(ERROR) << "Audio configuration specified "
381 << ChannelLayoutToChannelCount(config_.channel_layout()) 379 << ChannelLayoutToChannelCount(config_.channel_layout())
382 << " channels, but FFmpeg thinks the file contains " 380 << " channels, but FFmpeg thinks the file contains "
383 << codec_context_->channels << " channels"; 381 << codec_context_->channels << " channels";
384 ReleaseFFmpegResources(); 382 ReleaseFFmpegResources();
385 state_ = kUninitialized; 383 state_ = kUninitialized;
386 return false; 384 return false;
387 } 385 }
388 386
389 ResetTimestampState(); 387 ResetTimestampState();
390 return true; 388 return true;
391 } 389 }
392 390
393 void FFmpegAudioDecoder::ResetTimestampState() { 391 void FFmpegAudioDecoder::ResetTimestampState() {
394 discard_helper_->Reset(config_.codec_delay()); 392 discard_helper_->Reset(config_.codec_delay());
395 } 393 }
396 394
397 } // namespace media 395 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698