OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_jpeg_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_jpeg_decode_accelerator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
16 #include "content/common/gpu/gpu_channel.h" | 16 #include "content/common/gpu/gpu_channel.h" |
17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
18 #include "ipc/ipc_message_macros.h" | 18 #include "ipc/ipc_message_macros.h" |
19 #include "ipc/message_filter.h" | 19 #include "ipc/message_filter.h" |
20 #include "media/filters/jpeg_parser.h" | 20 #include "media/filters/jpeg_parser.h" |
21 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
22 | 22 |
23 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 23 #if defined(OS_CHROMEOS) |
| 24 #if defined(ARCH_CPU_X86_FAMILY) |
24 #include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h" | 25 #include "content/common/gpu/media/vaapi_jpeg_decode_accelerator.h" |
25 #endif | 26 #endif |
| 27 #if defined(USE_V4L2_CODEC) |
| 28 #include "content/common/gpu/media/v4l2_device.h" |
| 29 #include "content/common/gpu/media/v4l2_jpeg_decode_accelerator.h" |
| 30 #endif |
| 31 #endif |
26 | 32 |
27 namespace { | 33 namespace { |
28 | 34 |
29 void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { | 35 void DecodeFinished(scoped_ptr<base::SharedMemory> shm) { |
30 // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this | 36 // Do nothing. Because VideoFrame is backed by |shm|, the purpose of this |
31 // function is to just keep reference of |shm| to make sure it lives util | 37 // function is to just keep reference of |shm| to make sure it lives util |
32 // decode finishes. | 38 // decode finishes. |
33 } | 39 } |
34 | 40 |
35 bool VerifyDecodeParams(const AcceleratedJpegDecoderMsg_Decode_Params& params) { | 41 bool VerifyDecodeParams(const AcceleratedJpegDecoderMsg_Decode_Params& params) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 325 |
320 void GpuJpegDecodeAccelerator::AddClient(int32 route_id, | 326 void GpuJpegDecodeAccelerator::AddClient(int32 route_id, |
321 IPC::Message* reply_msg) { | 327 IPC::Message* reply_msg) { |
322 DCHECK(CalledOnValidThread()); | 328 DCHECK(CalledOnValidThread()); |
323 scoped_ptr<media::JpegDecodeAccelerator> accelerator; | 329 scoped_ptr<media::JpegDecodeAccelerator> accelerator; |
324 | 330 |
325 // When adding more platforms, VideoCaptureGpuJpegDecoder::Supported need | 331 // When adding more platforms, VideoCaptureGpuJpegDecoder::Supported need |
326 // update as well. | 332 // update as well. |
327 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 333 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
328 accelerator.reset(new VaapiJpegDecodeAccelerator(io_task_runner_)); | 334 accelerator.reset(new VaapiJpegDecodeAccelerator(io_task_runner_)); |
| 335 #elif defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 336 scoped_refptr<V4L2Device> device = V4L2Device::Create( |
| 337 V4L2Device::kJpegDecoder); |
| 338 if (device) { |
| 339 accelerator.reset(new V4L2JpegDecodeAccelerator( |
| 340 device, io_task_runner_)); |
| 341 } |
329 #else | 342 #else |
330 DVLOG(1) << "HW JPEG decode acceleration not available."; | 343 DVLOG(1) << "HW JPEG decode acceleration not available."; |
331 #endif | 344 #endif |
332 | 345 |
333 scoped_ptr<Client> client(new Client(this, route_id)); | 346 scoped_ptr<Client> client(new Client(this, route_id)); |
334 if (!accelerator.get() || !accelerator->Initialize(client.get())) { | 347 if (!accelerator.get() || !accelerator->Initialize(client.get())) { |
335 DLOG(ERROR) << "JPEG accelerator Initialize failed"; | 348 DLOG(ERROR) << "JPEG accelerator Initialize failed"; |
336 GpuMsg_CreateJpegDecoder::WriteReplyParams(reply_msg, false); | 349 GpuMsg_CreateJpegDecoder::WriteReplyParams(reply_msg, false); |
337 Send(reply_msg); | 350 Send(reply_msg); |
338 return; | 351 return; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 filter_ = nullptr; | 388 filter_ = nullptr; |
376 } | 389 } |
377 } | 390 } |
378 | 391 |
379 bool GpuJpegDecodeAccelerator::Send(IPC::Message* message) { | 392 bool GpuJpegDecodeAccelerator::Send(IPC::Message* message) { |
380 DCHECK(CalledOnValidThread()); | 393 DCHECK(CalledOnValidThread()); |
381 return channel_->Send(message); | 394 return channel_->Send(message); |
382 } | 395 } |
383 | 396 |
384 } // namespace content | 397 } // namespace content |
OLD | NEW |