Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Software decoding looks low quality #21850

Closed
1 of 7 tasks
TianZerL opened this issue Sep 12, 2022 · 22 comments · Fixed by #24221
Closed
1 of 7 tasks

Software decoding looks low quality #21850

TianZerL opened this issue Sep 12, 2022 · 22 comments · Fixed by #24221
Labels
Component: DirectX rendering Platform: Windows Platform: WindowsStore Resolution: Fixed issue was resolved by a code change Triage: Confirmed issue has been reproduced by a team member

Comments

@TianZerL
Copy link

TianZerL commented Sep 12, 2022

Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

it looks low quality if I use software decoding (ff-hevc) for hevc video, and will be fine if I enable hardware acceleration.
Same video software decoding in VLC or MPC-HC is OK.

Expected Behavior

Here is a clear and concise description of what was expected to happen:

The edges of the lines should be smooth.

Actual Behavior

Line edges are not smooth, it's especially evident in Anime.
There is no scale, so it's not because of nearest upscaling.

Possible Fix

Use hardware decoder instead of ff-hevc software decoder.

To Reproduce

Steps to reproduce the behavior:

  1. Make sure ff-hevc decoder is currently using.
  2. Play a hevc video, both 8 or 10bit is ok.

Debuglog

The debuglog can be found here:

kodi.old.log

Screenshots

Here are some links or screenshots to help explain the problem:

Please right click to see the original image. Notice the edges of the text, and the pattern in the middle of the first group of images

HEVC 10bit KODI SW (low quality)

kodi SW

HEVC 10bit VLC SW (OK)

VLC SW

HEVC 8bit KODI SW (low quality)

KODI1 SW

HEVC 8bit KODI HW (OK)

KODI1 HW

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • OSX

  • Windows

  • Windows UWP

  • Operating system version/name: Windows 11

  • Kodi version: 20 Alpha3

note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

@thexai
Copy link
Member

thexai commented Sep 12, 2022

Totally useless as you not provided none info (video resolution, render resolution, output resolution, debug log, etc.).

fine if I enable hardware acceleration.

This is the key point.

Some context:
Best upscaling method is DXVA (and only can be used is is used DVXA render method).
And by default DXVA only is used if is used DXVA2 video decoding.

DXVA2 = OFF ----> PixelShaders are used ----> DXVA upscaling cannot be used.

@thexai thexai closed this as completed Sep 12, 2022
@thexai thexai added the Ignored rules issue that does not follow the rules (no template, missing debug log, ...) label Sep 12, 2022
@TianZerL
Copy link
Author

TianZerL commented Sep 12, 2022

@thexai

video resolution, render resolution, output resolution

I have said that there was no scale, all 1080p, 100% point-to-point.
I don't think this is a problem with the renderer, PixelShaders or software render is same result. output from the ff-hevc decoder should be bad.
I updated the log of playing the video, if it is helpful, but this problem appeared on many of my machines, which I think may not be called as a 'bug', so I didn't upload it before.

@thexai
Copy link
Member

thexai commented Sep 12, 2022

Debug log is mandatory

@TianZerL
Copy link
Author

@thexai

After more tests, I found that this does not only happen with hevc, but also with H264. Therefore, I suspect that all software decoders have this problem.

It doesn't look like a scaling problem. I used MPC-HC in different scaling algorithm for comparison. These unsmooth edges are neither the nearest nor bilinear.

The log of h264 is as follows: kodi.log

@thexai
Copy link
Member

thexai commented Sep 12, 2022

Intel(R) HD Graphics 4400

INFO <general>: DX::DeviceResources::CheckNV12SharedTexturesSupport: extended NV12 shared textures is NOT supported

DX::DeviceResources::GetVideoDriverVersion: video driver version is Intel 20.19.15.5166

I'm sorry, but I'm not going to waste time looking at something that happens in outdated graphics (10 years old)

@TianZerL
Copy link
Author

TianZerL commented Sep 12, 2022

@thexai
it's definitely not the point!
Same in Nvidia GTX1660super or AMD vega8.

This happens all of my PC with different GPUs: Intel HD4400, AMD Vega8, AMD 5700xt and Nvidia GTX1660Super. I don't think all of them are out of date.

@thexai
Copy link
Member

thexai commented Sep 12, 2022

Debug log?

@TianZerL
Copy link
Author

@thexai
Debug log from AMD Vega8: kodi.log

@thexai thexai added Platform: Windows Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it and removed Ignored rules issue that does not follow the rules (no template, missing debug log, ...) labels Sep 13, 2022
@thexai thexai reopened this Sep 13, 2022
@thexai thexai changed the title HEVC software decoding looks low quality Software decoding looks low quality Sep 13, 2022
@sarbes
Copy link
Member

sarbes commented Sep 13, 2022

It looks to me that the Chroma siting is 0.5px off in both directions. I.E. sampling Type 2 4:2:0 media as Type 1.

@malvinas2
Copy link

Does the issue still occur under version 21 using FFmpeg 6.0 ?

@CrystalP
Copy link
Contributor

CrystalP commented Dec 1, 2023

Yes and dxva is affected sometimes, has to do with 8 or 10 bit but not clear yet how.
Not related to the decoding but the yuv to rgb conversion. It just happens that by default dvxa decoding yields dxva conversion, and software decoding to shader / ffmpeg swscale conversion.
The fact that the picture looks better with dxva doesn't necessarily mean that it's accurate, the vendor controls that path and could have added some " enhancement" processing. More digging needed.

@CrystalP
Copy link
Contributor

After some tests, with dxva the issue is the AMD dxva processor with 10 bit output (same results with 8 or 10 bit input). There is a pixellation of the chroma that doesn't exist with 8 bit output.

Intel and NVIDIA have no such issue.

The pixel shaders (Kodi color conversion) and software render method (ffmpeg color conversion) show a similar chroma pixellation.

dxva may have more advanced chroma upscaling algorithms, explaining the better results. To be further investigated.

@CrystalP CrystalP added Triage: Confirmed issue has been reproduced by a team member Platform: WindowsStore Component: DirectX rendering and removed Triage: Needed (managed by bot!) issue that was just created and needs someone looking at it labels Dec 12, 2023
@thexai thexai linked a pull request Dec 12, 2023 that will close this issue
14 tasks
@thexai thexai added the Resolution: Fixed issue was resolved by a code change label Dec 14, 2023
@CrystalP
Copy link
Contributor

If you're still around and can test with v21 beta2 + AMD other than the vega 8 (like 5700XT), you may find an issue with dxva render method when the new setting " High quality processing" is on. Please let us know.
(see discussion in the linked PR to fix, it's not clear if all AMD are impacted or only some)

@TianZerL
Copy link
Author

@CrystalP it seems ok with 5700xt.
kodi.log
I'm using a 10bit monitor, do I need to change anything?

@CrystalP
Copy link
Contributor

CrystalP commented Dec 15, 2023

Thanks!
Please adjust some settings, that did not use the path that causes issues. Per the log the dxva processor output was 8 bit, which was fine on my 5600G as well:

CRendererDXVA::Configure: chosen conversion: NV12 / YCBCR_STUDIO_G22_LEFT_P709 to B8G8R8A8_UNORM / RGB_FULL_G22_NONE_P709
...
DX::DeviceResources::ResizeBuffers: 8 bit swapchain is used with 6 flip discard buffers and SDR output (format B8G8R8A8_UNORM)

Set the following options:

  • "Use 10 bit for SDR": Always (System > Display)
  • "Use high precision processing": ON (Player > Videos)
  • "Render method": DXVA (Player > Videos)

Play an SDR video.

On my 5600G (contemporary with your vega 8) that makes the chroma pixillated even with latest driver.

@TianZerL
Copy link
Author

TianZerL commented Dec 15, 2023

@CrystalP

  • "Use 10 bit for SDR": Always (System > Display)
  • "Use high precision processing": ON (Player > Videos)
  • "Render method": DXVA (Player > Videos)

Did those and got same result.
kodi.log

image

Maybe it is for GCN only? New Xbox and 5700XT is RDNA.

@CrystalP
Copy link
Contributor

Something is wrong, it still picked 8 bit

CRendererDXVA::Configure: chosen conversion: NV12 / YCBCR_STUDIO_G22_LEFT_P709 to B8G8R8A8_UNORM / RGB_FULL_G22_NONE_P709

Maybe the processor doesn't have support for 10 bit.

Please turn on additional logging in System > Logging.
Enable debug logging ON
Enable component-specific logging ON
"Specify component-specific logging..." turn on for the "Video component"

Then play the video.

@TianZerL
Copy link
Author

TianZerL commented Dec 15, 2023

@CrystalP
Do I need to play a 10bit HEVC video?

Tested with 10 bit HEVC video, it still looks ok.

10bit video log:
kodi.log

@CrystalP
Copy link
Contributor

Thanks. I could grab your log file with 8 bit before you replaced it and have a clear picture now for the 5700XT,

For 8 bit source the dxva processor doesn't claim support for rgb10 output
For 10 bit source, the dxva processor claims support for rgb10 output and it's used with good visual result.

So yeah it's likely architecture related. Could you try your vega 8? (both 8 and 10 bit input)

@TianZerL
Copy link
Author

@CrystalP
I can confirm this issue with Vega8 (Ryzen 3500U).
It happens with both 8bit and 10 bit source, only if I enabled "Use high precision processing".

Vega8 log: kodi.log

@CrystalP
Copy link
Contributor

Great, now we have something. Thanks for your help, it confirms an issue with the GCN family. Now how to identify it...

Looks like AMD put GCN and RDNA in different branches recently: https://www.anandtech.com/show/21126/amd-reduces-ongoing-driver-support-for-polaris-and-vega-gpus

Looking at the driver version numbers, the 3500U has 31.0.21902.5, the 5600G has 31.0.21905.1001 (same for a couple months now, matches the timeline of the article)
The RDNA 5700 XT has 31.0.22023.1014 in your log and most recent available is 31.0.23013.1023.

We could probably filter with version < 31.0.22000.0.
@thexai could you please confirm driver version on xbox?

@thexai
Copy link
Member

thexai commented Dec 16, 2023

There is not easy way to know driver version on Xbox because apps not have access to Windows Registry (not reported on Kodi logs) and driver version also not seems present in Xbox system settings. Anyway is easy exclude/include Xbox from workarounds with this code:

if (CSysInfo::GetWindowsDeviceFamily() == CSysInfo::Xbox)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: DirectX rendering Platform: Windows Platform: WindowsStore Resolution: Fixed issue was resolved by a code change Triage: Confirmed issue has been reproduced by a team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants