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

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

Issue 1881933004: Introduce an IsMutable method on VideoFrameBuffer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. 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
92 uint8_t* I420Buffer::MutableData(PlaneType type) { 96 uint8_t* I420Buffer::MutableData(PlaneType type) {
93 RTC_DCHECK(HasOneRef()); 97 RTC_DCHECK(IsMutable());
94 return const_cast<uint8_t*>( 98 return const_cast<uint8_t*>(
95 static_cast<const VideoFrameBuffer*>(this)->data(type)); 99 static_cast<const VideoFrameBuffer*>(this)->data(type));
96 } 100 }
97 101
98 int I420Buffer::stride(PlaneType type) const { 102 int I420Buffer::stride(PlaneType type) const {
99 switch (type) { 103 switch (type) {
100 case kYPlane: 104 case kYPlane:
101 return stride_y_; 105 return stride_y_;
102 case kUPlane: 106 case kUPlane:
103 return stride_u_; 107 return stride_u_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 141
138 NativeHandleBuffer::NativeHandleBuffer(void* native_handle, 142 NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
139 int width, 143 int width,
140 int height) 144 int height)
141 : native_handle_(native_handle), width_(width), height_(height) { 145 : native_handle_(native_handle), width_(width), height_(height) {
142 RTC_DCHECK(native_handle != nullptr); 146 RTC_DCHECK(native_handle != nullptr);
143 RTC_DCHECK_GT(width, 0); 147 RTC_DCHECK_GT(width, 0);
144 RTC_DCHECK_GT(height, 0); 148 RTC_DCHECK_GT(height, 0);
145 } 149 }
146 150
151 bool NativeHandleBuffer::IsMutable() {
152 return false;
153 }
154
147 int NativeHandleBuffer::width() const { 155 int NativeHandleBuffer::width() const {
148 return width_; 156 return width_;
149 } 157 }
150 158
151 int NativeHandleBuffer::height() const { 159 int NativeHandleBuffer::height() const {
152 return height_; 160 return height_;
153 } 161 }
154 162
155 const uint8_t* NativeHandleBuffer::data(PlaneType type) const { 163 const uint8_t* NativeHandleBuffer::data(PlaneType type) const {
156 RTC_NOTREACHED(); // Should not be called. 164 RTC_NOTREACHED(); // Should not be called.
(...skipping 26 matching lines...) Expand all
183 y_stride_(y_stride), 191 y_stride_(y_stride),
184 u_stride_(u_stride), 192 u_stride_(u_stride),
185 v_stride_(v_stride), 193 v_stride_(v_stride),
186 no_longer_used_cb_(no_longer_used) { 194 no_longer_used_cb_(no_longer_used) {
187 } 195 }
188 196
189 WrappedI420Buffer::~WrappedI420Buffer() { 197 WrappedI420Buffer::~WrappedI420Buffer() {
190 no_longer_used_cb_(); 198 no_longer_used_cb_();
191 } 199 }
192 200
201 // Data owned by creator; never mutable.
202 bool WrappedI420Buffer::IsMutable() {
203 return false;
204 }
205
193 int WrappedI420Buffer::width() const { 206 int WrappedI420Buffer::width() const {
194 return width_; 207 return width_;
195 } 208 }
196 209
197 int WrappedI420Buffer::height() const { 210 int WrappedI420Buffer::height() const {
198 return height_; 211 return height_;
199 } 212 }
200 213
201 const uint8_t* WrappedI420Buffer::data(PlaneType type) const { 214 const uint8_t* WrappedI420Buffer::data(PlaneType type) const {
202 switch (type) { 215 switch (type) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x; 273 buffer->stride(kVPlane) * uv_offset_y + uv_offset_x;
261 return new rtc::RefCountedObject<WrappedI420Buffer>( 274 return new rtc::RefCountedObject<WrappedI420Buffer>(
262 cropped_width, cropped_height, 275 cropped_width, cropped_height,
263 y_plane, buffer->stride(kYPlane), 276 y_plane, buffer->stride(kYPlane),
264 u_plane, buffer->stride(kUPlane), 277 u_plane, buffer->stride(kUPlane),
265 v_plane, buffer->stride(kVPlane), 278 v_plane, buffer->stride(kVPlane),
266 rtc::KeepRefUntilDone(buffer)); 279 rtc::KeepRefUntilDone(buffer));
267 } 280 }
268 281
269 } // namespace webrtc 282 } // 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