Description
Describe the bug
Linux desktop streaming. I'm using x11grab which is a pixel format of bgr0.
AMF has a mapping for that: AV_PIX_FMT_BGR0
maps to AMF_SURFACE_BGRA
To be fair, it's just a mapping. It's not wired up to HEVC. So i did add that one myself. In amfenc.c
i just added AV_PIX_FMT_BGR0
in the ff_amf_pix_fmts
array.
Compiling ffmpeg with this makes it work and lets bgr0
be handled by AMF. Sweet! The more that can be offloaded to AMF in the encoding pipeline the better it is for latency purposes.
The following table shows the conversion as i think they happen. I do have to put a big fat disclaimer here. I'm assuming the cpu does a pix format conversion when pix_format
is supplied and that it does that conversion to a format the driver (hevc_amf) supports. I'm also assuming that no cpu conversion happens when pix_format
is not supplied.
Also note that no pix format in the table means i didn't supply pix_format
as argument thus it's the source format. Which is bgr0.
pix_format | CPU conversion | AMF conversion | Picture |
---|---|---|---|
none | none | bgr0 -> nv12 | ![]() |
nv12 | bgr0 -> nv12 | none | ![]() |
p010 | bgr0 -> p010 | p010 -> nv12 | ![]() |
By far the best one in that table is that last one, p010
. The color representation is good and 10 bit (irrelevant for this issue) means less banding too, which you can see in the grey gradient behind the AMD logo if you look carefully!
You can easily see that the first row looks very off. In theory this would be the best one as AMF would do all the work.
In practice it looks like the AMF conversion from bgr0 -> nv12 is not doing the same as the cpu based one when nv12
is provided as pix_format
.
At this point i'm not entirely convinced the issue is in ffmpeg (x11grab specifically) or in AMF. To try and rule out x11grab, i did modify it's code to output BGRA
instead of BGR0
but the results were the same.
Is this a hardware bug?
Setup (please complete the following information):
- OS: ArchLinux
- Driver Version 1.4.35 + latest header changes from this repo
- GPU 7900 XT
Activity