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

Side by Side Diff: webrtc/media/engine/webrtcvideoframe.cc

Issue 1921493004: Revert of Delete cricket::VideoFrame methods GetYPlane and GetYPitch. (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/media/engine/webrtcvideoframe.h ('k') | no next file » | 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 int WebRtcVideoFrame::width() const { 74 int WebRtcVideoFrame::width() const {
75 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; 75 return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
76 } 76 }
77 77
78 int WebRtcVideoFrame::height() const { 78 int WebRtcVideoFrame::height() const {
79 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; 79 return video_frame_buffer_ ? video_frame_buffer_->height() : 0;
80 } 80 }
81 81
82 const uint8_t* WebRtcVideoFrame::GetYPlane() const {
83 return video_frame_buffer_ ? video_frame_buffer_->DataY() : nullptr;
84 }
85
86 const uint8_t* WebRtcVideoFrame::GetUPlane() const {
87 return video_frame_buffer_ ? video_frame_buffer_->DataU() : nullptr;
88 }
89
90 const uint8_t* WebRtcVideoFrame::GetVPlane() const {
91 return video_frame_buffer_ ? video_frame_buffer_->DataV() : nullptr;
92 }
93
94 uint8_t* WebRtcVideoFrame::GetYPlane() {
95 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kYPlane)
96 : nullptr;
97 }
98
99 uint8_t* WebRtcVideoFrame::GetUPlane() {
100 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kUPlane)
101 : nullptr;
102 }
103
104 uint8_t* WebRtcVideoFrame::GetVPlane() {
105 return video_frame_buffer_ ? video_frame_buffer_->MutableData(kVPlane)
106 : nullptr;
107 }
108
109 int32_t WebRtcVideoFrame::GetYPitch() const {
110 return video_frame_buffer_ ? video_frame_buffer_->StrideY() : 0;
111 }
112
113 int32_t WebRtcVideoFrame::GetUPitch() const {
114 return video_frame_buffer_ ? video_frame_buffer_->StrideU() : 0;
115 }
116
117 int32_t WebRtcVideoFrame::GetVPitch() const {
118 return video_frame_buffer_ ? video_frame_buffer_->StrideV() : 0;
119 }
120
82 bool WebRtcVideoFrame::IsExclusive() const { 121 bool WebRtcVideoFrame::IsExclusive() const {
83 return video_frame_buffer_->IsMutable(); 122 return video_frame_buffer_->IsMutable();
84 } 123 }
85 124
86 void* WebRtcVideoFrame::GetNativeHandle() const { 125 void* WebRtcVideoFrame::GetNativeHandle() const {
87 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; 126 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr;
88 } 127 }
89 128
90 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& 129 rtc::scoped_refptr<webrtc::VideoFrameBuffer>
91 WebRtcVideoFrame::video_frame_buffer() const { 130 WebRtcVideoFrame::video_frame_buffer() const {
92 return video_frame_buffer_; 131 return video_frame_buffer_;
93 } 132 }
94 133
95 VideoFrame* WebRtcVideoFrame::Copy() const { 134 VideoFrame* WebRtcVideoFrame::Copy() const {
96 return new WebRtcVideoFrame(video_frame_buffer_, rotation_, timestamp_us_); 135 return new WebRtcVideoFrame(video_frame_buffer_, rotation_, timestamp_us_);
97 } 136 }
98 137
99 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, 138 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc,
100 uint8_t* buffer, 139 uint8_t* buffer,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation; 174 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
136 175
137 int horiz_crop = ((w - dw) / 2) & ~1; 176 int horiz_crop = ((w - dw) / 2) & ~1;
138 // ARGB on Windows has negative height. 177 // ARGB on Windows has negative height.
139 // The sample's layout in memory is normal, so just correct crop. 178 // The sample's layout in memory is normal, so just correct crop.
140 int vert_crop = ((abs(h) - dh) / 2) & ~1; 179 int vert_crop = ((abs(h) - dh) / 2) & ~1;
141 // Conversion functions expect negative height to flip the image. 180 // Conversion functions expect negative height to flip the image.
142 int idh = (h < 0) ? -dh : dh; 181 int idh = (h < 0) ? -dh : dh;
143 int r = libyuv::ConvertToI420( 182 int r = libyuv::ConvertToI420(
144 sample, sample_size, 183 sample, sample_size,
145 video_frame_buffer_->MutableDataY(), 184 GetYPlane(), GetYPitch(),
146 video_frame_buffer_->StrideY(), 185 GetUPlane(), GetUPitch(),
147 video_frame_buffer_->MutableDataU(), 186 GetVPlane(), GetVPitch(),
148 video_frame_buffer_->StrideU(),
149 video_frame_buffer_->MutableDataV(),
150 video_frame_buffer_->StrideV(),
151 horiz_crop, vert_crop, 187 horiz_crop, vert_crop,
152 w, h, 188 w, h,
153 dw, idh, 189 dw, idh,
154 static_cast<libyuv::RotationMode>( 190 static_cast<libyuv::RotationMode>(
155 apply_rotation ? rotation : webrtc::kVideoRotation_0), 191 apply_rotation ? rotation : webrtc::kVideoRotation_0),
156 format); 192 format);
157 if (r) { 193 if (r) {
158 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format) 194 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format)
159 << " return code : " << r; 195 << " return code : " << r;
160 return false; 196 return false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 rotated_width = orig_height; 245 rotated_width = orig_height;
210 rotated_height = orig_width; 246 rotated_height = orig_width;
211 } 247 }
212 248
213 rotated_frame_.reset( 249 rotated_frame_.reset(
214 CreateEmptyFrame(rotated_width, rotated_height, timestamp_us_)); 250 CreateEmptyFrame(rotated_width, rotated_height, timestamp_us_));
215 251
216 // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from 252 // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from
217 // VideoRotation to libyuv::RotationMode. 253 // VideoRotation to libyuv::RotationMode.
218 int ret = libyuv::I420Rotate( 254 int ret = libyuv::I420Rotate(
219 video_frame_buffer_->DataY(), video_frame_buffer_->StrideY(), 255 GetYPlane(), GetYPitch(), GetUPlane(), GetUPitch(), GetVPlane(),
220 video_frame_buffer_->DataU(), video_frame_buffer_->StrideU(), 256 GetVPitch(), rotated_frame_->GetYPlane(), rotated_frame_->GetYPitch(),
221 video_frame_buffer_->DataV(), video_frame_buffer_->StrideV(), 257 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(),
222 rotated_frame_->video_frame_buffer()->MutableDataY(), 258 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(),
223 rotated_frame_->video_frame_buffer()->StrideY(),
224 rotated_frame_->video_frame_buffer()->MutableDataU(),
225 rotated_frame_->video_frame_buffer()->StrideU(),
226 rotated_frame_->video_frame_buffer()->MutableDataV(),
227 rotated_frame_->video_frame_buffer()->StrideV(),
228 orig_width, orig_height, 259 orig_width, orig_height,
229 static_cast<libyuv::RotationMode>(rotation())); 260 static_cast<libyuv::RotationMode>(rotation()));
230 if (ret == 0) { 261 if (ret == 0) {
231 return rotated_frame_.get(); 262 return rotated_frame_.get();
232 } 263 }
233 return nullptr; 264 return nullptr;
234 } 265 }
235 266
236 } // namespace cricket 267 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698