FFmpegInteropX icon indicating copy to clipboard operation
FFmpegInteropX copied to clipboard

Fixed-Function Media Engines in GPUs with HW Media Acceleration Features

Open softworkz opened this issue 1 year ago • 2 comments

Intel

Intel GPUs have fixed-function media engines for quite a while. The important parts to know about are:

  • VDBOX: Video Decoding
  • VEBOX: Video Enhancement
  • SFC: Scaling and format conversion
  • VDEnc: Video Encoding

image

SFC was introduced in Kaby Lake to achieve low-power video playback without using shaders for scaling via EUs (Execution Units). EUs are the primary workhorses which are used by games for 3D computations but also for desktop composition, overlay and scaling of gpu surfaces. This is also what accounts for "3D" usage percentage in task manager.

Some video processing features are provided as EU Kernels, some via VEBOX fixed function blocks, sometimes, both. It depends on the GPU generation. Scaling is done via SFC since Kaby Lake

References:

  • https://www.anandtech.com/show/9562/intels-skylake-gpu-analyzing-the-media-capabilities
  • https://www.x.org/docs/intel/LKF/intel-gfx-prm-osrc-lkf-vol11-mediaengines.pdf
  • https://www.x.org/docs/intel/KBL/intel-gfx-prm-osrc-kbl-vol15-sfc.pdf
  • https://github.com/intel/media-driver#components-and-features
  • https://github.com/intel/media-driver/blob/master/docs/media_features.md#supported-video-processing-feature-combination

SFC is not a generic and independent feature. It is part of the Media Engines and requires a media pipeline context to be used. SFC cannot be used for generic scaling, such as is done for desktop composition. For desktop composition, scaling is done by EU kernels.

ffmpeg Implementation

The QSV processing filter in ffmpeg has a scale_mode option which allows you to switch between shader-based (EU kernel) scaling and fixed-function block (SFC, also called 'low-power mode') scaling:

With EU Kernel Scaling

ffmpeg -hwaccel qsv -c:v h264_qsv -i video.mkv -vf "vpp_qsv=w=1920:h=1080:scale_mode=2" -f null -

ffmpeg speed=7.69x CPU load: 25%

image

With Fixed-Function Scaling

ffmpeg -hwaccel qsv -c:v h264_qsv -i video.mkv -vf "vpp_qsv=w=1920:h=1080:scale_mode=1" -f null -

ffmpeg speed=8.05x CPU load: 25%

image

CPU Decoding and Scaling

ffmpeg -i  video.mkv -vf "scale=w=1920:h=1080" -f null -

speed=8.03x CPU load: 100%

NOTE: The test file I used is "Samsung Dubai" which you can find on DemoLandia.net

softworkz avatar Nov 20 '24 21:11 softworkz