Skip to content

Latest commit

 

History

History
219 lines (160 loc) · 6.82 KB

ns-dxva2api-dxva2_videodesc.md

File metadata and controls

219 lines (160 loc) · 6.82 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NS:dxva2api._DXVA2_VideoDesc
DXVA2_VideoDesc (dxva2api.h)
Describes a video stream for a DXVA decoder device or video processor device.
0e500a08-a3b5-475c-8bbc-e4b30cce247d
DXVA2_VideoDesc
DXVA2_VideoDesc structure [Media Foundation]
dxva2api/DXVA2_VideoDesc
mf.dxva2_videodesc
mf\dxva2_videodesc.htm
mf
0e500a08-a3b5-475c-8bbc-e4b30cce247d
12/05/2018
0e500a08-a3b5-475c-8bbc-e4b30cce247d, DXVA2_VideoDesc, DXVA2_VideoDesc structure [Media Foundation], dxva2api/DXVA2_VideoDesc, mf.dxva2_videodesc
dxva2api.h
Windows
Windows Vista [desktop apps only]
Windows Server 2008 [desktop apps only]
Windows
DXVA2_VideoDesc
19H1
_DXVA2_VideoDesc
dxva2api/_DXVA2_VideoDesc
DXVA2_VideoDesc
dxva2api/DXVA2_VideoDesc
c++
APIRef
kbSyntax
HeaderDef
dxva2api.h
DXVA2_VideoDesc

DXVA2_VideoDesc structure

-description

Describes a video stream for a DXVA decoder device or video processor device.

-struct-fields

-field SampleWidth

Width of the video frame, in pixels.

-field SampleHeight

Height of the video frame, in pixels.

-field SampleFormat

Additional details about the video format, specified as a DXVA2_ExtendedFormat structure.

-field Format

Surface format, specified as a D3DFORMAT value or FOURCC code. A FOURCC code can be constructed using the D3DFORMAT or MAKEFOURCC macros.

-field InputSampleFreq

Frame rate of the input video stream, specified as a DXVA2_Frequency structure.

-field OutputFrameFreq

Frame rate of the output video, specified as a DXVA2_Frequency structure.

-field UABProtectionLevel

Level of data protection required when the user accessible bus (UAB) is present. If TRUE, the video must be protected when a UAB is present. If FALSE, the video is not required to be protected.

-field Reserved

Reserved. Must be zero.

-remarks

The InputSampleFreq member gives the frame rate of the decoded video stream, as received by the video renderer. The OutputFrameFreq member gives the frame rate of the video that is displayed after deinterlacing. If the input video is interlaced and the samples contain interleaved fields, the output frame rate is twice the input frame rate. If the input video is progressive or contains single fields, the output frame rate is the same as the input frame rate.

Decoders should set the values of InputSampleFreq and OutputFrameFreq if the frame rate is known. Otherwise, set these members to 0/0 to indicate an unknown frame rate.

Examples

The following code converts a Media Foundation media type, represented using the IMFMediaType interface, into a DXVA2_VideoDesc structure.

// 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;
}

-see-also

IMFMediaType

Media Foundation Structures