[Bug]: AMF_VIDEO_ENCODER_STATISTIC_AVERAGE_QP reports numbers with shifted digites with AVC VBR encodes on RDNA4 GPU's.
Describe the bug https://github.com/rigaya/VCEEnc/issues/122
While issue is encountered with VCEEnc (not many other encoders report AMF_VIDEO_ENCODER_STATISTIC_AVERAGE_QP, so there is that), it is now confirmed that:
- Issue only impacts RDNA4
- Issue only impacts AVC
- Issue only impacts VBR based encodes
Basically instead of reporting avgQP = XX.XX where value is in range of 0-51, it reports avgQP = XXXXX.XX with misaligned rounding.
I could not find any issues with VCEEnc implementations, and it only impacts RDNA4 (RDNA3 was safe from this issue), meaning that issue is most likely on AMF side.
To Reproduce Steps to reproduce the behavior:
- Use VCEEnc
- Command:
%~dp0\VCEEncC64.exe -i %1 -o "%~n1_test%~x1" --avsw --codec avc --vbr 15000 --max-bitrate 45000 --bframes 2 --audio-copy[bframes are unnecessary, they just are also affected] - Observed outcome - avgQP show 5+2 digit float values instead of 2+2.
encoded 500 frames, 517.60 fps, 15780.06 kbps, 18.81 MB
encode time 0:00:00, CPULoad: 0.4%
frame type IDR 1
frame type I 1, avgQP 24576.00, total size 0.22 MB
frame type P 167, avgQP 31641.29, total size 16.41 MB
frame type B 332, avgQP 35065.83, total size 2.18 MB
I believe they are just rounded improperly. 24.58 is presented as 24576.00, 31.64 is presented as 31641.29 35.07 is presented as 35065.83
Setup:
- OS: Windows 11, 23H2, build 22631.5126
- Driver Version: 25.3.2
- GPU: 9070 XT
- Which component has the issue: Encoder?
Expected behavior Average QP should be properly reported as values within range.
I was not able to reproduce the average QP misaligned rounding internally on an RX 9070 XT with the latest 25.3.2 driver. AMF should not display the average QP differently based on the GPU. This may be on the VCEEnc app side.
Are you able to reproduce and trace this issue with one of the public AMF samples by setting AMF_VIDEO_ENCODER_STATISTICS_FEEDBACK and if so, could you please share the patch file with your changes?
AMF should not display the average QP differently based on the GPU. This may be on the VCEEnc app side.
I do understand that, but i also cannot see how same command can produce both proper output and misaligned one (without external factor)...
if (m_encCodec == RGY_CODEC_H264 \|\| m_encCodec == RGY_CODEC_HEVC) {
uint32_t value32 = 0;
if (buffer->GetProperty(AMF_PARAM_STATISTIC_AVERAGE_QP(m_encCodec), &value32) == AMF_OK) {
output.setAvgQP(value32);
}
...
if (avgQP >= 0.0) {
mes_len += _stprintf_s(mes + mes_len, _countof(mes) - mes_len, _T(", avgQP %4.2f"), avgQP);
Are you able to reproduce and trace this issue with one of the public AMF samples by setting AMF_VIDEO_ENCODER_STATISTICS_FEEDBACK and if so, could you please share the patch file with your changes?
Is there any way to set this parameter with TranscodeHW sample? I didn't change anything, but i don't know how to check it with just AMF samples, as i am not really a developer.
Hmm... Something definitely may be going on with my system then, but i have no idea what for the time being...
UPD: Ah yes, forgot to specify. VCEEnc avgQP statistics shows properly formatted numbers with HEVC and AVC CQP mode. Issue is only specific to AVC VBR modes (or variable QP ones as well, i assume. Tbh did not check QVBR)
UPD2: Oh, AVC QVBR is interesting. It always outputs avgQP 4096 despite encoding at different QVBR levels. Same source, just different QP levels. Different output bitrates (and sizes), same avgQP value of 4096.
QVBR level: 1
encoded 454 frames, 115.02 fps, 7011.93 kbps, 6.32 MB
encode time 0:00:03, CPU: 0.8%, GPU: 35.8%, VE: 99.2%
frame type IDR 2
frame type I 2, avgQP 4096.00, total size 0.15 MB
frame type P 452, avgQP 4096.00, total size 6.18 MB
QVBR level: 23
encoded 454 frames, 115.35 fps, 30120.62 kbps, 27.17 MB
encode time 0:00:03, CPU: 0.5%, GPU: 36.2%, VE: 99.2%
frame type IDR 2
frame type I 2, avgQP 4096.00, total size 0.46 MB
frame type P 452, avgQP 4096.00, total size 26.71 MB
QVBR level: 51
encoded 454 frames, 114.16 fps, 85558.12 kbps, 77.17 MB
encode time 0:00:03, CPU: 0.9%, GPU: 29.0%, VE: 79.0%
frame type IDR 2
frame type I 2, avgQP 4096.00, total size 1.09 MB
frame type P 452, avgQP 4096.00, total size 76.09 MB
Curiously with upgrade to 25.10.2 drivers and AMF Runtime 1.5.0, i stopped recieving avgQP metric from AVC encodes in VCEEnc. Same metric still works for HEVC, though. Not sure what happened, but i guess it can be counted as sort of fix? Or was that unintentional change?