// Formats protected void CreateOptimalVideoType(IMFMediaType pProposed, out IMFMediaType ppOptimal) { try { MFRect rcOutput; MFVideoArea displayArea; IMFMediaType pOptimalType = null; // Create the helper object to manipulate the optimal type. VideoTypeBuilder pmtOptimal = new VideoTypeBuilder(); // Clone the proposed type. pmtOptimal.CopyFrom(pProposed); // Modify the new type. // For purposes of this SDK sample, we assume // 1) The monitor's pixels are square. // 2) The presenter always preserves the pixel aspect ratio. // Set the pixel aspect ratio (PAR) to 1:1 (see assumption #1, above) pmtOptimal.SetPixelAspectRatio(1, 1); // Get the output rectangle. rcOutput = m_pD3DPresentEngine.GetDestinationRect(); if (rcOutput.IsEmpty()) { // Calculate the output rectangle based on the media type. CalculateOutputRectangle(pProposed, out rcOutput); } // Set the extended color information: Use BT.709 pmtOptimal.SetYUVMatrix(MFVideoTransferMatrix.BT709); pmtOptimal.SetTransferFunction(MFVideoTransferFunction.Func709); pmtOptimal.SetVideoPrimaries(MFVideoPrimaries.BT709); pmtOptimal.SetVideoNominalRange(MFNominalRange.MFNominalRange_16_235); pmtOptimal.SetVideoLighting(MFVideoLighting.Dim); // Set the target rect dimensions. pmtOptimal.SetFrameDimensions(rcOutput.right, rcOutput.bottom); // Set the geometric aperture, and disable pan/scan. displayArea = new MFVideoArea(0, 0, rcOutput.right, rcOutput.bottom); pmtOptimal.SetPanScanEnabled(false); pmtOptimal.SetGeometricAperture(displayArea); // Set the pan/scan aperture and the minimum display aperture. We don't care // about them per se, but the mixer will reject the type if these exceed the // frame dimentions. pmtOptimal.SetPanScanAperture(displayArea); pmtOptimal.SetMinDisplayAperture(displayArea); // Return the pointer to the caller. pmtOptimal.GetMediaType(out pOptimalType); pmtOptimal.Dispose(); ppOptimal = pOptimalType; } finally { //SafeRelease(pOptimalType); //SafeRelease(pmtOptimal); } }