Handling Format Changes from the Video Renderer

 
Microsoft DirectShow 9.0

Handling Format Changes from the Video Renderer

This section decribes how a decoder filter or transform filter should handle format changes from the video renderer.

Video Renderer Filter

When the old Video Renderer filter connects, it requires an RGB format that matches the display format of the primary monitor. This enables it to use GDI for rendering if DirectDraw is not available. When playback starts, the Video Renderer may switch to a DirectDraw-compatible format. To verfify whether the upstream filter can support the new format, the Video Renderer calls IPin::QueryAccept on the upstream filter's output pin. If the upstream filter accepts the new format, the QueryAccept method returns S_OK. The Video Renderer switches formats by attaching a media type with the new format to the next media sample returned by its allocator. The upstream filter should check for format changes by calling IMediaSample::GetMediaType on each sample. The Video Renderer may switch back and forth between the original format and new format at any time during streaming. It does not call QueryAccept after the first format change. Once the upstream filter has accepted the new format, it must be able to switch back and forth.

The upstream filter can reject the format change by returning S_FALSE from QueryAccept. In that case, the Video Renderer continues to GDI with the original format.

Video Mixing Renderer Filter

The Video Mixing Renderer filter (VMR-7 and VMR-9) will connect with any format that is supported by the graphics hardware on the system. The VMR-7 always uses DirectDraw for rendering, and allocates the underlying DirectDraw surfaces when the upstream filter connects. The VMR-9 always uses Direct3D for rendering, and allocates the underlying Direct3D surfaces when the upstream filter connects.

The graphics hardware may require a larger surface stride than the image width. In that case, the VMR requests a new format by calling QueryAccept. It reports the surface stride in the biWidth member of the BITMAPINFOHEADER in the video format. If the upstream filter does not return S_OK from QueryAccept, the VMR rejects the format and tries to connect using the next format advertised by the upstream filter. The VMR attaches the media type with the new format to the first media sample. After the first sample, the format remains constant; the VMR will not switch formats while the graph is running.

Enhanced Video Render (EVR)

The EVR always uses Direct3D for rendering. If a larger surface stride is needed, the EVR uses the same QueryAccept mechanism as the VMR.

See Also