Log in

View Full Version : Need Help w AVISynth+ HDR UHD and Intel Arc A770


Qaenos
22nd November 2022, 00:04
I had a NVidia GPU and I was successfully opening mkvs taken from UHDs using a combination of DGSource() and DGHDRtoSDR().

I've switched to an Intel Arc A770 discrete GPU and the DGHDRtoSDR no longer works because it needs uses CUDA for HW acceleration.

What do I need to do to open a UHD HDR mkv with AVISynth+ using my Intel A770 for HW acceleration?

Here's an example of the type of file I am trying to open:

Video #1
ID : 4113 (0x1011)
Menu ID : 1 (0x1)
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main 10@L5.1@High
HDR format : SMPTE ST 2086, HDR10 compatible
Codec ID : 36
Duration : 2 h 13 min
Width : 3 840 pixels
Height : 2 160 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 (24000/1001) FPS
Color space : YUV
Chroma subsampling : 4:2:0 (Type 2)
Bit depth : 10 bits
Color range : Limited
Color primaries : BT.2020
Transfer characteristics : PQ
Matrix coefficients : BT.2020 non-constant
Mastering display color primar : BT.2020
Mastering display luminance : min: 0.0001 cd/m2, max: 1000 cd/m2
Maximum Content Light Level : 787 cd/m2
Maximum Frame-Average Light Le : 506 cd/m2

Selur
22nd November 2022, 05:01
Have you tried LWLibavSource with prefer_hw=2 ?

Qaenos
22nd November 2022, 13:05
Have you tried LWLibavSource with prefer_hw=2 ?

Yes. I can open the video with LWLibavVideoSource with prefer_hw=2 but I need something to process the HDR. The colors are all washed out when I open it with prefer_hw=2. I used to use DGHDRtoSDR to process the HDR and get the colors to display properly, but without HW acceleration (DGHDRtoSDR only uses NVidia CUDA) it's too slow to use in real-time.

How do I get the HDR colors to display properly in real-time?

Selur
22nd November 2022, 20:41
Ah, okay. You are looking for hardware accelerated HDR10 to SDR.
Afaik there is no hardware accelerated HDR10 to SDR for QSV.
-> since I doubt that anybody will write a plugin for it any time soon, saving for a HDR display (like a innocn 27m2u if 60Hz is enough) or a newer NVIDIA card might be your best bet.
(maybe using some 3dlut might work)

Qaenos
22nd November 2022, 22:22
Ah, okay. You are looking for hardware accelerated HDR10 to SDR.
Afaik there is no hardware accelerated HDR10 to SDR for QSV.
-> since I doubt that anybody will write a plugin for it any time soon, saving for a HDR display (like a innocn 27m2u if 60Hz is enough) or a newer NVIDIA card might be your best bet.
(maybe using some 3dlut might work)

Actually my display is HDR capable. If i just want to play the mkv, i can do it no problem with mpc hc and madvr. However, if i want to manipulate the image (e.g. crop, realize, etc) via AVISynth first, that's where I need something to handle the HDR otherwise everything is washed out.

If my display is HDR can I use AVISnth toanipulate the video and display it with the right colors?

qyot27
23rd November 2022, 02:47
https://forum.doom9.org/showthread.php?p=1974149#post1974149

And anything built against a version of libavformat after those changes should also pick it up. Basically any build of mpv since March (September for the SAR stuff) certainly will.

Not sure if the way LAVFilters communicates with DirectShow requires special handling per media type or if it just carries over whatever libavformat reports, but if it does just work as is, it would only be possible with one of the latest versions, so long as the fork of FFmpeg it uses has those relevant commits (read: v0.77 at the least).

Reading of frame properties in FFmpeg was committed to upstream FFmpeg in February and fixed up in spots into March. SAR and the flags selector was added at the beginning of September. So for general frameprops, at least FFmpeg 5.1. For SAR and the selector, that'll be in the upcoming 5.2 release, whenever that happens. Or just use the git version.

(the side benefit of this, of course, is that you can also override frameprops in the script)



That said, I'm pretty sure that LSMASHSource can't activate QSV decoders on Arc, because I don't see anything about either A) Arc being selectable under the Media SDK that mfx_dispatch supports, or B) LSMASHSource using oneVPL (the successor to the Media SDK that is supposed to work with Arc). This also seems to bear out in actual tests, as Task Manager shows UHD Graphics 630 and prefer_hw=2 using the GPU's Video Decode. On the A770, the graph is empty when using LSMASHSource - even with prefer_hw=2 - while playing the file directly shows Video Decode working.

PoeBear
23rd November 2022, 04:13
DGHDRtoSDR(impl="sw") will run it in software/non-CUDA mode

Alternatively, you could use Cube() and a LUT (https://forum.doom9.org/showthread.php?t=176091)