Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aliasing/Quality issues in Media Foundation H264 hardware encoder, especially for text(aliasing and blur on text)

I've been working on Streaming real-time video using hardware accelerated h.264 encoding, decoding and I've been able to make it work using Windows Media Foundation .

I've compressed the frames from RGB to NV12 format using d3d11 Video Processor and encoded to h.264 using Hardware MFT.

The Only problem I have now is that after decoding and rendering the video, aliasing and halo effect appear on the screen along with the text.

The Images down below shows my problem.

Frame before Encoding

Original Image

Frame after encoding and decoding

Decoded Image

After some research, I came across H.264/AVC 444 in which Microsoft solved this by introducing full-screen AVC 444 mode with RDP 10.

In AVC 444 mode, we can get 4:4:4 quality text with 4:2:0 hardware encoders / decoders by improving the frame throughput significantly.

Introducing the AVC 444 mode The main challenge to use AVC/H.264 as the one and only Codec in Remote Desktop scenarios is that text shows a halo effect with typical implementations of AVC/H.264. This is caused by the color conversion process that happens as part of the compression which throws away some of the chrominance information, as represented in the 4:2:0 format. To the human eye the lack of chrominance information is not as apparent with video content, however with Remote Desktop scenarios, where mostly text is used, it is something that is noticeable and users will perceive this as blurry. The AVC/H.264 standard defines the capability to use 4:4:4 format which doesn’t lose the chrominance during conversion, however typically this isn’t part of most AVC/H.264 hardware encoder and decoder implementations and thus provides a challenge. To show the difference between 4:4:4 and 4:2:0 please see the following image which shows easily noticeable differences:

AVC 444

I tried to achieve the same in Media Foundation but unable find any resource to crack that yet.

I have figured out that color conversion to NV12 is the reason behind this problem and I've been trying to solve it, I have also tried YUV 444 but unable to find a hardware MFT that supports it. I was not able to encode any other color format except NV12 using Hardware MFT

Is there any way to overcome this problem?Any help would be appreciated.

like image 973
Bhuvanesh Murugaiyan Avatar asked Aug 05 '20 11:08

Bhuvanesh Murugaiyan


1 Answers

  1. You could use a Screen capture optimized codec: https://docs.microsoft.com/en-us/windows/win32/medfound/usingthewindowsmediavideo9screencodec

  2. NVIDIA supports 4:4:4 hardware assisted on a wide variety of cards: https://developer.nvidia.com/video-encode-decode-gpu-support-matrix

  3. Scale your screen from 1920x1080 to 3840x2160 convert to NV12 (4:2:0) compress to H.264 and do the reverse on the receiver. The upscaling and the subsequent 4:2:0 conversion should retain the full color resolution. This sounds wasteful but if it is done on hardware it should work.

like image 154
Markus Schumann Avatar answered Sep 27 '22 03:09

Markus Schumann