Community
cancel
Showing results for 
Search instead for 
Did you mean: 
____2
Beginner
133 Views

How to copy YUV data from d3d video surface to my system memory in Intel media SDK samples?

I noticed a interesting difference between Intel media samples 6.0.0.36,and some samples of earlier edition.

With samples 6.0.0.36, 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 
IDirectXVideoAccelerationService::CreateSurface(
  [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->Info.Width,
            request->Info.Height,
            request->NumFrameSuggested - 1,
            format,
            D3DPOOL_DEFAULT,
            m_surfaceUsage,
            target,
            (IDirect3DSurface9 **)mids.get(),
            NULL);

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 6.0.0.36 source file <d3d_allocator.cpp>, It defined a struct:

struct directxMemId
{
    IDirect3DSurface9* m_surface;
    HANDLE m_handle;
};

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?

0 Kudos
1 Reply
Surbhi_M_Intel
Employee
133 Views

Hi there, 

I see you are using samples_version_6.0.0.36 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. 

Thanks,
Surbhi

Reply