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

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

Issue 1226001: Merged VideoSurface, VideoFrame and VideoFrameImpl in VideoFrame. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « media/base/buffers.h ('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
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_
7
8 #include "media/base/buffers.h"
9
10 namespace media {
11
12 class VideoFrame : public StreamSample {
13 public:
14 static const size_t kMaxPlanes = 3;
15
16 static const size_t kNumRGBPlanes = 1;
17 static const size_t kRGBPlane = 0;
18
19 static const size_t kNumYUVPlanes = 3;
20 static const size_t kYPlane = 0;
21 static const size_t kUPlane = 1;
22 static const size_t kVPlane = 2;
23
24 // Surface formats roughly based on FOURCC labels, see:
25 // http://www.fourcc.org/rgb.php
26 // http://www.fourcc.org/yuv.php
27 enum Format {
28 INVALID, // Invalid format value. Used for error reporting.
29 RGB555, // 16bpp RGB packed 5:5:5
30 RGB565, // 16bpp RGB packed 5:6:5
31 RGB24, // 24bpp RGB packed 8:8:8
32 RGB32, // 32bpp RGB packed with extra byte 8:8:8
33 RGBA, // 32bpp RGBA packed 8:8:8:8
34 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples
35 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples
36 EMPTY, // An empty frame.
37 };
38
39 public:
40 // Creates a new frame with given parameters. Buffers for the frame are
41 // allocated but not initialized.
42 static void CreateFrame(Format format,
43 size_t width,
44 size_t height,
45 base::TimeDelta timestamp,
46 base::TimeDelta duration,
47 scoped_refptr<VideoFrame>* frame_out);
48
49 // Creates a frame with format equals to VideoFrame::EMPTY, width, height
50 // timestamp and duration are all 0.
51 static void CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out);
52
53 // Allocates YV12 frame based on |width| and |height|, and sets its data to
54 // the YUV equivalent of RGB(0,0,0).
55 static void CreateBlackFrame(int width, int height,
56 scoped_refptr<VideoFrame>* frame_out);
57
58 Format format() const { return format_; }
59
60 size_t width() const { return width_; }
61
62 size_t height() const { return height_; }
63
64 size_t planes() const { return planes_; }
65
66 int32 stride(size_t plane) const { return strides_[plane]; }
67
68 // Returns pointer to the buffer for a given plane. The memory is owned by
69 // VideoFrame object and must not be freed by the caller.
70 uint8* data(size_t plane) const { return data_[plane]; }
71
72 // StreamSample interface.
73 virtual bool IsEndOfStream() const;
74
75 private:
76 // Clients must use the static CreateFrame() method to create a new frame.
77 VideoFrame(Format format,
78 size_t video_width,
79 size_t video_height);
80
81 virtual ~VideoFrame();
82
83 // Used internally by CreateFrame().
84 bool AllocateRGB(size_t bytes_per_pixel);
85 bool AllocateYUV();
86
87 // Frame format.
88 Format format_;
89
90 // Width and height of surface.
91 size_t width_;
92 size_t height_;
93
94 // Number of planes, typically 1 for packed RGB formats and 3 for planar
95 // YUV formats.
96 size_t planes_;
97
98 // Array of strides for each plane, typically greater or equal to the width
99 // of the surface divided by the horizontal sampling period. Note that
100 // strides can be negative.
101 int32 strides_[kMaxPlanes];
102
103 // Array of data pointers to each plane.
104 uint8* data_[kMaxPlanes];
105
106 DISALLOW_COPY_AND_ASSIGN(VideoFrame);
107 };
108
109 } // namespace media
110
111 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « media/base/buffers.h ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698