Skip to content

Hardware accelerated Motion Search (DX12 ME) #52

@DTL2020

Description

@DTL2020

Good to add search method to MAnalyse: DirectX12 Motion Estimated search. It hopefully will be standartized via Mictosoft DirectX API from different hardware vendors (not NVIDIA only). Currently looks like limited only to Windows 10 build something upper 19041(?).

Description: https://docs.microsoft.com/en-us/windows/win32/medfound/direct3d-video-motion-estimation

doom9 thread: https://forum.doom9.org/showthread.php?t=183517

Example of checking support and init MotionEstimator:

  CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory));

    ComPtr<IDXGIAdapter1> hardwareAdapter;
    GetHardwareAdapter(factory.Get(), &hardwareAdapter);

    HRESULT hr = D3D12CreateDevice(
      hardwareAdapter.Get(),
      D3D_FEATURE_LEVEL_11_0,
      IID_PPV_ARGS(&m_device)
    );

  ComPtr<ID3D12VideoDevice> vid_dev;

  HRESULT query_device1_result = m_device->QueryInterface(IID_PPV_ARGS(&vid_dev));

  D3D12_FEATURE_DATA_VIDEO_MOTION_ESTIMATOR MotionEstimatorSupport = { 0u, DXGI_FORMAT_NV12 };
  HRESULT feature_support = vid_dev->CheckFeatureSupport(D3D12_FEATURE_VIDEO_MOTION_ESTIMATOR, &MotionEstimatorSupport, sizeof(MotionEstimatorSupport));

  ComPtr<ID3D12VideoDevice1> vid_dev1;

  HRESULT query_vid_device1_result = m_device->QueryInterface(IID_PPV_ARGS(&vid_dev1));

  D3D12_VIDEO_MOTION_ESTIMATOR_DESC motionEstimatorDesc = {
  0, //NodeIndex
  DXGI_FORMAT_NV12,
  D3D12_VIDEO_MOTION_ESTIMATOR_SEARCH_BLOCK_SIZE_8X8,
  D3D12_VIDEO_MOTION_ESTIMATOR_VECTOR_PRECISION_QUARTER_PEL,
  {1920, 1080, 1280, 720} // D3D12_VIDEO_SIZE_RANGE
  };

  ComPtr<ID3D12VideoMotionEstimator> spVideoMotionEstimator;
  HRESULT vid_est_result = vid_dev1->CreateVideoMotionEstimator(
    &motionEstimatorDesc,
    nullptr,
    IID_PPV_ARGS(&spVideoMotionEstimator));```

Currently only support block sizes 8x8 and 16x16 and colour format NV12. But qpel precision that is very slow to calculate using CPU. It easy to downscale to half and full pel.
For development (building) need Windows SDK 10.0.20348.0 or newer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions