Chromium Code Reviews| 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 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1771 // This function is also called from FlushInternal in a loop which could | 1771 // This function is also called from FlushInternal in a loop which could |
| 1772 // result in the state transitioning to kStopped due to no decoded output. | 1772 // result in the state transitioning to kStopped due to no decoded output. |
| 1773 State state = GetState(); | 1773 State state = GetState(); |
| 1774 RETURN_AND_NOTIFY_ON_FAILURE( | 1774 RETURN_AND_NOTIFY_ON_FAILURE( |
| 1775 (state == kNormal || state == kFlushing || state == kStopped), | 1775 (state == kNormal || state == kFlushing || state == kStopped), |
| 1776 "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, ); | 1776 "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, ); |
| 1777 | 1777 |
| 1778 if (D3D11Device()) | 1778 if (D3D11Device()) |
| 1779 g_last_device_removed_reason = D3D11Device()->GetDeviceRemovedReason(); | 1779 g_last_device_removed_reason = D3D11Device()->GetDeviceRemovedReason(); |
| 1780 | 1780 |
| 1781 MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0}; | |
| 1782 DWORD status = 0; | |
| 1783 HRESULT hr; | |
| 1784 { | |
| 1785 ScopedExceptionCatcher catcher(using_ms_vp9_mft_); | |
| 1786 g_last_process_output_time = GetCurrentQPC(); | |
| 1787 hr = decoder_->ProcessOutput(0, // No flags | |
| 1788 1, // # of out streams to pull from | |
| 1789 &output_data_buffer, &status); | |
| 1790 } | |
| 1791 IMFCollection* events = output_data_buffer.pEvents; | |
| 1792 if (events != NULL) { | |
| 1793 DVLOG(1) << "Got events from ProcessOuput, but discarding"; | |
| 1794 events->Release(); | |
| 1795 } | |
| 1796 base::win::ScopedComPtr<IMFSample> output_sample; | 1781 base::win::ScopedComPtr<IMFSample> output_sample; |
| 1797 output_sample.Attach(output_data_buffer.pSample); | 1782 int retries = 10; |
| 1798 if (FAILED(hr)) { | 1783 while (true) { |
| 1799 // A stream change needs further ProcessInput calls to get back decoder | 1784 MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0}; |
|
jbauman
2017/04/29 00:03:44
output_sample.Reset(); here in case the previous i
hubbe
2017/05/01 22:39:33
Done.
| |
| 1800 // output which is why we need to set the state to stopped. | 1785 DWORD status = 0; |
| 1801 if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { | 1786 HRESULT hr; |
| 1802 if (!SetDecoderOutputMediaType(MFVideoFormat_NV12) && | 1787 { |
| 1803 !SetDecoderOutputMediaType(MFVideoFormat_P010) && | 1788 ScopedExceptionCatcher catcher(using_ms_vp9_mft_); |
| 1804 !SetDecoderOutputMediaType(MFVideoFormat_P016)) { | 1789 g_last_process_output_time = GetCurrentQPC(); |
| 1805 // Decoder didn't let us set NV12 output format. Not sure as to why | 1790 hr = decoder_->ProcessOutput(0, // No flags |
| 1806 // this can happen. Give up in disgust. | 1791 1, // # of out streams to pull from |
| 1807 NOTREACHED() << "Failed to set decoder output media type to NV12"; | 1792 &output_data_buffer, &status); |
| 1793 } | |
| 1794 IMFCollection* events = output_data_buffer.pEvents; | |
| 1795 if (events != NULL) { | |
| 1796 DVLOG(1) << "Got events from ProcessOuput, but discarding"; | |
| 1797 events->Release(); | |
| 1798 } | |
| 1799 output_sample.Attach(output_data_buffer.pSample); | |
| 1800 if (FAILED(hr)) { | |
| 1801 // A stream change needs further ProcessInput calls to get back decoder | |
| 1802 // output which is why we need to set the state to stopped. | |
| 1803 if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { | |
| 1804 if (!SetDecoderOutputMediaType(MFVideoFormat_NV12) && | |
| 1805 !SetDecoderOutputMediaType(MFVideoFormat_P010) && | |
| 1806 !SetDecoderOutputMediaType(MFVideoFormat_P016)) { | |
| 1807 // Decoder didn't let us set NV12 output format. Not sure as to why | |
| 1808 // this can happen. Give up in disgust. | |
| 1809 NOTREACHED() << "Failed to set decoder output media type to NV12"; | |
| 1810 SetState(kStopped); | |
| 1811 } else { | |
| 1812 if (retries-- > 0) { | |
| 1813 DVLOG(1) << "Received format change from the decoder, retrying."; | |
| 1814 continue; // Retry | |
| 1815 } else { | |
| 1816 DVLOG(1) << "Received too many format changes from decoder."; | |
|
jbauman
2017/04/29 00:03:44
Use RETURN_AND_NOTIFY_ON_FAILURE here so we can de
hubbe
2017/05/01 22:39:33
Done.
| |
| 1817 return; | |
| 1818 } | |
| 1819 } | |
| 1820 return; | |
| 1821 } else if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { | |
| 1822 // No more output from the decoder. Stop playback. | |
| 1808 SetState(kStopped); | 1823 SetState(kStopped); |
| 1824 return; | |
| 1809 } else { | 1825 } else { |
| 1810 DVLOG(1) << "Received output format change from the decoder." | 1826 NOTREACHED() << "Unhandled error in DoDecode()"; |
| 1811 " Recursively invoking DoDecode"; | 1827 g_last_unhandled_error = hr; |
| 1812 DoDecode(color_space); | 1828 return; |
| 1813 } | 1829 } |
| 1814 return; | |
| 1815 } else if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { | |
| 1816 // No more output from the decoder. Stop playback. | |
| 1817 SetState(kStopped); | |
| 1818 return; | |
| 1819 } else { | |
| 1820 NOTREACHED() << "Unhandled error in DoDecode()"; | |
| 1821 g_last_unhandled_error = hr; | |
| 1822 return; | |
| 1823 } | 1830 } |
| 1831 | |
| 1832 break; // No more retries needed. | |
| 1824 } | 1833 } |
| 1825 TRACE_EVENT_ASYNC_END0("gpu", "DXVAVideoDecodeAccelerator.Decoding", this); | 1834 TRACE_EVENT_ASYNC_END0("gpu", "DXVAVideoDecodeAccelerator.Decoding", this); |
| 1826 | 1835 |
| 1827 TRACE_COUNTER1("DXVA Decoding", "TotalPacketsBeforeDecode", | 1836 TRACE_COUNTER1("DXVA Decoding", "TotalPacketsBeforeDecode", |
| 1828 inputs_before_decode_); | 1837 inputs_before_decode_); |
| 1829 | 1838 |
| 1830 inputs_before_decode_ = 0; | 1839 inputs_before_decode_ = 0; |
| 1831 | 1840 |
| 1832 RETURN_AND_NOTIFY_ON_FAILURE(ProcessOutputSample(output_sample, color_space), | 1841 RETURN_AND_NOTIFY_ON_FAILURE(ProcessOutputSample(output_sample, color_space), |
| 1833 "Failed to process output sample.", | 1842 "Failed to process output sample.", |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3006 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { | 3015 uint32_t DXVAVideoDecodeAccelerator::GetTextureTarget() const { |
| 3007 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 3016 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 3008 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; | 3017 return provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D; |
| 3009 } | 3018 } |
| 3010 | 3019 |
| 3011 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const { | 3020 ID3D11Device* DXVAVideoDecodeAccelerator::D3D11Device() const { |
| 3012 return share_nv12_textures_ ? angle_device_.Get() : d3d11_device_.Get(); | 3021 return share_nv12_textures_ ? angle_device_.Get() : d3d11_device_.Get(); |
| 3013 } | 3022 } |
| 3014 | 3023 |
| 3015 } // namespace media | 3024 } // namespace media |
| OLD | NEW |