cancel
Showing results for 
Search instead for 
Did you mean: 
Views: 1,640

 

Hardware video acceleration encoding and decoding

 

Consumer technology came a long way since it’s introduction to our daily lives. Media consumption grew exponentially and currently over a third of every byte in the internet traffic comes from video streaming. To cope with the increased demand for media streaming, not only the internet bandwidth had to be increased, but also hardware had to be able to decode and encode high quality video streams and files.

While CPUs can cope with such workloads, dedicated hardware can perform much better at a lower energy cost. This article covers the means and benefits of using Intel Quick Sync Video (QSV) in video decoding and encoding mainly with gaming and media consumption in mind.

 

What is Intel Quick Sync?

 

Intel Quick Sync Video is a video encoding and decoding hardware within the same die as Intel CPU as a part of the integrated Intel GPU (HD, Iris, Iris Pro). It has been introduced in 2011 with Sandy Bridge microarchitecture (the "2nd generation" of Core processors) and has been improved with every generation since then. Benefits of using QSV are mainly highly improved efficiency and offloading video processing workloads leaving more processing power for other tasks.

 

Testing methodology

 

To demonstrate the impact and benefits of using hardware accelerated video processing in various tasks I performed few decoding and encoding tasks using software decoder/encoder and hardware decoder/encoder utilising Intel Quick Sync and Nvidia CUVID. All tests/benchmarks were performed using Lenovo Legion Y530 in the following configuration:

Intel Core i7 8750h, 16GB of RAM, Nvidia GTX 1050ti

Please note, that Intel Quick Sync and Nvidia CUVID are supported both under Linux and Windows, but this article covers Windows side only. “Films and TV”, the video player built in Windows 10 natively uses QSV, so it works out of the box. However, since it has limited functionality and doesn’t have an option to change the decoder, it would be rather hard to demonstrate the benefits of using QSV. Instead, MPC-HC with LAV codecs and popular VLC Player were used. The test video was a 4k 250mbps 30 second test video encoded with h.264, which is currently the most common codec and it's younger brother HEVC/h.265, which slowly replaces it (link below).

http://jell.yfish.us/

 

Decoding video

 

The first test consisted of checking the utilisation of CPU and both GPUs in task manager while playing the video in MPC-HC.

To change the decoder, go to the properties of LAV Video Decoder and set the desired Hardware Decoder:

LAV decoder.png

 

Results for h.264 video:

 

CPU

Intel GPU

NVidia GPU

Software

43%

39%

0%

 

CUVID

7%

41%

32%

 

QuickSync

14%

42%

0%

 

DXVA2 (native)

6%

48%

0%

 

 

Before I proceed to analyzing the results it's necessary to explain the inclusion of DXVA2. DXVA2 is the second iteration of DirectX Video Acceleration (DXVA) which is Microsoft's implementation of offloading video processing from CPU to GPU on PCs running Windows OS and XBox consoles. DXVA2 will utilise any hardware acceleration available on the given hardware.

 

As we can see the integrated Intel GPU (HD630 in this case) is being utilised whichever device decodes the video. This is because in the Optimus configuration the integrated video adapter is always used as the last device in the chain right before the video output is displayed on the screen even if the dedicated GPU renders the actual image. Both the CPUs you can find in Legion Y530 (8300h and 8750h) as well as dedicated GPUs (Nvidia 1050 and 1050ti) potentially consume much more power than the integrated Intel GPU. That means that whenever we see a decrease in CPU and dedicated GPU utilisation, our power consumption drops dramatically. For a laptop running on battery power this is crucial.

 

In case of the h.264 encoded video we can observe 3 to 7-fold drop in CPU utilisation when a hardware decoder is used. Each time the video played smoothly without any hiccups or stuttering. However, any time the CPU utilisation increases or the Nvidia GPU is being used, the overall power consumption will increase significantly.

01-videotest-software a.pngSoftware decodinghevc-02-nvidia a.pngCUVID decoder

03-videotest-qvs a.pngQVS decoder

Results for HEVC/h.265 video:

 

CPU

Intel GPU

NVidia GPU

Software

85-100%

42%

0%

CUVID

7%

40%

29%

QuickSync

85-100%

41%

0%

DXVA2 (native)

85-100%

41%

0%

DXVA2

(copy-back)

12%

33%

0%

 

For the HEVC video we can see that even the hexa core 8750h struggles to decode the video. Surprisingly the 1050ti had slightly less utilisation when decoding the HEVC video than the h264 video. Due to lack of implementation of HEVC decoding using QSV in the current version of LAV video decoder both the DXVA2 (native) and QuickSync options did not properly work with the video. However, HEVC decoding is supported by QuickSync since Skylake microarchitecture. Strangely enough in copy-back mode there was no issue at all and again the utilisation of the GPU went down when compared to h264 video. For further reading on DXVA2 modes please refer to the link below.

https://en.wikipedia.org/wiki/DirectX_Video_Acceleration

 

VLC Player natively doesn’t give as much flexibility in choosing the hardware decoding, and the video playback did not work with HEVC video using DXVA decoding. Due to those issues the test was not performed using VLC player in the end. However, with all settings set to automatic, both videos played with no issues and utilised the QVS properly.

 

Encoding video

 

Y530 is more than powerful enough to be used for video editing, but since it’s considered a gaming laptop it’s best to test it with gaming in mind. Free streaming/recording software OBS can utilise both the Intel QSV and Nvidia NVENC hardware encoders, so it is good choice to test hardware accelerated video encoding. The main concern is the impact the encoder has on the gaming performance. Secondary, but also important point, is the quality of the output video.

To change the encoder settings in OBS go to file->settings->Output. You can find both streaming and recording settings in here.

obs.png

The test was performed using 2 games: Tomb Raider (2013) and Rise of the Tomb Raider. Both of them have inbuilt benchmark, which can be used to easily measure the impact of the encoding. All tests were performed using default settings within OBS and 1080p resolution. Both games were set to max settings with anti-aliasing and v-sync turned off.

 

Tomb Raider:

 

Min FPS

Max FPS

Avg FPS

OBS off

50

82

67

OBS w/ QSV

44

82

62.4

OBS w/ NVENC

44

70

58.2

 

Rise of the Tomb Raider:

 

Mountain Peak

Syria

Geothermal Valley

Overall

OBS off

29.58/54.18/83.82

5.86/42.22/76.74

13.32/37.01/51.99

44.6

OBS w/ QSV

25.89/46.99/96.52

6.12/32.43/48.48

13.28/29.45/46.49

36.49

OBS w/ NVENC

23.63/47.64/78.76

2.83/31.52/52.49

7.24/27.99/59.95

35.91

Score in FPS min/avg/max

 

The impact of the encoder is noticeable in both cases. Since the integrated GPU is mostly unused when gaming using the dedicated GPU, it’s clear that it’s much better idea to utilise the Intel’s encoder than to burden the Nvidia GPU with both rendering and encoding the video. There’s no noticeable difference in quality either. Screenshots below.

enc-intel-samp2.jpgQVS encoderenc-nvidia-samp2.jpgNVENC encoderenc-nvidia-samp1.jpgQVS encoderenc-intel-samp1.jpgNVENC encoder

Was this information helpful?

Contributors