There are issues in your code:
Your file specifies the input file as plush1_720p_10s.m2v but you gave us H265.bin (which is an HEVC elementary file).
I’m not sure why you turn off g_bUseInterop but it doesn’t matter for my experiment I describe below.
You hack g_nWindowWidth to 320 and g_nWindowHeight to 240 but your source file is 1920 x 1080.
There seems no apparent reason for the changes around renderVideoFrame(hWnd, g_bUseInterop).
The main problem is the placement of your x100 loop. It apparently does not cleanly initialize and deinitialize everything. I haven’t studied it in detail to identify what you have missed but I did an experiment to prove that it must be the case and that NVDec is not the problem here. Bear in mind that this application is designed to run once. If you want to modify that, you’ll have to carefully check everything, not just add a quick hack and hope it is OK.
Here is my experiment. Minimally change the original SDK code to decode your H265.bin. Build the app. Run it and see that it works fine. Then open a CMD window and run this:
FOR /L %%A IN (1,1,100) DO (
This runs and completes 100 times without crashing, which excludes any issues with NVDec. It’s up to you to try to find a proper way to loop within the code if you really need that. You haven’t told us the reason for this looping you want to do.