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 코드로 지정됩니다. FOURCC 코드는 D3DFORMAT 또는 MAKEFOURCC 매크로를 사용하여 생성할 수 있습니다.

InputSampleFreq

DXVA2_Frequency 구조체로 지정된 입력 비디오 스트림의 프레임 속도입니다.

OutputFrameFreq

DXVA2_Frequency 구조체로 지정된 출력 비디오의 프레임 속도입니다.

UABProtectionLevel

UAB(사용자 액세스 가능 버스)가 있는 경우 필요한 데이터 보호 수준입니다. TRUE이면 UAB가 있을 때 비디오를 보호해야 합니다. FALSE이면 비디오를 보호할 필요가 없습니다.

Reserved

예약되어 있습니다. 0이어야 합니다.

설명

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

미디어 파운데이션 구조