| 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 "media/filters/gpu_video_decoder.h" | 5 #include "media/filters/gpu_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/cpu.h" | |
| 13 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 15 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 16 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
| 18 #include "gpu/command_buffer/common/mailbox_holder.h" | 17 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 19 #include "media/base/bind_to_current_loop.h" | 18 #include "media/base/bind_to_current_loop.h" |
| 20 #include "media/base/decoder_buffer.h" | 19 #include "media/base/decoder_buffer.h" |
| 21 #include "media/base/media_switches.h" | |
| 22 #include "media/base/pipeline.h" | 20 #include "media/base/pipeline.h" |
| 23 #include "media/base/pipeline_status.h" | 21 #include "media/base/pipeline_status.h" |
| 24 #include "media/base/video_decoder_config.h" | 22 #include "media/base/video_decoder_config.h" |
| 25 #include "media/filters/gpu_video_accelerator_factories.h" | 23 #include "media/filters/gpu_video_accelerator_factories.h" |
| 26 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
| 27 | 25 |
| 28 namespace media { | 26 namespace media { |
| 29 | 27 |
| 30 const char GpuVideoDecoder::kDecoderName[] = "GpuVideoDecoder"; | 28 const char GpuVideoDecoder::kDecoderName[] = "GpuVideoDecoder"; |
| 31 | 29 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 89 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
| 92 return; | 90 return; |
| 93 } | 91 } |
| 94 | 92 |
| 95 DCHECK(pending_reset_cb_.is_null()); | 93 DCHECK(pending_reset_cb_.is_null()); |
| 96 pending_reset_cb_ = BindToCurrentLoop(closure); | 94 pending_reset_cb_ = BindToCurrentLoop(closure); |
| 97 | 95 |
| 98 vda_->Reset(); | 96 vda_->Reset(); |
| 99 } | 97 } |
| 100 | 98 |
| 101 static bool IsCodedSizeSupported(const gfx::Size& coded_size) { | |
| 102 #if defined(OS_WIN) | |
| 103 // Windows Media Foundation H.264 decoding does not support decoding videos | |
| 104 // with any dimension smaller than 48 pixels: | |
| 105 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 | |
| 106 if (coded_size.width() < 48 || coded_size.height() < 48) | |
| 107 return false; | |
| 108 #endif | |
| 109 | |
| 110 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. | |
| 111 // We test against 1088 to account for 16x16 macroblocks. | |
| 112 if (coded_size.width() <= 1920 && coded_size.height() <= 1088) | |
| 113 return true; | |
| 114 | |
| 115 // NOTE: additional autodetection logic may require updating input buffer size | |
| 116 // selection in platform-specific implementations, such as | |
| 117 // V4L2VideoDecodeAccelerator. | |
| 118 base::CPU cpu; | |
| 119 bool hw_large_video_support = | |
| 120 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 121 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || | |
| 122 ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55); | |
| 123 bool os_large_video_support = true; | |
| 124 #if defined(OS_WIN) | |
| 125 os_large_video_support = false; | |
| 126 #endif | |
| 127 return os_large_video_support && hw_large_video_support; | |
| 128 } | |
| 129 | |
| 130 // Report |status| to UMA and run |cb| with it. This is super-specific to the | 99 // Report |status| to UMA and run |cb| with it. This is super-specific to the |
| 131 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a | 100 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a |
| 132 // callsite to always be called with the same stat name (can't parameterize it). | 101 // callsite to always be called with the same stat name (can't parameterize it). |
| 133 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( | 102 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( |
| 134 const PipelineStatusCB& cb, | 103 const PipelineStatusCB& cb, |
| 135 PipelineStatus status) { | 104 PipelineStatus status) { |
| 136 UMA_HISTOGRAM_ENUMERATION( | 105 UMA_HISTOGRAM_ENUMERATION( |
| 137 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); | 106 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); |
| 138 cb.Run(status); | 107 cb.Run(status); |
| 139 } | 108 } |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 585 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 617 if (!vda_) | 586 if (!vda_) |
| 618 return; | 587 return; |
| 619 | 588 |
| 620 state_ = kError; | 589 state_ = kError; |
| 621 | 590 |
| 622 DLOG(ERROR) << "VDA Error: " << error; | 591 DLOG(ERROR) << "VDA Error: " << error; |
| 623 DestroyVDA(); | 592 DestroyVDA(); |
| 624 } | 593 } |
| 625 | 594 |
| 595 bool GpuVideoDecoder::IsCodedSizeSupported(const gfx::Size& coded_size) { |
| 596 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 597 media::VideoDecodeAccelerator::SupportedResolution supported_resolution = |
| 598 factories_->GetVideoDecodeAcceleratorSupportedResolution(); |
| 599 if (coded_size.width() <= supported_resolution.max.width() && |
| 600 coded_size.height() <= supported_resolution.max.height() && |
| 601 coded_size.width() >= supported_resolution.min.width() && |
| 602 coded_size.height() >= supported_resolution.min.height()) { |
| 603 return true; |
| 604 } |
| 605 return false; |
| 606 } |
| 607 |
| 626 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 608 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 627 const { | 609 const { |
| 628 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 610 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 629 } | 611 } |
| 630 | 612 |
| 631 } // namespace media | 613 } // namespace media |
| OLD | NEW |