共用方式為


正在檢查支援的 DXVA-HD 格式

檢查支援的輸入格式

若要取得 Microsoft DirectX Video Acceleration High Definition (DXVA-HD) 裝置支援的輸入格式清單,請執行下列動作:

  1. 呼叫 IDXVAHD_Device::GetVideoProcessorDeviceCaps 以取得裝置功能。
  2. 檢查 DXVAHD_VPDEVCAPS 結構體中的 InputFormatCount 成員。 這個成員會提供支持的輸入格式數目。
  3. 分配一個大小為 InputFormatCountD3DFORMAT 值的陣列。
  4. 將此陣列傳遞至 IDXVAHD_Device::GetVideoProcessorInputFormats 方法。 方法會用輸入格式的列表填充數組。

下列程式代碼顯示下列步驟:

// Checks whether a DXVA-HD device supports a specified input format.

HRESULT CheckInputFormatSupport(
    IDXVAHD_Device          *pDXVAHD,
    const DXVAHD_VPDEVCAPS& caps,
    D3DFORMAT               d3dformat
    )
{
    D3DFORMAT *pFormats = new (std::nothrow) D3DFORMAT[ caps.InputFormatCount ];
    if (pFormats == NULL)
    {
        return E_OUTOFMEMORY;
    }

    HRESULT hr = pDXVAHD->GetVideoProcessorInputFormats(
        caps.InputFormatCount, 
        pFormats
        );

    if (FAILED(hr)) 
    { 
        goto done; 
    }

    UINT index;
    for (index = 0; index < caps.InputFormatCount; index++)
    {
        if (pFormats[index] == d3dformat)
        {
            break;
        }
    }
    if (index == caps.InputFormatCount)
    {
        hr = E_FAIL;
    }

done:
    delete [] pFormats;
    return hr;
}

檢查支持的輸出格式

若要取得 DXVA-HD 裝置支援的輸出格式清單,請執行下列動作:

  1. 呼叫 IDXVAHD_Device::GetVideoProcessorDeviceCaps 以取得裝置功能。
  2. 檢查 DXVAHD_VPDEVCAPS 結構的 OutputFormatCount 成員。 這個成員會提供支持的輸入格式數目。
  3. 分配一個大小為 OutputFormatCountD3DFORMAT 值的陣列。
  4. 將此陣列傳遞至 IDXVAHD_Device::GetVideoProcessorOutputFormats 方法。 該方法會用輸出格式的清單填滿陣列。

下列程式代碼顯示下列步驟:

// Checks whether a DXVA-HD device supports a specified output format.

HRESULT CheckOutputFormatSupport(
    IDXVAHD_Device          *pDXVAHD,
    const DXVAHD_VPDEVCAPS& caps,
    D3DFORMAT               d3dformat
    )
{
    D3DFORMAT *pFormats = new (std::nothrow) D3DFORMAT[caps.OutputFormatCount];
    if (pFormats == NULL)
    {
        return E_OUTOFMEMORY;
    }

    HRESULT hr = pDXVAHD->GetVideoProcessorOutputFormats(
        caps.OutputFormatCount, 
        pFormats
        );

    if (FAILED(hr)) 
    { 
        goto done; 
    }

    UINT index;
    for (index = 0; index < caps.OutputFormatCount; index++)
    {
        if (pFormats[index] == d3dformat)
        {
            break;
        }
    }
    if (index == caps.OutputFormatCount)
    {
        hr = E_FAIL;
    }

done:
    delete [] pFormats;
    return hr;
}

DXVA-HD