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/gpu/dxva_video_decode_accelerator_win.h" | 5 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #if !defined(OS_WIN) | 9 #if !defined(OS_WIN) |
10 #error This file should only be built on Windows. | 10 #error This file should only be built on Windows. |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 config_changed_ = true; | 444 config_changed_ = true; |
445 } else { | 445 } else { |
446 pending_config_changed_ = true; | 446 pending_config_changed_ = true; |
447 } | 447 } |
448 } | 448 } |
449 last_pps_.swap(pps); | 449 last_pps_.swap(pps); |
450 } | 450 } |
451 return true; | 451 return true; |
452 } | 452 } |
453 | 453 |
454 gfx::ColorSpace H264ConfigChangeDetector::current_color_space() const { | 454 VideoColorSpace H264ConfigChangeDetector::current_color_space() const { |
455 if (!parser_) | 455 if (!parser_) |
456 return gfx::ColorSpace(); | 456 return VideoColorSpace(); |
457 // TODO(hubbe): Is using last_sps_id_ correct here? | 457 // TODO(hubbe): Is using last_sps_id_ correct here? |
458 const H264SPS* sps = parser_->GetSPS(last_sps_id_); | 458 const H264SPS* sps = parser_->GetSPS(last_sps_id_); |
459 if (sps) | 459 if (sps) |
460 return sps->GetColorSpace(); | 460 return sps->GetColorSpace(); |
461 return gfx::ColorSpace(); | 461 return VideoColorSpace(); |
462 } | 462 } |
463 | 463 |
464 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 464 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
465 int32_t buffer_id, | 465 int32_t buffer_id, |
466 base::win::ScopedComPtr<IMFSample> sample, | 466 base::win::ScopedComPtr<IMFSample> sample, |
467 const gfx::ColorSpace& color_space) | 467 const gfx::ColorSpace& color_space) |
468 : input_buffer_id(buffer_id), | 468 : input_buffer_id(buffer_id), |
469 picture_buffer_id(-1), | 469 picture_buffer_id(-1), |
470 color_space(color_space), | 470 color_space(color_space), |
471 output_sample(sample) {} | 471 output_sample(sample) {} |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 RETURN_AND_NOTIFY_ON_FAILURE(SendMFTMessage(MFT_MESSAGE_COMMAND_DRAIN, 0), | 2167 RETURN_AND_NOTIFY_ON_FAILURE(SendMFTMessage(MFT_MESSAGE_COMMAND_DRAIN, 0), |
2168 "Failed to send drain message", | 2168 "Failed to send drain message", |
2169 PLATFORM_FAILURE, ); | 2169 PLATFORM_FAILURE, ); |
2170 sent_drain_message_ = true; | 2170 sent_drain_message_ = true; |
2171 } | 2171 } |
2172 } | 2172 } |
2173 | 2173 |
2174 // Attempt to retrieve an output frame from the decoder. If we have one, | 2174 // Attempt to retrieve an output frame from the decoder. If we have one, |
2175 // return and proceed when the output frame is processed. If we don't have a | 2175 // return and proceed when the output frame is processed. If we don't have a |
2176 // frame then we are done. | 2176 // frame then we are done. |
2177 gfx::ColorSpace color_space = config_change_detector_->current_color_space(); | 2177 VideoColorSpace color_space = config_change_detector_->current_color_space(); |
2178 if (!color_space.IsValid()) | 2178 if (color_space == VideoColorSpace()) |
2179 color_space = config_.color_space; | 2179 color_space = config_.color_space; |
2180 DoDecode(color_space); | 2180 DoDecode(color_space.ToGfxColorSpace()); |
2181 if (OutputSamplesPresent()) | 2181 if (OutputSamplesPresent()) |
2182 return; | 2182 return; |
2183 | 2183 |
2184 if (!processing_config_changed_) { | 2184 if (!processing_config_changed_) { |
2185 SetState(kFlushing); | 2185 SetState(kFlushing); |
2186 | 2186 |
2187 main_thread_task_runner_->PostTask( | 2187 main_thread_task_runner_->PostTask( |
2188 FROM_HERE, | 2188 FROM_HERE, |
2189 base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone, weak_ptr_)); | 2189 base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone, weak_ptr_)); |
2190 } else { | 2190 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
2219 PLATFORM_FAILURE, ); | 2219 PLATFORM_FAILURE, ); |
2220 | 2220 |
2221 processing_config_changed_ = config_changed; | 2221 processing_config_changed_ = config_changed; |
2222 | 2222 |
2223 if (config_changed) { | 2223 if (config_changed) { |
2224 pending_input_buffers_.push_back(sample); | 2224 pending_input_buffers_.push_back(sample); |
2225 FlushInternal(); | 2225 FlushInternal(); |
2226 return; | 2226 return; |
2227 } | 2227 } |
2228 | 2228 |
2229 gfx::ColorSpace color_space = config_change_detector_->current_color_space(); | 2229 VideoColorSpace color_space = config_change_detector_->current_color_space(); |
2230 if (!color_space.IsValid()) | 2230 if (color_space == VideoColorSpace()) |
2231 color_space = config_.color_space; | 2231 color_space = config_.color_space; |
2232 | 2232 |
2233 if (!inputs_before_decode_) { | 2233 if (!inputs_before_decode_) { |
2234 TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding", | 2234 TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding", |
2235 this); | 2235 this); |
2236 } | 2236 } |
2237 inputs_before_decode_++; | 2237 inputs_before_decode_++; |
2238 { | 2238 { |
2239 ScopedExceptionCatcher catcher(using_ms_vp9_mft_); | 2239 ScopedExceptionCatcher catcher(using_ms_vp9_mft_); |
2240 hr = decoder_->ProcessInput(0, sample.get(), 0); | 2240 hr = decoder_->ProcessInput(0, sample.get(), 0); |
2241 } | 2241 } |
2242 // As per msdn if the decoder returns MF_E_NOTACCEPTING then it means that it | 2242 // As per msdn if the decoder returns MF_E_NOTACCEPTING then it means that it |
2243 // has enough data to produce one or more output samples. In this case the | 2243 // has enough data to produce one or more output samples. In this case the |
2244 // recommended options are to | 2244 // recommended options are to |
2245 // 1. Generate new output by calling IMFTransform::ProcessOutput until it | 2245 // 1. Generate new output by calling IMFTransform::ProcessOutput until it |
2246 // returns MF_E_TRANSFORM_NEED_MORE_INPUT. | 2246 // returns MF_E_TRANSFORM_NEED_MORE_INPUT. |
2247 // 2. Flush the input data | 2247 // 2. Flush the input data |
2248 // We implement the first option, i.e to retrieve the output sample and then | 2248 // We implement the first option, i.e to retrieve the output sample and then |
2249 // process the input again. Failure in either of these steps is treated as a | 2249 // process the input again. Failure in either of these steps is treated as a |
2250 // decoder failure. | 2250 // decoder failure. |
2251 if (hr == MF_E_NOTACCEPTING) { | 2251 if (hr == MF_E_NOTACCEPTING) { |
2252 DoDecode(color_space); | 2252 DoDecode(color_space.ToGfxColorSpace()); |
2253 // If the DoDecode call resulted in an output frame then we should not | 2253 // If the DoDecode call resulted in an output frame then we should not |
2254 // process any more input until that frame is copied to the target surface. | 2254 // process any more input until that frame is copied to the target surface. |
2255 if (!OutputSamplesPresent()) { | 2255 if (!OutputSamplesPresent()) { |
2256 State state = GetState(); | 2256 State state = GetState(); |
2257 RETURN_AND_NOTIFY_ON_FAILURE( | 2257 RETURN_AND_NOTIFY_ON_FAILURE( |
2258 (state == kStopped || state == kNormal || state == kFlushing), | 2258 (state == kStopped || state == kNormal || state == kFlushing), |
2259 "Failed to process output. Unexpected decoder state: " << state, | 2259 "Failed to process output. Unexpected decoder state: " << state, |
2260 PLATFORM_FAILURE, ); | 2260 PLATFORM_FAILURE, ); |
2261 hr = decoder_->ProcessInput(0, sample.get(), 0); | 2261 hr = decoder_->ProcessInput(0, sample.get(), 0); |
2262 } | 2262 } |
(...skipping 11 matching lines...) Expand all Loading... |
2274 decoder_thread_task_runner_->PostTask( | 2274 decoder_thread_task_runner_->PostTask( |
2275 FROM_HERE, | 2275 FROM_HERE, |
2276 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2276 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2277 base::Unretained(this))); | 2277 base::Unretained(this))); |
2278 return; | 2278 return; |
2279 } | 2279 } |
2280 } | 2280 } |
2281 RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to process input sample", | 2281 RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to process input sample", |
2282 PLATFORM_FAILURE, ); | 2282 PLATFORM_FAILURE, ); |
2283 | 2283 |
2284 DoDecode(color_space); | 2284 DoDecode(color_space.ToGfxColorSpace()); |
2285 | 2285 |
2286 State state = GetState(); | 2286 State state = GetState(); |
2287 RETURN_AND_NOTIFY_ON_FAILURE( | 2287 RETURN_AND_NOTIFY_ON_FAILURE( |
2288 (state == kStopped || state == kNormal || state == kFlushing), | 2288 (state == kStopped || state == kNormal || state == kFlushing), |
2289 "Failed to process output. Unexpected decoder state: " << state, | 2289 "Failed to process output. Unexpected decoder state: " << state, |
2290 ILLEGAL_STATE, ); | 2290 ILLEGAL_STATE, ); |
2291 | 2291 |
2292 LONGLONG input_buffer_id = 0; | 2292 LONGLONG input_buffer_id = 0; |
2293 RETURN_ON_HR_FAILURE( | 2293 RETURN_ON_HR_FAILURE( |
2294 sample->GetSampleTime(&input_buffer_id), | 2294 sample->GetSampleTime(&input_buffer_id), |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2974 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2974 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
2975 base::Unretained(this))); | 2975 base::Unretained(this))); |
2976 } | 2976 } |
2977 | 2977 |
2978 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | 2978 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
2979 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 2979 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
2980 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; | 2980 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; |
2981 } | 2981 } |
2982 | 2982 |
2983 } // namespace media | 2983 } // namespace media |
OLD | NEW |