Calling the Deinterlace DDI from a User-Mode Component

A user-mode component, such as the VMR, initiates calls to the deinterlacing DDI.

So that the VMR can deinterlace and perform frame-rate conversion on video content, the display driver must implement the motion compensation callback functions, which are defined by members of the DD_MOTIONCOMPCALLBACKS structure.

To simplify driver development, driver writers can use a motion-compensation code template and implement the deinterlacing sample functions. The motion-compensation template calls the deinterlacing sample functions to perform deinterlacing and frame-rate conversion on video content. For more information about using a motion-compensation template, see Example Code for DirectX VA Devices.

The following steps explain how the VMR initiates calls to the deinterlace DDI:

  1. When the VMR is added to a filter graph, it initiates a call to the driver-supplied DdMoCompGetGuids callback function to retrieve the list of devices supported by the driver. The GetMoCompGuids member of the DD_MOTIONCOMPCALLBACKS structure points to this callback function. For more information about a filter graph, see KS Minidriver Architecture.

  2. If the deinterlace container device GUID is present, the VMR initiates a call to the DdMoCompCreate callback function to create an instance of the device. The CreateMoComp member of DD_MOTIONCOMPCALLBACKS points to the callback function. In the DdMoCompCreate call, a pointer to the container device GUID is specified in the lpGuid member of the DD_CREATEMOCOMPDATA structure. The container device GUID is defined as follows:

    DEFINE_GUID(DXVA_DeinterlaceContainerDevice, 0x0e85cb93,0x3046,0x4ff0,0xae,0xcc,0xd5,0x8c,0xb5,0xf0,0x35,0xfd);
    
  3. To determine the available deinterlacing or frame-rate conversion modes for a particular input video format, the VMR initiates a call to the driver-supplied DdMoCompRender callback function. The RenderMoComp member of DD_MOTIONCOMPCALLBACKS points to the callback function. In the DdMoCompRender call, the DXVA_ProcAmpControlQueryCapsFnCode constant (defined in dxva.h) is set in the dwFunction member of the DD_RENDERMOCOMPDATA structure. The lpInputData member of DD_RENDERMOCOMPDATA passes the input parameters to the driver by pointing to a completed DXVA_VideoDesc structure. The driver returns its output through the lpOutputData member of DD_RENDERMOCOMPDATA; lpOutputData points to a DXVA_DeinterlaceQueryAvailableModes structure.

    If the driver implements a DeinterlaceQueryAvailableModes sample function, the DdMoCompRender callback function calls DeinterlaceQueryAvailableModes.

  4. For each deinterlace mode supported by the driver, the VMR initiates a call to the driver-supplied DdMoCompRendercallback function. In the DdMoCompRender call, the DXVA_DeinterlaceQueryModeCapsFnCode constant (defined in dxva.h) is set in the dwFunction member of DD_RENDERMOCOMPDATA. The lpInputData member of DD_RENDERMOCOMPDATA passes the input parameters to the driver by pointing to a completed DXVA_DeinterlaceQueryModeCaps structure. The driver returns its output through the lpOutputData member of DD_RENDERMOCOMPDATA; lpOutputData points to a DXVA_DeinterlaceCaps structure.

    If the driver implements a DeinterlaceQueryModeCaps sample function, the DdMoCompRender callback function calls DeinterlaceQueryModeCaps.

  5. After the VMR has determined the deinterlacing capabilities of a particular deinterlace mode (for example, bob deinterlacing), it initiates a call to DdMoCompCreate to create an instance of the deinterlace mode device (for example, the deinterlace bob device). In the DdMoCompCreate call, a pointer to the deinterlace mode device GUID is specified in the lpGuid member of DD_CREATEMOCOMPDATA. The deinterlace bob device GUID is defined as follows:

    DEFINE_GUID(DXVAp_DeinterlaceBobDevice, 0x335aa36e,0x7884,0x43a4,0x9c,0x91,0x7f,0x87,0xfa,0xf3,0xe3,0x7e);
    

    If the driver implements a DeinterlaceOpenStream sample function, the DdMoCompCreate callback function calls DeinterlaceOpenStream.

  6. For each deinterlacing operation, the VMR initiates a call to the driver-supplied DdMoCompRender callback function. In the DdMoCompRender call, the DXVA_ProcAmpControlQueryCapsFnCode constant (defined in dxva.h) is set in the dwFunction member of DD_RENDERMOCOMPDATA. The lpBufferInfo member of DD_RENDERMOCOMPDATA points to an array of buffers that describes the destination surface and each input video source sample. The lpInputData member of DD_RENDERMOCOMPDATA passes the input parameters to the driver by pointing to a completed DXVA_DeinterlaceBlt structure. The driver does not return any output; that is, the lpOutputData member of DD_RENDERMOCOMPDATA is NULL.

    If the driver implements a DeinterlaceBlt sample function, the DdMoCompRender callback function calls DeinterlaceBlt.

  7. For each combination deinterlacing and substream compositing operation, the VMR on Microsoft Windows Server 2003 SP1 and later and Windows XP SP2 and later initiates a call to the driver-supplied DdMoCompRender callback function. In the DdMoCompRender call, the DXVA_DeinterlaceBltExFnCode constant (defined in dxva.h) is set in the dwFunction member of DD_RENDERMOCOMPDATA. The lpBufferInfo member of DD_RENDERMOCOMPDATA points to an array of buffers that describes the destination surface and the surface for each input video source sample. The lpInputData member of DD_RENDERMOCOMPDATA passes the input parameters to the driver by pointing to a completed DXVA_DeinterlaceBltEx structure. The driver does not return any output; that is, the lpOutputData member of DD_RENDERMOCOMPDATA is NULL.

    If the driver implements a DeinterlaceBltEx sample function, the DdMoCompRender callback function calls DeinterlaceBltEx.

  8. When the VMR no longer needs to perform any more deinterlace operations, the driver-supplied DdMoCompDestroy callback function is called. The DestroyMoComp member of DD_MOTIONCOMPCALLBACKS points to the callback function.

    If the driver implements a DeinterlaceCloseStream sample function, the DdMoCompDestroy callback function calls DeinterlaceCloseStream.

  9. The driver then releases any resources used by the deinterlace mode device.