| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 config_changed_ = true; | 451 config_changed_ = true; |
| 452 } else { | 452 } else { |
| 453 pending_config_changed_ = true; | 453 pending_config_changed_ = true; |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 last_pps_.swap(pps); | 456 last_pps_.swap(pps); |
| 457 } | 457 } |
| 458 return true; | 458 return true; |
| 459 } | 459 } |
| 460 | 460 |
| 461 gfx::ColorSpace H264ConfigChangeDetector::current_color_space() const { | |
| 462 // TODO(hubbe): Is using last_sps_id_ correct here? | |
| 463 const H264SPS* sps = parser_->GetSPS(last_sps_id_); | |
| 464 if (sps) | |
| 465 return sps->GetColorSpace(); | |
| 466 return gfx::ColorSpace(); | |
| 467 } | |
| 468 | 461 |
| 469 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 462 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
| 470 int32_t buffer_id, | 463 int32_t buffer_id, |
| 471 IMFSample* sample, | 464 IMFSample* sample) |
| 472 const gfx::ColorSpace& color_space) | 465 : input_buffer_id(buffer_id), picture_buffer_id(-1) { |
| 473 : input_buffer_id(buffer_id), | |
| 474 picture_buffer_id(-1), | |
| 475 color_space(color_space) { | |
| 476 output_sample.Attach(sample); | 466 output_sample.Attach(sample); |
| 477 } | 467 } |
| 478 | 468 |
| 479 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( | 469 DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo( |
| 480 const PendingSampleInfo& other) = default; | 470 const PendingSampleInfo& other) = default; |
| 481 | 471 |
| 482 DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} | 472 DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {} |
| 483 | 473 |
| 484 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( | 474 DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator( |
| 485 const GetGLContextCallback& get_gl_context_cb, | 475 const GetGLContextCallback& get_gl_context_cb, |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1602 DVLOG(1) << "Flags: " << std::hex << std::showbase | 1592 DVLOG(1) << "Flags: " << std::hex << std::showbase |
| 1603 << output_stream_info_.dwFlags; | 1593 << output_stream_info_.dwFlags; |
| 1604 if (codec_ == kCodecH264) { | 1594 if (codec_ == kCodecH264) { |
| 1605 CHECK_EQ(output_stream_info_.dwFlags, 0x107u); | 1595 CHECK_EQ(output_stream_info_.dwFlags, 0x107u); |
| 1606 } | 1596 } |
| 1607 DVLOG(1) << "Min buffer size: " << output_stream_info_.cbSize; | 1597 DVLOG(1) << "Min buffer size: " << output_stream_info_.cbSize; |
| 1608 DVLOG(1) << "Alignment: " << output_stream_info_.cbAlignment; | 1598 DVLOG(1) << "Alignment: " << output_stream_info_.cbAlignment; |
| 1609 return true; | 1599 return true; |
| 1610 } | 1600 } |
| 1611 | 1601 |
| 1612 void DXVAVideoDecodeAccelerator::DoDecode(const gfx::ColorSpace& color_space) { | 1602 void DXVAVideoDecodeAccelerator::DoDecode() { |
| 1613 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::DoDecode"); | 1603 TRACE_EVENT0("media", "DXVAVideoDecodeAccelerator::DoDecode"); |
| 1614 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); | 1604 DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread()); |
| 1615 // This function is also called from FlushInternal in a loop which could | 1605 // This function is also called from FlushInternal in a loop which could |
| 1616 // result in the state transitioning to kStopped due to no decoded output. | 1606 // result in the state transitioning to kStopped due to no decoded output. |
| 1617 State state = GetState(); | 1607 State state = GetState(); |
| 1618 RETURN_AND_NOTIFY_ON_FAILURE( | 1608 RETURN_AND_NOTIFY_ON_FAILURE( |
| 1619 (state == kNormal || state == kFlushing || state == kStopped), | 1609 (state == kNormal || state == kFlushing || state == kStopped), |
| 1620 "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, ); | 1610 "DoDecode: not in normal/flushing/stopped state", ILLEGAL_STATE, ); |
| 1621 | 1611 |
| 1622 MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0}; | 1612 MFT_OUTPUT_DATA_BUFFER output_data_buffer = {0}; |
| 1623 DWORD status = 0; | 1613 DWORD status = 0; |
| 1614 |
| 1624 HRESULT hr = decoder_->ProcessOutput(0, // No flags | 1615 HRESULT hr = decoder_->ProcessOutput(0, // No flags |
| 1625 1, // # of out streams to pull from | 1616 1, // # of out streams to pull from |
| 1626 &output_data_buffer, &status); | 1617 &output_data_buffer, &status); |
| 1627 IMFCollection* events = output_data_buffer.pEvents; | 1618 IMFCollection* events = output_data_buffer.pEvents; |
| 1628 if (events != NULL) { | 1619 if (events != NULL) { |
| 1629 DVLOG(1) << "Got events from ProcessOuput, but discarding"; | 1620 DVLOG(1) << "Got events from ProcessOuput, but discarding"; |
| 1630 events->Release(); | 1621 events->Release(); |
| 1631 } | 1622 } |
| 1632 if (FAILED(hr)) { | 1623 if (FAILED(hr)) { |
| 1633 // A stream change needs further ProcessInput calls to get back decoder | 1624 // A stream change needs further ProcessInput calls to get back decoder |
| 1634 // output which is why we need to set the state to stopped. | 1625 // output which is why we need to set the state to stopped. |
| 1635 if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { | 1626 if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { |
| 1636 if (!SetDecoderOutputMediaType(MFVideoFormat_NV12) && | 1627 if (!SetDecoderOutputMediaType(MFVideoFormat_NV12) && |
| 1637 !SetDecoderOutputMediaType(MFVideoFormat_P010)) { | 1628 !SetDecoderOutputMediaType(MFVideoFormat_P010)) { |
| 1638 // Decoder didn't let us set NV12 output format. Not sure as to why | 1629 // Decoder didn't let us set NV12 output format. Not sure as to why |
| 1639 // this can happen. Give up in disgust. | 1630 // this can happen. Give up in disgust. |
| 1640 NOTREACHED() << "Failed to set decoder output media type to NV12"; | 1631 NOTREACHED() << "Failed to set decoder output media type to NV12"; |
| 1641 SetState(kStopped); | 1632 SetState(kStopped); |
| 1642 } else { | 1633 } else { |
| 1643 DVLOG(1) << "Received output format change from the decoder." | 1634 DVLOG(1) << "Received output format change from the decoder." |
| 1644 " Recursively invoking DoDecode"; | 1635 " Recursively invoking DoDecode"; |
| 1645 DoDecode(color_space); | 1636 DoDecode(); |
| 1646 } | 1637 } |
| 1647 return; | 1638 return; |
| 1648 } else if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { | 1639 } else if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { |
| 1649 // No more output from the decoder. Stop playback. | 1640 // No more output from the decoder. Stop playback. |
| 1650 SetState(kStopped); | 1641 SetState(kStopped); |
| 1651 return; | 1642 return; |
| 1652 } else { | 1643 } else { |
| 1653 NOTREACHED() << "Unhandled error in DoDecode()"; | 1644 NOTREACHED() << "Unhandled error in DoDecode()"; |
| 1654 return; | 1645 return; |
| 1655 } | 1646 } |
| 1656 } | 1647 } |
| 1657 TRACE_EVENT_ASYNC_END0("gpu", "DXVAVideoDecodeAccelerator.Decoding", this); | 1648 TRACE_EVENT_ASYNC_END0("gpu", "DXVAVideoDecodeAccelerator.Decoding", this); |
| 1658 | 1649 |
| 1659 TRACE_COUNTER1("DXVA Decoding", "TotalPacketsBeforeDecode", | 1650 TRACE_COUNTER1("DXVA Decoding", "TotalPacketsBeforeDecode", |
| 1660 inputs_before_decode_); | 1651 inputs_before_decode_); |
| 1661 | 1652 |
| 1662 inputs_before_decode_ = 0; | 1653 inputs_before_decode_ = 0; |
| 1663 | 1654 |
| 1664 RETURN_AND_NOTIFY_ON_FAILURE( | 1655 RETURN_AND_NOTIFY_ON_FAILURE(ProcessOutputSample(output_data_buffer.pSample), |
| 1665 ProcessOutputSample(output_data_buffer.pSample, color_space), | 1656 "Failed to process output sample.", |
| 1666 "Failed to process output sample.", PLATFORM_FAILURE, ); | 1657 PLATFORM_FAILURE, ); |
| 1667 } | 1658 } |
| 1668 | 1659 |
| 1669 bool DXVAVideoDecodeAccelerator::ProcessOutputSample( | 1660 bool DXVAVideoDecodeAccelerator::ProcessOutputSample(IMFSample* sample) { |
| 1670 IMFSample* sample, | |
| 1671 const gfx::ColorSpace& color_space) { | |
| 1672 RETURN_ON_FAILURE(sample, "Decode succeeded with NULL output sample", false); | 1661 RETURN_ON_FAILURE(sample, "Decode succeeded with NULL output sample", false); |
| 1673 | 1662 |
| 1674 LONGLONG input_buffer_id = 0; | 1663 LONGLONG input_buffer_id = 0; |
| 1675 RETURN_ON_HR_FAILURE(sample->GetSampleTime(&input_buffer_id), | 1664 RETURN_ON_HR_FAILURE(sample->GetSampleTime(&input_buffer_id), |
| 1676 "Failed to get input buffer id associated with sample", | 1665 "Failed to get input buffer id associated with sample", |
| 1677 false); | 1666 false); |
| 1678 | 1667 |
| 1679 { | 1668 { |
| 1680 base::AutoLock lock(decoder_lock_); | 1669 base::AutoLock lock(decoder_lock_); |
| 1681 DCHECK(pending_output_samples_.empty()); | 1670 DCHECK(pending_output_samples_.empty()); |
| 1682 pending_output_samples_.push_back( | 1671 pending_output_samples_.push_back( |
| 1683 PendingSampleInfo(input_buffer_id, sample, color_space)); | 1672 PendingSampleInfo(input_buffer_id, sample)); |
| 1684 } | 1673 } |
| 1685 | 1674 |
| 1686 if (pictures_requested_) { | 1675 if (pictures_requested_) { |
| 1687 DVLOG(1) << "Waiting for picture slots from the client."; | 1676 DVLOG(1) << "Waiting for picture slots from the client."; |
| 1688 main_thread_task_runner_->PostTask( | 1677 main_thread_task_runner_->PostTask( |
| 1689 FROM_HERE, | 1678 FROM_HERE, |
| 1690 base::Bind(&DXVAVideoDecodeAccelerator::ProcessPendingSamples, | 1679 base::Bind(&DXVAVideoDecodeAccelerator::ProcessPendingSamples, |
| 1691 weak_ptr_)); | 1680 weak_ptr_)); |
| 1692 return true; | 1681 return true; |
| 1693 } | 1682 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 } | 1733 } |
| 1745 | 1734 |
| 1746 if (width != index->second->size().width() || | 1735 if (width != index->second->size().width() || |
| 1747 height != index->second->size().height()) { | 1736 height != index->second->size().height()) { |
| 1748 HandleResolutionChanged(width, height); | 1737 HandleResolutionChanged(width, height); |
| 1749 return; | 1738 return; |
| 1750 } | 1739 } |
| 1751 | 1740 |
| 1752 pending_sample->picture_buffer_id = index->second->id(); | 1741 pending_sample->picture_buffer_id = index->second->id(); |
| 1753 index->second->set_bound(); | 1742 index->second->set_bound(); |
| 1754 index->second->set_color_space(pending_sample->color_space); | |
| 1755 if (share_nv12_textures_) { | 1743 if (share_nv12_textures_) { |
| 1756 main_thread_task_runner_->PostTask( | 1744 main_thread_task_runner_->PostTask( |
| 1757 FROM_HERE, | 1745 FROM_HERE, |
| 1758 base::Bind(&DXVAVideoDecodeAccelerator::BindPictureBufferToSample, | 1746 base::Bind(&DXVAVideoDecodeAccelerator::BindPictureBufferToSample, |
| 1759 weak_ptr_, pending_sample->output_sample, | 1747 weak_ptr_, pending_sample->output_sample, |
| 1760 pending_sample->picture_buffer_id, | 1748 pending_sample->picture_buffer_id, |
| 1761 pending_sample->input_buffer_id)); | 1749 pending_sample->input_buffer_id)); |
| 1762 continue; | 1750 continue; |
| 1763 } | 1751 } |
| 1764 | 1752 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 // they need to be GL_TEXTURE_EXTERNAL_OES. | 1886 // they need to be GL_TEXTURE_EXTERNAL_OES. |
| 1899 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; | 1887 bool provide_nv12_textures = share_nv12_textures_ || copy_nv12_textures_; |
| 1900 client_->ProvidePictureBuffers( | 1888 client_->ProvidePictureBuffers( |
| 1901 kNumPictureBuffers, | 1889 kNumPictureBuffers, |
| 1902 provide_nv12_textures ? PIXEL_FORMAT_NV12 : PIXEL_FORMAT_UNKNOWN, | 1890 provide_nv12_textures ? PIXEL_FORMAT_NV12 : PIXEL_FORMAT_UNKNOWN, |
| 1903 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), | 1891 provide_nv12_textures ? 2 : 1, gfx::Size(width, height), |
| 1904 provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); | 1892 provide_nv12_textures ? GL_TEXTURE_EXTERNAL_OES : GL_TEXTURE_2D); |
| 1905 } | 1893 } |
| 1906 } | 1894 } |
| 1907 | 1895 |
| 1908 void DXVAVideoDecodeAccelerator::NotifyPictureReady( | 1896 void DXVAVideoDecodeAccelerator::NotifyPictureReady(int picture_buffer_id, |
| 1909 int picture_buffer_id, | 1897 int input_buffer_id) { |
| 1910 int input_buffer_id, | |
| 1911 const gfx::ColorSpace& color_space) { | |
| 1912 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1898 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1913 // This task could execute after the decoder has been torn down. | 1899 // This task could execute after the decoder has been torn down. |
| 1914 if (GetState() != kUninitialized && client_) { | 1900 if (GetState() != kUninitialized && client_) { |
| 1915 // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use | 1901 // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use |
| 1916 // coded size here so use (0, 0) intentionally to have the client choose. | 1902 // coded size here so use (0, 0) intentionally to have the client choose. |
| 1917 Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0), | 1903 Picture picture(picture_buffer_id, input_buffer_id, gfx::Rect(0, 0), false); |
| 1918 color_space, false); | |
| 1919 client_->PictureReady(picture); | 1904 client_->PictureReady(picture); |
| 1920 } | 1905 } |
| 1921 } | 1906 } |
| 1922 | 1907 |
| 1923 void DXVAVideoDecodeAccelerator::NotifyInputBuffersDropped() { | 1908 void DXVAVideoDecodeAccelerator::NotifyInputBuffersDropped() { |
| 1924 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1909 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1925 if (!client_) | 1910 if (!client_) |
| 1926 return; | 1911 return; |
| 1927 | 1912 |
| 1928 for (PendingInputs::iterator it = pending_input_buffers_.begin(); | 1913 for (PendingInputs::iterator it = pending_input_buffers_.begin(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 RETURN_AND_NOTIFY_ON_FAILURE(SendMFTMessage(MFT_MESSAGE_COMMAND_DRAIN, 0), | 1972 RETURN_AND_NOTIFY_ON_FAILURE(SendMFTMessage(MFT_MESSAGE_COMMAND_DRAIN, 0), |
| 1988 "Failed to send drain message", | 1973 "Failed to send drain message", |
| 1989 PLATFORM_FAILURE, ); | 1974 PLATFORM_FAILURE, ); |
| 1990 sent_drain_message_ = true; | 1975 sent_drain_message_ = true; |
| 1991 } | 1976 } |
| 1992 } | 1977 } |
| 1993 | 1978 |
| 1994 // Attempt to retrieve an output frame from the decoder. If we have one, | 1979 // Attempt to retrieve an output frame from the decoder. If we have one, |
| 1995 // return and proceed when the output frame is processed. If we don't have a | 1980 // return and proceed when the output frame is processed. If we don't have a |
| 1996 // frame then we are done. | 1981 // frame then we are done. |
| 1997 DoDecode(config_change_detector_->current_color_space()); | 1982 DoDecode(); |
| 1998 if (OutputSamplesPresent()) | 1983 if (OutputSamplesPresent()) |
| 1999 return; | 1984 return; |
| 2000 | 1985 |
| 2001 if (!processing_config_changed_) { | 1986 if (!processing_config_changed_) { |
| 2002 SetState(kFlushing); | 1987 SetState(kFlushing); |
| 2003 | 1988 |
| 2004 main_thread_task_runner_->PostTask( | 1989 main_thread_task_runner_->PostTask( |
| 2005 FROM_HERE, | 1990 FROM_HERE, |
| 2006 base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone, weak_ptr_)); | 1991 base::Bind(&DXVAVideoDecodeAccelerator::NotifyFlushDone, weak_ptr_)); |
| 2007 } else { | 1992 } else { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2036 PLATFORM_FAILURE, ); | 2021 PLATFORM_FAILURE, ); |
| 2037 | 2022 |
| 2038 processing_config_changed_ = config_changed; | 2023 processing_config_changed_ = config_changed; |
| 2039 | 2024 |
| 2040 if (config_changed) { | 2025 if (config_changed) { |
| 2041 pending_input_buffers_.push_back(sample); | 2026 pending_input_buffers_.push_back(sample); |
| 2042 FlushInternal(); | 2027 FlushInternal(); |
| 2043 return; | 2028 return; |
| 2044 } | 2029 } |
| 2045 | 2030 |
| 2046 gfx::ColorSpace color_space = config_change_detector_->current_color_space(); | |
| 2047 | |
| 2048 if (!inputs_before_decode_) { | 2031 if (!inputs_before_decode_) { |
| 2049 TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding", | 2032 TRACE_EVENT_ASYNC_BEGIN0("gpu", "DXVAVideoDecodeAccelerator.Decoding", |
| 2050 this); | 2033 this); |
| 2051 } | 2034 } |
| 2052 inputs_before_decode_++; | 2035 inputs_before_decode_++; |
| 2053 | 2036 |
| 2054 hr = decoder_->ProcessInput(0, sample.get(), 0); | 2037 hr = decoder_->ProcessInput(0, sample.get(), 0); |
| 2055 // As per msdn if the decoder returns MF_E_NOTACCEPTING then it means that it | 2038 // As per msdn if the decoder returns MF_E_NOTACCEPTING then it means that it |
| 2056 // has enough data to produce one or more output samples. In this case the | 2039 // has enough data to produce one or more output samples. In this case the |
| 2057 // recommended options are to | 2040 // recommended options are to |
| 2058 // 1. Generate new output by calling IMFTransform::ProcessOutput until it | 2041 // 1. Generate new output by calling IMFTransform::ProcessOutput until it |
| 2059 // returns MF_E_TRANSFORM_NEED_MORE_INPUT. | 2042 // returns MF_E_TRANSFORM_NEED_MORE_INPUT. |
| 2060 // 2. Flush the input data | 2043 // 2. Flush the input data |
| 2061 // We implement the first option, i.e to retrieve the output sample and then | 2044 // We implement the first option, i.e to retrieve the output sample and then |
| 2062 // process the input again. Failure in either of these steps is treated as a | 2045 // process the input again. Failure in either of these steps is treated as a |
| 2063 // decoder failure. | 2046 // decoder failure. |
| 2064 if (hr == MF_E_NOTACCEPTING) { | 2047 if (hr == MF_E_NOTACCEPTING) { |
| 2065 DoDecode(color_space); | 2048 DoDecode(); |
| 2066 // If the DoDecode call resulted in an output frame then we should not | 2049 // If the DoDecode call resulted in an output frame then we should not |
| 2067 // process any more input until that frame is copied to the target surface. | 2050 // process any more input until that frame is copied to the target surface. |
| 2068 if (!OutputSamplesPresent()) { | 2051 if (!OutputSamplesPresent()) { |
| 2069 State state = GetState(); | 2052 State state = GetState(); |
| 2070 RETURN_AND_NOTIFY_ON_FAILURE( | 2053 RETURN_AND_NOTIFY_ON_FAILURE( |
| 2071 (state == kStopped || state == kNormal || state == kFlushing), | 2054 (state == kStopped || state == kNormal || state == kFlushing), |
| 2072 "Failed to process output. Unexpected decoder state: " << state, | 2055 "Failed to process output. Unexpected decoder state: " << state, |
| 2073 PLATFORM_FAILURE, ); | 2056 PLATFORM_FAILURE, ); |
| 2074 hr = decoder_->ProcessInput(0, sample.get(), 0); | 2057 hr = decoder_->ProcessInput(0, sample.get(), 0); |
| 2075 } | 2058 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2087 decoder_thread_task_runner_->PostTask( | 2070 decoder_thread_task_runner_->PostTask( |
| 2088 FROM_HERE, | 2071 FROM_HERE, |
| 2089 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2072 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2090 base::Unretained(this))); | 2073 base::Unretained(this))); |
| 2091 return; | 2074 return; |
| 2092 } | 2075 } |
| 2093 } | 2076 } |
| 2094 RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to process input sample", | 2077 RETURN_AND_NOTIFY_ON_HR_FAILURE(hr, "Failed to process input sample", |
| 2095 PLATFORM_FAILURE, ); | 2078 PLATFORM_FAILURE, ); |
| 2096 | 2079 |
| 2097 DoDecode(color_space); | 2080 DoDecode(); |
| 2098 | 2081 |
| 2099 State state = GetState(); | 2082 State state = GetState(); |
| 2100 RETURN_AND_NOTIFY_ON_FAILURE( | 2083 RETURN_AND_NOTIFY_ON_FAILURE( |
| 2101 (state == kStopped || state == kNormal || state == kFlushing), | 2084 (state == kStopped || state == kNormal || state == kFlushing), |
| 2102 "Failed to process output. Unexpected decoder state: " << state, | 2085 "Failed to process output. Unexpected decoder state: " << state, |
| 2103 ILLEGAL_STATE, ); | 2086 ILLEGAL_STATE, ); |
| 2104 | 2087 |
| 2105 LONGLONG input_buffer_id = 0; | 2088 LONGLONG input_buffer_id = 0; |
| 2106 RETURN_ON_HR_FAILURE( | 2089 RETURN_ON_HR_FAILURE( |
| 2107 sample->GetSampleTime(&input_buffer_id), | 2090 sample->GetSampleTime(&input_buffer_id), |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 RETURN_AND_NOTIFY_ON_FAILURE(make_context_current_cb_.Run(), | 2250 RETURN_AND_NOTIFY_ON_FAILURE(make_context_current_cb_.Run(), |
| 2268 "Failed to make context current", | 2251 "Failed to make context current", |
| 2269 PLATFORM_FAILURE, ); | 2252 PLATFORM_FAILURE, ); |
| 2270 | 2253 |
| 2271 DCHECK(!output_picture_buffers_.empty()); | 2254 DCHECK(!output_picture_buffers_.empty()); |
| 2272 | 2255 |
| 2273 bool result = picture_buffer->CopySurfaceComplete(src_surface, dest_surface); | 2256 bool result = picture_buffer->CopySurfaceComplete(src_surface, dest_surface); |
| 2274 RETURN_AND_NOTIFY_ON_FAILURE(result, "Failed to complete copying surface", | 2257 RETURN_AND_NOTIFY_ON_FAILURE(result, "Failed to complete copying surface", |
| 2275 PLATFORM_FAILURE, ); | 2258 PLATFORM_FAILURE, ); |
| 2276 | 2259 |
| 2277 NotifyPictureReady(picture_buffer->id(), input_buffer_id, gfx::ColorSpace()); | 2260 NotifyPictureReady(picture_buffer->id(), input_buffer_id); |
| 2278 | 2261 |
| 2279 { | 2262 { |
| 2280 base::AutoLock lock(decoder_lock_); | 2263 base::AutoLock lock(decoder_lock_); |
| 2281 if (!pending_output_samples_.empty()) | 2264 if (!pending_output_samples_.empty()) |
| 2282 pending_output_samples_.pop_front(); | 2265 pending_output_samples_.pop_front(); |
| 2283 } | 2266 } |
| 2284 | 2267 |
| 2285 if (pending_flush_ || processing_config_changed_) { | 2268 if (pending_flush_ || processing_config_changed_) { |
| 2286 decoder_thread_task_runner_->PostTask( | 2269 decoder_thread_task_runner_->PostTask( |
| 2287 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal, | 2270 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 RETURN_AND_NOTIFY_ON_FAILURE(make_context_current_cb_.Run(), | 2302 RETURN_AND_NOTIFY_ON_FAILURE(make_context_current_cb_.Run(), |
| 2320 "Failed to make context current", | 2303 "Failed to make context current", |
| 2321 PLATFORM_FAILURE, ); | 2304 PLATFORM_FAILURE, ); |
| 2322 | 2305 |
| 2323 DCHECK(!output_picture_buffers_.empty()); | 2306 DCHECK(!output_picture_buffers_.empty()); |
| 2324 | 2307 |
| 2325 bool result = picture_buffer->BindSampleToTexture(sample); | 2308 bool result = picture_buffer->BindSampleToTexture(sample); |
| 2326 RETURN_AND_NOTIFY_ON_FAILURE(result, "Failed to complete copying surface", | 2309 RETURN_AND_NOTIFY_ON_FAILURE(result, "Failed to complete copying surface", |
| 2327 PLATFORM_FAILURE, ); | 2310 PLATFORM_FAILURE, ); |
| 2328 | 2311 |
| 2329 NotifyPictureReady(picture_buffer->id(), input_buffer_id, | 2312 NotifyPictureReady(picture_buffer->id(), input_buffer_id); |
| 2330 picture_buffer->color_space()); | |
| 2331 | 2313 |
| 2332 { | 2314 { |
| 2333 base::AutoLock lock(decoder_lock_); | 2315 base::AutoLock lock(decoder_lock_); |
| 2334 if (!pending_output_samples_.empty()) | 2316 if (!pending_output_samples_.empty()) |
| 2335 pending_output_samples_.pop_front(); | 2317 pending_output_samples_.pop_front(); |
| 2336 } | 2318 } |
| 2337 | 2319 |
| 2338 if (pending_flush_ || processing_config_changed_) { | 2320 if (pending_flush_ || processing_config_changed_) { |
| 2339 decoder_thread_task_runner_->PostTask( | 2321 decoder_thread_task_runner_->PostTask( |
| 2340 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal, | 2322 FROM_HERE, base::Bind(&DXVAVideoDecodeAccelerator::FlushInternal, |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2707 SetState(kConfigChange); | 2689 SetState(kConfigChange); |
| 2708 Invalidate(); | 2690 Invalidate(); |
| 2709 Initialize(config_, client_); | 2691 Initialize(config_, client_); |
| 2710 decoder_thread_task_runner_->PostTask( | 2692 decoder_thread_task_runner_->PostTask( |
| 2711 FROM_HERE, | 2693 FROM_HERE, |
| 2712 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2694 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2713 base::Unretained(this))); | 2695 base::Unretained(this))); |
| 2714 } | 2696 } |
| 2715 | 2697 |
| 2716 } // namespace media | 2698 } // namespace media |
| OLD | NEW |