@@ -145,7 +145,7 @@ int MSDKVideoEncoder::InitEncodeOnEncoderThread(
145
145
}
146
146
147
147
// Create frame allocator, let the allocator create the param of its own
148
- m_pMFXAllocator = m_pMFXAllocator = MSDKFactory::CreateFrameAllocator ();
148
+ m_pMFXAllocator = MSDKFactory::CreateFrameAllocator ();
149
149
if (nullptr == m_pMFXAllocator) {
150
150
return WEBRTC_VIDEO_CODEC_ERROR;
151
151
}
@@ -163,6 +163,7 @@ int MSDKVideoEncoder::InitEncodeOnEncoderThread(
163
163
164
164
// Init the encoding params:
165
165
MSDK_ZERO_MEMORY (m_mfxEncParams);
166
+ m_EncExtParams.clear ();
166
167
m_mfxEncParams.mfx .CodecId = codec_id;
167
168
m_mfxEncParams.mfx .TargetUsage = MFX_TARGETUSAGE_BALANCED;
168
169
m_mfxEncParams.mfx .TargetKbps = codec_settings->maxBitrate ; // in-kbps
@@ -631,7 +632,26 @@ webrtc::VideoEncoder::EncoderInfo MSDKVideoEncoder::GetEncoderInfo() const {
631
632
}
632
633
633
634
int MSDKVideoEncoder::Release () {
634
- callback_ = nullptr ;
635
+ if (m_pmfxENC != nullptr ) {
636
+ m_pmfxENC->Close ();
637
+ delete m_pmfxENC;
638
+ m_pmfxENC = nullptr ;
639
+ }
640
+ MSDK_SAFE_DELETE_ARRAY (m_pEncSurfaces);
641
+ m_pEncSurfaces = nullptr ;
642
+
643
+ if (m_mfxSession) {
644
+ MSDKFactory* factory = MSDKFactory::Get ();
645
+ if (factory) {
646
+ factory->UnloadMSDKPlugin (m_mfxSession, &m_pluginID);
647
+ factory->DestroySession (m_mfxSession);
648
+ }
649
+ m_mfxSession = nullptr ;
650
+ }
651
+ if (m_pMFXAllocator)
652
+ m_pMFXAllocator->Close ();
653
+ m_pMFXAllocator.reset ();
654
+
635
655
inited_ = false ;
636
656
// Need to reset to that the session is invalidated and won't use the
637
657
// callback anymore.
0 commit comments