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

Unified Diff: media/gpu/v4l2_video_encode_accelerator.cc

Issue 1939683002: Test X11 header pollution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/gpu/v4l2_video_encode_accelerator.h ('k') | media/gpu/va.sigs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/v4l2_video_encode_accelerator.cc
diff --git a/content/common/gpu/media/v4l2_video_encode_accelerator.cc b/media/gpu/v4l2_video_encode_accelerator.cc
similarity index 94%
rename from content/common/gpu/media/v4l2_video_encode_accelerator.cc
rename to media/gpu/v4l2_video_encode_accelerator.cc
index 414118207123640a26a11403075ed4a8d6c44305..8c3afa41f4108a7b2cfe0bc250e2c80112aca610 100644
--- a/content/common/gpu/media/v4l2_video_encode_accelerator.cc
+++ b/media/gpu/v4l2_video_encode_accelerator.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
+#include "media/gpu/v4l2_video_encode_accelerator.h"
#include <fcntl.h>
#include <linux/videodev2.h>
@@ -20,9 +20,9 @@
#include "base/numerics/safe_conversions.h"
#include "base/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
-#include "content/common/gpu/media/shared_memory_region.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/bitstream_buffer.h"
+#include "media/gpu/shared_memory_region.h"
#define NOTIFY_ERROR(x) \
do { \
@@ -30,13 +30,13 @@
SetErrorState(x); \
} while (0)
-#define IOCTL_OR_ERROR_RETURN_VALUE(type, arg, value, type_str) \
- do { \
- if (device_->Ioctl(type, arg) != 0) { \
- PLOG(ERROR) << __func__ << "(): ioctl() failed: " << type_str; \
- NOTIFY_ERROR(kPlatformFailureError); \
- return value; \
- } \
+#define IOCTL_OR_ERROR_RETURN_VALUE(type, arg, value, type_str) \
+ do { \
+ if (device_->Ioctl(type, arg) != 0) { \
+ PLOG(ERROR) << __func__ << "(): ioctl() failed: " << type_str; \
+ NOTIFY_ERROR(kPlatformFailureError); \
+ return value; \
+ } \
} while (0)
#define IOCTL_OR_ERROR_RETURN(type, arg) \
@@ -45,13 +45,13 @@
#define IOCTL_OR_ERROR_RETURN_FALSE(type, arg) \
IOCTL_OR_ERROR_RETURN_VALUE(type, arg, false, #type)
-#define IOCTL_OR_LOG_ERROR(type, arg) \
- do { \
- if (device_->Ioctl(type, arg) != 0) \
- PLOG(ERROR) << __func__ << "(): ioctl() failed: " << #type; \
+#define IOCTL_OR_LOG_ERROR(type, arg) \
+ do { \
+ if (device_->Ioctl(type, arg) != 0) \
+ PLOG(ERROR) << __func__ << "(): ioctl() failed: " << #type; \
} while (0)
-namespace content {
+namespace media {
struct V4L2VideoEncodeAccelerator::BitstreamBufferRef {
BitstreamBufferRef(int32_t id, std::unique_ptr<SharedMemoryRegion> shm)
@@ -60,18 +60,14 @@ struct V4L2VideoEncodeAccelerator::BitstreamBufferRef {
const std::unique_ptr<SharedMemoryRegion> shm;
};
-V4L2VideoEncodeAccelerator::InputRecord::InputRecord() : at_device(false) {
-}
+V4L2VideoEncodeAccelerator::InputRecord::InputRecord() : at_device(false) {}
-V4L2VideoEncodeAccelerator::InputRecord::~InputRecord() {
-}
+V4L2VideoEncodeAccelerator::InputRecord::~InputRecord() {}
V4L2VideoEncodeAccelerator::OutputRecord::OutputRecord()
- : at_device(false), address(NULL), length(0) {
-}
+ : at_device(false), address(NULL), length(0) {}
-V4L2VideoEncodeAccelerator::OutputRecord::~OutputRecord() {
-}
+V4L2VideoEncodeAccelerator::OutputRecord::~OutputRecord() {}
V4L2VideoEncodeAccelerator::ImageProcessorInputRecord::
ImageProcessorInputRecord()
@@ -136,7 +132,8 @@ bool V4L2VideoEncodeAccelerator::Initialize(
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYCAP, &caps);
if ((caps.capabilities & kCapsRequired) != kCapsRequired) {
LOG(ERROR) << "Initialize(): ioctl() failed: VIDIOC_QUERYCAP: "
- "caps check failed: 0x" << std::hex << caps.capabilities;
+ "caps check failed: 0x"
+ << std::hex << caps.capabilities;
return false;
}
@@ -249,11 +246,8 @@ void V4L2VideoEncodeAccelerator::Encode(
}
} else {
encoder_thread_.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&V4L2VideoEncodeAccelerator::EncodeTask,
- base::Unretained(this),
- frame,
- force_keyframe));
+ FROM_HERE, base::Bind(&V4L2VideoEncodeAccelerator::EncodeTask,
+ base::Unretained(this), frame, force_keyframe));
}
}
@@ -279,8 +273,7 @@ void V4L2VideoEncodeAccelerator::UseOutputBitstreamBuffer(
encoder_thread_.message_loop()->PostTask(
FROM_HERE,
base::Bind(&V4L2VideoEncodeAccelerator::UseOutputBitstreamBufferTask,
- base::Unretained(this),
- base::Passed(&buffer_ref)));
+ base::Unretained(this), base::Passed(&buffer_ref)));
}
void V4L2VideoEncodeAccelerator::RequestEncodingParametersChange(
@@ -294,9 +287,7 @@ void V4L2VideoEncodeAccelerator::RequestEncodingParametersChange(
FROM_HERE,
base::Bind(
&V4L2VideoEncodeAccelerator::RequestEncodingParametersChangeTask,
- base::Unretained(this),
- bitrate,
- framerate));
+ base::Unretained(this), bitrate, framerate));
}
void V4L2VideoEncodeAccelerator::Destroy() {
@@ -313,9 +304,8 @@ void V4L2VideoEncodeAccelerator::Destroy() {
// If the encoder thread is running, destroy using posted task.
if (encoder_thread_.IsRunning()) {
encoder_thread_.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&V4L2VideoEncodeAccelerator::DestroyTask,
- base::Unretained(this)));
+ FROM_HERE, base::Bind(&V4L2VideoEncodeAccelerator::DestroyTask,
+ base::Unretained(this)));
// DestroyTask() will put the encoder into kError state and cause all tasks
// to no-op.
encoder_thread_.Stop();
@@ -342,8 +332,8 @@ V4L2VideoEncodeAccelerator::GetSupportedProfiles() {
memset(&fmtdesc, 0, sizeof(fmtdesc));
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
for (; device_->Ioctl(VIDIOC_ENUM_FMT, &fmtdesc) == 0; ++fmtdesc.index) {
- device_->GetSupportedResolution(fmtdesc.pixelformat,
- &min_resolution, &profile.max_resolution);
+ device_->GetSupportedResolution(fmtdesc.pixelformat, &min_resolution,
+ &profile.max_resolution);
switch (fmtdesc.pixelformat) {
case V4L2_PIX_FMT_H264:
profile.profile = media::H264PROFILE_MAIN;
@@ -521,20 +511,15 @@ void V4L2VideoEncodeAccelerator::ServiceDeviceTask() {
DCHECK(device_poll_thread_.message_loop());
// Queue the DevicePollTask() now.
device_poll_thread_.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&V4L2VideoEncodeAccelerator::DevicePollTask,
- base::Unretained(this),
- poll_device));
-
- DVLOG(2) << __func__ << ": buffer counts: ENC["
- << encoder_input_queue_.size() << "] => DEVICE["
- << free_input_buffers_.size() << "+"
- << input_buffer_queued_count_ << "/"
- << input_buffer_map_.size() << "->"
- << free_output_buffers_.size() << "+"
- << output_buffer_queued_count_ << "/"
- << output_buffer_map_.size() << "] => OUT["
- << encoder_output_queue_.size() << "]";
+ FROM_HERE, base::Bind(&V4L2VideoEncodeAccelerator::DevicePollTask,
+ base::Unretained(this), poll_device));
+
+ DVLOG(2) << __func__ << ": buffer counts: ENC[" << encoder_input_queue_.size()
+ << "] => DEVICE[" << free_input_buffers_.size() << "+"
+ << input_buffer_queued_count_ << "/" << input_buffer_map_.size()
+ << "->" << free_output_buffers_.size() << "+"
+ << output_buffer_queued_count_ << "/" << output_buffer_map_.size()
+ << "] => OUT[" << encoder_output_queue_.size() << "]";
}
void V4L2VideoEncodeAccelerator::Enqueue() {
@@ -673,8 +658,9 @@ void V4L2VideoEncodeAccelerator::Dequeue() {
}
DVLOG(3) << "Dequeue(): returning "
- "bitstream_buffer_id=" << output_record.buffer_ref->id
- << ", size=" << output_size << ", key_frame=" << key_frame;
+ "bitstream_buffer_id="
+ << output_record.buffer_ref->id << ", size=" << output_size
+ << ", key_frame=" << key_frame;
child_task_runner_->PostTask(
FROM_HERE,
base::Bind(&Client::BitstreamBufferReady, client_,
@@ -706,9 +692,9 @@ bool V4L2VideoEncodeAccelerator::EnqueueInputRecord() {
DCHECK_EQ(device_input_format_, frame->format());
for (size_t i = 0; i < input_planes_count_; ++i) {
- qbuf.m.planes[i].bytesused =
- base::checked_cast<__u32>(media::VideoFrame::PlaneSize(
- frame->format(), i, input_allocated_size_).GetArea());
+ qbuf.m.planes[i].bytesused = base::checked_cast<__u32>(
+ media::VideoFrame::PlaneSize(frame->format(), i, input_allocated_size_)
+ .GetArea());
switch (input_memory_type_) {
case V4L2_MEMORY_USERPTR:
@@ -784,10 +770,8 @@ bool V4L2VideoEncodeAccelerator::StartDevicePoll() {
// Enqueue a poll task with no devices to poll on -- it will wait only on the
// interrupt fd.
device_poll_thread_.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&V4L2VideoEncodeAccelerator::DevicePollTask,
- base::Unretained(this),
- false));
+ FROM_HERE, base::Bind(&V4L2VideoEncodeAccelerator::DevicePollTask,
+ base::Unretained(this), false));
return true;
}
@@ -855,9 +839,8 @@ void V4L2VideoEncodeAccelerator::DevicePollTask(bool poll_device) {
// All processing should happen on ServiceDeviceTask(), since we shouldn't
// touch encoder state from this thread.
encoder_thread_.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&V4L2VideoEncodeAccelerator::ServiceDeviceTask,
- base::Unretained(this)));
+ FROM_HERE, base::Bind(&V4L2VideoEncodeAccelerator::ServiceDeviceTask,
+ base::Unretained(this)));
}
void V4L2VideoEncodeAccelerator::NotifyError(Error error) {
@@ -1214,11 +1197,9 @@ bool V4L2VideoEncodeAccelerator::CreateOutputBuffers() {
buffer.m.planes = planes;
buffer.length = arraysize(planes);
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
- void* address = device_->Mmap(NULL,
- buffer.m.planes[0].length,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- buffer.m.planes[0].m.mem_offset);
+ void* address =
+ device_->Mmap(NULL, buffer.m.planes[0].length, PROT_READ | PROT_WRITE,
+ MAP_SHARED, buffer.m.planes[0].m.mem_offset);
if (address == MAP_FAILED) {
PLOG(ERROR) << "CreateOutputBuffers(): mmap() failed";
return false;
@@ -1269,4 +1250,4 @@ void V4L2VideoEncodeAccelerator::DestroyOutputBuffers() {
free_output_buffers_.clear();
}
-} // namespace content
+} // namespace media
« no previous file with comments | « media/gpu/v4l2_video_encode_accelerator.h ('k') | media/gpu/va.sigs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698