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

Side by Side Diff: media/gpu/v4l2_image_processor.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
« no previous file with comments | « media/gpu/v4l2_image_processor.h ('k') | media/gpu/v4l2_jpeg_decode_accelerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <linux/videodev2.h> 7 #include <linux/videodev2.h>
8 #include <poll.h> 8 #include <poll.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/eventfd.h> 10 #include <sys/eventfd.h>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 V4L2ImageProcessor::OutputRecord::OutputRecord() : at_device(false) {} 47 V4L2ImageProcessor::OutputRecord::OutputRecord() : at_device(false) {}
48 48
49 V4L2ImageProcessor::OutputRecord::~OutputRecord() {} 49 V4L2ImageProcessor::OutputRecord::~OutputRecord() {}
50 50
51 V4L2ImageProcessor::JobRecord::JobRecord() : output_buffer_index(-1) {} 51 V4L2ImageProcessor::JobRecord::JobRecord() : output_buffer_index(-1) {}
52 52
53 V4L2ImageProcessor::JobRecord::~JobRecord() {} 53 V4L2ImageProcessor::JobRecord::~JobRecord() {}
54 54
55 V4L2ImageProcessor::V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device) 55 V4L2ImageProcessor::V4L2ImageProcessor(const scoped_refptr<V4L2Device>& device)
56 : input_format_(media::PIXEL_FORMAT_UNKNOWN), 56 : input_format_(PIXEL_FORMAT_UNKNOWN),
57 output_format_(media::PIXEL_FORMAT_UNKNOWN), 57 output_format_(PIXEL_FORMAT_UNKNOWN),
58 input_memory_type_(V4L2_MEMORY_USERPTR), 58 input_memory_type_(V4L2_MEMORY_USERPTR),
59 input_format_fourcc_(0), 59 input_format_fourcc_(0),
60 output_format_fourcc_(0), 60 output_format_fourcc_(0),
61 input_planes_count_(0), 61 input_planes_count_(0),
62 output_planes_count_(0), 62 output_planes_count_(0),
63 child_task_runner_(base::ThreadTaskRunnerHandle::Get()), 63 child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
64 device_(device), 64 device_(device),
65 device_thread_("V4L2ImageProcessorThread"), 65 device_thread_("V4L2ImageProcessorThread"),
66 device_poll_thread_("V4L2ImageProcessorDevicePollThread"), 66 device_poll_thread_("V4L2ImageProcessorDevicePollThread"),
67 input_streamon_(false), 67 input_streamon_(false),
(...skipping 21 matching lines...) Expand all
89 FROM_HERE, base::Bind(&V4L2ImageProcessor::NotifyErrorOnChildThread, 89 FROM_HERE, base::Bind(&V4L2ImageProcessor::NotifyErrorOnChildThread,
90 weak_this_, error_cb_)); 90 weak_this_, error_cb_));
91 } 91 }
92 92
93 void V4L2ImageProcessor::NotifyErrorOnChildThread( 93 void V4L2ImageProcessor::NotifyErrorOnChildThread(
94 const base::Closure& error_cb) { 94 const base::Closure& error_cb) {
95 DCHECK(child_task_runner_->BelongsToCurrentThread()); 95 DCHECK(child_task_runner_->BelongsToCurrentThread());
96 error_cb_.Run(); 96 error_cb_.Run();
97 } 97 }
98 98
99 bool V4L2ImageProcessor::Initialize(media::VideoPixelFormat input_format, 99 bool V4L2ImageProcessor::Initialize(VideoPixelFormat input_format,
100 media::VideoPixelFormat output_format, 100 VideoPixelFormat output_format,
101 v4l2_memory input_memory_type, 101 v4l2_memory input_memory_type,
102 gfx::Size input_visible_size, 102 gfx::Size input_visible_size,
103 gfx::Size input_allocated_size, 103 gfx::Size input_allocated_size,
104 gfx::Size output_visible_size, 104 gfx::Size output_visible_size,
105 gfx::Size output_allocated_size, 105 gfx::Size output_allocated_size,
106 int num_buffers, 106 int num_buffers,
107 const base::Closure& error_cb) { 107 const base::Closure& error_cb) {
108 DCHECK(!error_cb.is_null()); 108 DCHECK(!error_cb.is_null());
109 DCHECK_GT(num_buffers, 0); 109 DCHECK_GT(num_buffers, 0);
110 DCHECK(input_memory_type == V4L2_MEMORY_USERPTR || 110 DCHECK(input_memory_type == V4L2_MEMORY_USERPTR ||
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return false; 148 return false;
149 } 149 }
150 150
151 // StartDevicePoll will NotifyError on failure, so IgnoreResult is fine here. 151 // StartDevicePoll will NotifyError on failure, so IgnoreResult is fine here.
152 device_thread_.message_loop()->PostTask( 152 device_thread_.message_loop()->PostTask(
153 FROM_HERE, 153 FROM_HERE,
154 base::Bind(base::IgnoreResult(&V4L2ImageProcessor::StartDevicePoll), 154 base::Bind(base::IgnoreResult(&V4L2ImageProcessor::StartDevicePoll),
155 base::Unretained(this))); 155 base::Unretained(this)));
156 156
157 DVLOG(1) << "V4L2ImageProcessor initialized for " 157 DVLOG(1) << "V4L2ImageProcessor initialized for "
158 << " input_format:" << media::VideoPixelFormatToString(input_format) 158 << " input_format:" << VideoPixelFormatToString(input_format)
159 << ", output_format:" 159 << ", output_format:" << VideoPixelFormatToString(output_format)
160 << media::VideoPixelFormatToString(output_format)
161 << ", input_visible_size: " << input_visible_size.ToString() 160 << ", input_visible_size: " << input_visible_size.ToString()
162 << ", input_allocated_size: " << input_allocated_size_.ToString() 161 << ", input_allocated_size: " << input_allocated_size_.ToString()
163 << ", input_planes_count: " << input_planes_count_ 162 << ", input_planes_count: " << input_planes_count_
164 << ", output_visible_size: " << output_visible_size.ToString() 163 << ", output_visible_size: " << output_visible_size.ToString()
165 << ", output_allocated_size: " << output_allocated_size_.ToString() 164 << ", output_allocated_size: " << output_allocated_size_.ToString()
166 << ", output_planes_count: " << output_planes_count_; 165 << ", output_planes_count: " << output_planes_count_;
167 166
168 return true; 167 return true;
169 } 168 }
170 169
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 format.fmt.pix_mp.pixelformat = pixelformat; 210 format.fmt.pix_mp.pixelformat = pixelformat;
212 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_TRY_FMT, &format); 211 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_TRY_FMT, &format);
213 212
214 *num_planes = format.fmt.pix_mp.num_planes; 213 *num_planes = format.fmt.pix_mp.num_planes;
215 *size = V4L2Device::CodedSizeFromV4L2Format(format); 214 *size = V4L2Device::CodedSizeFromV4L2Format(format);
216 DVLOG(1) << __func__ << ": adjusted output coded size=" << size->ToString() 215 DVLOG(1) << __func__ << ": adjusted output coded size=" << size->ToString()
217 << ", num_planes=" << *num_planes; 216 << ", num_planes=" << *num_planes;
218 return true; 217 return true;
219 } 218 }
220 219
221 void V4L2ImageProcessor::Process(const scoped_refptr<media::VideoFrame>& frame, 220 void V4L2ImageProcessor::Process(const scoped_refptr<VideoFrame>& frame,
222 int output_buffer_index, 221 int output_buffer_index,
223 const FrameReadyCB& cb) { 222 const FrameReadyCB& cb) {
224 DVLOG(3) << __func__ << ": ts=" << frame->timestamp().InMilliseconds(); 223 DVLOG(3) << __func__ << ": ts=" << frame->timestamp().InMilliseconds();
225 224
226 std::unique_ptr<JobRecord> job_record(new JobRecord()); 225 std::unique_ptr<JobRecord> job_record(new JobRecord());
227 job_record->frame = frame; 226 job_record->frame = frame;
228 job_record->output_buffer_index = output_buffer_index; 227 job_record->output_buffer_index = output_buffer_index;
229 job_record->ready_cb = cb; 228 job_record->ready_cb = cb;
230 229
231 device_thread_.message_loop()->PostTask( 230 device_thread_.message_loop()->PostTask(
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 struct v4l2_plane qbuf_planes[VIDEO_MAX_PLANES]; 591 struct v4l2_plane qbuf_planes[VIDEO_MAX_PLANES];
593 memset(&qbuf, 0, sizeof(qbuf)); 592 memset(&qbuf, 0, sizeof(qbuf));
594 memset(qbuf_planes, 0, sizeof(qbuf_planes)); 593 memset(qbuf_planes, 0, sizeof(qbuf_planes));
595 qbuf.index = index; 594 qbuf.index = index;
596 qbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 595 qbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
597 qbuf.memory = input_memory_type_; 596 qbuf.memory = input_memory_type_;
598 qbuf.m.planes = qbuf_planes; 597 qbuf.m.planes = qbuf_planes;
599 qbuf.length = input_planes_count_; 598 qbuf.length = input_planes_count_;
600 for (size_t i = 0; i < input_planes_count_; ++i) { 599 for (size_t i = 0; i < input_planes_count_; ++i) {
601 qbuf.m.planes[i].bytesused = 600 qbuf.m.planes[i].bytesused =
602 media::VideoFrame::PlaneSize(input_record.frame->format(), i, 601 VideoFrame::PlaneSize(input_record.frame->format(), i,
603 input_allocated_size_) 602 input_allocated_size_)
604 .GetArea(); 603 .GetArea();
605 qbuf.m.planes[i].length = qbuf.m.planes[i].bytesused; 604 qbuf.m.planes[i].length = qbuf.m.planes[i].bytesused;
606 if (input_memory_type_ == V4L2_MEMORY_USERPTR) { 605 if (input_memory_type_ == V4L2_MEMORY_USERPTR) {
607 qbuf.m.planes[i].m.userptr = 606 qbuf.m.planes[i].m.userptr =
608 reinterpret_cast<unsigned long>(input_record.frame->data(i)); 607 reinterpret_cast<unsigned long>(input_record.frame->data(i));
609 } else { 608 } else {
610 qbuf.m.planes[i].m.fd = input_record.frame->dmabuf_fd(i); 609 qbuf.m.planes[i].m.fd = input_record.frame->dmabuf_fd(i);
611 } 610 }
612 } 611 }
613 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QBUF, &qbuf); 612 IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QBUF, &qbuf);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 return true; 711 return true;
713 } 712 }
714 713
715 void V4L2ImageProcessor::FrameReady(const FrameReadyCB& cb, 714 void V4L2ImageProcessor::FrameReady(const FrameReadyCB& cb,
716 int output_buffer_index) { 715 int output_buffer_index) {
717 DCHECK(child_task_runner_->BelongsToCurrentThread()); 716 DCHECK(child_task_runner_->BelongsToCurrentThread());
718 cb.Run(output_buffer_index); 717 cb.Run(output_buffer_index);
719 } 718 }
720 719
721 } // namespace media 720 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/v4l2_image_processor.h ('k') | media/gpu/v4l2_jpeg_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698