I have started with the main video decode sample (the one with HEVC, MVC, and VP8 support etc.) I stripped it down to only MVC decode with MFX_D3D11 support turned off. I get an EXE decoder that works perfectly and does not crash. Building with VS 2013 Express on a Win8 machine.
Now, I take the files from the EXE decoder and add them to an existing Avisynth DLL project and change _tmain() name to sample_main(). Everything builds fine. I call sample_main() from a constructor in the Avisynth code and it runs, decodes fine, writes the two YUV files and then tries to exit. However, on exit, when the decdoing pipeline closes I get a crash when m_pmfxDEC is freed in CDecodingPipeline::Close(), as follows:
void CDecodingPipeline::Close()
{
...
WipeMfxBitstream(&m_mfxBS); // does not crash
MSDK_SAFE_DELETE(&m_pmfxDEC); // crashes here
The crash is: exception at 0x5D56F488 (libmfxsw32.dll)
Please help me to understand why this crash is occurring when I package the decoder in a DLL and how I might fix it. Thank you.