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

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

Issue 1923903002: Reland 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
121 bool WebRtcVideoFrame::IsExclusive() const { 82 bool WebRtcVideoFrame::IsExclusive() const {
122 return video_frame_buffer_->IsMutable(); 83 return video_frame_buffer_->IsMutable();
123 } 84 }
124 85
125 void* WebRtcVideoFrame::GetNativeHandle() const { 86 void* WebRtcVideoFrame::GetNativeHandle() const {
126 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; 87 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr;
127 } 88 }
128 89
129 rtc::scoped_refptr<webrtc::VideoFrameBuffer> 90 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>&
130 WebRtcVideoFrame::video_frame_buffer() const { 91 WebRtcVideoFrame::video_frame_buffer() const {
131 return video_frame_buffer_; 92 return video_frame_buffer_;
132 } 93 }
133 94
134 VideoFrame* WebRtcVideoFrame::Copy() const { 95 VideoFrame* WebRtcVideoFrame::Copy() const {
135 return new WebRtcVideoFrame(video_frame_buffer_, rotation_, timestamp_us_); 96 return new WebRtcVideoFrame(video_frame_buffer_, rotation_, timestamp_us_);
136 } 97 }
137 98
138 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, 99 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc,
139 uint8_t* buffer, 100 uint8_t* buffer,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation; 135 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
175 136
176 int horiz_crop = ((w - dw) / 2) & ~1; 137 int horiz_crop = ((w - dw) / 2) & ~1;
177 // ARGB on Windows has negative height. 138 // ARGB on Windows has negative height.
178 // The sample's layout in memory is normal, so just correct crop. 139 // The sample's layout in memory is normal, so just correct crop.
179 int vert_crop = ((abs(h) - dh) / 2) & ~1; 140 int vert_crop = ((abs(h) - dh) / 2) & ~1;
180 // Conversion functions expect negative height to flip the image. 141 // Conversion functions expect negative height to flip the image.
181 int idh = (h < 0) ? -dh : dh; 142 int idh = (h < 0) ? -dh : dh;
182 int r = libyuv::ConvertToI420( 143 int r = libyuv::ConvertToI420(
183 sample, sample_size, 144 sample, sample_size,
184 GetYPlane(), GetYPitch(), 145 video_frame_buffer_->MutableDataY(),
185 GetUPlane(), GetUPitch(), 146 video_frame_buffer_->StrideY(),
186 GetVPlane(), GetVPitch(), 147 video_frame_buffer_->MutableDataU(),
148 video_frame_buffer_->StrideU(),
149 video_frame_buffer_->MutableDataV(),
150 video_frame_buffer_->StrideV(),
187 horiz_crop, vert_crop, 151 horiz_crop, vert_crop,
188 w, h, 152 w, h,
189 dw, idh, 153 dw, idh,
190 static_cast<libyuv::RotationMode>( 154 static_cast<libyuv::RotationMode>(
191 apply_rotation ? rotation : webrtc::kVideoRotation_0), 155 apply_rotation ? rotation : webrtc::kVideoRotation_0),
192 format); 156 format);
193 if (r) { 157 if (r) {
194 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format) 158 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format)
195 << " return code : " << r; 159 << " return code : " << r;
196 return false; 160 return false;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 rotated_width = orig_height; 209 rotated_width = orig_height;
246 rotated_height = orig_width; 210 rotated_height = orig_width;
247 } 211 }
248 212
249 rotated_frame_.reset( 213 rotated_frame_.reset(
250 CreateEmptyFrame(rotated_width, rotated_height, timestamp_us_)); 214 CreateEmptyFrame(rotated_width, rotated_height, timestamp_us_));
251 215
252 // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from 216 // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from
253 // VideoRotation to libyuv::RotationMode. 217 // VideoRotation to libyuv::RotationMode.
254 int ret = libyuv::I420Rotate( 218 int ret = libyuv::I420Rotate(
255 GetYPlane(), GetYPitch(), GetUPlane(), GetUPitch(), GetVPlane(), 219 video_frame_buffer_->DataY(), video_frame_buffer_->StrideY(),
256 GetVPitch(), rotated_frame_->GetYPlane(), rotated_frame_->GetYPitch(), 220 video_frame_buffer_->DataU(), video_frame_buffer_->StrideU(),
257 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), 221 video_frame_buffer_->DataV(), video_frame_buffer_->StrideV(),
258 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), 222 rotated_frame_->video_frame_buffer()->MutableDataY(),
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(),
259 orig_width, orig_height, 228 orig_width, orig_height,
260 static_cast<libyuv::RotationMode>(rotation())); 229 static_cast<libyuv::RotationMode>(rotation()));
261 if (ret == 0) { 230 if (ret == 0) {
262 return rotated_frame_.get(); 231 return rotated_frame_.get();
263 } 232 }
264 return nullptr; 233 return nullptr;
265 } 234 }
266 235
267 } // namespace cricket 236 } // 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