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

Side by Side Diff: media/gpu/generic_v4l2_device.cc

Issue 2061823003: media: Drop "media::" in media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work around clang format by adding an empty line Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 5
6 #include "media/gpu/generic_v4l2_device.h" 6 #include "media/gpu/generic_v4l2_device.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <libdrm/drm_fourcc.h> 10 #include <libdrm/drm_fourcc.h>
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 const gfx::Size& size, 225 const gfx::Size& size,
226 unsigned int buffer_index, 226 unsigned int buffer_index,
227 uint32_t v4l2_pixfmt, 227 uint32_t v4l2_pixfmt,
228 const std::vector<base::ScopedFD>& dmabuf_fds) { 228 const std::vector<base::ScopedFD>& dmabuf_fds) {
229 DVLOG(3) << "CreateEGLImage()"; 229 DVLOG(3) << "CreateEGLImage()";
230 if (!CanCreateEGLImageFrom(v4l2_pixfmt)) { 230 if (!CanCreateEGLImageFrom(v4l2_pixfmt)) {
231 LOG(ERROR) << "Unsupported V4L2 pixel format"; 231 LOG(ERROR) << "Unsupported V4L2 pixel format";
232 return EGL_NO_IMAGE_KHR; 232 return EGL_NO_IMAGE_KHR;
233 } 233 }
234 234
235 media::VideoPixelFormat vf_format = V4L2PixFmtToVideoPixelFormat(v4l2_pixfmt); 235 VideoPixelFormat vf_format = V4L2PixFmtToVideoPixelFormat(v4l2_pixfmt);
236 // Number of components, as opposed to the number of V4L2 planes, which is 236 // Number of components, as opposed to the number of V4L2 planes, which is
237 // just a buffer count. 237 // just a buffer count.
238 size_t num_planes = media::VideoFrame::NumPlanes(vf_format); 238 size_t num_planes = VideoFrame::NumPlanes(vf_format);
239 DCHECK_LE(num_planes, 3u); 239 DCHECK_LE(num_planes, 3u);
240 if (num_planes < dmabuf_fds.size()) { 240 if (num_planes < dmabuf_fds.size()) {
241 // It's possible for more than one DRM plane to reside in one V4L2 plane, 241 // It's possible for more than one DRM plane to reside in one V4L2 plane,
242 // but not the other way around. We must use all V4L2 planes. 242 // but not the other way around. We must use all V4L2 planes.
243 LOG(ERROR) << "Invalid plane count"; 243 LOG(ERROR) << "Invalid plane count";
244 return EGL_NO_IMAGE_KHR; 244 return EGL_NO_IMAGE_KHR;
245 } 245 }
246 246
247 std::vector<EGLint> attrs; 247 std::vector<EGLint> attrs;
248 attrs.push_back(EGL_WIDTH); 248 attrs.push_back(EGL_WIDTH);
(...skipping 10 matching lines...) Expand all
259 // with an offset equal to the size of the preceding planes in the same 259 // with an offset equal to the size of the preceding planes in the same
260 // V4L2 plane. 260 // V4L2 plane.
261 size_t v4l2_plane = 0; 261 size_t v4l2_plane = 0;
262 size_t plane_offset = 0; 262 size_t plane_offset = 0;
263 for (size_t plane = 0; plane < num_planes; ++plane) { 263 for (size_t plane = 0; plane < num_planes; ++plane) {
264 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3); 264 attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3);
265 attrs.push_back(dmabuf_fds[v4l2_plane].get()); 265 attrs.push_back(dmabuf_fds[v4l2_plane].get());
266 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3); 266 attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3);
267 attrs.push_back(plane_offset); 267 attrs.push_back(plane_offset);
268 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3); 268 attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3);
269 attrs.push_back( 269 attrs.push_back(VideoFrame::RowBytes(plane, vf_format, size.width()));
270 media::VideoFrame::RowBytes(plane, vf_format, size.width()));
271 270
272 if (v4l2_plane + 1 < dmabuf_fds.size()) { 271 if (v4l2_plane + 1 < dmabuf_fds.size()) {
273 ++v4l2_plane; 272 ++v4l2_plane;
274 plane_offset = 0; 273 plane_offset = 0;
275 } else { 274 } else {
276 plane_offset += 275 plane_offset += VideoFrame::PlaneSize(vf_format, plane, size).GetArea();
277 media::VideoFrame::PlaneSize(vf_format, plane, size).GetArea();
278 } 276 }
279 } 277 }
280 278
281 attrs.push_back(EGL_NONE); 279 attrs.push_back(EGL_NONE);
282 280
283 EGLImageKHR egl_image = eglCreateImageKHR( 281 EGLImageKHR egl_image = eglCreateImageKHR(
284 egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, &attrs[0]); 282 egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, &attrs[0]);
285 if (egl_image == EGL_NO_IMAGE_KHR) { 283 if (egl_image == EGL_NO_IMAGE_KHR) {
286 LOG(ERROR) << "Failed creating EGL image: " << ui::GetLastEGLErrorString(); 284 LOG(ERROR) << "Failed creating EGL image: " << ui::GetLastEGLErrorString();
287 return egl_image; 285 return egl_image;
(...skipping 26 matching lines...) Expand all
314 StubPathMap paths; 312 StubPathMap paths;
315 paths[kModuleV4l2].push_back(kV4l2Lib); 313 paths[kModuleV4l2].push_back(kV4l2Lib);
316 314
317 return InitializeStubs(paths); 315 return InitializeStubs(paths);
318 #else 316 #else
319 return true; 317 return true;
320 #endif 318 #endif
321 } 319 }
322 320
323 } // namespace media 321 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/fake_video_decode_accelerator.cc ('k') | media/gpu/gpu_video_decode_accelerator_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698