Commit 24ffc7e8 authored by Andres Calderon Jaramillo's avatar Andres Calderon Jaramillo Committed by Chromium LUCI CQ

media/V4L2VEA: Remove dependency on GMB factory.

This CL removes the usage of a GpuMemoryBufferFactory from the
V4L2VideoEncodeAccelerator. This is because we don't actually need it to
allocate buffers and it simplifies things.

Note that we must start the |encoder_task_runner_| with base::MayBlock()
because the first encoder to make use of this path will open the render
node.

Bug: b:173167846
Test: video.EncodeAccel.h264_720p_nv12_dmabuf on elm
Change-Id: I01d5f63f0b358c0ee9bb448ded7ba24355a72f9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568548
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835114}
parent ee6f7f9f
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "media/base/bitstream_buffer.h" #include "media/base/bitstream_buffer.h"
#include "media/base/color_plane_layout.h" #include "media/base/color_plane_layout.h"
#include "media/base/scopedfd_helper.h" #include "media/base/scopedfd_helper.h"
...@@ -181,7 +180,7 @@ V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator( ...@@ -181,7 +180,7 @@ V4L2VideoEncodeAccelerator::V4L2VideoEncodeAccelerator(
// TODO(akahuang): Remove WithBaseSyncPrimitives() after replacing poll // TODO(akahuang): Remove WithBaseSyncPrimitives() after replacing poll
// thread by V4L2DevicePoller. // thread by V4L2DevicePoller.
encoder_task_runner_(base::ThreadPool::CreateSingleThreadTaskRunner( encoder_task_runner_(base::ThreadPool::CreateSingleThreadTaskRunner(
{base::WithBaseSyncPrimitives()}, {base::WithBaseSyncPrimitives(), base::MayBlock()},
base::SingleThreadTaskRunnerThreadMode::DEDICATED)), base::SingleThreadTaskRunnerThreadMode::DEDICATED)),
device_poll_thread_("V4L2EncoderDevicePollThread") { device_poll_thread_("V4L2EncoderDevicePollThread") {
DCHECK_CALLED_ON_VALID_SEQUENCE(child_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(child_sequence_checker_);
...@@ -402,17 +401,8 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor( ...@@ -402,17 +401,8 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor(
return false; return false;
} }
if (!image_processor_gmb_factory_) {
image_processor_gmb_factory_ =
gpu::GpuMemoryBufferFactory::CreateNativeType(nullptr);
if (!image_processor_gmb_factory_) {
VLOGF(1) << "Failed to create GpuMemoryBufferFactory";
return false;
}
}
auto platform_layout = GetPlatformVideoFrameLayout( auto platform_layout = GetPlatformVideoFrameLayout(
image_processor_gmb_factory_.get(), output_format, output_size, /*gpu_memory_buffer_factory=*/nullptr, output_format, output_size,
gfx::BufferUsage::SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE); gfx::BufferUsage::SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE);
if (!platform_layout) { if (!platform_layout) {
VLOGF(1) << "Failed to get Platform VideoFrameLayout"; VLOGF(1) << "Failed to get Platform VideoFrameLayout";
...@@ -467,7 +457,6 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor( ...@@ -467,7 +457,6 @@ bool V4L2VideoEncodeAccelerator::CreateImageProcessor(
bool V4L2VideoEncodeAccelerator::AllocateImageProcessorOutputBuffers( bool V4L2VideoEncodeAccelerator::AllocateImageProcessorOutputBuffers(
size_t count) { size_t count) {
DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(encoder_sequence_checker_);
DCHECK(image_processor_gmb_factory_);
DCHECK(image_processor_); DCHECK(image_processor_);
DCHECK_EQ(image_processor_->output_mode(), DCHECK_EQ(image_processor_->output_mode(),
ImageProcessor::OutputMode::IMPORT); ImageProcessor::OutputMode::IMPORT);
...@@ -483,7 +472,7 @@ bool V4L2VideoEncodeAccelerator::AllocateImageProcessorOutputBuffers( ...@@ -483,7 +472,7 @@ bool V4L2VideoEncodeAccelerator::AllocateImageProcessorOutputBuffers(
switch (output_config.storage_type()) { switch (output_config.storage_type()) {
case VideoFrame::STORAGE_GPU_MEMORY_BUFFER: case VideoFrame::STORAGE_GPU_MEMORY_BUFFER:
image_processor_output_buffers_[i] = CreateGpuMemoryBufferVideoFrame( image_processor_output_buffers_[i] = CreateGpuMemoryBufferVideoFrame(
image_processor_gmb_factory_.get(), /*gpu_memory_buffer_factory=*/nullptr,
output_config.fourcc.ToVideoPixelFormat(), output_config.size, output_config.fourcc.ToVideoPixelFormat(), output_config.size,
output_config.visible_rect, output_config.visible_rect.size(), output_config.visible_rect, output_config.visible_rect.size(),
base::TimeDelta(), base::TimeDelta(),
...@@ -1654,16 +1643,8 @@ bool V4L2VideoEncodeAccelerator::SetFormats(VideoPixelFormat input_format, ...@@ -1654,16 +1643,8 @@ bool V4L2VideoEncodeAccelerator::SetFormats(VideoPixelFormat input_format,
gfx::Size input_size = encoder_input_visible_rect_.size(); gfx::Size input_size = encoder_input_visible_rect_.size();
if (native_input_mode_) { if (native_input_mode_) {
DCHECK(!image_processor_gmb_factory_);
image_processor_gmb_factory_ =
gpu::GpuMemoryBufferFactory::CreateNativeType(nullptr);
if (!image_processor_gmb_factory_) {
VLOGF(1) << "Failed to create GpuMemoryBufferFactory";
return false;
}
auto input_layout = GetPlatformVideoFrameLayout( auto input_layout = GetPlatformVideoFrameLayout(
image_processor_gmb_factory_.get(), input_format, /*gpu_memory_buffer_factory=*/nullptr, input_format,
encoder_input_visible_rect_.size(), encoder_input_visible_rect_.size(),
gfx::BufferUsage::SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE); gfx::BufferUsage::SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE);
if (!input_layout) if (!input_layout)
......
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
#include "media/video/video_encode_accelerator.h" #include "media/video/video_encode_accelerator.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
namespace gpu {
class GpuMemoryBufferFactory;
} // namespace gpu
namespace media { namespace media {
class BitstreamBuffer; class BitstreamBuffer;
...@@ -330,9 +326,6 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator ...@@ -330,9 +326,6 @@ class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
// Image processor, if one is in use. // Image processor, if one is in use.
std::unique_ptr<ImageProcessor> image_processor_; std::unique_ptr<ImageProcessor> image_processor_;
// GpuMemoryBufferFactory to create GMB-based VideoFrame. This is needed only
// if image processor is used and its output buffer is GMB-based VideoFrame.
std::unique_ptr<gpu::GpuMemoryBufferFactory> image_processor_gmb_factory_;
// Video frames for image processor output / VideoEncodeAccelerator input. // Video frames for image processor output / VideoEncodeAccelerator input.
// Only accessed on child thread. // Only accessed on child thread.
std::vector<scoped_refptr<VideoFrame>> image_processor_output_buffers_; std::vector<scoped_refptr<VideoFrame>> image_processor_output_buffers_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment