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

Side by Side Diff: webrtc/common_video/include/video_frame_buffer.h

Issue 1885943004: Revert of Introduce an IsMutable method on VideoFrameBuffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 | « webrtc/common_video/i420_buffer_pool_unittest.cc ('k') | webrtc/common_video/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 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 15 matching lines...) Expand all
26 kYPlane = 0, 26 kYPlane = 0,
27 kUPlane = 1, 27 kUPlane = 1,
28 kVPlane = 2, 28 kVPlane = 2,
29 kNumOfPlanes = 3, 29 kNumOfPlanes = 3,
30 }; 30 };
31 31
32 // Interface of a simple frame buffer containing pixel data. This interface does 32 // Interface of a simple frame buffer containing pixel data. This interface does
33 // not contain any frame metadata such as rotation, timestamp, pixel_width, etc. 33 // not contain any frame metadata such as rotation, timestamp, pixel_width, etc.
34 class VideoFrameBuffer : public rtc::RefCountInterface { 34 class VideoFrameBuffer : public rtc::RefCountInterface {
35 public: 35 public:
36 // Returns true if the caller is exclusive owner, and allowed to 36 // Returns true if this buffer has a single exclusive owner.
37 // call MutableData.
38 virtual bool IsMutable() = 0;
39
40 // Underlying refcount access, used to implement IsMutable.
41 // TODO(nisse): Demote to protected, as soon as Chrome is changed to
42 // use IsMutable.
43 virtual bool HasOneRef() const = 0; 37 virtual bool HasOneRef() const = 0;
44 38
45 // The resolution of the frame in pixels. For formats where some planes are 39 // The resolution of the frame in pixels. For formats where some planes are
46 // subsampled, this is the highest-resolution plane. 40 // subsampled, this is the highest-resolution plane.
47 virtual int width() const = 0; 41 virtual int width() const = 0;
48 virtual int height() const = 0; 42 virtual int height() const = 0;
49 43
50 // Returns pointer to the pixel data for a given plane. The memory is owned by 44 // Returns pointer to the pixel data for a given plane. The memory is owned by
51 // the VideoFrameBuffer object and must not be freed by the caller. 45 // the VideoFrameBuffer object and must not be freed by the caller.
52 virtual const uint8_t* data(PlaneType type) const = 0; 46 virtual const uint8_t* data(PlaneType type) const = 0;
(...skipping 22 matching lines...) Expand all
75 public: 69 public:
76 I420Buffer(int width, int height); 70 I420Buffer(int width, int height);
77 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v); 71 I420Buffer(int width, int height, int stride_y, int stride_u, int stride_v);
78 void InitializeData(); 72 void InitializeData();
79 73
80 int width() const override; 74 int width() const override;
81 int height() const override; 75 int height() const override;
82 const uint8_t* data(PlaneType type) const override; 76 const uint8_t* data(PlaneType type) const override;
83 // Non-const data access is only allowed if HasOneRef() is true to protect 77 // Non-const data access is only allowed if HasOneRef() is true to protect
84 // against unexpected overwrites. 78 // against unexpected overwrites.
85 bool IsMutable() override;
86 uint8_t* MutableData(PlaneType type) override; 79 uint8_t* MutableData(PlaneType type) override;
87 int stride(PlaneType type) const override; 80 int stride(PlaneType type) const override;
88 void* native_handle() const override; 81 void* native_handle() const override;
89 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; 82 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
90 83
91 // Create a new buffer and copy the pixel data. 84 // Create a new buffer and copy the pixel data.
92 static rtc::scoped_refptr<I420Buffer> Copy( 85 static rtc::scoped_refptr<I420Buffer> Copy(
93 const rtc::scoped_refptr<VideoFrameBuffer>& buffer); 86 const rtc::scoped_refptr<VideoFrameBuffer>& buffer);
94 87
95 protected: 88 protected:
(...skipping 14 matching lines...) Expand all
110 // as their own destructors or conversion methods back to software I420). 103 // as their own destructors or conversion methods back to software I420).
111 class NativeHandleBuffer : public VideoFrameBuffer { 104 class NativeHandleBuffer : public VideoFrameBuffer {
112 public: 105 public:
113 NativeHandleBuffer(void* native_handle, int width, int height); 106 NativeHandleBuffer(void* native_handle, int width, int height);
114 107
115 int width() const override; 108 int width() const override;
116 int height() const override; 109 int height() const override;
117 const uint8_t* data(PlaneType type) const override; 110 const uint8_t* data(PlaneType type) const override;
118 int stride(PlaneType type) const override; 111 int stride(PlaneType type) const override;
119 void* native_handle() const override; 112 void* native_handle() const override;
120 bool IsMutable() override;
121 113
122 protected: 114 protected:
123 void* native_handle_; 115 void* native_handle_;
124 const int width_; 116 const int width_;
125 const int height_; 117 const int height_;
126 }; 118 };
127 119
128 class WrappedI420Buffer : public webrtc::VideoFrameBuffer { 120 class WrappedI420Buffer : public webrtc::VideoFrameBuffer {
129 public: 121 public:
130 WrappedI420Buffer(int width, 122 WrappedI420Buffer(int width,
131 int height, 123 int height,
132 const uint8_t* y_plane, 124 const uint8_t* y_plane,
133 int y_stride, 125 int y_stride,
134 const uint8_t* u_plane, 126 const uint8_t* u_plane,
135 int u_stride, 127 int u_stride,
136 const uint8_t* v_plane, 128 const uint8_t* v_plane,
137 int v_stride, 129 int v_stride,
138 const rtc::Callback0<void>& no_longer_used); 130 const rtc::Callback0<void>& no_longer_used);
139 int width() const override; 131 int width() const override;
140 int height() const override; 132 int height() const override;
141 133
142 bool IsMutable() override;
143
144 const uint8_t* data(PlaneType type) const override; 134 const uint8_t* data(PlaneType type) const override;
145 135
146 int stride(PlaneType type) const override; 136 int stride(PlaneType type) const override;
147 void* native_handle() const override; 137 void* native_handle() const override;
148 138
149 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; 139 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override;
150 140
151 private: 141 private:
152 friend class rtc::RefCountedObject<WrappedI420Buffer>; 142 friend class rtc::RefCountedObject<WrappedI420Buffer>;
153 ~WrappedI420Buffer() override; 143 ~WrappedI420Buffer() override;
(...skipping 12 matching lines...) Expand all
166 // Helper function to crop |buffer| without making a deep copy. May only be used 156 // Helper function to crop |buffer| without making a deep copy. May only be used
167 // for non-native frames. 157 // for non-native frames.
168 rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop( 158 rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop(
169 const rtc::scoped_refptr<VideoFrameBuffer>& buffer, 159 const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
170 int cropped_width, 160 int cropped_width,
171 int cropped_height); 161 int cropped_height);
172 162
173 } // namespace webrtc 163 } // namespace webrtc
174 164
175 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ 165 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/common_video/i420_buffer_pool_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698