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

Side by Side Diff: webrtc/common_video/video_frame_buffer.cc

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/video_frame.cc ('k') | webrtc/media/engine/webrtcvideoframe.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return data_.get() + stride_y_ * height_; 82 return data_.get() + stride_y_ * height_;
83 case kVPlane: 83 case kVPlane:
84 return data_.get() + stride_y_ * height_ + 84 return data_.get() + stride_y_ * height_ +
85 stride_u_ * ((height_ + 1) / 2); 85 stride_u_ * ((height_ + 1) / 2);
86 default: 86 default:
87 RTC_NOTREACHED(); 87 RTC_NOTREACHED();
88 return nullptr; 88 return nullptr;
89 } 89 }
90 } 90 }
91 91
92 bool I420Buffer::IsMutable() {
93 return HasOneRef();
94 }
95
96 uint8_t* I420Buffer::MutableData(PlaneType type) { 92 uint8_t* I420Buffer::MutableData(PlaneType type) {
97 RTC_DCHECK(IsMutable()); 93 RTC_DCHECK(HasOneRef());
98 return const_cast<uint8_t*>( 94 return const_cast<uint8_t*>(
99 static_cast<const VideoFrameBuffer*>(this)->data(type)); 95 static_cast<const VideoFrameBuffer*>(this)->data(type));
100 } 96 }
101 97
102 int I420Buffer::stride(PlaneType type) const { 98 int I420Buffer::stride(PlaneType type) const {
103 switch (type) { 99 switch (type) {
104 case kYPlane: 100 case kYPlane:
105 return stride_y_; 101 return stride_y_;
106 case kUPlane: 102 case kUPlane:
107 return stride_u_; 103 return stride_u_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 137
142 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, 138 NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
143 int width, 139 int width,
144 int height) 140 int height)
145 : native_handle_(native_handle), width_(width), height_(height) { 141 : native_handle_(native_handle), width_(width), height_(height) {
146 RTC_DCHECK(native_handle != nullptr); 142 RTC_DCHECK(native_handle != nullptr);
147 RTC_DCHECK_GT(width, 0); 143 RTC_DCHECK_GT(width, 0);
148 RTC_DCHECK_GT(height, 0); 144 RTC_DCHECK_GT(height, 0);
149 } 145 }
150 146
151 bool NativeHandleBuffer::IsMutable() {
152 return false;
153 }
154
155 int NativeHandleBuffer::width() const { 147 int NativeHandleBuffer::width() const {
156 return width_; 148 return width_;
157 } 149 }
158 150
159 int NativeHandleBuffer::height() const { 151 int NativeHandleBuffer::height() const {
160 return height_; 152 return height_;
161 } 153 }
162 154
163 const uint8_t* NativeHandleBuffer::data(PlaneType type) const { 155 const uint8_t* NativeHandleBuffer::data(PlaneType type) const {
164 RTC_NOTREACHED(); // Should not be called. 156 RTC_NOTREACHED(); // Should not be called.
(...skipping 26 matching lines...) Expand all
191 y_stride_(y_stride), 183 y_stride_(y_stride),
192 u_stride_(u_stride), 184 u_stride_(u_stride),
193 v_stride_(v_stride), 185 v_stride_(v_stride),
194 no_longer_used_cb_(no_longer_used) { 186 no_longer_used_cb_(no_longer_used) {
195 } 187 }
196 188
197 WrappedI420Buffer::~WrappedI420Buffer() { 189 WrappedI420Buffer::~WrappedI420Buffer() {
198 no_longer_used_cb_(); 190 no_longer_used_cb_();
199 } 191 }
200 192
201 // Data owned by creator; never mutable.
202 bool WrappedI420Buffer::IsMutable() {
203 return false;
204 }
205
206 int WrappedI420Buffer::width() const { 193 int WrappedI420Buffer::width() const {
207 return width_; 194 return width_;
208 } 195 }
209 196
210 int WrappedI420Buffer::height() const { 197 int WrappedI420Buffer::height() const {
211 return height_; 198 return height_;
212 } 199 }
213 200
214 const uint8_t* WrappedI420Buffer::data(PlaneType type) const { 201 const uint8_t* WrappedI420Buffer::data(PlaneType type) const {
215 switch (type) { 202 switch (type) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x; 260 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x;
274 return new rtc::RefCountedObject<WrappedI420Buffer>( 261 return new rtc::RefCountedObject<WrappedI420Buffer>(
275 cropped_width, cropped_height, 262 cropped_width, cropped_height,
276 y_plane, buffer->stride(kYPlane), 263 y_plane, buffer->stride(kYPlane),
277 u_plane, buffer->stride(kUPlane), 264 u_plane, buffer->stride(kUPlane),
278 v_plane, buffer->stride(kVPlane), 265 v_plane, buffer->stride(kVPlane),
279 rtc::KeepRefUntilDone(buffer)); 266 rtc::KeepRefUntilDone(buffer));
280 } 267 }
281 268
282 } // namespace webrtc 269 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/video_frame.cc ('k') | webrtc/media/engine/webrtcvideoframe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698