summaryrefslogtreecommitdiffstats
path: root/media/base/video_frame.h
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 22:21:47 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-29 22:21:47 +0000
commitbeecad254659b4f8ae525f44efe08cb33fff0551 (patch)
tree71609939e839c27bd500b42ef550e46c0637069a /media/base/video_frame.h
parenta30b9400a39eaf92ce1a1f0770c725255542deaa (diff)
downloadchromium_src-beecad254659b4f8ae525f44efe08cb33fff0551.zip
chromium_src-beecad254659b4f8ae525f44efe08cb33fff0551.tar.gz
chromium_src-beecad254659b4f8ae525f44efe08cb33fff0551.tar.bz2
Encrypted Media: Remove memcpy of decoded video frame in ContentDecryptorDelegate.
Memory copy of decoded video frame is expensive and unnecessary. This CL wraps the decoded YUV data into media::VideoFrame directly without copying any data. The VideoFrame does not own the YUV data passed in. When the YUV data is no longer needed, VideoFrame notifies the owner of that data by calling no_longer_needed_cb. On Linux debug build, this saves about 0.6ms per frame. On slower (memory bandwidth limited) platforms the saving can be even larger. BUG=162193 TEST=test passes and EME demo still works. Review URL: https://chromiumcodereview.appspot.com/11316211 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/video_frame.h')
-rw-r--r--media/base/video_frame.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index effdafd..09e6b43 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -65,7 +65,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
typedef base::Callback<void(void*)> ReadPixelsCB;
// Wraps a native texture of the given parameters with a VideoFrame. When the
- // frame is destroyed |no_longer_needed.Run()| will be called.
+ // frame is destroyed |no_longer_needed_cb.Run()| will be called.
// |coded_size| is the width and height of the frame data in pixels.
// |visible_rect| is the visible portion of |coded_size|, after cropping (if
// any) is applied.
@@ -81,13 +81,30 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
const gfx::Size& natural_size,
base::TimeDelta timestamp,
const ReadPixelsCB& read_pixels_cb,
- const base::Closure& no_longer_needed);
+ const base::Closure& no_longer_needed_cb);
// Read pixels from the native texture backing |*this| and write
// them to |*pixels| as BGRA. |pixels| must point to a buffer at
// least as large as 4*visible_rect().width()*visible_rect().height().
void ReadPixelsFromNativeTexture(void* pixels);
+ // Wraps external YUV data of the given parameters with a VideoFrame.
+ // The returned VideoFrame does not own the data passed in. When the frame
+ // is destroyed |no_longer_needed_cb.Run()| will be called.
+ static scoped_refptr<VideoFrame> WrapExternalYuvData(
+ Format format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ int32 y_stride,
+ int32 u_stride,
+ int32 v_stride,
+ uint8* y_data,
+ uint8* u_data,
+ uint8* v_data,
+ base::TimeDelta timestamp,
+ const base::Closure& no_longer_needed_cb);
+
// Creates a frame with format equals to VideoFrame::EMPTY, width, height,
// and timestamp are all 0.
static scoped_refptr<VideoFrame> CreateEmptyFrame();
@@ -184,7 +201,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
uint32 texture_id_;
uint32 texture_target_;
ReadPixelsCB read_pixels_cb_;
- base::Closure texture_no_longer_needed_;
+
+ base::Closure no_longer_needed_cb_;
base::TimeDelta timestamp_;