| 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 VideoCodecProfile profile) { |
| 101 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 102 // Windows Media Foundation H.264 decoding does not support decoding videos | 103 // Windows Media Foundation H.264 decoding does not support decoding videos |
| 103 // with any dimension smaller than 48 pixels: | 104 // with any dimension smaller than 48 pixels: |
| 104 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 | 105 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 |
| 105 if (coded_size.width() < 48 || coded_size.height() < 48) | 106 if (coded_size.width() < 48 || coded_size.height() < 48) |
| 106 return false; | 107 return false; |
| 107 #endif | 108 #endif |
| 108 | 109 |
| 109 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. | 110 // Only non-Windows, Ivy Bridge+ platforms can support more than 1920x1080. |
| 110 // We test against 1088 to account for 16x16 macroblocks. | 111 // We test against 1088 to account for 16x16 macroblocks. |
| 111 if (coded_size.width() <= 1920 && coded_size.height() <= 1088) | 112 if (coded_size.width() <= 1920 && coded_size.height() <= 1088) |
| 112 return true; | 113 return true; |
| 113 | 114 |
| 114 // NOTE: additional autodetection logic may require updating input buffer size | 115 // NOTE: additional autodetection logic may require updating input buffer size |
| 115 // selection in platform-specific implementations, such as | 116 // selection in platform-specific implementations, such as |
| 116 // V4L2VideoDecodeAccelerator. | 117 // V4L2VideoDecodeAccelerator. |
| 117 base::CPU cpu; | 118 base::CPU cpu; |
| 118 bool hw_large_video_support = | 119 bool hw_large_video_support = |
| 119 base::CommandLine::ForCurrentProcess()->HasSwitch( | 120 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 120 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || | 121 switches::kIgnoreResolutionLimitsForAcceleratedVideoDecode) || |
| 121 ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55); | 122 ((cpu.vendor_name() == "GenuineIntel") && cpu.model() >= 55 && |
| 123 // TODO(posciak, henryhsu): Remove this once we can query in runtime. |
| 124 profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX); |
| 122 bool os_large_video_support = true; | 125 bool os_large_video_support = true; |
| 123 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
| 124 os_large_video_support = false; | 127 os_large_video_support = false; |
| 125 #endif | 128 #endif |
| 126 return os_large_video_support && hw_large_video_support; | 129 return os_large_video_support && hw_large_video_support; |
| 127 } | 130 } |
| 128 | 131 |
| 129 // Report |status| to UMA and run |cb| with it. This is super-specific to the | 132 // 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 | 133 // 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). | 134 // callsite to always be called with the same stat name (can't parameterize it). |
| (...skipping 27 matching lines...) Expand all Loading... |
| 159 << config.AsHumanReadableString(); | 162 << config.AsHumanReadableString(); |
| 160 | 163 |
| 161 // TODO(posciak): destroy and create a new VDA on codec/profile change | 164 // TODO(posciak): destroy and create a new VDA on codec/profile change |
| 162 // (http://crbug.com/260224). | 165 // (http://crbug.com/260224). |
| 163 if (previously_initialized && (config_.profile() != config.profile())) { | 166 if (previously_initialized && (config_.profile() != config.profile())) { |
| 164 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; | 167 DVLOG(1) << "Codec or profile changed, cannot reinitialize."; |
| 165 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 168 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 166 return; | 169 return; |
| 167 } | 170 } |
| 168 | 171 |
| 169 if (!IsCodedSizeSupported(config.coded_size())) { | 172 if (!IsCodedSizeSupported(config.coded_size(), config.profile())) { |
| 170 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); | 173 status_cb.Run(DECODER_ERROR_NOT_SUPPORTED); |
| 171 return; | 174 return; |
| 172 } | 175 } |
| 173 | 176 |
| 174 config_ = config; | 177 config_ = config; |
| 175 needs_bitstream_conversion_ = (config.codec() == kCodecH264); | 178 needs_bitstream_conversion_ = (config.codec() == kCodecH264); |
| 176 output_cb_ = BindToCurrentLoop(output_cb); | 179 output_cb_ = BindToCurrentLoop(output_cb); |
| 177 | 180 |
| 178 if (previously_initialized) { | 181 if (previously_initialized) { |
| 179 // Reinitialization with a different config (but same codec and profile). | 182 // Reinitialization with a different config (but same codec and profile). |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 DLOG(ERROR) << "VDA Error: " << error; | 592 DLOG(ERROR) << "VDA Error: " << error; |
| 590 DestroyVDA(); | 593 DestroyVDA(); |
| 591 } | 594 } |
| 592 | 595 |
| 593 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 596 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 594 const { | 597 const { |
| 595 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 598 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 596 } | 599 } |
| 597 | 600 |
| 598 } // namespace media | 601 } // namespace media |
| OLD | NEW |