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

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

Issue 1983583002: Revert of Delete webrtc::VideoFrame methods buffer and stride. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/libyuv/webrtc_libyuv.cc ('k') | webrtc/media/engine/webrtcvideoengine2.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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Creating empty frame - reset all values. 62 // Creating empty frame - reset all values.
63 timestamp_ = 0; 63 timestamp_ = 0;
64 ntp_time_ms_ = 0; 64 ntp_time_ms_ = 0;
65 render_time_ms_ = 0; 65 render_time_ms_ = 0;
66 rotation_ = kVideoRotation_0; 66 rotation_ = kVideoRotation_0;
67 67
68 // Check if it's safe to reuse allocation. 68 // Check if it's safe to reuse allocation.
69 if (video_frame_buffer_ && video_frame_buffer_->IsMutable() && 69 if (video_frame_buffer_ && video_frame_buffer_->IsMutable() &&
70 !video_frame_buffer_->native_handle() && 70 !video_frame_buffer_->native_handle() &&
71 width == video_frame_buffer_->width() && 71 width == video_frame_buffer_->width() &&
72 height == video_frame_buffer_->height() && 72 height == video_frame_buffer_->height() && stride_y == stride(kYPlane) &&
73 stride_y == video_frame_buffer_->StrideY() && 73 stride_u == stride(kUPlane) && stride_v == stride(kVPlane)) {
74 stride_u == video_frame_buffer_->StrideU() &&
75 stride_v == video_frame_buffer_->StrideV()) {
76 return; 74 return;
77 } 75 }
78 76
79 // Need to allocate new buffer. 77 // Need to allocate new buffer.
80 video_frame_buffer_ = new rtc::RefCountedObject<I420Buffer>( 78 video_frame_buffer_ = new rtc::RefCountedObject<I420Buffer>(
81 width, height, stride_y, stride_u, stride_v); 79 width, height, stride_y, stride_u, stride_v);
82 } 80 }
83 81
84 void VideoFrame::CreateFrame(const uint8_t* buffer_y, 82 void VideoFrame::CreateFrame(const uint8_t* buffer_y,
85 const uint8_t* buffer_u, 83 const uint8_t* buffer_u,
86 const uint8_t* buffer_v, 84 const uint8_t* buffer_v,
87 int width, 85 int width,
88 int height, 86 int height,
89 int stride_y, 87 int stride_y,
90 int stride_u, 88 int stride_u,
91 int stride_v, 89 int stride_v,
92 VideoRotation rotation) { 90 VideoRotation rotation) {
93 const int half_height = (height + 1) / 2; 91 const int half_height = (height + 1) / 2;
94 const int expected_size_y = height * stride_y; 92 const int expected_size_y = height * stride_y;
95 const int expected_size_u = half_height * stride_u; 93 const int expected_size_u = half_height * stride_u;
96 const int expected_size_v = half_height * stride_v; 94 const int expected_size_v = half_height * stride_v;
97 CreateEmptyFrame(width, height, stride_y, stride_u, stride_v); 95 CreateEmptyFrame(width, height, stride_y, stride_u, stride_v);
98 memcpy(video_frame_buffer_->MutableDataY(), buffer_y, expected_size_y); 96 memcpy(buffer(kYPlane), buffer_y, expected_size_y);
99 memcpy(video_frame_buffer_->MutableDataU(), buffer_u, expected_size_u); 97 memcpy(buffer(kUPlane), buffer_u, expected_size_u);
100 memcpy(video_frame_buffer_->MutableDataV(), buffer_v, expected_size_v); 98 memcpy(buffer(kVPlane), buffer_v, expected_size_v);
101 rotation_ = rotation; 99 rotation_ = rotation;
102 } 100 }
103 101
104 void VideoFrame::CreateFrame(const uint8_t* buffer, 102 void VideoFrame::CreateFrame(const uint8_t* buffer,
105 int width, 103 int width,
106 int height, 104 int height,
107 VideoRotation rotation) { 105 VideoRotation rotation) {
108 const int stride_y = width; 106 const int stride_y = width;
109 const int stride_uv = (width + 1) / 2; 107 const int stride_uv = (width + 1) / 2;
110 108
(...skipping 14 matching lines...) Expand all
125 } 123 }
126 124
127 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { 125 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) {
128 video_frame_buffer_ = videoFrame.video_frame_buffer(); 126 video_frame_buffer_ = videoFrame.video_frame_buffer();
129 timestamp_ = videoFrame.timestamp_; 127 timestamp_ = videoFrame.timestamp_;
130 ntp_time_ms_ = videoFrame.ntp_time_ms_; 128 ntp_time_ms_ = videoFrame.ntp_time_ms_;
131 render_time_ms_ = videoFrame.render_time_ms_; 129 render_time_ms_ = videoFrame.render_time_ms_;
132 rotation_ = videoFrame.rotation_; 130 rotation_ = videoFrame.rotation_;
133 } 131 }
134 132
135 // TODO(nisse): Delete. Besides test code, only one use, in 133 uint8_t* VideoFrame::buffer(PlaneType type) {
136 // webrtcvideoengine2.cc:CreateBlackFrame. 134 return video_frame_buffer_ ? video_frame_buffer_->MutableData(type)
135 : nullptr;
136 }
137
138 const uint8_t* VideoFrame::buffer(PlaneType type) const {
139 return video_frame_buffer_ ? video_frame_buffer_->data(type) : nullptr;
140 }
141
137 int VideoFrame::allocated_size(PlaneType type) const { 142 int VideoFrame::allocated_size(PlaneType type) const {
138 const int plane_height = (type == kYPlane) ? height() : (height() + 1) / 2; 143 const int plane_height = (type == kYPlane) ? height() : (height() + 1) / 2;
139 int stride; 144 return plane_height * stride(type);
140 switch (type) { 145 }
141 case kYPlane: 146
142 stride = video_frame_buffer_->StrideY(); 147 int VideoFrame::stride(PlaneType type) const {
143 break; 148 return video_frame_buffer_ ? video_frame_buffer_->stride(type) : 0;
144 case kUPlane:
145 stride = video_frame_buffer_->StrideU();
146 break;
147 case kVPlane:
148 stride = video_frame_buffer_->StrideV();
149 break;
150 default:
151 RTC_NOTREACHED();
152 return 0;
153 }
154 return plane_height * stride;
155 } 149 }
156 150
157 int VideoFrame::width() const { 151 int VideoFrame::width() const {
158 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; 152 return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
159 } 153 }
160 154
161 int VideoFrame::height() const { 155 int VideoFrame::height() const {
162 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; 156 return video_frame_buffer_ ? video_frame_buffer_->height() : 0;
163 } 157 }
164 158
165 bool VideoFrame::IsZeroSize() const { 159 bool VideoFrame::IsZeroSize() const {
166 return !video_frame_buffer_; 160 return !video_frame_buffer_;
167 } 161 }
168 162
169 const rtc::scoped_refptr<VideoFrameBuffer>& VideoFrame::video_frame_buffer() 163 rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const {
170 const {
171 return video_frame_buffer_; 164 return video_frame_buffer_;
172 } 165 }
173 166
174 void VideoFrame::set_video_frame_buffer( 167 void VideoFrame::set_video_frame_buffer(
175 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer) { 168 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer) {
176 video_frame_buffer_ = buffer; 169 video_frame_buffer_ = buffer;
177 } 170 }
178 171
179 VideoFrame VideoFrame::ConvertNativeToI420Frame() const { 172 VideoFrame VideoFrame::ConvertNativeToI420Frame() const {
180 RTC_DCHECK(video_frame_buffer_->native_handle()); 173 RTC_DCHECK(video_frame_buffer_->native_handle());
(...skipping 15 matching lines...) Expand all
196 case kVideoCodecULPFEC: 189 case kVideoCodecULPFEC:
197 case kVideoCodecGeneric: 190 case kVideoCodecGeneric:
198 case kVideoCodecUnknown: 191 case kVideoCodecUnknown:
199 return 0; 192 return 0;
200 } 193 }
201 RTC_NOTREACHED(); 194 RTC_NOTREACHED();
202 return 0; 195 return 0;
203 } 196 }
204 197
205 } // namespace webrtc 198 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/libyuv/webrtc_libyuv.cc ('k') | webrtc/media/engine/webrtcvideoengine2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698