| 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" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 90 base::MessageLoop::current()->PostTask(FROM_HERE, closure); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 | 93 |
| 94 DCHECK(pending_reset_cb_.is_null()); | 94 DCHECK(pending_reset_cb_.is_null()); |
| 95 pending_reset_cb_ = BindToCurrentLoop(closure); | 95 pending_reset_cb_ = BindToCurrentLoop(closure); |
| 96 | 96 |
| 97 vda_->Reset(); | 97 vda_->Reset(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 static bool IsCodedSizeSupported(const gfx::Size& coded_size) { | 100 static bool IsCodedSizeSupported(const gfx::Size& coded_size, |
| 101 #if defined(OS_WIN) | 101 const gfx::Size& min_resolution, |
| 102 // Windows Media Foundation H.264 decoding does not support decoding videos | 102 const gfx::Size& max_resolution) { |
| 103 // with any dimension smaller than 48 pixels: | 103 return (coded_size.width() <= max_resolution.width() && |
| 104 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 | 104 coded_size.height() <= max_resolution.height() && |
| 105 if (coded_size.width() < 48 || coded_size.height() < 48) | 105 coded_size.width() >= min_resolution.width() && |
| 106 return false; | 106 coded_size.height() >= min_resolution.height()); |
| 107 #endif | |
| 108 | |
| 109 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. | |
| 110 // We test against 1088 to account for 16x16 macroblocks. | |
| 111 if (coded_size.width() <= 1920 && coded_size.height() <= 1088) | |
| 112 return true; | |
| 113 | |
| 114 // NOTE: additional autodetection logic may require updating input buffer size | |
| 115 // selection in platform-specific implementations, such as | |
| 116 // V4L2VideoDecodeAccelerator. | |
| 117 base::CPU cpu; | |
| 118 bool hw_large_video_support = | |
| 119 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 120 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || | |
| 121 ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55); | |
| 122 bool os_large_video_support = true; | |
| 123 #if defined(OS_WIN) | |
| 124 os_large_video_support = false; | |
| 125 #endif | |
| 126 return os_large_video_support && hw_large_video_support; | |
| 127 } | 107 } |
| 128 | 108 |
| 129 // Report |status| to UMA and run |cb| with it. This is super-specific to the | 109 // Report |status| to UMA and run |cb| with it. This is super-specific to the |
| 130 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a | 110 // UMA stat reported because the UMA_HISTOGRAM_ENUMERATION API requires a |
| 131 // callsite to always be called with the same stat name (can't parameterize it). | 111 // callsite to always be called with the same stat name (can't parameterize it). |
| 132 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( | 112 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( |
| 133 const PipelineStatusCB& cb, | 113 const PipelineStatusCB& cb, |
| 134 PipelineStatus status) { | 114 PipelineStatus status) { |
| 135 UMA_HISTOGRAM_ENUMERATION( | 115 UMA_HISTOGRAM_ENUMERATION( |
| 136 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); | 116 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 159 << config.AsHumanReadableString(); | 139 << config.AsHumanReadableString(); |
| 160 | 140 |
| 161 // TODO(posciak): destroy and create a new VDA on codec/profile change | 141 // TODO(posciak): destroy and create a new VDA on codec/profile change |
| 162 // (http://crbug.com/260224). | 142 // (http://crbug.com/260224). |
| 163 if (previously_initialized && (config_.profile() != config.profile())) { | 143 if (previously_initialized && (config_.profile() != config.profile())) { |
| 164 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; | 144 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; |
| 165 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 145 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 166 return; | 146 return; |
| 167 } | 147 } |
| 168 | 148 |
| 169 if (!IsCodedSizeSupported(config.coded_size())) { | 149 if (!IsProfileSupported(config.profile(), config.coded_size())) { |
| 170 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 150 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 171 return; | 151 return; |
| 172 } | 152 } |
| 173 | 153 |
| 174 config_ = config; | 154 config_ = config; |
| 175 needs_bitstream_conversion_ = (config.codec() == kCodecH264); | 155 needs_bitstream_conversion_ = (config.codec() == kCodecH264); |
| 176 output_cb_ = BindToCurrentLoop(output_cb); | 156 output_cb_ = BindToCurrentLoop(output_cb); |
| 177 | 157 |
| 178 if (previously_initialized) { | 158 if (previously_initialized) { |
| 179 // Reinitialization with a different config (but same codec and profile). | 159 // Reinitialization with a different config (but same codec and profile). |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 563 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 584 if (!vda_) | 564 if (!vda_) |
| 585 return; | 565 return; |
| 586 | 566 |
| 587 state_ = kError; | 567 state_ = kError; |
| 588 | 568 |
| 589 DLOG(ERROR) << "VDA Error: " << error; | 569 DLOG(ERROR) << "VDA Error: " << error; |
| 590 DestroyVDA(); | 570 DestroyVDA(); |
| 591 } | 571 } |
| 592 | 572 |
| 573 bool GpuVideoDecoder::IsProfileSupported(VideoCodecProfile profile, |
| 574 const gfx::Size& coded_size) { |
| 575 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 576 VideoDecodeAccelerator::SupportedProfiles supported_profiles = |
| 577 factories_->GetVideoDecodeAcceleratorSupportedProfiles(); |
| 578 for (const auto& supported_profile : supported_profiles) { |
| 579 if (profile == supported_profile.profile) { |
| 580 return IsCodedSizeSupported(coded_size, |
| 581 supported_profile.min_resolution, |
| 582 supported_profile.max_resolution); |
| 583 } |
| 584 } |
| 585 return false; |
| 586 } |
| 587 |
| 593 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 588 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 594 const { | 589 const { |
| 595 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 590 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 596 } | 591 } |
| 597 | 592 |
| 598 } // namespace media | 593 } // namespace media |
| OLD | NEW |