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

Side by Side Diff: media/video/capture/linux/v4l2_capture_delegate_multi_plane.cc

Issue 1124723006: VideoCaptureDeviceLinux: Add support for SPLANE+DMABUF V4L2 type capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 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 "media/video/capture/linux/v4l2_capture_delegate_multi_plane.h" 5 #include "media/video/capture/linux/v4l2_capture_delegate_multi_plane.h"
6 6
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 28 matching lines...) Expand all
39 if (num_v4l2_planes == 0u) 39 if (num_v4l2_planes == 0u)
40 return false; 40 return false;
41 DCHECK_LE(num_v4l2_planes, static_cast<size_t>(VIDEO_MAX_PLANES)); 41 DCHECK_LE(num_v4l2_planes, static_cast<size_t>(VIDEO_MAX_PLANES));
42 format->fmt.pix_mp.num_planes = num_v4l2_planes; 42 format->fmt.pix_mp.num_planes = num_v4l2_planes;
43 43
44 v4l2_planes_.resize(num_v4l2_planes); 44 v4l2_planes_.resize(num_v4l2_planes);
45 return true; 45 return true;
46 } 46 }
47 47
48 void V4L2CaptureDelegateMultiPlane::FinishFillingV4L2Buffer( 48 void V4L2CaptureDelegateMultiPlane::FinishFillingV4L2Buffer(
49 v4l2_buffer* buffer) const { 49 v4l2_buffer* buffer,
50 bool /* for_enqueue */) const {
51 buffer->memory = V4L2_MEMORY_MMAP;
50 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 52 buffer->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
51 buffer->length = v4l2_planes_.size(); 53 buffer->length = v4l2_planes_.size();
52 54
53 static const struct v4l2_plane empty_plane = {}; 55 static const struct v4l2_plane empty_plane = {};
54 std::fill(v4l2_planes_.begin(), v4l2_planes_.end(), empty_plane); 56 std::fill(v4l2_planes_.begin(), v4l2_planes_.end(), empty_plane);
55 buffer->m.planes = v4l2_planes_.data(); 57 buffer->m.planes = v4l2_planes_.data();
56 } 58 }
57 59
58 void V4L2CaptureDelegateMultiPlane::SetPayloadSize( 60 void V4L2CaptureDelegateMultiPlane::SetPayloadSize(
59 const scoped_refptr<BufferTracker>& buffer_tracker, 61 const scoped_refptr<BufferTracker>& buffer_tracker,
60 const v4l2_buffer& buffer) const { 62 const v4l2_buffer& buffer) const {
61 for (size_t i = 0; i < v4l2_planes_.size() && i < buffer.length; i++) 63 for (size_t i = 0; i < v4l2_planes_.size() && i < buffer.length; i++)
62 buffer_tracker->SetPlanePayloadSize(i, buffer.m.planes[i].bytesused); 64 buffer_tracker->SetPlanePayloadSize(i, buffer.m.planes[i].bytesused);
63 } 65 }
64 66
67 void V4L2CaptureDelegateMultiPlane::FinishFillingV4L2RequestBuffers(
68 v4l2_requestbuffers* request) const {
69 request->memory = V4L2_MEMORY_MMAP;
70 }
71
65 void V4L2CaptureDelegateMultiPlane::SendBuffer( 72 void V4L2CaptureDelegateMultiPlane::SendBuffer(
66 const scoped_refptr<BufferTracker>& buffer_tracker, 73 const scoped_refptr<BufferTracker>& buffer_tracker,
67 const v4l2_format& format) const { 74 const v4l2_format& format) const {
68 DCHECK_EQ(capture_format().pixel_format, PIXEL_FORMAT_I420); 75 DCHECK_EQ(capture_format().pixel_format, PIXEL_FORMAT_I420);
69 const size_t y_stride = format.fmt.pix_mp.plane_fmt[0].bytesperline; 76 const size_t y_stride = format.fmt.pix_mp.plane_fmt[0].bytesperline;
70 const size_t u_stride = format.fmt.pix_mp.plane_fmt[1].bytesperline; 77 const size_t u_stride = format.fmt.pix_mp.plane_fmt[1].bytesperline;
71 const size_t v_stride = format.fmt.pix_mp.plane_fmt[2].bytesperline; 78 const size_t v_stride = format.fmt.pix_mp.plane_fmt[2].bytesperline;
72 DCHECK_GE(y_stride, 1u * capture_format().frame_size.width()); 79 DCHECK_GE(y_stride, 1u * capture_format().frame_size.width());
73 DCHECK_GE(u_stride, 1u * capture_format().frame_size.width() / 2); 80 DCHECK_GE(u_stride, 1u * capture_format().frame_size.width() / 2);
74 DCHECK_GE(v_stride, 1u * capture_format().frame_size.width() / 2); 81 DCHECK_GE(v_stride, 1u * capture_format().frame_size.width() / 2);
(...skipping 22 matching lines...) Expand all
97 return false; 104 return false;
98 } 105 }
99 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.m.planes[p].length); 106 AddMmapedPlane(static_cast<uint8_t*>(start), buffer.m.planes[p].length);
100 DVLOG(3) << "Mmap()ed plane #" << p << " of " << buffer.m.planes[p].length 107 DVLOG(3) << "Mmap()ed plane #" << p << " of " << buffer.m.planes[p].length
101 << "B"; 108 << "B";
102 } 109 }
103 return true; 110 return true;
104 } 111 }
105 112
106 } // namespace media 113 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698