summaryrefslogtreecommitdiffstats
path: root/media/base/video_frame.h
diff options
context:
space:
mode:
authorsheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 22:01:21 +0000
committersheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 22:01:21 +0000
commitd418203614fe5aacf0f2e03fe21644218c1e4f10 (patch)
tree86ce1fc632d7c258f677fabbfa435491afdf1083 /media/base/video_frame.h
parent309ad6ae56d328c58867bed9567d2045cfa49673 (diff)
downloadchromium_src-d418203614fe5aacf0f2e03fe21644218c1e4f10.zip
chromium_src-d418203614fe5aacf0f2e03fe21644218c1e4f10.tar.gz
chromium_src-d418203614fe5aacf0f2e03fe21644218c1e4f10.tar.bz2
Plumb through cropped output size for VideoFrame
The video playback path needs to be able to handle cropped video frames, e.g. for HW decoders that output to macroblock-rounded buffer sizes. * Composite only the visible subrect from WebVideoFrame in cc::VideoLayerImpl * Remove some extraneous cropping logic from cc::VideoLayerImpl now that we have exact cropping info. * media::VideoFrame replaces "data_size_" member with "coded_size_", and adds a "visible_rect_" gfx::Rect to indicate the sub-rect of the entire frame that should be visible (after cropping) * Associated changes to various decoder/capture pipelines to plumb this through. TEST=build, run on x86, ARM BUG=155416,140509,chrome-os-partner:15230 Change-Id: I284bc893959db427bc9ae677aed8b07292d228ae Review URL: https://chromiumcodereview.appspot.com/11269017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166988 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/video_frame.h')
-rw-r--r--media/base/video_frame.h43
1 files changed, 28 insertions, 15 deletions
diff --git a/media/base/video_frame.h b/media/base/video_frame.h
index 0840839..effdafd 100644
--- a/media/base/video_frame.h
+++ b/media/base/video_frame.h
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/md5.h"
#include "media/base/buffers.h"
+#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
namespace media {
@@ -40,19 +41,23 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Creates a new frame in system memory with given parameters. Buffers for
// the frame are allocated but not initialized.
- // |data_size| is the width and height of the frame data in pixels.
+ // |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.
// |natural_size| is the width and height of the frame when the frame's aspect
- // ratio is applied to |data_size|.
+ // ratio is applied to |visible_rect|.
static scoped_refptr<VideoFrame> CreateFrame(
Format format,
- const gfx::Size& data_size,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp);
// Call prior to CreateFrame to ensure validity of frame configuration. Called
// automatically by VideoDecoderConfig::IsValidConfig().
// TODO(scherkus): VideoDecoderConfig shouldn't call this method
- static bool IsValidConfig(Format format, const gfx::Size& data_size,
+ static bool IsValidConfig(Format format, const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
const gfx::Size& natural_size);
// CB to write pixels from the texture backing this frame into the
@@ -61,15 +66,18 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Wraps a native texture of the given parameters with a VideoFrame. When the
// frame is destroyed |no_longer_needed.Run()| will be called.
- // |data_size| is the width and height of the frame data in pixels.
+ // |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.
// |natural_size| is the width and height of the frame when the frame's aspect
- // ratio is applied to |size|.
+ // ratio is applied to |visible_rect|.
// |read_pixels_cb| may be used to do (slow!) readbacks from the
// texture to main memory.
static scoped_refptr<VideoFrame> WrapNativeTexture(
uint32 texture_id,
uint32 texture_target,
- const gfx::Size& data_size,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp,
const ReadPixelsCB& read_pixels_cb,
@@ -77,7 +85,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// 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*data_size().width()*data_size().height().
+ // least as large as 4*visible_rect().width()*visible_rect().height().
void ReadPixelsFromNativeTexture(void* pixels);
// Creates a frame with format equals to VideoFrame::EMPTY, width, height,
@@ -86,7 +94,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Allocates YV12 frame based on |size|, and sets its data to the YUV(y,u,v).
static scoped_refptr<VideoFrame> CreateColorFrame(
- const gfx::Size& data_size,
+ const gfx::Size& size,
uint8 y, uint8 u, uint8 v,
base::TimeDelta timestamp);
@@ -96,7 +104,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
Format format() const { return format_; }
- const gfx::Size& data_size() const { return data_size_; }
+ const gfx::Size& coded_size() const { return coded_size_; }
+ const gfx::Rect& visible_rect() const { return visible_rect_; }
const gfx::Size& natural_size() const { return natural_size_; }
int stride(size_t plane) const;
@@ -104,7 +113,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
// Returns the number of bytes per row and number of rows for a given plane.
//
// As opposed to stride(), row_bytes() refers to the bytes representing
- // visible pixels.
+ // frame data scanlines (coded_size.width() pixels, without stride padding).
int row_bytes(size_t plane) const;
int rows(size_t plane) const;
@@ -137,7 +146,8 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
friend class base::RefCountedThreadSafe<VideoFrame>;
// Clients must use the static CreateFrame() method to create a new frame.
VideoFrame(Format format,
- const gfx::Size& size,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
const gfx::Size& natural_size,
base::TimeDelta timestamp);
virtual ~VideoFrame();
@@ -153,10 +163,13 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
Format format_;
// Width and height of the video frame.
- gfx::Size data_size_;
+ gfx::Size coded_size_;
- // Width and height of the video frame with aspect ratio taken
- // into account.
+ // Width, height, and offsets of the visible portion of the video frame.
+ gfx::Rect visible_rect_;
+
+ // Width and height of the visible portion of the video frame with aspect
+ // ratio taken into account.
gfx::Size natural_size_;
// Array of strides for each plane, typically greater or equal to the width