Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: content/common/gpu/media/dxva_video_decode_accelerator_win.cc

Issue 1817353002: Fix input frames being dropped when the h.264 DXVA decoder detects a configuration change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dxva_video_decode_accelerator_win.h" 5 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #error This file should only be built on Windows. 8 #error This file should only be built on Windows.
9 #endif // !defined(OS_WIN) 9 #endif // !defined(OS_WIN)
10 10
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 1816
1817 void DXVAVideoDecodeAccelerator::Invalidate() { 1817 void DXVAVideoDecodeAccelerator::Invalidate() {
1818 if (GetState() == kUninitialized) 1818 if (GetState() == kUninitialized)
1819 return; 1819 return;
1820 1820
1821 decoder_thread_.Stop(); 1821 decoder_thread_.Stop();
1822 weak_this_factory_.InvalidateWeakPtrs(); 1822 weak_this_factory_.InvalidateWeakPtrs();
1823 output_picture_buffers_.clear(); 1823 output_picture_buffers_.clear();
1824 stale_output_picture_buffers_.clear(); 1824 stale_output_picture_buffers_.clear();
1825 pending_output_samples_.clear(); 1825 pending_output_samples_.clear();
1826 pending_input_buffers_.clear(); 1826 // We want to continue processing pending input after detecting a config
1827 // change.
1828 if (GetState() != kConfigChange)
1829 pending_input_buffers_.clear();
1827 decoder_.Release(); 1830 decoder_.Release();
1828 pictures_requested_ = false; 1831 pictures_requested_ = false;
1829 1832
1830 if (use_dx11_) { 1833 if (use_dx11_) {
1831 if (video_format_converter_mft_.get()) { 1834 if (video_format_converter_mft_.get()) {
1832 video_format_converter_mft_->ProcessMessage( 1835 video_format_converter_mft_->ProcessMessage(
1833 MFT_MESSAGE_NOTIFY_END_STREAMING, 0); 1836 MFT_MESSAGE_NOTIFY_END_STREAMING, 0);
1834 video_format_converter_mft_.Release(); 1837 video_format_converter_mft_.Release();
1835 } 1838 }
1836 d3d11_device_context_.Release(); 1839 d3d11_device_context_.Release();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 1998
1996 // Check if the resolution, bit rate, etc changed in the stream. If yes we 1999 // Check if the resolution, bit rate, etc changed in the stream. If yes we
1997 // reinitialize the decoder to ensure that the stream decodes correctly. 2000 // reinitialize the decoder to ensure that the stream decodes correctly.
1998 bool config_changed = false; 2001 bool config_changed = false;
1999 2002
2000 HRESULT hr = CheckConfigChanged(sample.get(), &config_changed); 2003 HRESULT hr = CheckConfigChanged(sample.get(), &config_changed);
2001 RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to check video stream config", 2004 RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to check video stream config",
2002 PLATFORM_FAILURE,); 2005 PLATFORM_FAILURE,);
2003 2006
2004 if (config_changed) { 2007 if (config_changed) {
2008 pending_input_buffers_.push_back(sample);
2005 main_thread_task_runner_->PostTask( 2009 main_thread_task_runner_->PostTask(
2006 FROM_HERE, 2010 FROM_HERE,
2007 base::Bind(&DXVAVideoDecodeAccelerator::ConfigChanged, 2011 base::Bind(&DXVAVideoDecodeAccelerator::ConfigChanged,
2008 weak_this_factory_.GetWeakPtr(), 2012 weak_this_factory_.GetWeakPtr(),
2009 config_, 2013 config_));
2010 sample));
2011 return; 2014 return;
2012 } 2015 }
2013 2016
2014 if (!inputs_before_decode_) { 2017 if (!inputs_before_decode_) {
2015 TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding", 2018 TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding",
2016 this); 2019 this);
2017 } 2020 }
2018 inputs_before_decode_++; 2021 inputs_before_decode_++;
2019 2022
2020 hr = decoder_->ProcessInput(0, sample.get(), 0); 2023 hr = decoder_->ProcessInput(0, sample.get(), 0);
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 scoped_media_buffer.get(), 2638 scoped_media_buffer.get(),
2636 scoped_media_buffer.current_length())) { 2639 scoped_media_buffer.current_length())) {
2637 RETURN_ON_HR_FAILURE(E_FAIL, "Failed to detect H.264 stream config", 2640 RETURN_ON_HR_FAILURE(E_FAIL, "Failed to detect H.264 stream config",
2638 E_FAIL); 2641 E_FAIL);
2639 } 2642 }
2640 *config_changed = config_change_detector_.config_changed(); 2643 *config_changed = config_change_detector_.config_changed();
2641 return S_OK; 2644 return S_OK;
2642 } 2645 }
2643 2646
2644 void DXVAVideoDecodeAccelerator::ConfigChanged( 2647 void DXVAVideoDecodeAccelerator::ConfigChanged(
2645 const Config& config, 2648 const Config& config) {
2646 const base::win::ScopedComPtr<IMFSample>& input_sample) {
2647 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); 2649 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
2650 SetState(kConfigChange);
2648 DismissStaleBuffers(true); 2651 DismissStaleBuffers(true);
2649 Invalidate(); 2652 Invalidate();
2650 Initialize(config_, client_); 2653 Initialize(config_, client_);
2651 decoder_thread_task_runner_->PostTask( 2654 decoder_thread_task_runner_->PostTask(
2652 FROM_HERE, 2655 FROM_HERE,
2653 base::Bind(&DXVAVideoDecodeAccelerator::DecodeInternal, 2656 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers,
2654 base::Unretained(this), input_sample)); 2657 base::Unretained(this)));
2655 } 2658 }
2656 2659
2657 } // namespace content 2660 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/dxva_video_decode_accelerator_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698