Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use hardware video scalers?

Modern graphics cards have hardware video scalers, for example as part of AMD Avivo, NVIDIA PureVideo or Intel ClearVideo. For example, AMD's Avivo whitepaper says:

"The image output scalers support up to 6 vertical filter taps and up to 10 horizontal filter taps. These scalers are high-precision polyphase scalers that are highly programmable; they are suitable for upscaling by practically any ratio, or for downscaling by up to 4:1."

The question: How can the video scaler hardware be used from a Windows program?

Assume there already exists a decoded video frame, for example in a IDirect3DSurface9, and the goal is to display that video frame on screen using the hardware scaler. I would like to use a Windows API like Media Foundation or DirectShow, rather than vendor-specific APIs if possible. I am mainly interested in upscaling by a fairly large factor around 1.5-3x.

A secondary question is, how can the video scaler hardware parameters be controlled? (For example, the filter coefficients in the polyphase filters mentioned above)

EDIT: Bounty started. Please provide an example of any way to use video scaler hardware in video card (this may be vendor specific, or use any version of DirectX/DirectShow/Media Foundation API).

EDIT: Update: Some examples of programs that do use the video scaler hardware: WinDVD, PowerDVD, madVR. I want to know how to accomplish what they do, which is to use the GPU's builtin video hardware scaler, not a scaler implemented using D3D shaders and texture samplers.

like image 700
Alex I Avatar asked Dec 03 '12 21:12

Alex I


People also ask

How does video scaler work?

A video scaler is a system which converts video signals from one display resolution to another; typically, scalers are used to convert a signal from a lower resolution (such as 480p standard definition) to a higher resolution (such as 1080i high definition), a process known as "upconversion" or "upscaling" (by contrast ...

Do I need a video scaler?

A video scaler becomes necessary when the resolution of the input device is significantly different from the output device so that without the scaler the image quality would be distorted or compromised. While video scalers come in numerous shapes and sizes, they typically are classified as either internal or external.

What is a scaler input?

A scaler is a device that samples an input signal and scales it up or down to a resolution and timing suitable for the display. A scaler may optionally also convert the signal to a different format. A scaler that downscales video is sometimes called a scan converter.

What is a scaler IC?

S2D13V52 is a simple add-on scaler chip which can be used to up/downscale streaming image in different resolution. It helps customer to realize a higher & lower resolution of Central Information Display or Instrumental Cluster Display without changing the current SOC/ECU platform.


1 Answers

Some of the possible approaches are:

  1. Use MFCreateVideoRenderer to create an EVR media sink, and call IMFVideoDisplayControl::SetRenderingPrefs with MFVideoRenderPrefs_AllowScaling flag set (or use IMFAttributes and set the EVRConfig_AllowScaling attribute) and then call IMFVideoDisplayControl::SetVideoPosition to define how the result is scaled. This is part of the Enhanced Video Renderer (EVR).

  2. Use IDirectXVideoProcessor::VideoProcessBlt and set DXVA2_VideoProcessBltParams::ConstrictionSize to define how the result is scaled. This is also based on EVR/DXVA.

  3. (suggested by ananthonline) Use Video Resizer DSP and use IWMResizerProps::SetFullCropRegion (or MFPKEY_RESIZE_DST_WIDTH and MFPKEY_RESIZE_DST_HEIGHT) to scale the result. This is both a DirectX Media Object (DMO) and Media Foundation Transform (MFT). Note: A video MFT has the attribute MF_SA_D3D_AWARE which can be used to query whether it supports DirectX 3D hardware acceleration, and this can be enabled by sending it the MFT_MESSAGE_SET_D3D_MANAGER message.

  4. Use Video Processor MFT and set IMFVideoProcessorControl::SetConstrictionSize to scale the result. This is a MFT.

  5. Use a DirectX 3D device and call StretchRect to scale a surface. Note: this pretty obviously does not use the video scaler hardware, it uses texture sampler hardware. A texture can be rendered on a quad with similar effect.

I am still not sure which, if any, of these approaches uses the video scaler hardware. It is likely that at least approaches 1 and 2 would, because they are tied directly to EVR/DXVA; approaches 3 and 4 also might if they are accelerated by DXVA. A definitive answer is still needed, ideally with a reference to documentation and/or a code sample.

like image 80
Alex I Avatar answered Oct 01 '22 04:10

Alex I