I noticed a interesting difference between Intel media samples 126.96.36.199,and some samples of earlier edition.
With samples 188.8.131.52, when I selected d3d9 surface video memory as the video memory type, run D3D API IDirect3DSurface9::LockRect and UnLockRect method, hoping to copy YUV data from surface to my system memory. Then my program would always be crashed ! However, in the earlier edition sample, the calling of LockRect and UnLockRect works perfectly.
Then I try to find some clues in the samples.
Firstly, In some earlier samples, source file <d3d_allocator.cpp>, function D3DFrameAllocator::AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response), it pass a pointer array to "response", all the members of the array are pointers to video surfaces assigned by
[in] UINT Width,
[in] UINT Height, [in] UINT BackBuffers,
[in] D3DFORMAT Format,
[in] D3DPOOL Pool,
[in] DWORD Usage,
[in] DWORD DxvaType,
[out] IDirect3DSurface9 **ppSurface,
[in, out] HANDLE *pSharedHandle)with a "NULL" in parameter"HANDLE *pSharedHandle". like:
hr = m_decoderService->CreateSurface(
request->NumFrameSuggested - 1,
After allocate surface memory in this way, I could run my program on methods like "LockRect and UnLockRect ", YUV data could be copied out of that way.
However in samples 184.108.40.206 source file <d3d_allocator.cpp>, It defined a struct:
Then it called IDirectXVideoAccelerationService::CreateSurface(); , pass a surface pointer and a HANDLE as parameters to create aviliable d3d surfaces and pass them to the user. As a user, I got a surface and a handle once time. Then I would never get my YUV data out !!!
I searched msdn, it told me the parameter" pSharedHandle" is pointer to a handle that is used to share the surfaces between Direct3D devices. I can pass a NULL to it. I tried it and LockRect and UnLockRect could no longer cause a crash. But I do need this "pSharedHandle" when creating a opencl&d3d shared surface(call clCreateFromDX9MediaSurfaceKHR).
I guess things may get related to the "Handle". How can I copy YUV data from d3d video surface to my system memory now?
I see you are using samples_version_220.127.116.11 which was released earlier this year. There has been couple more releases after that, can you please move to the latest sample and confirm the same behavior. If you do, please let us know your test case so that we can reproduce the issue at our end, debug and suggest a solution/workaround.