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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 2871263003: Set |config_| only after decoder has been successfully configured (Closed)
Patch Set: fixed unittests Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_video_decoder.cc
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index 094720566e1eaa7cb03ff02a8784fec0c325231d..427eab6dd722f6676ed8ffbef778505289290b78 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -240,18 +240,15 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
}
FFmpegGlue::InitializeFFmpeg();
- config_ = config;
- // TODO(xhwang): Only set |config_| after we successfully configure the
- // decoder.
- if (!ConfigureDecoder(low_delay)) {
+ if (!ConfigureDecoder(config, low_delay)) {
bound_init_cb.Run(false);
return;
}
- output_cb_ = output_cb;
-
// Success!
+ config_ = config;
+ output_cb_ = output_cb;
state_ = kNormal;
bound_init_cb.Run(true);
}
@@ -407,18 +404,19 @@ void FFmpegVideoDecoder::ReleaseFFmpegResources() {
av_frame_.reset();
}
-bool FFmpegVideoDecoder::ConfigureDecoder(bool low_delay) {
- DCHECK(config_.IsValidConfig());
- DCHECK(!config_.is_encrypted());
+bool FFmpegVideoDecoder::ConfigureDecoder(const VideoDecoderConfig& config,
+ bool low_delay) {
+ DCHECK(config.IsValidConfig());
+ DCHECK(!config.is_encrypted());
// Release existing decoder resources if necessary.
ReleaseFFmpegResources();
// Initialize AVCodecContext structure.
codec_context_.reset(avcodec_alloc_context3(NULL));
- VideoDecoderConfigToAVCodecContext(config_, codec_context_.get());
+ VideoDecoderConfigToAVCodecContext(config, codec_context_.get());
- codec_context_->thread_count = GetThreadCount(config_);
+ codec_context_->thread_count = GetThreadCount(config);
codec_context_->thread_type =
FF_THREAD_SLICE | (low_delay ? 0 : FF_THREAD_FRAME);
codec_context_->opaque = this;
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698