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

Unified Diff: media/gpu/v4l2_video_encode_accelerator.cc

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues 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
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 f8b56ab89faba4e1f1a74d78939dbdeb55c4bdc1..291f57116980292e5b89b7a2d47a08dffe021c25 100644
--- a/content/common/gpu/media/v4l2_video_encode_accelerator.cc
+++ b/media/gpu/v4l2_video_encode_accelerator.cc
@@ -17,10 +17,10 @@
#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 "content/common/gpu/media/v4l2_video_encode_accelerator.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/bitstream_buffer.h"
+#include "media/gpu/shared_memory_region.h"
+#include "media/gpu/v4l2_video_encode_accelerator.h"
#define NOTIFY_ERROR(x) \
do { \
@@ -28,13 +28,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) \
@@ -43,13 +43,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)
@@ -58,18 +58,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()
@@ -134,7 +130,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;
}
@@ -227,11 +224,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));
}
}
@@ -257,8 +251,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(
@@ -272,9 +265,7 @@ void V4L2VideoEncodeAccelerator::RequestEncodingParametersChange(
FROM_HERE,
base::Bind(
&V4L2VideoEncodeAccelerator::RequestEncodingParametersChangeTask,
- base::Unretained(this),
- bitrate,
- framerate));
+ base::Unretained(this), bitrate, framerate));
}
void V4L2VideoEncodeAccelerator::Destroy() {
@@ -291,9 +282,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();
@@ -320,8 +310,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;
@@ -498,20 +488,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() {
@@ -650,8 +635,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_,
@@ -683,9 +669,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:
@@ -761,10 +747,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;
}
@@ -832,9 +816,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) {
@@ -1191,11 +1174,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;
@@ -1246,4 +1227,4 @@ void V4L2VideoEncodeAccelerator::DestroyOutputBuffers() {
free_output_buffers_.clear();
}
-} // namespace content
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698