OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/gpu/media/gpu_video_encode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
11 #include "base/numerics/safe_math.h" | 11 #include "base/numerics/safe_math.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | |
15 #include "content/common/gpu/gpu_channel.h" | 14 #include "content/common/gpu/gpu_channel.h" |
16 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
17 #include "content/common/gpu/media/gpu_video_accelerator_util.h" | 16 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
18 #include "content/common/gpu/media/media_messages.h" | 17 #include "content/common/gpu/media/media_messages.h" |
| 18 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" |
19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
20 #include "media/base/bind_to_current_loop.h" | 20 #include "media/base/bind_to_current_loop.h" |
21 #include "media/base/limits.h" | 21 #include "media/base/limits.h" |
22 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
23 | 23 |
24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
25 #if defined(USE_V4L2_CODEC) | 25 #if defined(USE_V4L2_CODEC) |
26 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 26 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
27 #endif | 27 #endif |
28 #if defined(ARCH_CPU_X86_FAMILY) | 28 #if defined(ARCH_CPU_X86_FAMILY) |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 uint8_t* data[media::VideoFrame::kMaxPlanes]; | 342 uint8_t* data[media::VideoFrame::kMaxPlanes]; |
343 int32_t strides[media::VideoFrame::kMaxPlanes]; | 343 int32_t strides[media::VideoFrame::kMaxPlanes]; |
344 ScopedVector<gfx::GpuMemoryBuffer> buffers; | 344 ScopedVector<gfx::GpuMemoryBuffer> buffers; |
345 const auto& handles = params.gpu_memory_buffer_handles; | 345 const auto& handles = params.gpu_memory_buffer_handles; |
346 for (size_t i = 0; i < handles.size(); ++i) { | 346 for (size_t i = 0; i < handles.size(); ++i) { |
347 const size_t width = | 347 const size_t width = |
348 media::VideoFrame::Columns(i, input_format_, params.size.width()); | 348 media::VideoFrame::Columns(i, input_format_, params.size.width()); |
349 const size_t height = | 349 const size_t height = |
350 media::VideoFrame::Rows(i, input_format_, params.size.height()); | 350 media::VideoFrame::Rows(i, input_format_, params.size.height()); |
351 scoped_ptr<gfx::GpuMemoryBuffer> buffer = | 351 scoped_ptr<gfx::GpuMemoryBuffer> buffer = |
352 GpuMemoryBufferImpl::CreateFromHandle( | 352 gpu::GpuMemoryBufferImpl::CreateFromHandle( |
353 handles[i], gfx::Size(width, height), gfx::BufferFormat::R_8, | 353 handles[i], gfx::Size(width, height), gfx::BufferFormat::R_8, |
354 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, | 354 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, |
355 media::BindToCurrentLoop(base::Bind(&DestroyGpuMemoryBuffer))); | 355 media::BindToCurrentLoop(base::Bind(&DestroyGpuMemoryBuffer))); |
356 | 356 |
357 // TODO(emircan): Refactor such that each frame is mapped once. | 357 // TODO(emircan): Refactor such that each frame is mapped once. |
358 // See http://crbug/536938. | 358 // See http://crbug/536938. |
359 if (!buffer.get() || !buffer->Map()) { | 359 if (!buffer.get() || !buffer->Map()) { |
360 map_result = false; | 360 map_result = false; |
361 continue; | 361 continue; |
362 } | 362 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, | 467 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, |
468 frame_id)); | 468 frame_id)); |
469 // Just let |buffers| fall out of scope. | 469 // Just let |buffers| fall out of scope. |
470 } | 470 } |
471 | 471 |
472 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { | 472 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { |
473 stub_->channel()->Send(message); | 473 stub_->channel()->Send(message); |
474 } | 474 } |
475 | 475 |
476 } // namespace content | 476 } // namespace content |
OLD | NEW |