DXVA2_VideoDesc 結構 (dxva2api.h)

描述 DXVA 解碼器裝置或視訊處理器裝置的視訊資料流程。

語法

typedef struct _DXVA2_VideoDesc {
  UINT                 SampleWidth;
  UINT                 SampleHeight;
  DXVA2_ExtendedFormat SampleFormat;
  D3DFORMAT            Format;
  DXVA2_Frequency      InputSampleFreq;
  DXVA2_Frequency      OutputFrameFreq;
  UINT                 UABProtectionLevel;
  UINT                 Reserved;
} DXVA2_VideoDesc;

成員

SampleWidth

視訊畫面的寬度,以圖元為單位。

SampleHeight

視訊畫面的高度,以圖元為單位。

SampleFormat

視訊格式的其他詳細資料,指定為 DXVA2_ExtendedFormat 結構。

Format

Surface 格式,指定為 D3DFORMAT 值或 FOURCC 程式碼。 您可以使用 D3DFORMATMAKEFOURCC 宏來建構 FOURCC 程式碼。

InputSampleFreq

輸入視訊資料流程的畫面播放速率,指定為 DXVA2_Frequency 結構。

OutputFrameFreq

輸出視訊的畫面播放速率,指定為 DXVA2_Frequency 結構。

UABProtectionLevel

使用者存取匯流排 (UAB) 時所需的資料保護層級。 如果 為 TRUE,則當 UAB 存在時,影片必須受到保護。 如果 為 FALSE,則不需要保護視訊。

Reserved

保留的。 必須為零。

備註

InputSampleFreq成員會提供解碼視訊資料流程的畫面播放速率,如影片轉譯器所接收。 OutputFrameFreq成員會提供反交錯之後所顯示之視訊的畫面播放速率。 如果輸入視訊交錯,而且樣本包含交錯欄位,輸出畫面播放速率會是輸入畫面播放速率的兩倍。 如果輸入視訊是漸進式或包含單一欄位,則輸出畫面播放速率與輸入畫面播放速率相同。

如果已知畫面播放速率,解碼器應該設定 InputSampleFreqOutputFrameFreq 的值。 否則,請將這些成員設定為 0/0,以指出未知的畫面播放速率。

範例

下列程式碼會將使用 IMFMediaType 介面表示的 Media Foundation 媒體類型轉換成 DXVA2_VideoDesc 結構。

// Fills in the DXVA2_ExtendedFormat structure.
void GetDXVA2ExtendedFormatFromMFMediaType(
    IMFMediaType *pType, 
    DXVA2_ExtendedFormat *pFormat
)
{
    // Get the interlace mode.
    MFVideoInterlaceMode interlace = 
        (MFVideoInterlaceMode)MFGetAttributeUINT32(
            pType, MF_MT_INTERLACE_MODE, MFVideoInterlace_Unknown
         );

    // The values for interlace mode translate directly, except for mixed 
    // interlace or progressive mode.

    if (interlace == MFVideoInterlace_MixedInterlaceOrProgressive)
    {
        // Default to interleaved fields.
        pFormat->SampleFormat = DXVA2_SampleFieldInterleavedEvenFirst;
    }
    else
    {
        pFormat->SampleFormat = (UINT)interlace;
    }

    // The remaining values translate directly.
    
    // Use the "no-fail" attribute functions and default to "unknown."
    
    pFormat->VideoChromaSubsampling = MFGetAttributeUINT32(
        pType, MF_MT_VIDEO_CHROMA_SITING, MFVideoChromaSubsampling_Unknown);

    pFormat->NominalRange = MFGetAttributeUINT32(
        pType, MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_Unknown);

    pFormat->VideoTransferMatrix = MFGetAttributeUINT32(
        pType, MF_MT_YUV_MATRIX, MFVideoTransferMatrix_Unknown);

    pFormat->VideoLighting = MFGetAttributeUINT32(
        pType, MF_MT_VIDEO_LIGHTING, MFVideoLighting_Unknown);

    pFormat->VideoPrimaries = MFGetAttributeUINT32(
        pType, MF_MT_VIDEO_PRIMARIES, MFVideoPrimaries_Unknown);

    pFormat->VideoTransferFunction = MFGetAttributeUINT32(
        pType, MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_Unknown);

}


HRESULT ConvertMFTypeToDXVAType(IMFMediaType *pType, DXVA2_VideoDesc *pDesc)
{
    ZeroMemory(pDesc, sizeof(*pDesc));

    GUID                    subtype = GUID_NULL;
    UINT32                  width = 0;
    UINT32                  height = 0;
    UINT32                  fpsNumerator = 0;
    UINT32                  fpsDenominator = 0;

    // The D3D format is the first DWORD of the subtype GUID.
    HRESULT hr = pType->GetGUID(MF_MT_SUBTYPE, &subtype);
    if (FAILED(hr))
    {
        goto done;
    }

    pDesc->Format = (D3DFORMAT)subtype.Data1;

    // Frame size.
    hr = MFGetAttributeSize(pType, MF_MT_FRAME_SIZE, &width, &height);
    if (FAILED(hr))
    {
        goto done;
    }

    pDesc->SampleWidth = width;
    pDesc->SampleHeight = height;

    // Frame rate.
    hr = MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator, &fpsDenominator);
    if (FAILED(hr))
    {
        goto done;
    }

    pDesc->InputSampleFreq.Numerator = fpsNumerator;
    pDesc->InputSampleFreq.Denominator = fpsDenominator;

    // Extended format information.
    GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat);

    // For progressive or single-field types, the output frequency is the same as
    // the input frequency. For interleaved-field types, the output frequency is
    // twice the input frequency.  
    pDesc->OutputFrameFreq = pDesc->InputSampleFreq;

    if ((pDesc->SampleFormat.SampleFormat == DXVA2_SampleFieldInterleavedEvenFirst) ||
        (pDesc->SampleFormat.SampleFormat == DXVA2_SampleFieldInterleavedOddFirst))
    {
        pDesc->OutputFrameFreq.Numerator *= 2;
    }

done:
    return hr;
}

需求

   
最低支援的用戶端 Windows Vista [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 [僅限傳統型應用程式]
標頭 dxva2api.h

另請參閱

IMFMediaType

媒體基礎結構