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

Unified Diff: media/filters/omx_video_decode_engine.cc

Issue 1669002: remove AVFrame Dependency (Closed)
Patch Set: more patch Created 10 years, 8 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/omx_video_decode_engine.h ('k') | media/filters/video_decode_engine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/omx_video_decode_engine.cc
diff --git a/media/filters/omx_video_decode_engine.cc b/media/filters/omx_video_decode_engine.cc
index 6b456b28126cbff2265accff7e38bfeb4066d504..e0db841f044c9ee13e7de4aa0e094348c100b86b 100644
--- a/media/filters/omx_video_decode_engine.cc
+++ b/media/filters/omx_video_decode_engine.cc
@@ -91,7 +91,7 @@ void OmxVideoDecodeEngine::OnHardwareError() {
// decoder. So when a read complete callback is received, a corresponding
// decode request must exist.
void OmxVideoDecodeEngine::DecodeFrame(Buffer* buffer,
- AVFrame* yuv_frame,
+ scoped_refptr<VideoFrame>* video_frame,
bool* got_result,
Task* done_cb) {
DCHECK_EQ(message_loop_, MessageLoop::current());
@@ -110,7 +110,7 @@ void OmxVideoDecodeEngine::DecodeFrame(Buffer* buffer,
// Enqueue the decode request and the associated buffer.
decode_request_queue_.push_back(
- DecodeRequest(yuv_frame, got_result, done_cb));
+ DecodeRequest(video_frame, got_result, done_cb));
// Submit a read request to the decoder.
omx_codec_->Read(NewCallback(this, &OmxVideoDecodeEngine::OnReadComplete));
@@ -178,46 +178,48 @@ void OmxVideoDecodeEngine::BufferReady(int buffer_id,
MergeBytesFrameQueue(buffer, size);
}
+ // Notify OmxCodec that we have finished using this buffer.
+ if (callback) {
+ callback->Run(buffer_id);
+ delete callback;
+ }
+
// We assume that when we receive a read complete callback from
// OmxCodec there was a read request made.
CHECK(!decode_request_queue_.empty());
- const DecodeRequest request = decode_request_queue_.front();
+ DecodeRequest request = decode_request_queue_.front();
decode_request_queue_.pop_front();
*request.got_result = false;
+ // Notify the read request to this object has been fulfilled.
+ AutoTaskRunner done_cb_runner(request.done_cb);
+
// Detect if we have received a full decoded frame.
if (DecodedFrameAvailable()) {
// |frame| carries the decoded frame.
scoped_ptr<YuvFrame> frame(yuv_frame_queue_.front());
yuv_frame_queue_.pop_front();
+
+ VideoFrame::CreateFrame(GetSurfaceFormat(),
+ width_, height_,
+ StreamSample::kInvalidTimestamp,
+ StreamSample::kInvalidTimestamp,
+ request.frame);
+ if (!request.frame->get()) {
+ // TODO(jiesun): this is also an error case handled as normal.
+ return;
+ }
*request.got_result = true;
- // TODO(ajwong): This is a memcpy(). Avoid this.
- // TODO(ajwong): This leaks memory. Fix by not using AVFrame.
+ // TODO(jiesun): Assume YUV 420 format.
const int pixels = width_ * height_;
- request.frame->data[0] = y_buffer_.get();
- request.frame->data[1] = u_buffer_.get();
- request.frame->data[2] = v_buffer_.get();
- request.frame->linesize[0] = width_;
- request.frame->linesize[1] = width_ / 2;
- request.frame->linesize[2] = width_ / 2;
-
- memcpy(request.frame->data[0], frame->data, pixels);
- memcpy(request.frame->data[1], frame->data + pixels,
+ memcpy((*request.frame)->data(VideoFrame::kYPlane), frame->data, pixels);
+ memcpy((*request.frame)->data(VideoFrame::kUPlane), frame->data + pixels,
pixels / 4);
- memcpy(request.frame->data[2],
+ memcpy((*request.frame)->data(VideoFrame::kVPlane),
frame->data + pixels + pixels /4,
pixels / 4);
}
-
- // Notify the read request to this object has been fulfilled.
- request.done_cb->Run();
-
- // Notify OmxCodec that we have finished using this buffer.
- if (callback) {
- callback->Run(buffer_id);
- delete callback;
- }
}
void OmxVideoDecodeEngine::OnReadComplete(
« no previous file with comments | « media/filters/omx_video_decode_engine.h ('k') | media/filters/video_decode_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698