| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/cpu.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 | 15 |
| 15 #include "content/common/gpu/gpu_channel.h" | 16 #include "content/common/gpu/gpu_channel.h" |
| 16 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
| 17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 18 #include "gpu/command_buffer/common/command_buffer.h" | 19 #include "gpu/command_buffer/common/command_buffer.h" |
| 19 #include "ipc/ipc_message_macros.h" | 20 #include "ipc/ipc_message_macros.h" |
| 20 #include "ipc/ipc_message_utils.h" | 21 #include "ipc/ipc_message_utils.h" |
| 21 #include "ipc/message_filter.h" | 22 #include "ipc/message_filter.h" |
| 22 #include "media/base/limits.h" | 23 #include "media/base/limits.h" |
| 24 #include "media/base/media_switches.h" |
| 23 #include "ui/gl/gl_context.h" | 25 #include "ui/gl/gl_context.h" |
| 24 #include "ui/gl/gl_surface_egl.h" | 26 #include "ui/gl/gl_surface_egl.h" |
| 25 | 27 |
| 26 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 27 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
| 28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 30 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 29 #elif defined(OS_MACOSX) | 31 #elif defined(OS_MACOSX) |
| 30 #include "content/common/gpu/media/vt_video_decode_accelerator.h" | 32 #include "content/common/gpu/media/vt_video_decode_accelerator.h" |
| 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 33 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
| 32 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 34 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 310 } |
| 309 | 311 |
| 310 if (!video_decode_accelerator_->Initialize(profile, this)) { | 312 if (!video_decode_accelerator_->Initialize(profile, this)) { |
| 311 SendCreateDecoderReply(init_done_msg, false); | 313 SendCreateDecoderReply(init_done_msg, false); |
| 312 return; | 314 return; |
| 313 } | 315 } |
| 314 | 316 |
| 315 SendCreateDecoderReply(init_done_msg, true); | 317 SendCreateDecoderReply(init_done_msg, true); |
| 316 } | 318 } |
| 317 | 319 |
| 320 gpu::VideoDecodeAcceleratorSupportedResolution |
| 321 GpuVideoDecodeAccelerator::GetSupportedResolution() { |
| 322 gpu::VideoDecodeAcceleratorSupportedResolution resolution; |
| 323 // Set default values. |
| 324 resolution.min.SetSize(16, 16); |
| 325 // Use 1088 to account for 16x16 macroblocks. |
| 326 resolution.max.SetSize(1920, 1088); |
| 327 |
| 328 #if defined(OS_WIN) |
| 329 // Windows Media Foundation H.264 decoding does not support decoding videos |
| 330 // with any dimension smaller than 48 pixels: |
| 331 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 |
| 332 resolution.min.SetSize(48, 48); |
| 333 #else |
| 334 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. |
| 335 // NOTE: additional autodetection logic may require updating input buffer size |
| 336 // selection in platform-specific implementations, such as |
| 337 // V4L2VideoDecodeAccelerator. |
| 338 base::CPU cpu; |
| 339 bool hw_large_video_support = |
| 340 CommandLine::ForCurrentProcess()->HasSwitch( |
| 341 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || |
| 342 ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55); |
| 343 if (hw_large_video_support) |
| 344 resolution.max.SetSize(4096, 2160); |
| 345 #endif |
| 346 return resolution; |
| 347 } |
| 348 |
| 318 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 349 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
| 319 // true, otherwise on the main thread. | 350 // true, otherwise on the main thread. |
| 320 void GpuVideoDecodeAccelerator::OnDecode( | 351 void GpuVideoDecodeAccelerator::OnDecode( |
| 321 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 352 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
| 322 DCHECK(video_decode_accelerator_.get()); | 353 DCHECK(video_decode_accelerator_.get()); |
| 323 if (id < 0) { | 354 if (id < 0) { |
| 324 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 355 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
| 325 if (child_message_loop_->BelongsToCurrentThread()) { | 356 if (child_message_loop_->BelongsToCurrentThread()) { |
| 326 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 357 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
| 327 } else { | 358 } else { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return stub_->channel()->Send(message); | 545 return stub_->channel()->Send(message); |
| 515 } | 546 } |
| 516 | 547 |
| 517 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 548 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
| 518 bool succeeded) { | 549 bool succeeded) { |
| 519 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 550 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
| 520 Send(message); | 551 Send(message); |
| 521 } | 552 } |
| 522 | 553 |
| 523 } // namespace content | 554 } // namespace content |
| OLD | NEW |