Aleksoid1978 / VideoRenderer

Внешний видео-рендерер
GNU General Public License v3.0
1.03k stars 115 forks source link

Dithering from 10-bit to 8-bit is not working well. #48

Closed FX8350 closed 2 years ago

FX8350 commented 2 years ago

Hi

I encoded the 8-bit video (from BD) to 10-bit x265 using the following command of ffmpeg. ffmpeg -i input.m2ts -pix_fmt yuv420p10le -c:v libx265 out.mp4 When I play it with MPC-xx+MPC-VR, there is a slight but noticeable color problem. (A little strong green-color) I've tried changing settings Texture format: and Use dithering but that doesn't fix the problem. I don't have the GPU that have the hardware decoder for HEVC, so I use software decoding for playback. The following is an example, but I have tried it with several Blu-rays I own, and they all gave the same result.

Original, 8-bit H.264 ![00000 m2ts_snapshot_10 23 845](https://user-images.githubusercontent.com/10481430/154836865-073bc9bc-624d-4507-83f2-41dd144ea0d7.png)
10-bit HEVC, MPC-HC/MPC-BE with MPC-VR ![MPC-VR](https://user-images.githubusercontent.com/10481430/154836932-bd253034-3b03-4876-8f94-88992efab88c.png)
10-bit HEVC, MPC-BE with built-in EVR-CP ![MPC-BE](https://user-images.githubusercontent.com/10481430/154836975-ee316e17-7c26-44ed-960c-ff97738e8ac0.png)
10-bit HEVC, MPC-HC with built-in EVR-CP ![MPC-HC](https://user-images.githubusercontent.com/10481430/154836987-e48f6cd1-ba95-4869-851d-8d18233366e8.png)

My system environment: MPC Video Renderer 0.5.7.1811 (git-2021.12.21-f448e90) x64 MPC-BE 1.6.1.6845 x64 MPC-HC 1.9.19 x64 NVIDIA GeForce GTX 750 Ti with 472.12 driver 8-bit monitor (Dell AW3418DW)

UPDATE: I have tried 8-bit and 12-bit encoding, and both seem to play fine.

8-bit HEVC, MPC-HC/MPC-BE with MPC-VR whitout any `-pix_fmt` option ![test_8bit mp4_snapshot_02 10 408](https://user-images.githubusercontent.com/10481430/154846850-1f06ad20-7955-40a2-891d-72a510884eaa.png)
12-bit HEVC, MPC-HC/MPC-BE with MPC-VR with the `-pix_fmt yuv420p12le` option ![test_12bit mp4_snapshot_02 10 227](https://user-images.githubusercontent.com/10481430/154846886-ed4703ae-d8d4-41aa-b127-8abf4b0352ee.png)
v0lt commented 2 years ago

Compare renderer statistics when playing input.m2ts and out.mp4.

FX8350 commented 2 years ago

Here is the status of renderers

out.mp4 with MPC-VR ![MPC-VR_HEVC](https://user-images.githubusercontent.com/10481430/154841305-fbc7d0ce-deb8-4eb8-986b-d8c5ff4c21ee.png)
out,mp4 with EVR-CP ![EVR_HEVC](https://user-images.githubusercontent.com/10481430/154841089-c51180e2-2842-4466-bbad-7d2c4ebb9f01.png)
input.m2ts with MPC-VR ![MPC-VR_H264](https://user-images.githubusercontent.com/10481430/154841274-b5b7eba4-d6c6-4c49-a6ae-771f8a31dcaa.png)
input.m2ts with EVR-CP ![EVR_H264](https://user-images.githubusercontent.com/10481430/154841119-c6852c39-c910-4db3-91dc-70792f587440.png)

UPDATE:

12-bit output.mp4 with MPC-VR To reduce encoding time, I used the `-ss` and `-to` options for trimming. ![image](https://user-images.githubusercontent.com/10481430/154850327-321161f6-4fee-40a2-aeea-f9bf74376544.png)
8-bit output.mp4 with MPC-VR To reduce encoding time, I used the `-ss` and `-to` options for trimming. ![image](https://user-images.githubusercontent.com/10481430/154850310-0d0eae76-7afc-4e3e-8375-2d5acc3e33af.png)
v0lt commented 2 years ago

I switch these two screenshots: input.m2ts with MPC-VR out.mp4 with MPC-VR The video frame parameters are the same (only the format of the input texture is different). I don't see the difference in the pictures.

FX8350 commented 2 years ago

I don't see the difference in the pictures.

Does this mean that there is no difference in color between those two pictures? Hmm... https://user-images.githubusercontent.com/10481430/154856376-8818dec9-800f-4f4f-8b29-517341078504.png https://user-images.githubusercontent.com/10481430/154856713-e2429312-1fef-4788-acde-954e3cffc1b0.png ~~This shows the YUV histogram of each screenshot. The top left is input.m2ts, the top right is out.mp4 (MPC-VR), the bottom left is out.mp4 (EVR-CP), and the bottom right is 8-bit HEVC (MPC-VR). Only in out.mp4+MPC-VR is there a noticeable difference in the histogram of U. ...Isn't there?~~

EDIT: deleted YUV histogram

v0lt commented 2 years ago

On your screenshots RGB. The renderer outputs RGB. Looking at the YUV histogram is strange to me.

To convert from NV12 and P010 to RGB you use D3D11 VP. This conversion is controlled by the driver manufacturer and MicroSoft. But you can disable NV12 and P010 options and convert with our shader.

v0lt commented 2 years ago

Also, if you think Dithering is the problem, you can turn it off and check again.

v0lt commented 2 years ago

You can also use the software decoder for the original video too, so that the FFmpeg decoder is used in both cases.

FX8350 commented 2 years ago

On your screenshots RGB. The renderer outputs RGB. Looking at the YUV histogram is strange to me.

Sorry, here is the RGB histogram

input.m2ts histogram overlaid with EVR-CP histogram with translucency. There is a difference in the histogram due to encoding, but it is basically accurate to input.m2ts. ![INPUT+EVR-CP](https://user-images.githubusercontent.com/10481430/154894461-fc910007-1123-41a5-a28e-95f24faaf3e7.png)
input.m2ts histogram overlaid with MPC-VR histogram with translucency. There is more difference in the histograms for both R and B, but histogram of G is looks fine ![INPUT+MPC-VR](https://user-images.githubusercontent.com/10481430/154894440-a3f8b0a7-24ab-4fac-950e-7ee95a15752e.png)
EVR-CP histogram overlaid with MPC-VR histogram with translucency. Playing the same video, but the histograms for R and B are different. ![EVR-CP+MPC-VR](https://user-images.githubusercontent.com/10481430/154894408-be672c34-4466-4494-bb81-c5a4c4b6aaed.png)
gif ![8FaWTaO11YIEtQGKhVTe1645422480-1645423112](https://user-images.githubusercontent.com/10481430/154897781-f0e89c28-9e3e-4cca-ba46-f0fe4002d34e.gif)

To convert from NV12 and P010 to RGB you use D3D11 VP. This conversion is controlled by the driver manufacturer and MicroSoft. But you can disable NV12 and P010 options and convert with our shader.

Thanks, Disabling them fixed the problem.

fireattack commented 7 months ago

Sorry for necroing an old ticket.

This bug seems to be nVidia specific. nVidia's D3D11 video processor (VP) has been having this green tint issue for years. In MPC-VR's context, it happens whenever you convert P010 to R10G10B10A2_UNORM.

It does not happen if you use Intel iGPU like UHD 770.

It also does not happen if you use D3D9/DXVA2 (I did remember some other players had this green issue even with DXVA2, but at least it works fine in MPC-VR.)

I suspect #98 is also related to this than HDR.