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

Unified Diff: media/cast/video_receiver/codecs/vp8/vp8_decoder.cc

Issue 80383006: Cast: Forcing codec initialization on a designated thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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/cast/video_receiver/codecs/vp8/vp8_decoder.h ('k') | media/cast/video_receiver/video_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/video_receiver/codecs/vp8/vp8_decoder.cc
diff --git a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc
index bf56b0a2ad11896d851fd498b95e18de54fe8883..ecb7e63249b58d876cc47dd5976af51f2b464793 100644
--- a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc
+++ b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc
@@ -19,18 +19,20 @@ void LogFrameDecodedEvent(CastEnvironment* const cast_environment,
// 0, frame_id);
}
-Vp8Decoder::Vp8Decoder(int number_of_cores,
- scoped_refptr<CastEnvironment> cast_environment)
+Vp8Decoder::Vp8Decoder(scoped_refptr<CastEnvironment> cast_environment)
: decoder_(new vpx_dec_ctx_t()),
cast_environment_(cast_environment) {
- InitDecode(number_of_cores);
+ // Make sure that we initialize the decoder from the correct thread.
+ cast_environment_->PostTask(CastEnvironment::VIDEO_DECODER, FROM_HERE,
+ base::Bind(&Vp8Decoder::InitDecoder, base::Unretained(this)));
}
Vp8Decoder::~Vp8Decoder() {}
-void Vp8Decoder::InitDecode(int number_of_cores) {
- vpx_codec_dec_cfg_t cfg;
- cfg.threads = number_of_cores;
+void Vp8Decoder::InitDecoder() {
+ vpx_codec_dec_cfg_t cfg;
+ // Initializing to use one core.
+ cfg.threads = 1;
vpx_codec_flags_t flags = VPX_CODEC_USE_POSTPROC;
if (vpx_codec_dec_init(decoder_.get(), vpx_codec_vp8_dx(), &cfg, flags)) {
@@ -41,6 +43,7 @@ void Vp8Decoder::InitDecode(int number_of_cores) {
bool Vp8Decoder::Decode(const EncodedVideoFrame* encoded_frame,
const base::TimeTicks render_time,
const VideoFrameDecodedCallback& frame_decoded_cb) {
+ DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::VIDEO_DECODER));
const int frame_id_int = static_cast<int>(encoded_frame->frame_id);
VLOG(1) << "VP8 decode frame:" << frame_id_int
<< " sized:" << encoded_frame->data.size();
@@ -94,8 +97,8 @@ bool Vp8Decoder::Decode(const EncodedVideoFrame* encoded_frame,
// Log:: Decoding complete (should be called from the main thread).
cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, base::Bind(
LogFrameDecodedEvent, cast_environment_,encoded_frame->frame_id));
- VLOG(1) << "Decoded frame " << frame_id_int;
+ VLOG(1) << "Decoded frame " << frame_id_int;
// Frame decoded - return frame to the user via callback.
cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE,
base::Bind(frame_decoded_cb, base::Passed(&decoded_frame),
« no previous file with comments | « media/cast/video_receiver/codecs/vp8/vp8_decoder.h ('k') | media/cast/video_receiver/video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698