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

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: Responding to review 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..0cad6ca0563f3b4604654712e81a934e75bff7d8 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_cb) {
Alpha Left Google 2013/11/06 18:41:49 I'm sorry but this should be a const ref, you were
mikhal 2013/11/06 18:53:07 Done.
+ int frame_id_int = static_cast<int>(encoded_frame->frame_id);
Alpha Left Google 2013/11/06 18:41:49 nit: const int frame_id_int.
mikhal 2013/11/06 18:53:07 Done.
+ VLOG(1) << "VP8 decode frame:" << frame_id_int
+ << " 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.";
@@ -47,11 +53,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);
+ VLOG(1) << "Skip rendering VP8 frame:" << frame_id_int;
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 +83,12 @@ 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 " << 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), render_time));
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698