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

Side by Side Diff: content/browser/renderer_host/media/video_capture_device_client.cc

Issue 1685713003: Remove V4L2CaptureDelegate{Single,Multi}Plane, VCD::Client::OnIncomingCapturedYuvData() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perkj@ comments and reverted change to WeakPtr Created 4 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/media/video_capture_device_client.h" 5 #include "content/browser/renderer_host/media/video_capture_device_client.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // Windows RGB24 defines blue at lowest byte, 181 // Windows RGB24 defines blue at lowest byte,
182 // see https://msdn.microsoft.com/en-us/library/windows/desktop/dd407253 182 // see https://msdn.microsoft.com/en-us/library/windows/desktop/dd407253
183 #if defined(OS_LINUX) 183 #if defined(OS_LINUX)
184 origin_colorspace = libyuv::FOURCC_RAW; 184 origin_colorspace = libyuv::FOURCC_RAW;
185 #elif defined(OS_WIN) 185 #elif defined(OS_WIN)
186 origin_colorspace = libyuv::FOURCC_24BG; 186 origin_colorspace = libyuv::FOURCC_24BG;
187 #else 187 #else
188 NOTREACHED() << "RGB24 is only available in Linux and Windows platforms"; 188 NOTREACHED() << "RGB24 is only available in Linux and Windows platforms";
189 #endif 189 #endif
190 #if defined(OS_WIN) 190 #if defined(OS_WIN)
191 // TODO(wjia): Currently, for RGB24 on WIN, capture device always 191 // TODO(wjia): Currently, for RGB24 on WIN, capture device always passes
192 // passes in positive src_width and src_height. Remove this hardcoded 192 // in positive src_width and src_height. Remove this hardcoded value when
193 // value when nagative src_height is supported. The negative src_height 193 // negative src_height is supported. The negative src_height indicates
194 // indicates that vertical flipping is needed. 194 // that vertical flipping is needed.
195 flip = true; 195 flip = true;
196 #endif 196 #endif
197 break; 197 break;
198 case media::PIXEL_FORMAT_RGB32: 198 case media::PIXEL_FORMAT_RGB32:
199 // Fallback to PIXEL_FORMAT_ARGB setting |flip| in Windows 199 // Fallback to PIXEL_FORMAT_ARGB setting |flip| in Windows
200 // platforms. 200 // platforms.
201 #if defined(OS_WIN) 201 #if defined(OS_WIN)
202 flip = true; 202 flip = true;
203 #endif 203 #endif
204 case media::PIXEL_FORMAT_ARGB: 204 case media::PIXEL_FORMAT_ARGB:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 << media::VideoPixelFormatToString(frame_format.pixel_format); 249 << media::VideoPixelFormatToString(frame_format.pixel_format);
250 return; 250 return;
251 } 251 }
252 252
253 const VideoCaptureFormat output_format = VideoCaptureFormat( 253 const VideoCaptureFormat output_format = VideoCaptureFormat(
254 dimensions, frame_format.frame_rate, 254 dimensions, frame_format.frame_rate,
255 media::PIXEL_FORMAT_I420, output_pixel_storage); 255 media::PIXEL_FORMAT_I420, output_pixel_storage);
256 OnIncomingCapturedBuffer(std::move(buffer), output_format, timestamp); 256 OnIncomingCapturedBuffer(std::move(buffer), output_format, timestamp);
257 } 257 }
258 258
259 void VideoCaptureDeviceClient::OnIncomingCapturedYuvData(
260 const uint8_t* y_data,
261 const uint8_t* u_data,
262 const uint8_t* v_data,
263 size_t y_stride,
264 size_t u_stride,
265 size_t v_stride,
266 const VideoCaptureFormat& frame_format,
267 int clockwise_rotation,
268 const base::TimeTicks& timestamp) {
269 TRACE_EVENT0("video", "VideoCaptureDeviceClient::OnIncomingCapturedYuvData");
270 DCHECK_EQ(media::PIXEL_FORMAT_I420, frame_format.pixel_format);
271 DCHECK_EQ(media::PIXEL_STORAGE_CPU, frame_format.pixel_storage);
272 DCHECK_EQ(0, clockwise_rotation) << "Rotation not supported";
273
274 uint8_t *y_plane_data, *u_plane_data, *v_plane_data;
275 scoped_ptr<Buffer> buffer(ReserveI420OutputBuffer(
276 frame_format.frame_size, frame_format.pixel_storage, &y_plane_data,
277 &u_plane_data, &v_plane_data));
278 if (!buffer.get())
279 return;
280
281 const size_t dst_y_stride =
282 VideoFrame::RowBytes(VideoFrame::kYPlane, media::PIXEL_FORMAT_I420,
283 frame_format.frame_size.width());
284 const size_t dst_u_stride =
285 VideoFrame::RowBytes(VideoFrame::kUPlane, media::PIXEL_FORMAT_I420,
286 frame_format.frame_size.width());
287 const size_t dst_v_stride =
288 VideoFrame::RowBytes(VideoFrame::kVPlane, media::PIXEL_FORMAT_I420,
289 frame_format.frame_size.width());
290 DCHECK_GE(y_stride, dst_y_stride);
291 DCHECK_GE(u_stride, dst_u_stride);
292 DCHECK_GE(v_stride, dst_v_stride);
293
294 if (libyuv::I420Copy(y_data, y_stride,
295 u_data, u_stride,
296 v_data, v_stride,
297 y_plane_data, dst_y_stride,
298 u_plane_data, dst_u_stride,
299 v_plane_data, dst_v_stride,
300 frame_format.frame_size.width(),
301 frame_format.frame_size.height())) {
302 DLOG(WARNING) << "Failed to copy buffer";
303 return;
304 }
305
306 OnIncomingCapturedBuffer(std::move(buffer), frame_format, timestamp);
307 };
308
309 scoped_ptr<media::VideoCaptureDevice::Client::Buffer> 259 scoped_ptr<media::VideoCaptureDevice::Client::Buffer>
310 VideoCaptureDeviceClient::ReserveOutputBuffer( 260 VideoCaptureDeviceClient::ReserveOutputBuffer(
311 const gfx::Size& frame_size, 261 const gfx::Size& frame_size,
312 media::VideoPixelFormat pixel_format, 262 media::VideoPixelFormat pixel_format,
313 media::VideoPixelStorage pixel_storage) { 263 media::VideoPixelStorage pixel_storage) {
314 DCHECK_GT(frame_size.width(), 0); 264 DCHECK_GT(frame_size.width(), 0);
315 DCHECK_GT(frame_size.height(), 0); 265 DCHECK_GT(frame_size.height(), 0);
316 // Currently, only I420 pixel format is supported. 266 // Currently, only I420 pixel format is supported.
317 DCHECK_EQ(media::PIXEL_FORMAT_I420, pixel_format); 267 DCHECK_EQ(media::PIXEL_FORMAT_I420, pixel_format);
318 268
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kUPlane)); 406 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kUPlane));
457 *v_plane_data = 407 *v_plane_data =
458 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kVPlane)); 408 reinterpret_cast<uint8_t*>(buffer->data(VideoFrame::kVPlane));
459 return buffer; 409 return buffer;
460 } 410 }
461 NOTREACHED(); 411 NOTREACHED();
462 return scoped_ptr<Buffer>(); 412 return scoped_ptr<Buffer>();
463 } 413 }
464 414
465 } // namespace content 415 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698