From 1cb6c3ccf387d87634b90c496ed9d8651e15861a Mon Sep 17 00:00:00 2001 From: "Zhang.Zhenjiang" Date: Wed, 27 Jul 2022 16:22:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DIntelGPU=E8=A7=A3?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8E=9F=E5=9B=A0=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E4=BD=BF=E7=94=A8=E9=9D=9EDX3D11=20=E7=9A=84Renderer?= =?UTF-8?q?=20=E5=BF=85=E9=A1=BB=E5=B0=86=E6=95=B0=E6=8D=AE=E4=BB=8ESurfac?= =?UTF-8?q?e=E4=B8=AD=E6=8B=BF=E5=87=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/win/msdkvideodecoder.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/win/msdkvideodecoder.cc b/src/win/msdkvideodecoder.cc index 339a314893..9ad44dfa16 100644 --- a/src/win/msdkvideodecoder.cc +++ b/src/win/msdkvideodecoder.cc @@ -8,7 +8,8 @@ #include "src/win/d3d11_allocator.h" #include "src/win/msdkvideodecoder.h" #include "api/scoped_refptr.h" - +#include "api/video/i420_buffer.h" +#include "libyuv/convert.h" using namespace rtc; #define MSDK_BS_INIT_SIZE (1024*1024) @@ -365,27 +366,27 @@ int32_t MSDKVideoDecoder::Decode( if (sts == MFX_ERR_NONE && syncp != nullptr) { sts = m_mfx_session_->SyncOperation(syncp, MSDK_DEC_WAIT_INTERVAL); if (sts >= MFX_ERR_NONE) { + mfxFrameData* pData = &pOutputSurface->Data; mfxMemId dxMemId = pOutputSurface->Data.MemId; mfxFrameInfo frame_info = pOutputSurface->Info; mfxHDLPair pair = {nullptr}; // Maybe we should also send the allocator as part of the frame // handle for locking/unlocking purpose. m_pmfx_allocator_->GetFrameHDL(dxMemId, (mfxHDL*)&pair); - + m_pmfx_allocator_->LockFrame(dxMemId, pData); + rtc::scoped_refptr i420_buffer = + I420Buffer::Create(frame_info.Width, frame_info.Height); + libyuv::NV12ToI420(pData->Y, pData->Pitch, pData->UV, pData->Pitch/2, + i420_buffer->MutableDataY(), i420_buffer->StrideY(), + i420_buffer->MutableDataU(), i420_buffer->StrideU(), + i420_buffer->MutableDataV(), i420_buffer->StrideV(), + frame_info.Width, frame_info.Height); + m_pmfx_allocator_->UnlockFrame(dxMemId, pData); + if (callback_) { + webrtc::VideoFrame decoded_frame(i420_buffer, inputImage.Timestamp(), 0, webrtc::kVideoRotation_0); + callback_->Decoded(decoded_frame); + } #if 0 - rtc::scoped_refptr cropped_buffer = - WrapI420Buffer(frame_info.Width, frame_info.Height, - av_frame_->data[kYPlaneIndex], - av_frame_->linesize[kYPlaneIndex], - av_frame_->data[kUPlaneIndex], - - av_frame_->linesize[kUPlaneIndex], - av_frame_->data[kVPlaneIndex], - av_frame_->linesize[kVPlaneIndex], - // To keep reference alive. - [frame_buffer] {}); - -#endif if (callback_) { surface_handle_->d3d11_device = d3d11_device_.p; surface_handle_->texture = @@ -408,6 +409,7 @@ int32_t MSDKVideoDecoder::Decode( decoded_frame.set_timestamp(inputImage.Timestamp()); callback_->Decoded(decoded_frame); } +#endif } } else if (MFX_ERR_MORE_DATA == sts) { return WEBRTC_VIDEO_CODEC_OK; From 8b15f3c780d58df0f1a6eb5cb0a44e63ad1aee51 Mon Sep 17 00:00:00 2001 From: "Zhang.Zhenjiang" Date: Wed, 27 Jul 2022 22:26:03 +0800 Subject: [PATCH 2/4] set_ntp_time_ms & set_timestamp --- src/win/msdkvideodecoder.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win/msdkvideodecoder.cc b/src/win/msdkvideodecoder.cc index 9ad44dfa16..cc02574671 100644 --- a/src/win/msdkvideodecoder.cc +++ b/src/win/msdkvideodecoder.cc @@ -384,6 +384,8 @@ int32_t MSDKVideoDecoder::Decode( m_pmfx_allocator_->UnlockFrame(dxMemId, pData); if (callback_) { webrtc::VideoFrame decoded_frame(i420_buffer, inputImage.Timestamp(), 0, webrtc::kVideoRotation_0); + decoded_frame.set_ntp_time_ms(inputImage.ntp_time_ms_); + decoded_frame.set_timestamp(inputImage.Timestamp()); callback_->Decoded(decoded_frame); } #if 0 From 0d303e35c8276f7c1e6fd78e6442941fbe1d9b13 Mon Sep 17 00:00:00 2001 From: "Zhang.Zhenjiang" Date: Thu, 28 Jul 2022 09:31:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDecode=20Release=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=B8=BB=E5=8A=A8=E5=85=B3=E9=97=ADm=5Fpmfx=5Fdec=5F?= =?UTF-8?q?=20=E8=80=8C=E9=80=A0=E6=88=90=E7=9A=84=E5=A4=9A=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/win/msdkvideodecoder.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/win/msdkvideodecoder.cc b/src/win/msdkvideodecoder.cc index cc02574671..f5faa30ce8 100644 --- a/src/win/msdkvideodecoder.cc +++ b/src/win/msdkvideodecoder.cc @@ -21,6 +21,10 @@ namespace base { int32_t MSDKVideoDecoder::Release() { WipeMfxBitstream(&m_mfx_bs_); + if (m_pmfx_dec_ != nullptr) { + m_pmfx_dec_->Close(); + m_pmfx_dec_.reset(); + } if (m_mfx_session_) { MSDKFactory* factory = MSDKFactory::Get(); if (factory) { @@ -28,6 +32,8 @@ int32_t MSDKVideoDecoder::Release() { factory->DestroySession(m_mfx_session_); } } + if (m_pmfx_allocator_) + m_pmfx_allocator_->Close(); m_pmfx_allocator_.reset(); MSDK_SAFE_DELETE_ARRAY(m_pinput_surfaces_); inited_ = false; From f145595f9ae1150e927f8add02f46ca96c99f482 Mon Sep 17 00:00:00 2001 From: "Zhang.Zhenjiang" Date: Tue, 9 Aug 2022 22:56:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DNV12ToI420=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/win/msdkvideodecoder.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/win/msdkvideodecoder.cc b/src/win/msdkvideodecoder.cc index f5faa30ce8..018573b3fe 100644 --- a/src/win/msdkvideodecoder.cc +++ b/src/win/msdkvideodecoder.cc @@ -372,17 +372,18 @@ int32_t MSDKVideoDecoder::Decode( if (sts == MFX_ERR_NONE && syncp != nullptr) { sts = m_mfx_session_->SyncOperation(syncp, MSDK_DEC_WAIT_INTERVAL); if (sts >= MFX_ERR_NONE) { - mfxFrameData* pData = &pOutputSurface->Data; mfxMemId dxMemId = pOutputSurface->Data.MemId; mfxFrameInfo frame_info = pOutputSurface->Info; mfxHDLPair pair = {nullptr}; // Maybe we should also send the allocator as part of the frame // handle for locking/unlocking purpose. m_pmfx_allocator_->GetFrameHDL(dxMemId, (mfxHDL*)&pair); +#if 1 + mfxFrameData* pData = &pOutputSurface->Data; m_pmfx_allocator_->LockFrame(dxMemId, pData); rtc::scoped_refptr i420_buffer = I420Buffer::Create(frame_info.Width, frame_info.Height); - libyuv::NV12ToI420(pData->Y, pData->Pitch, pData->UV, pData->Pitch/2, + libyuv::NV12ToI420(pData->Y, pData->Pitch, pData->UV, pData->Pitch, i420_buffer->MutableDataY(), i420_buffer->StrideY(), i420_buffer->MutableDataU(), i420_buffer->StrideU(), i420_buffer->MutableDataV(), i420_buffer->StrideV(), @@ -394,7 +395,7 @@ int32_t MSDKVideoDecoder::Decode( decoded_frame.set_timestamp(inputImage.Timestamp()); callback_->Decoded(decoded_frame); } -#if 0 +#else if (callback_) { surface_handle_->d3d11_device = d3d11_device_.p; surface_handle_->texture =