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

Side by Side Diff: media/base/video_frame.h

Issue 10824141: Remove VideoDecoder::natural_size() & added VideoFrame::natural_size(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright year. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/video_decoder_config.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_ 6 #define MEDIA_BASE_VIDEO_FRAME_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "media/base/buffers.h" 10 #include "media/base/buffers.h"
11 #include "ui/gfx/size.h"
11 12
12 namespace media { 13 namespace media {
13 14
14 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { 15 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
15 public: 16 public:
16 enum { 17 enum {
17 kMaxPlanes = 3, 18 kMaxPlanes = 3,
18 19
19 kRGBPlane = 0, 20 kRGBPlane = 0,
20 21
(...skipping 11 matching lines...) Expand all
32 RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8 33 RGB32 = 4, // 32bpp RGB packed with extra byte 8:8:8
33 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples 34 YV12 = 6, // 12bpp YVU planar 1x1 Y, 2x2 VU samples
34 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples 35 YV16 = 7, // 16bpp YVU planar 1x1 Y, 2x1 VU samples
35 EMPTY = 9, // An empty frame. 36 EMPTY = 9, // An empty frame.
36 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples. 37 I420 = 11, // 12bpp YVU planar 1x1 Y, 2x2 UV samples.
37 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic. 38 NATIVE_TEXTURE = 12, // Native texture. Pixel-format agnostic.
38 }; 39 };
39 40
40 // Creates a new frame in system memory with given parameters. Buffers for 41 // Creates a new frame in system memory with given parameters. Buffers for
41 // the frame are allocated but not initialized. 42 // the frame are allocated but not initialized.
43 // |data_size| is the width and height of the frame data in pixels.
44 // |natural_size| is the width and height of the frame when the frame's aspect
45 // ratio is applied to |data_size|.
42 static scoped_refptr<VideoFrame> CreateFrame( 46 static scoped_refptr<VideoFrame> CreateFrame(
43 Format format, 47 Format format,
44 size_t width, 48 const gfx::Size& data_size,
45 size_t height, 49 const gfx::Size& natural_size,
46 base::TimeDelta timestamp); 50 base::TimeDelta timestamp);
47 51
48 // Call prior to CreateFrame to ensure validity of frame configuration. Called 52 // Call prior to CreateFrame to ensure validity of frame configuration. Called
49 // automatically by VideoDecoderConfig::IsValidConfig(). 53 // automatically by VideoDecoderConfig::IsValidConfig().
50 // TODO(scherkus): VideoDecoderConfig shouldn't call this method 54 // TODO(scherkus): VideoDecoderConfig shouldn't call this method
51 static bool IsValidConfig( 55 static bool IsValidConfig(Format format, const gfx::Size& data_size,
52 Format format, 56 const gfx::Size& natural_size);
53 size_t width,
54 size_t height);
55 57
56 // Wraps a native texture of the given parameters with a VideoFrame. When the 58 // Wraps a native texture of the given parameters with a VideoFrame. When the
57 // frame is destroyed |no_longer_needed.Run()| will be called. 59 // frame is destroyed |no_longer_needed.Run()| will be called.
60 // |data_size| is the width and height of the frame data in pixels.
61 // |natural_size| is the width and height of the frame when the frame's aspect
62 // ratio is applied to |size|.
58 static scoped_refptr<VideoFrame> WrapNativeTexture( 63 static scoped_refptr<VideoFrame> WrapNativeTexture(
59 uint32 texture_id, 64 uint32 texture_id,
60 uint32 texture_target, 65 uint32 texture_target,
61 size_t width, 66 const gfx::Size& data_size,
62 size_t height, 67 const gfx::Size& natural_size,
63 base::TimeDelta timestamp, 68 base::TimeDelta timestamp,
64 const base::Closure& no_longer_needed); 69 const base::Closure& no_longer_needed);
65 70
66 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, 71 // Creates a frame with format equals to VideoFrame::EMPTY, width, height,
67 // and timestamp are all 0. 72 // and timestamp are all 0.
68 static scoped_refptr<VideoFrame> CreateEmptyFrame(); 73 static scoped_refptr<VideoFrame> CreateEmptyFrame();
69 74
70 // Allocates YV12 frame based on |width| and |height|, and sets its data to 75 // Allocates YV12 frame based on |width| and |height|, and sets its data to
71 // the YUV equivalent of RGB(0,0,0). 76 // the YUV equivalent of RGB(0,0,0).
72 static scoped_refptr<VideoFrame> CreateBlackFrame(int width, int height); 77 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size);
73 78
74 Format format() const { return format_; } 79 Format format() const { return format_; }
75 80
76 size_t width() const { return width_; } 81 const gfx::Size& data_size() const { return data_size_; }
77 82 const gfx::Size& natural_size() const { return natural_size_; }
78 size_t height() const { return height_; }
79 83
80 int stride(size_t plane) const; 84 int stride(size_t plane) const;
81 85
82 // Returns the number of bytes per row and number of rows for a given plane. 86 // Returns the number of bytes per row and number of rows for a given plane.
83 // 87 //
84 // As opposed to stride(), row_bytes() refers to the bytes representing 88 // As opposed to stride(), row_bytes() refers to the bytes representing
85 // visible pixels. 89 // visible pixels.
86 int row_bytes(size_t plane) const; 90 int row_bytes(size_t plane) const;
87 int rows(size_t plane) const; 91 int rows(size_t plane) const;
88 92
(...skipping 19 matching lines...) Expand all
108 } 112 }
109 113
110 // Used to keep a running hash of seen frames. Expects an initialized MD5 114 // Used to keep a running hash of seen frames. Expects an initialized MD5
111 // context. Calls MD5Update with the context and the contents of the frame. 115 // context. Calls MD5Update with the context and the contents of the frame.
112 void HashFrameForTesting(base::MD5Context* context); 116 void HashFrameForTesting(base::MD5Context* context);
113 117
114 private: 118 private:
115 friend class base::RefCountedThreadSafe<VideoFrame>; 119 friend class base::RefCountedThreadSafe<VideoFrame>;
116 // Clients must use the static CreateFrame() method to create a new frame. 120 // Clients must use the static CreateFrame() method to create a new frame.
117 VideoFrame(Format format, 121 VideoFrame(Format format,
118 size_t video_width, 122 const gfx::Size& size,
119 size_t video_height, 123 const gfx::Size& natural_size,
120 base::TimeDelta timestamp); 124 base::TimeDelta timestamp);
121 virtual ~VideoFrame(); 125 virtual ~VideoFrame();
122 126
123 // Used internally by CreateFrame(). 127 // Used internally by CreateFrame().
124 void AllocateRGB(size_t bytes_per_pixel); 128 void AllocateRGB(size_t bytes_per_pixel);
125 void AllocateYUV(); 129 void AllocateYUV();
126 130
127 // Used to DCHECK() plane parameters. 131 // Used to DCHECK() plane parameters.
128 bool IsValidPlane(size_t plane) const; 132 bool IsValidPlane(size_t plane) const;
129 133
130 // Frame format. 134 // Frame format.
131 Format format_; 135 Format format_;
132 136
133 // Width and height of surface. 137 // Width and height of the video frame.
134 size_t width_; 138 gfx::Size data_size_;
135 size_t height_; 139
140 // Width and height of the video frame with aspect ratio taken
141 // into account.
142 gfx::Size natural_size_;
136 143
137 // Array of strides for each plane, typically greater or equal to the width 144 // Array of strides for each plane, typically greater or equal to the width
138 // of the surface divided by the horizontal sampling period. Note that 145 // of the surface divided by the horizontal sampling period. Note that
139 // strides can be negative. 146 // strides can be negative.
140 int32 strides_[kMaxPlanes]; 147 int32 strides_[kMaxPlanes];
141 148
142 // Array of data pointers to each plane. 149 // Array of data pointers to each plane.
143 uint8* data_[kMaxPlanes]; 150 uint8* data_[kMaxPlanes];
144 151
145 // Native texture ID, if this is a NATIVE_TEXTURE frame. 152 // Native texture ID, if this is a NATIVE_TEXTURE frame.
146 uint32 texture_id_; 153 uint32 texture_id_;
147 uint32 texture_target_; 154 uint32 texture_target_;
148 base::Closure texture_no_longer_needed_; 155 base::Closure texture_no_longer_needed_;
149 156
150 base::TimeDelta timestamp_; 157 base::TimeDelta timestamp_;
151 158
152 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 159 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
153 }; 160 };
154 161
155 } // namespace media 162 } // namespace media
156 163
157 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 164 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « media/base/video_decoder_config.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698