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

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: Minor cleanup 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
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 // |size| is the width and height of the frame data in pixels.
Ami GONE FROM CHROMIUM 2012/08/02 17:34:45 This line does not tell me this is "coded size".
acolwell GONE FROM CHROMIUM 2012/08/02 20:20:21 Renamed to data_size as agreed in offline discussi
44 // |natural_size| is the width and height of the frame when the frame's aspect
45 // ratio is applied to |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& 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& size);
52 Format format,
53 size_t width,
54 size_t height);
55 56
56 // Wraps a native texture of the given parameters with a VideoFrame. When the 57 // Wraps a native texture of the given parameters with a VideoFrame. When the
57 // frame is destroyed |no_longer_needed.Run()| will be called. 58 // frame is destroyed |no_longer_needed.Run()| will be called.
59 // |size| is the width and height of the frame data in pixels.
Ami GONE FROM CHROMIUM 2012/08/02 17:34:45 ditto
acolwell GONE FROM CHROMIUM 2012/08/02 20:20:21 Done.
60 // |natural_size| is the width and height of the frame when the frame's aspect
61 // ratio is applied to |size|.
58 static scoped_refptr<VideoFrame> WrapNativeTexture( 62 static scoped_refptr<VideoFrame> WrapNativeTexture(
59 uint32 texture_id, 63 uint32 texture_id,
60 uint32 texture_target, 64 uint32 texture_target,
61 size_t width, 65 const gfx::Size& size,
62 size_t height, 66 const gfx::Size& natural_size,
63 base::TimeDelta timestamp, 67 base::TimeDelta timestamp,
64 const base::Closure& no_longer_needed); 68 const base::Closure& no_longer_needed);
65 69
66 // Creates a frame with format equals to VideoFrame::EMPTY, width, height, 70 // Creates a frame with format equals to VideoFrame::EMPTY, width, height,
67 // and timestamp are all 0. 71 // and timestamp are all 0.
68 static scoped_refptr<VideoFrame> CreateEmptyFrame(); 72 static scoped_refptr<VideoFrame> CreateEmptyFrame();
69 73
70 // Allocates YV12 frame based on |width| and |height|, and sets its data to 74 // Allocates YV12 frame based on |width| and |height|, and sets its data to
71 // the YUV equivalent of RGB(0,0,0). 75 // the YUV equivalent of RGB(0,0,0).
72 static scoped_refptr<VideoFrame> CreateBlackFrame(int width, int height); 76 static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size);
73 77
74 Format format() const { return format_; } 78 Format format() const { return format_; }
75 79
76 size_t width() const { return width_; } 80 const gfx::Size& size() const { return size_; }
Ami GONE FROM CHROMIUM 2012/08/02 17:34:45 ditto
acolwell GONE FROM CHROMIUM 2012/08/02 20:20:21 Done.
77 81 const gfx::Size& natural_size() const { return natural_size_; }
78 size_t height() const { return height_; }
79 82
80 int stride(size_t plane) const; 83 int stride(size_t plane) const;
81 84
82 // Returns the number of bytes per row and number of rows for a given plane. 85 // Returns the number of bytes per row and number of rows for a given plane.
83 // 86 //
84 // As opposed to stride(), row_bytes() refers to the bytes representing 87 // As opposed to stride(), row_bytes() refers to the bytes representing
85 // visible pixels. 88 // visible pixels.
86 int row_bytes(size_t plane) const; 89 int row_bytes(size_t plane) const;
87 int rows(size_t plane) const; 90 int rows(size_t plane) const;
88 91
(...skipping 19 matching lines...) Expand all
108 } 111 }
109 112
110 // Used to keep a running hash of seen frames. Expects an initialized MD5 113 // 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. 114 // context. Calls MD5Update with the context and the contents of the frame.
112 void HashFrameForTesting(base::MD5Context* context); 115 void HashFrameForTesting(base::MD5Context* context);
113 116
114 private: 117 private:
115 friend class base::RefCountedThreadSafe<VideoFrame>; 118 friend class base::RefCountedThreadSafe<VideoFrame>;
116 // Clients must use the static CreateFrame() method to create a new frame. 119 // Clients must use the static CreateFrame() method to create a new frame.
117 VideoFrame(Format format, 120 VideoFrame(Format format,
118 size_t video_width, 121 const gfx::Size& size,
Ami GONE FROM CHROMIUM 2012/08/02 17:34:45 ditto
acolwell GONE FROM CHROMIUM 2012/08/02 20:20:21 Done.
119 size_t video_height, 122 const gfx::Size& natural_size,
120 base::TimeDelta timestamp); 123 base::TimeDelta timestamp);
121 virtual ~VideoFrame(); 124 virtual ~VideoFrame();
122 125
123 // Used internally by CreateFrame(). 126 // Used internally by CreateFrame().
124 void AllocateRGB(size_t bytes_per_pixel); 127 void AllocateRGB(size_t bytes_per_pixel);
125 void AllocateYUV(); 128 void AllocateYUV();
126 129
127 // Used to DCHECK() plane parameters. 130 // Used to DCHECK() plane parameters.
128 bool IsValidPlane(size_t plane) const; 131 bool IsValidPlane(size_t plane) const;
129 132
130 // Frame format. 133 // Frame format.
131 Format format_; 134 Format format_;
132 135
133 // Width and height of surface. 136 // Width and height of the video frame.
Ami GONE FROM CHROMIUM 2012/08/02 17:34:45 ditto
acolwell GONE FROM CHROMIUM 2012/08/02 20:20:21 Done.
134 size_t width_; 137 gfx::Size size_;
135 size_t height_; 138
139 // Width and height of the video frame with aspect ratio taken
140 // into account.
141 gfx::Size natural_size_;
136 142
137 // Array of strides for each plane, typically greater or equal to the width 143 // 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 144 // of the surface divided by the horizontal sampling period. Note that
139 // strides can be negative. 145 // strides can be negative.
140 int32 strides_[kMaxPlanes]; 146 int32 strides_[kMaxPlanes];
141 147
142 // Array of data pointers to each plane. 148 // Array of data pointers to each plane.
143 uint8* data_[kMaxPlanes]; 149 uint8* data_[kMaxPlanes];
144 150
145 // Native texture ID, if this is a NATIVE_TEXTURE frame. 151 // Native texture ID, if this is a NATIVE_TEXTURE frame.
146 uint32 texture_id_; 152 uint32 texture_id_;
147 uint32 texture_target_; 153 uint32 texture_target_;
148 base::Closure texture_no_longer_needed_; 154 base::Closure texture_no_longer_needed_;
149 155
150 base::TimeDelta timestamp_; 156 base::TimeDelta timestamp_;
151 157
152 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 158 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
153 }; 159 };
154 160
155 } // namespace media 161 } // namespace media
156 162
157 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 163 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698