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

Side by Side Diff: media/gpu/ipc/service/gpu_video_encode_accelerator.cc

Issue 2058413003: H264 HW encode using MediaFoundation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wuchengli@ and ananta@ comments. Created 4 years, 5 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
OLDNEW
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 "media/gpu/ipc/service/gpu_video_encode_accelerator.h" 5 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 17 matching lines...) Expand all
28 #if defined(USE_V4L2_CODEC) 28 #if defined(USE_V4L2_CODEC)
29 #include "media/gpu/v4l2_video_encode_accelerator.h" 29 #include "media/gpu/v4l2_video_encode_accelerator.h"
30 #endif 30 #endif
31 #if defined(ARCH_CPU_X86_FAMILY) 31 #if defined(ARCH_CPU_X86_FAMILY)
32 #include "media/gpu/vaapi_video_encode_accelerator.h" 32 #include "media/gpu/vaapi_video_encode_accelerator.h"
33 #endif 33 #endif
34 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 34 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
35 #include "media/gpu/android_video_encode_accelerator.h" 35 #include "media/gpu/android_video_encode_accelerator.h"
36 #elif defined(OS_MACOSX) 36 #elif defined(OS_MACOSX)
37 #include "media/gpu/vt_video_encode_accelerator_mac.h" 37 #include "media/gpu/vt_video_encode_accelerator_mac.h"
38 #elif defined(OS_WIN)
39 #include "media/base/media_switches.h"
40 #include "media/gpu/media_foundation_video_encode_accelerator_win.h"
38 #endif 41 #endif
39 42
40 namespace media { 43 namespace media {
41 44
42 static bool MakeDecoderContextCurrent( 45 static bool MakeDecoderContextCurrent(
43 const base::WeakPtr<gpu::GpuCommandBufferStub> stub) { 46 const base::WeakPtr<gpu::GpuCommandBufferStub> stub) {
44 if (!stub) { 47 if (!stub) {
45 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; 48 DLOG(ERROR) << "Stub is gone; won't MakeCurrent().";
46 return false; 49 return false;
47 } 50 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) 204 if (!gpu_preferences.disable_vaapi_accelerated_video_encode)
202 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); 205 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA);
203 #endif 206 #endif
204 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 207 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
205 if (!gpu_preferences.disable_web_rtc_hw_encoding) 208 if (!gpu_preferences.disable_web_rtc_hw_encoding)
206 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); 209 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA);
207 #endif 210 #endif
208 #if defined(OS_MACOSX) 211 #if defined(OS_MACOSX)
209 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVTVEA); 212 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVTVEA);
210 #endif 213 #endif
214 #if defined(OS_WIN)
215 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
216 switches::kEnableMFH264Encoding)) {
217 create_vea_fps.push_back(
218 &GpuVideoEncodeAccelerator::CreateMediaFoundationVEA);
219 }
220 #endif
211 return create_vea_fps; 221 return create_vea_fps;
212 } 222 }
213 223
214 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) 224 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
215 // static 225 // static
216 std::unique_ptr<VideoEncodeAccelerator> 226 std::unique_ptr<VideoEncodeAccelerator>
217 GpuVideoEncodeAccelerator::CreateV4L2VEA() { 227 GpuVideoEncodeAccelerator::CreateV4L2VEA() {
218 std::unique_ptr<VideoEncodeAccelerator> encoder; 228 std::unique_ptr<VideoEncodeAccelerator> encoder;
219 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); 229 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
220 if (device) 230 if (device)
(...skipping 22 matching lines...) Expand all
243 253
244 #if defined(OS_MACOSX) 254 #if defined(OS_MACOSX)
245 // static 255 // static
246 std::unique_ptr<VideoEncodeAccelerator> 256 std::unique_ptr<VideoEncodeAccelerator>
247 GpuVideoEncodeAccelerator::CreateVTVEA() { 257 GpuVideoEncodeAccelerator::CreateVTVEA() {
248 return base::WrapUnique<VideoEncodeAccelerator>( 258 return base::WrapUnique<VideoEncodeAccelerator>(
249 new VTVideoEncodeAccelerator()); 259 new VTVideoEncodeAccelerator());
250 } 260 }
251 #endif 261 #endif
252 262
263 #if defined(OS_WIN)
264 // static
265 std::unique_ptr<media::VideoEncodeAccelerator>
266 GpuVideoEncodeAccelerator::CreateMediaFoundationVEA() {
267 return base::WrapUnique<media::VideoEncodeAccelerator>(
268 new MediaFoundationVideoEncodeAccelerator());
269 }
270 #endif
271
253 void GpuVideoEncodeAccelerator::OnEncode( 272 void GpuVideoEncodeAccelerator::OnEncode(
254 const AcceleratedVideoEncoderMsg_Encode_Params& params) { 273 const AcceleratedVideoEncoderMsg_Encode_Params& params) {
255 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " 274 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = "
256 << params.frame_id << ", buffer_size=" << params.buffer_size 275 << params.frame_id << ", buffer_size=" << params.buffer_size
257 << ", force_keyframe=" << params.force_keyframe; 276 << ", force_keyframe=" << params.force_keyframe;
258 DCHECK_EQ(PIXEL_FORMAT_I420, input_format_); 277 DCHECK_EQ(PIXEL_FORMAT_I420, input_format_);
259 278
260 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| 279 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle|
261 // is cleaned properly in case of an early return. 280 // is cleaned properly in case of an early return.
262 std::unique_ptr<base::SharedMemory> shm( 281 std::unique_ptr<base::SharedMemory> shm(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, 386 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_,
368 frame_id)); 387 frame_id));
369 // Just let |shm| fall out of scope. 388 // Just let |shm| fall out of scope.
370 } 389 }
371 390
372 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { 391 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) {
373 stub_->channel()->Send(message); 392 stub_->channel()->Send(message);
374 } 393 }
375 394
376 } // namespace media 395 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698