AMF icon indicating copy to clipboard operation
AMF copied to clipboard

Various: Rate control modes, quality settings, QVBR

Open Chipcraft opened this issue 3 years ago • 7 comments

Issue 1 (Navi 31, AV1 & HEVC): CBR and VBR rc-modes produce the same output:

  • HEVC VBR: "TranscodeHW -codec HEVC -input Input.mp4 -width 1920 -height 1080 -output Output1.mp4 -HevcTargetBitrate 8000000 -HevcPeakBitrate 12000000 -HevcFrameRate 23976,1000 -HevcUsage transcoding -HevcQualityPreset quality -HevcRateControlMethod VBR"

  • HEVC CBR: "TranscodeHW -codec HEVC -input Input.mp4 -width 1920 -height 1080 -output Output2.mp4 -HevcTargetBitrate 8000000 -HevcPeakBitrate 12000000 -HevcFrameRate 23976,1000 -HevcUsage transcoding -HevcQualityPreset quality -HevcRateControlMethod CBR"

HEVC VBR (Output1.mp4): 339 066 253 / SHA-256: 886b70477cf67bab5970c240af5dd6d98e15c2d1789b95e654c846f09e908113 HEVC CBR (Output2.mp4): 339 066 253 / SHA-256: 886b70477cf67bab5970c240af5dd6d98e15c2d1789b95e654c846f09e908113

Omitting "-HevcPeakBitrate" from either or both makes no difference to the output.

  • AV1 VBR: "TranscodeHW -codec AV1 -input Input.mp4 -width 1920 -height 1080 -output Output3.mp4 -Av1TargetBitrate 8000000 -Av1PeakBitrate 12000000 -Av1FrameRate 23976,1000 -Av1Usage transcoding -Av1QualityPreset quality -Av1AlignmentMode 2 -Av1RateControlMethod VBR"

  • AV1 CBR: "TranscodeHW -codec AV1 -input Input.mp4 -width 1920 -height 1080 -output Output4.mp4 -Av1TargetBitrate 8000000 -Av1PeakBitrate 12000000 -Av1FrameRate 23976,1000 -Av1Usage transcoding -Av1QualityPreset quality -Av1AlignmentMode 2 -Av1RateControlMethod CBR"

AV1 VBR (Output3.mp4): 300 305 231 / SHA-256: 2536b3f867b94686790c48df42d2872c7bd9cfebcc96876b49277cb6c2e91304 AV1 CBR (Output4.mp4): 300 305 231 / SHA-256: 2536b3f867b94686790c48df42d2872c7bd9cfebcc96876b49277cb6c2e91304

Omitting "-Av1PeakBitrate" from either or both makes no difference to the output.


Issue 2 (Navi 31, AV1): Quality presets "Speed" and "Balanced" produce identical output:

  • AV1 VBR "Speed": "TranscodeHW -codec AV1 -input Input.mp4 -width 1920 -height 1080 -output Output5.mp4 -Av1TargetBitrate 8000000 -Av1PeakBitrate 12000000 -Av1FrameRate 23976,1000 -Av1Usage transcoding -Av1QualityPreset speed -Av1AlignmentMode 2 -Av1RateControlMethod VBR"

  • AV1 VBR "Balanced": "TranscodeHW -codec AV1 -input Input.mp4 -width 1920 -height 1080 -output Output6.mp4 -Av1TargetBitrate 8000000 -Av1PeakBitrate 12000000 -Av1FrameRate 23976,1000 -Av1Usage transcoding -Av1QualityPreset balanced -Av1AlignmentMode 2 -Av1RateControlMethod VBR"

AV1 "Speed" (Output5.mp4): 300 364 727 / SHA-256 e3aed49d942c93d2bfa2c67a69715078395d3343c4949bece4023f586c6add97 AV1 "Balanced" (Output6.mp4): 300 364 727 / SHA-256 e3aed49d942c93d2bfa2c67a69715078395d3343c4949bece4023f586c6add97

NOTE: Three of the available quality options work: Speed OR Balanced, Quality and High Quality.


Issue 3 (Navi 21, HEVC) : QVBR rc-mode not available

[hevc_amf @ 00000293b3c25ac0] AMFEncoderCoreHevc: 2022-12-18 23:46:33.487 C0C [AMFEncoderCoreHevc] Debug: SetProperty HevcRateControlPreAnalysisEnable:true

[hevc_amf @ 00000293b3c25ac0] AMFEncoderCoreHevc: 2022-12-18 23:46:33.487 C0C [AMFEncoderCoreHevc] Debug: SetProperty HevcRateControlMethod:4

[hevc_amf @ 00000293b3c25ac0] PropertyStorageExImpl: 2022-12-18 23:46:33.487 C0C [PropertyStorageExImpl] Error: c:\constructicon\builds\gfx\six\22.20\drivers\amf\stable\public/common/PropertyStorageExImpl.h(277):AMF_ERROR 4 : AMF_INVALID_ARG: Property=HevcRateControlMethod

[hevc_amf @ 00000293b3c25ac0] AMFEncoderCoreHevc: 2022-12-18 23:46:33.487 C0C [AMFEncoderCoreHevc] Error: ..........\runtime\src\components\EncoderCore\EncoderCoreHevcImpl.cpp(1248):AMF_ERROR 4 : AMF_INVALID_ARG: SetProperty HevcRateControlMethod failed in AMFPropertyStorageExImpl with return code:0x4, and will not set driver either!

Windows 10 Pro 19045 Adrenalin 22.11.2 WHQL (Navi 21), Adrenalin 22.12.1 (Navi 31) AMD reference 6800 XT (Navi 21), AMD reference 7900 XTX (Navi 31)

Chipcraft avatar Dec 18 '22 22:12 Chipcraft

I can only speak to "Issue 3". I was working on implementing QVBR, and while h264 went fine, HEVC fails. Confirmed in transcodeHW as well. 4500u APU, 23.2.2 driver.

flaeri avatar Mar 02 '23 17:03 flaeri

Update on issue 3. My friend has a RX 6950 XT, and running driver 31.0.14001.45012 (23.2.1), they have working QVBR.

So I guess I am now curious. Could it a driver issue? Or do only certain chips have access to this rate control?

Edit: I tried downgrading to the same version on my 4500U, but still get the same error.

flaeri avatar Mar 03 '23 12:03 flaeri

Re-checked these today using Adrenalin 23.5.1 WHQL drivers. Issues 1 & 2 remain unchanged however, Issue 3 (HEVC QVBR) has indeed been fixed in the driver, at some point.

Chipcraft avatar May 25 '23 00:05 Chipcraft

Issue 1

  • AV1 produces different bitstreams with the provided settings so the original reported issue cannot be reproduced.
  • For HEVC, the difference between CBR and VBR lies in the fact that CBR does not allow DPB to overflow and underflow, while VBR allows DPB to overflow. It is expected that CBR and VBR would produce identical results if all the RC parameters are the same, and without enforcing HRD conformance. To prevent the DPB buffer from overflow HRD must be enforced for CBR. The suggestions are:
    1. For CBR, set HevcEnforceHRD to true.
    2. For CBR, set HevcPeakBitrate = HevcTargetBitrate to reduce bitrate fluctuation.

Hence an appropriate command would be :

.\TranscodeHW.exe -codec HEVC -input planet_earth_1080p_5_mins.mp4 -width 1920 -height 1080 -output Output1_hevc_vbr_hrd_false.mp4 -HevcTargetBitrate 8000000 -HevcPeakBitrate 12000000 -HevcFrameRate 23976,1000 -HevcUsage transcoding -HevcQualityPreset quality -HevcRateControlMethod VBR -HevcEnforceHRD false

.\TranscodeHW.exe -codec HEVC -input planet_earth_1080p_5_mins.mp4 -width 1920 -height 1080 -output Output2_hevc_cbr_hrd_true.mp4 -HevcTargetBitrate 8000000 -HevcPeakBitrate 8000000 -HevcFrameRate 23976,1000 -HevcUsage transcoding -HevcQualityPreset quality -HevcRateControlMethod CBR -HevcEnforceHRD true

Issue 2

  • It is by design for the RX 7000 series.

Issue 3

  • Not able to reproduce. @Chipcraft confirmed it is no longer an issue in a more recent driver.

rhutsAMD avatar Jul 07 '23 15:07 rhutsAMD

I am happy to hear that. My personal machine (R5 4500u APU) still will not do QVBR, even on the latest drivers:

23.5.2 AMFComponent::Init failed: AMF_INVALID_ARG

23.4.2 QVBR 30, 720p60: AMFComponent::Init failed: AMF_INVALID_ARG

I suspect its either the "RDNA1" APU class, or perhaps any RDNA1. It would be nice to have clarification on what devices support it. It supports lookahead (at least to some degree), but I've got no idea as to why it wont fly on my chip.

I think you can consider Issue 3 closed as well, since its resolved on the other chips :)

Thank you for your time.

flaeri avatar Jul 07 '23 21:07 flaeri

The latest public driver 23.7.1 has been tested on our side to have QVBR support. As confirmed by our internal testing, 23.5.2 did not have QVBR support for the 4500U APU while 23.7.1 did have this support.

rhutsAMD avatar Jul 21 '23 13:07 rhutsAMD

I can confirm that 23.7.1 got me working QVBR on R5 4500u APU. Thank you rhuts <3

flaeri avatar Jul 24 '23 14:07 flaeri

Closing. Please open a separate issue if there are any additional bugs.

rhutsAMD avatar Apr 03 '24 18:04 rhutsAMD