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

Side by Side Diff: media/gpu/gpu_video_decode_accelerator_factory_impl.cc

Issue 2061823003: media: Drop "media::" in media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: work around clang format by adding an empty line Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « media/gpu/gpu_video_decode_accelerator_factory_impl.h ('k') | media/gpu/h264_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/gpu/gpu_video_decode_accelerator_factory_impl.h" 5 #include "media/gpu/gpu_video_decode_accelerator_factory_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "gpu/command_buffer/service/gpu_preferences.h" 8 #include "gpu/command_buffer/service/gpu_preferences.h"
9 #include "media/gpu/gpu_video_accelerator_util.h" 9 #include "media/gpu/gpu_video_accelerator_util.h"
10 #include "media/gpu/media_gpu_export.h" 10 #include "media/gpu/media_gpu_export.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl> 58 MEDIA_GPU_EXPORT std::unique_ptr<GpuVideoDecodeAcceleratorFactoryImpl>
59 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithNoGL() { 59 GpuVideoDecodeAcceleratorFactoryImpl::CreateWithNoGL() {
60 return Create(GetGLContextCallback(), MakeGLContextCurrentCallback(), 60 return Create(GetGLContextCallback(), MakeGLContextCurrentCallback(),
61 BindGLImageCallback()); 61 BindGLImageCallback());
62 } 62 }
63 63
64 // static 64 // static
65 MEDIA_GPU_EXPORT gpu::VideoDecodeAcceleratorCapabilities 65 MEDIA_GPU_EXPORT gpu::VideoDecodeAcceleratorCapabilities
66 GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities( 66 GpuVideoDecodeAcceleratorFactoryImpl::GetDecoderCapabilities(
67 const gpu::GpuPreferences& gpu_preferences) { 67 const gpu::GpuPreferences& gpu_preferences) {
68 media::VideoDecodeAccelerator::Capabilities capabilities; 68 VideoDecodeAccelerator::Capabilities capabilities;
69 if (gpu_preferences.disable_accelerated_video_decode) 69 if (gpu_preferences.disable_accelerated_video_decode)
70 return gpu::VideoDecodeAcceleratorCapabilities(); 70 return gpu::VideoDecodeAcceleratorCapabilities();
71 71
72 // Query VDAs for their capabilities and construct a set of supported 72 // Query VDAs for their capabilities and construct a set of supported
73 // profiles for current platform. This must be done in the same order as in 73 // profiles for current platform. This must be done in the same order as in
74 // CreateVDA(), as we currently preserve additional capabilities (such as 74 // CreateVDA(), as we currently preserve additional capabilities (such as
75 // resolutions supported) only for the first VDA supporting the given codec 75 // resolutions supported) only for the first VDA supporting the given codec
76 // profile (instead of calculating a superset). 76 // profile (instead of calculating a superset).
77 // TODO(posciak,henryhsu): improve this so that we choose a superset of 77 // TODO(posciak,henryhsu): improve this so that we choose a superset of
78 // resolutions and other supported profile parameters. 78 // resolutions and other supported profile parameters.
79 #if defined(OS_WIN) 79 #if defined(OS_WIN)
80 capabilities.supported_profiles = 80 capabilities.supported_profiles =
81 DXVAVideoDecodeAccelerator::GetSupportedProfiles(); 81 DXVAVideoDecodeAccelerator::GetSupportedProfiles();
82 #elif defined(OS_CHROMEOS) 82 #elif defined(OS_CHROMEOS)
83 media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; 83 VideoDecodeAccelerator::SupportedProfiles vda_profiles;
84 #if defined(USE_V4L2_CODEC) 84 #if defined(USE_V4L2_CODEC)
85 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); 85 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
86 media::GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( 86 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(
87 vda_profiles, &capabilities.supported_profiles); 87 vda_profiles, &capabilities.supported_profiles);
88 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); 88 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles();
89 media::GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( 89 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(
90 vda_profiles, &capabilities.supported_profiles); 90 vda_profiles, &capabilities.supported_profiles);
91 #endif 91 #endif
92 #if defined(ARCH_CPU_X86_FAMILY) 92 #if defined(ARCH_CPU_X86_FAMILY)
93 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); 93 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles();
94 media::GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( 94 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(
95 vda_profiles, &capabilities.supported_profiles); 95 vda_profiles, &capabilities.supported_profiles);
96 #endif 96 #endif
97 #elif defined(OS_MACOSX) 97 #elif defined(OS_MACOSX)
98 capabilities.supported_profiles = 98 capabilities.supported_profiles =
99 VTVideoDecodeAccelerator::GetSupportedProfiles(); 99 VTVideoDecodeAccelerator::GetSupportedProfiles();
100 #elif defined(OS_ANDROID) 100 #elif defined(OS_ANDROID)
101 capabilities = 101 capabilities =
102 AndroidVideoDecodeAccelerator::GetCapabilities(gpu_preferences); 102 AndroidVideoDecodeAccelerator::GetCapabilities(gpu_preferences);
103 #endif 103 #endif
104 return media::GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeCapabilities( 104 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeCapabilities(
105 capabilities); 105 capabilities);
106 } 106 }
107 107
108 MEDIA_GPU_EXPORT std::unique_ptr<media::VideoDecodeAccelerator> 108 MEDIA_GPU_EXPORT std::unique_ptr<VideoDecodeAccelerator>
109 GpuVideoDecodeAcceleratorFactoryImpl::CreateVDA( 109 GpuVideoDecodeAcceleratorFactoryImpl::CreateVDA(
110 media::VideoDecodeAccelerator::Client* client, 110 VideoDecodeAccelerator::Client* client,
111 const media::VideoDecodeAccelerator::Config& config, 111 const VideoDecodeAccelerator::Config& config,
112 const gpu::GpuPreferences& gpu_preferences) { 112 const gpu::GpuPreferences& gpu_preferences) {
113 DCHECK(thread_checker_.CalledOnValidThread()); 113 DCHECK(thread_checker_.CalledOnValidThread());
114 114
115 if (gpu_preferences.disable_accelerated_video_decode) 115 if (gpu_preferences.disable_accelerated_video_decode)
116 return nullptr; 116 return nullptr;
117 117
118 // Array of Create..VDA() function pointers, potentially usable on current 118 // Array of Create..VDA() function pointers, potentially usable on current
119 // platform. This list is ordered by priority, from most to least preferred, 119 // platform. This list is ordered by priority, from most to least preferred,
120 // if applicable. This list must be in the same order as the querying order 120 // if applicable. This list must be in the same order as the querying order
121 // in GetDecoderCapabilities() above. 121 // in GetDecoderCapabilities() above.
122 using CreateVDAFp = std::unique_ptr<media::VideoDecodeAccelerator> ( 122 using CreateVDAFp = std::unique_ptr<VideoDecodeAccelerator> (
123 GpuVideoDecodeAcceleratorFactoryImpl::*)(const gpu::GpuPreferences&) 123 GpuVideoDecodeAcceleratorFactoryImpl::*)(const gpu::GpuPreferences&)
124 const; 124 const;
125 const CreateVDAFp create_vda_fps[] = { 125 const CreateVDAFp create_vda_fps[] = {
126 #if defined(OS_WIN) 126 #if defined(OS_WIN)
127 &GpuVideoDecodeAcceleratorFactoryImpl::CreateDXVAVDA, 127 &GpuVideoDecodeAcceleratorFactoryImpl::CreateDXVAVDA,
128 #endif 128 #endif
129 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) 129 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
130 &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA, 130 &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA,
131 &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA, 131 &GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA,
132 #endif 132 #endif
133 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 133 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
134 &GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA, 134 &GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA,
135 #endif 135 #endif
136 #if defined(OS_MACOSX) 136 #if defined(OS_MACOSX)
137 &GpuVideoDecodeAcceleratorFactoryImpl::CreateVTVDA, 137 &GpuVideoDecodeAcceleratorFactoryImpl::CreateVTVDA,
138 #endif 138 #endif
139 #if defined(OS_ANDROID) 139 #if defined(OS_ANDROID)
140 &GpuVideoDecodeAcceleratorFactoryImpl::CreateAndroidVDA, 140 &GpuVideoDecodeAcceleratorFactoryImpl::CreateAndroidVDA,
141 #endif 141 #endif
142 }; 142 };
143 143
144 std::unique_ptr<media::VideoDecodeAccelerator> vda; 144 std::unique_ptr<VideoDecodeAccelerator> vda;
145 145
146 for (const auto& create_vda_function : create_vda_fps) { 146 for (const auto& create_vda_function : create_vda_fps) {
147 vda = (this->*create_vda_function)(gpu_preferences); 147 vda = (this->*create_vda_function)(gpu_preferences);
148 if (vda && vda->Initialize(config, client)) 148 if (vda && vda->Initialize(config, client))
149 return vda; 149 return vda;
150 } 150 }
151 151
152 return nullptr; 152 return nullptr;
153 } 153 }
154 154
155 #if defined(OS_WIN) 155 #if defined(OS_WIN)
156 std::unique_ptr<media::VideoDecodeAccelerator> 156 std::unique_ptr<VideoDecodeAccelerator>
157 GpuVideoDecodeAcceleratorFactoryImpl::CreateDXVAVDA( 157 GpuVideoDecodeAcceleratorFactoryImpl::CreateDXVAVDA(
158 const gpu::GpuPreferences& gpu_preferences) const { 158 const gpu::GpuPreferences& gpu_preferences) const {
159 std::unique_ptr<media::VideoDecodeAccelerator> decoder; 159 std::unique_ptr<VideoDecodeAccelerator> decoder;
160 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { 160 if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
161 DVLOG(0) << "Initializing DXVA HW decoder for windows."; 161 DVLOG(0) << "Initializing DXVA HW decoder for windows.";
162 decoder.reset(new DXVAVideoDecodeAccelerator( 162 decoder.reset(new DXVAVideoDecodeAccelerator(
163 get_gl_context_cb_, make_context_current_cb_, gpu_preferences)); 163 get_gl_context_cb_, make_context_current_cb_, gpu_preferences));
164 } 164 }
165 return decoder; 165 return decoder;
166 } 166 }
167 #endif 167 #endif
168 168
169 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) 169 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
170 std::unique_ptr<media::VideoDecodeAccelerator> 170 std::unique_ptr<VideoDecodeAccelerator>
171 GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA( 171 GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2VDA(
172 const gpu::GpuPreferences& gpu_preferences) const { 172 const gpu::GpuPreferences& gpu_preferences) const {
173 std::unique_ptr<media::VideoDecodeAccelerator> decoder; 173 std::unique_ptr<VideoDecodeAccelerator> decoder;
174 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 174 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
175 if (device.get()) { 175 if (device.get()) {
176 decoder.reset(new V4L2VideoDecodeAccelerator( 176 decoder.reset(new V4L2VideoDecodeAccelerator(
177 gl::GLSurfaceEGL::GetHardwareDisplay(), get_gl_context_cb_, 177 gl::GLSurfaceEGL::GetHardwareDisplay(), get_gl_context_cb_,
178 make_context_current_cb_, device)); 178 make_context_current_cb_, device));
179 } 179 }
180 return decoder; 180 return decoder;
181 } 181 }
182 182
183 std::unique_ptr<media::VideoDecodeAccelerator> 183 std::unique_ptr<VideoDecodeAccelerator>
184 GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA( 184 GpuVideoDecodeAcceleratorFactoryImpl::CreateV4L2SVDA(
185 const gpu::GpuPreferences& gpu_preferences) const { 185 const gpu::GpuPreferences& gpu_preferences) const {
186 std::unique_ptr<media::VideoDecodeAccelerator> decoder; 186 std::unique_ptr<VideoDecodeAccelerator> decoder;
187 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 187 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
188 if (device.get()) { 188 if (device.get()) {
189 decoder.reset(new V4L2SliceVideoDecodeAccelerator( 189 decoder.reset(new V4L2SliceVideoDecodeAccelerator(
190 device, gl::GLSurfaceEGL::GetHardwareDisplay(), get_gl_context_cb_, 190 device, gl::GLSurfaceEGL::GetHardwareDisplay(), get_gl_context_cb_,
191 make_context_current_cb_)); 191 make_context_current_cb_));
192 } 192 }
193 return decoder; 193 return decoder;
194 } 194 }
195 #endif 195 #endif
196 196
197 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 197 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
198 std::unique_ptr<media::VideoDecodeAccelerator> 198 std::unique_ptr<VideoDecodeAccelerator>
199 GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA( 199 GpuVideoDecodeAcceleratorFactoryImpl::CreateVaapiVDA(
200 const gpu::GpuPreferences& gpu_preferences) const { 200 const gpu::GpuPreferences& gpu_preferences) const {
201 std::unique_ptr<media::VideoDecodeAccelerator> decoder; 201 std::unique_ptr<VideoDecodeAccelerator> decoder;
202 decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_, 202 decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_,
203 bind_image_cb_)); 203 bind_image_cb_));
204 return decoder; 204 return decoder;
205 } 205 }
206 #endif 206 #endif
207 207
208 #if defined(OS_MACOSX) 208 #if defined(OS_MACOSX)
209 std::unique_ptr<media::VideoDecodeAccelerator> 209 std::unique_ptr<VideoDecodeAccelerator>
210 GpuVideoDecodeAcceleratorFactoryImpl::CreateVTVDA( 210 GpuVideoDecodeAcceleratorFactoryImpl::CreateVTVDA(
211 const gpu::GpuPreferences& gpu_preferences) const { 211 const gpu::GpuPreferences& gpu_preferences) const {
212 std::unique_ptr<media::VideoDecodeAccelerator> decoder; 212 std::unique_ptr<VideoDecodeAccelerator> decoder;
213 decoder.reset( 213 decoder.reset(
214 new VTVideoDecodeAccelerator(make_context_current_cb_, bind_image_cb_)); 214 new VTVideoDecodeAccelerator(make_context_current_cb_, bind_image_cb_));
215 return decoder; 215 return decoder;
216 } 216 }
217 #endif 217 #endif
218 218
219 #if defined(OS_ANDROID) 219 #if defined(OS_ANDROID)
220 std::unique_ptr<media::VideoDecodeAccelerator> 220 std::unique_ptr<VideoDecodeAccelerator>
221 GpuVideoDecodeAcceleratorFactoryImpl::CreateAndroidVDA( 221 GpuVideoDecodeAcceleratorFactoryImpl::CreateAndroidVDA(
222 const gpu::GpuPreferences& gpu_preferences) const { 222 const gpu::GpuPreferences& gpu_preferences) const {
223 std::unique_ptr<media::VideoDecodeAccelerator> decoder; 223 std::unique_ptr<VideoDecodeAccelerator> decoder;
224 decoder.reset(new AndroidVideoDecodeAccelerator(make_context_current_cb_, 224 decoder.reset(new AndroidVideoDecodeAccelerator(make_context_current_cb_,
225 get_gles2_decoder_cb_)); 225 get_gles2_decoder_cb_));
226 return decoder; 226 return decoder;
227 } 227 }
228 #endif 228 #endif
229 229
230 GpuVideoDecodeAcceleratorFactoryImpl::GpuVideoDecodeAcceleratorFactoryImpl( 230 GpuVideoDecodeAcceleratorFactoryImpl::GpuVideoDecodeAcceleratorFactoryImpl(
231 const GetGLContextCallback& get_gl_context_cb, 231 const GetGLContextCallback& get_gl_context_cb,
232 const MakeGLContextCurrentCallback& make_context_current_cb, 232 const MakeGLContextCurrentCallback& make_context_current_cb,
233 const BindGLImageCallback& bind_image_cb, 233 const BindGLImageCallback& bind_image_cb,
234 const GetGLES2DecoderCallback& get_gles2_decoder_cb) 234 const GetGLES2DecoderCallback& get_gles2_decoder_cb)
235 : get_gl_context_cb_(get_gl_context_cb), 235 : get_gl_context_cb_(get_gl_context_cb),
236 make_context_current_cb_(make_context_current_cb), 236 make_context_current_cb_(make_context_current_cb),
237 bind_image_cb_(bind_image_cb), 237 bind_image_cb_(bind_image_cb),
238 get_gles2_decoder_cb_(get_gles2_decoder_cb) {} 238 get_gles2_decoder_cb_(get_gles2_decoder_cb) {}
239 239
240 GpuVideoDecodeAcceleratorFactoryImpl::~GpuVideoDecodeAcceleratorFactoryImpl() {} 240 GpuVideoDecodeAcceleratorFactoryImpl::~GpuVideoDecodeAcceleratorFactoryImpl() {}
241 241
242 } // namespace media 242 } // namespace media
OLDNEW
« no previous file with comments | « media/gpu/gpu_video_decode_accelerator_factory_impl.h ('k') | media/gpu/h264_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698