struktur DXVA2_VideoDesc (dxva2api.h)

Menjelaskan aliran video untuk perangkat dekoder DXVA atau perangkat prosesor video.

Sintaks

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;

Anggota

SampleWidth

Lebar bingkai video, dalam piksel.

SampleHeight

Tinggi bingkai video, dalam piksel.

SampleFormat

Detail tambahan tentang format video, ditentukan sebagai struktur DXVA2_ExtendedFormat .

Format

Format permukaan, ditentukan sebagai nilai D3DFORMAT atau kode FOURCC. Kode FOURCC dapat dibangun menggunakan makro D3DFORMAT atau MAKEFOURCC .

InputSampleFreq

Kecepatan bingkai aliran video input, ditentukan sebagai struktur DXVA2_Frequency .

OutputFrameFreq

Kecepatan bingkai video output, ditentukan sebagai struktur DXVA2_Frequency .

UABProtectionLevel

Tingkat perlindungan data yang diperlukan saat bus yang dapat diakses pengguna (UAB) ada. Jika TRUE, video harus dilindungi saat UAB ada. Jika FALSE, video tidak perlu dilindungi.

Reserved

Dicadangkan. Harus nol.

Keterangan

Anggota InputSampleFreq memberikan kecepatan bingkai aliran video yang didekodekan, seperti yang diterima oleh perender video. Anggota OutputFrameFreq memberikan kecepatan bingkai video yang ditampilkan setelah deinterlacing. Jika video input diselingi dan sampel berisi bidang yang saling terkait, kecepatan bingkai output adalah dua kali kecepatan bingkai input. Jika video input progresif atau berisi bidang tunggal, kecepatan bingkai output sama dengan kecepatan bingkai input.

Decoders harus mengatur nilai InputSampleFreq dan OutputFrameFreq jika kecepatan bingkai diketahui. Jika tidak, atur anggota ini ke 0/0 untuk menunjukkan kecepatan bingkai yang tidak diketahui.

Contoh

Kode berikut mengonversi jenis media Media Foundation, yang diwakili menggunakan antarmuka IMFMediaType , menjadi struktur 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;
}

Persyaratan

   
Klien minimum yang didukung Windows Vista [hanya aplikasi desktop]
Server minimum yang didukung Windows Server 2008 [hanya aplikasi desktop]
Header dxva2api.h

Lihat juga

IMFMediaType

Struktur Yayasan Media