| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/gpu/arc_gpu_video_decode_accelerator.h" | 5 #include "chrome/gpu/arc_gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "content/public/gpu/gpu_video_decode_accelerator_factory.h" | |
| 12 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
| 12 #include "media/gpu/gpu_video_decode_accelerator_factory_impl.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 namespace arc { | 15 namespace arc { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // An arbitrary chosen limit of the number of buffers. The number of | 19 // An arbitrary chosen limit of the number of buffers. The number of |
| 20 // buffers used is requested from the untrusted client side. | 20 // buffers used is requested from the untrusted client side. |
| 21 const size_t kMaxBufferCount = 128; | 21 const size_t kMaxBufferCount = 128; |
| 22 | 22 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 ArcGpuVideoDecodeAccelerator::InputBufferInfo::~InputBufferInfo() = default; | 45 ArcGpuVideoDecodeAccelerator::InputBufferInfo::~InputBufferInfo() = default; |
| 46 | 46 |
| 47 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo() = default; | 47 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo() = default; |
| 48 | 48 |
| 49 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo( | 49 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::OutputBufferInfo( |
| 50 OutputBufferInfo&& other) = default; | 50 OutputBufferInfo&& other) = default; |
| 51 | 51 |
| 52 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::~OutputBufferInfo() = default; | 52 ArcGpuVideoDecodeAccelerator::OutputBufferInfo::~OutputBufferInfo() = default; |
| 53 | 53 |
| 54 ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator() | 54 ArcGpuVideoDecodeAccelerator::ArcGpuVideoDecodeAccelerator( |
| 55 const gpu::GpuPreferences& gpu_preferences) |
| 55 : arc_client_(nullptr), | 56 : arc_client_(nullptr), |
| 56 next_bitstream_buffer_id_(0), | 57 next_bitstream_buffer_id_(0), |
| 57 output_pixel_format_(media::PIXEL_FORMAT_UNKNOWN), | 58 output_pixel_format_(media::PIXEL_FORMAT_UNKNOWN), |
| 58 output_buffer_size_(0) {} | 59 output_buffer_size_(0), |
| 60 gpu_preferences_(gpu_preferences) {} |
| 59 | 61 |
| 60 ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() { | 62 ArcGpuVideoDecodeAccelerator::~ArcGpuVideoDecodeAccelerator() { |
| 61 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 if (vda_) { | 64 if (vda_) { |
| 63 client_count_--; | 65 client_count_--; |
| 64 } | 66 } |
| 65 } | 67 } |
| 66 | 68 |
| 67 ArcVideoAccelerator::Result ArcGpuVideoDecodeAccelerator::Initialize( | 69 ArcVideoAccelerator::Result ArcGpuVideoDecodeAccelerator::Initialize( |
| 68 const Config& config, | 70 const Config& config, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 case HAL_PIXEL_FORMAT_VP8: | 104 case HAL_PIXEL_FORMAT_VP8: |
| 103 vda_config.profile = media::VP8PROFILE_ANY; | 105 vda_config.profile = media::VP8PROFILE_ANY; |
| 104 break; | 106 break; |
| 105 default: | 107 default: |
| 106 DLOG(ERROR) << "Unsupported input format: " << config.input_pixel_format; | 108 DLOG(ERROR) << "Unsupported input format: " << config.input_pixel_format; |
| 107 return INVALID_ARGUMENT; | 109 return INVALID_ARGUMENT; |
| 108 } | 110 } |
| 109 vda_config.output_mode = | 111 vda_config.output_mode = |
| 110 media::VideoDecodeAccelerator::Config::OutputMode::IMPORT; | 112 media::VideoDecodeAccelerator::Config::OutputMode::IMPORT; |
| 111 | 113 |
| 112 std::unique_ptr<content::GpuVideoDecodeAcceleratorFactory> vda_factory = | 114 auto vda_factory = |
| 113 content::GpuVideoDecodeAcceleratorFactory::CreateWithNoGL(); | 115 media::GpuVideoDecodeAcceleratorFactoryImpl::CreateWithNoGL(); |
| 114 vda_ = vda_factory->CreateVDA(this, vda_config); | 116 vda_ = vda_factory->CreateVDA( |
| 117 this, vda_config, gpu::GpuDriverBugWorkarounds(), gpu_preferences_); |
| 115 if (!vda_) { | 118 if (!vda_) { |
| 116 DLOG(ERROR) << "Failed to create VDA."; | 119 DLOG(ERROR) << "Failed to create VDA."; |
| 117 return PLATFORM_FAILURE; | 120 return PLATFORM_FAILURE; |
| 118 } | 121 } |
| 119 | 122 |
| 120 client_count_++; | 123 client_count_++; |
| 121 DVLOG(5) << "Number of concurrent ArcVideoAccelerator clients: " | 124 DVLOG(5) << "Number of concurrent ArcVideoAccelerator clients: " |
| 122 << client_count_; | 125 << client_count_; |
| 123 | 126 |
| 124 return SUCCESS; | 127 return SUCCESS; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 494 } |
| 492 return true; | 495 return true; |
| 493 default: | 496 default: |
| 494 DLOG(ERROR) << "Invalid port: " << port; | 497 DLOG(ERROR) << "Invalid port: " << port; |
| 495 return false; | 498 return false; |
| 496 } | 499 } |
| 497 } | 500 } |
| 498 | 501 |
| 499 } // namespace arc | 502 } // namespace arc |
| 500 } // namespace chromeos | 503 } // namespace chromeos |
| OLD | NEW |