Video Quality Management

This topic describes some improvements to the video pipeline in Windows 7, both for Microsoft Media Foundation and Microsoft DirectShow.

In a perfect world, video would never glitch, regardless of the video resolution or the CPU/GPU load. In reality, of course, the video pipeline must be able to cope with finite hardware resources, and it must adaptively tailor playback to the system environment. The goals for video quality management are to:

  • Reduce glitching (dropped or late frames).
  • Reduce memory usage, especially in the GPU.
  • Reduce power consumption, especially in laptops running on battery power.
  • Get the best image quality possible, given resource constraints.
  • Keep video synchronized with audio.

Some of these goals are contrary, particularly on low-end systems. Generally there is a trade-off between speed and quality. Glitching is more objectionable than moderate reductions in visual quality. The relative importance of power consumption varies with the environment; in a laptop running on battery power, it is very important.

In Windows 7, the enhanced video renderer (EVR) has better support for video quality management. Both the Media Foundation pipeline and the DirectShow pipeline have been updated to take advantage of these capabilities. A two-pronged approach is used:

  • Before playback starts, the pipeline can perform static optimizations, based on the user's power management settings and information about the hardware.
  • After playback starts, the pipeline can apply dynamic optimizations, based on run-time performance.

Quality Management in Media Foundation

To enable static optimizations, set the MF_TOPOLOGY_STATIC_PLAYBACK_OPTIMIZATIONS attribute on the partial topology before resolving the topology. The topology loader queries this attribute in its IMFTopoLoader::Load method.

If you enable static optimizations, you should set two other attributes on the topology:

Attribute Description
MF_TOPOLOGY_PLAYBACK_MAX_DIMS
Specifies the maximum size of the video playback window.
MF_TOPOLOGY_PLAYBACK_FRAMERATE
Specifies the monitor refresh rate.

 

These two attributes help the pipeline calculate the most effective setting for quality management.

Dynamic optimizations are performed by the quality manager. You do not need to do anything to enable the quality manager; it is automatically enabled. The quality manager existed in Windows Vista; in Windows 7, the EVR can respond better to messages from the quality manager.

Quality Management in DirectShow

DirectShow supports static and dynamic optimizations for DVD playback. To enable these optimizations in a DVD playback application, set the following flags in the dwFlags parameter of the IDvdGraphBuilder::RenderDvdVideoVolume method:

Flag Description
AM_DVD_ADAPT_GRAPH Enables static optimizations.
AM_DVD_EVR_QOS Enables dynamic optimizations.

 

Other DirectShow applications can enable dynamic optimizations by calling the IEVRFilterConfigEx::SetConfigPrefs method directly on the EVR filter. Specify the EVRFilterConfigPrefs_EnableQoS flag.

Note

Static optimizations in DirectShow are limited to DVD playback.

 

Quality Management in the EVR

The EVR supports some new configuration flags for quality management. If you enable the quality management optimizations described previously, you do not have to set these flags directly. However, they are documented for applications that want more granular control over the EVR.

Set the following flags on the EVR mixer by calling the IMFVideoMixerControl2::SetMixingPrefs method:

Flags Description
  • MFVideoMixPrefs_ForceHalfInterlace
  • MFVideoMixPrefs_AllowDropToHalfInterlace
Skip the second field of every interlaced frame.
  • MFVideoMixPrefs_AllowDropToBob
  • MFVideoMixPrefs_ForceBob
Use bob deinterlacing, even if the driver supports a higher-quality deinterlace mode.

 

Set the following flags on the EVR presenter by calling the IMFVideoDisplayControl::SetRenderingPrefs method:

Flags Description
  • MFVideoRenderPrefs_ForceOutputThrottling
  • MFVideoRenderPrefs_AllowOutputThrottling
Throttle output to match GPU bandwidth.
  • MFVideoRenderPrefs_ForceBatching
  • MFVideoRenderPrefs_AllowBatching
Batch Direct3D Present calls. This optimization enables the system to enter into idle states more frequently, which can reduce power consumption.
  • MFVideoRenderPrefs_ForceScaling
  • MFVideoRenderPrefs_AllowScaling
Perform video mixing using a rectangle smaller than the output rectangle. Scale the result to the correct output size.

 

In addition, the EVR media sink supports configuration attributes that correspond to each of these flags:

Before playback starts, you can set these attributes directly on the EVR media sink, as an alternative to calling the IMFVideoMixerControl2 and IMFVideoDisplayControl methods. To set these attributes, query the EVR media sink for IMFAttributes.

Media Session