Open
Conversation
Commit 7734964, which introduced the InitProfileLevel method, also introduced a bug in that code where a call to the GOP structure's GetConsecutiveBFrameCount() method was replaced by the GetMaxBFrameCount() method. This is problematic because GetMaxBFrameCount() depends on device capabilities which have not been queried yet. This commit restores the call to GetConsecutiveBFrameCount() in the profile determination code. This commit also removes a check on the rate control mode when lossless encoding is requested, as the rate control mode may not have been specified by the user (and it will be determined later when querying the quality level properties). This change works as lossless encoding inherently requires the HIGH_444_PREDICTIVE profile regardless of rate control settings. Together, these changes make it safe to call InitProfileLevel() early in the overall initialization sequence, before any capabilities or recommended settings have been queried. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
The current call to EncoderConfigH264::InitProfileLevel() happens in the
following sequence:
VkVideoEncoderH264::InitEncoderCodec()
|
+-- EncoderConfigH264::InitProfileLevel()
|
+-- InitEncoder()
|
+-- InitVideoProfile()
|
+-- InitDeviceCapabilities()
This serves the purpose of initializing the codec profile and level
before constructing the video profile but as InitProfileLevel()
initializes more parameters within the encoder config structure itself,
calling it from within VkVideoEncoderH264 seems a bit awkward.
A much better place to call it from is
EncoderConfigH264::InitializeParameters(), which is what this commit
implements. This gets done immediately after the command line parameters
have been parsed and is part of the overall encoder config structure
initialization process
Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
…er init This commit adds an InitProfileLevel() method similar to what EncoderConfigH264 contains, for common initialization of the codec profile, level and tier. This makes use of the preexisting profile and levelIdc members defined in EncoderConfigH265 but not used otherwise. With this addition, the InitParamameters() and InitRateControl() methods have been changed to remove the redundant and repetitive initialization of the profile and level. The codec profile and level determined earlier in the encoder config initialization are now used directly instead. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
This change is not a plain renaming, as it also modifies the method to directly set the level and tier members in the class instead of initializing and returning a StdVideoH265ProfileTierLevel structure. The method name is also now consistent with that for the other codecs. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
…r init This commit adds an InitProfileLevel() method similar to what EncoderConfigH264 and EncoderConfigH265 contain, for common initialization of the codec profile, level and tier. With this addition, the InitRateControl() method have been changed to remove the redundant and repetitive initialization of the level and tier. The codec profile and level determined earlier in the encoder config initialization are now used directly instead. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
Prior to this commit, the profile was computed twice: 1. InitProfileLevel() set the codec-specific profile member based on encoding features (B-frames, CABAC, bit depth, chroma format, etc.) 2. InitVideoProfile() recomputed the profile via GetDefaultVideoProfileIdc() based only on bit depth and chroma format, storing it in videoProfileIdc Importantly, there were cases where the codec profile determined by InitProfileLevel() was different from videoProfileIdc. As videoProfileIdc is used for constructing the video profile structure used in capability and recommended settings queries, there was a possibility of the encoder getting configured with a different codec profile than the one required for the user configuration. This refactoring eliminates redundant profile storage and computation by using the codec-specific profile members (profileIdc/profile) that are already set by InitProfileLevel(). The main changes in this refactoring are: - Remove videoProfileIdc member variable from EncoderConfig base class - Replace GetDefaultVideoProfileIdc() virtual method with GetCodecProfile() - Add GetCodecProfile() implementations in H.264/H.265/AV1 that return the already-initialized codec-specific profile members - Update InitVideoProfile() to call GetCodecProfile() instead of using videoProfileIdc - Add an assertion in each GetCodecProfile() implementation to ensure that the profile is initialized With this change, the codec profile is determined once and used everywhere else in the codebase. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
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.
This PR completes the work started in #179 to refactor the code related to the determination of the codec profile and level (and tier, as applicable) for all codecs, in order to avoid redundant calculations / storage and to provide a single point early in the encoder initialization stage where these values are decided.
Another effect of this refactoring is to use the proper codec profile when creating the video profile used for queries of capabilities and recommended settings. Previously, the video profile constructed for these purposes used a default codec profile, which may not be representative of (or may not support) the coding tools requested.