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

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

Issue 59753007: Passing frame decoded callback to the codec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 7 years, 1 month 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
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 26113cd3d6947f5185ec8e8af4c7bb540ec8965e..8069741655b5433424b0d1582dc44938af82fcf9 100644
--- a/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc
+++ b/media/cast/video_receiver/codecs/vp8/vp8_decoder.cc
@@ -4,14 +4,18 @@
#include "media/cast/video_receiver/codecs/vp8/vp8_decoder.h"
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "third_party/libvpx/source/libvpx/vpx/vp8dx.h"
namespace media {
namespace cast {
-Vp8Decoder::Vp8Decoder(int number_of_cores) {
- decoder_.reset(new vpx_dec_ctx_t());
+Vp8Decoder::Vp8Decoder(int number_of_cores,
+ scoped_refptr<CastEnvironment> cast_environment)
+ : decoder_(new vpx_dec_ctx_t()),
+ cast_environment_(cast_environment) {
InitDecode(number_of_cores);
}
@@ -27,18 +31,20 @@ void Vp8Decoder::InitDecode(int number_of_cores) {
}
}
-bool Vp8Decoder::Decode(const EncodedVideoFrame& input_image,
- I420VideoFrame* decoded_frame) {
- VLOG(1) << "VP8 decode frame:" << static_cast<int>(input_image.frame_id)
- << " sized:" << input_image.data.size();
+bool Vp8Decoder::Decode(const EncodedVideoFrame* encoded_frame,
+ const base::TimeTicks render_time,
+ const VideoFrameDecodedCallback&
+ frame_decoded_callback) {
+ VLOG(1) << "VP8 decode frame:" << static_cast<int>(encoded_frame->frame_id)
Alpha Left Google 2013/11/06 02:22:06 There's 3 static_cast<int> for the frame id. I'd d
mikhal 2013/11/06 18:29:16 Done.
+ << " sized:" << encoded_frame->data.size();
- if (input_image.data.empty()) return false;
+ if (encoded_frame->data.empty()) return false;
vpx_codec_iter_t iter = NULL;
vpx_image_t* img;
if (vpx_codec_decode(decoder_.get(),
- input_image.data.data(),
- static_cast<unsigned int>(input_image.data.size()),
+ encoded_frame->data.data(),
+ static_cast<unsigned int>(encoded_frame->data.size()),
0,
1 /* real time*/)) {
VLOG(1) << "Failed to decode VP8 frame.";
@@ -48,10 +54,12 @@ bool Vp8Decoder::Decode(const EncodedVideoFrame& input_image,
img = vpx_codec_get_frame(decoder_.get(), &iter);
if (img == NULL) {
VLOG(1) << "Skip rendering VP8 frame:"
- << static_cast<int>(input_image.frame_id);
+ << static_cast<int>(encoded_frame->frame_id);
return false;
}
+ scoped_ptr<I420VideoFrame> decoded_frame(new I420VideoFrame());
+
// The img is only valid until the next call to vpx_codec_decode.
// Populate the decoded image.
decoded_frame->width = img->d_w;
@@ -76,6 +84,13 @@ bool Vp8Decoder::Decode(const EncodedVideoFrame& input_image,
memcpy(decoded_frame->v_plane.data, img->planes[VPX_PLANE_V],
decoded_frame->v_plane.length);
+ // Return frame.
+ VLOG(1) << "Decoded frame " << static_cast<int>(encoded_frame->frame_id);
+ // Frame decoded - return frame to the user via callback.
+ cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE,
+ base::Bind(frame_decoded_callback,
+ base::Passed(&decoded_frame), render_time));
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698