Make I-frame max QP and encode quality level configurable - #32
Open
skirsten wants to merge 1 commit into
Open
Conversation
EncodeConfig grows max_qp_i, capping the QP of I/IDR frames under rate control (H.264/H.265), and encode_quality_level, the Vulkan video encode quality level applied to the session parameters and the first-frame control command of all codecs. Both default to the previous hardcoded behavior. Capping the I-frame QP keeps the first GOP from visibly banding while the driver's rate control is still adapting to the content: the initial QP estimate on a cold encoder can land well above what a static, dark scene needs, and skip-coded P-frames then carry the banded keyframe until the next IDR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EncodeConfig grows two knobs, both defaulting to the previous hardcoded behavior:
max_qp_icaps the QP of I/IDR frames in rate-controlled modes (H.264/H.265; the codec defaults of 42/51 apply when unset, values below the codec's min bound are raised to it, AV1 and CQP/disabled are unaffected).encode_quality_levelsets the Vulkan video encode quality level, previously hardcoded to 0. It is applied consistently to session parameters creation and the first-frame RESET/RATE_CONTROL/QUALITY_LEVEL control command in all three codecs, since the spec requires the bound session parameters to match the session's effective quality level.Motivation: on a cold encoder the driver's rate control opens the stream with a conservative QP estimate. On static content the skip-coded P-frames then carry that first coarse keyframe until the next IDR, which shows up as gradient banding for the whole first GOP. Bounding
qp_iforces the first keyframe to spend enough bits regardless of the initial estimate; verified on NVIDIA (RTX 3080 dev, L40S production) withmax_qp_i: 28under VBR.🤖 Generated with Claude Code