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

Unified Diff: media/filters/skcanvas_video_renderer.cc

Issue 901573004: Use the supplied memory for YUV decoding. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added optimized copy for well aligned planes Created 5 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/skcanvas_video_renderer.cc
diff --git a/media/filters/skcanvas_video_renderer.cc b/media/filters/skcanvas_video_renderer.cc
index 743efc04f648c8fc4171fb50d2909bd4858fdf70..7a18eaacc4cfb642402e6feef576df1008d3e2a4 100644
--- a/media/filters/skcanvas_video_renderer.cc
+++ b/media/filters/skcanvas_video_renderer.cc
@@ -390,8 +390,27 @@ class VideoImageGenerator : public SkImageGenerator {
(frame_->visible_rect().y() >> y_shift)) +
(frame_->visible_rect().x() >> 1);
}
- row_bytes[plane] = static_cast<size_t>(frame_->stride(plane));
- planes[plane] = frame_->data(plane) + offset;
+
+ // Copy the frame to the supplied memory.
+ // TODO: Find a way (API change?) to avoid this copy.
+ char* out_line = static_cast<char*>(planes[plane]);
+ int out_line_stride = row_bytes[plane];
+ uint8* in_line = frame_->data(plane) + offset;
+ int in_line_stride = frame_->stride(plane);
+ int plane_height = sizes[plane].height();
+ if (in_line_stride == out_line_stride) {
+ memcpy(out_line, in_line, plane_height * in_line_stride);
+ } else {
+ // Different line padding so need to copy one line at a time.
+ int bytes_to_copy_per_line = out_line_stride < in_line_stride
+ ? out_line_stride
+ : in_line_stride;
+ for (int line_no = 0; line_no < plane_height; line_no++) {
+ memcpy(out_line, in_line, bytes_to_copy_per_line);
+ in_line += in_line_stride;
+ out_line += out_line_stride;
+ }
+ }
}
}
return true;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698