encode: codec profile and level fixes#171
Open
srinathkr-nv wants to merge 9 commits intoKhronosGroup:mainfrom
Open
encode: codec profile and level fixes#171srinathkr-nv wants to merge 9 commits intoKhronosGroup:mainfrom
srinathkr-nv wants to merge 9 commits intoKhronosGroup:mainfrom
Conversation
This makes it easier to read and compare these limits against the data from table A-1 of the H.264 specification (from where these limits have been copied), and to add new entries if required in the future. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
The values in this column have been taken from table A-4 of the H.264 specification and specify the value to be used for the SPS frame_mbs_only_flag syntax element for a given level. These values are not used anywhere in the code as interlaced encoding is not supported (and therefore frame_mbs_only_flag = 1 always). Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
These are defined in table A-1 of the H.264 specification but were missing from the level limits table defined in our code. These new entries also allow removing some workarounds where the level was previously artifically limited to level 5.2 as the maximum supported level. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
…init The codec profile and level are currently set in the following places: - level in EncoderConfigH264::InitDpbCount() - profile in EncoderConfigH264::InitSpsPpsParameters() The profile and level are fairly basic encoding parameters and it is desirable to set these as early as possible. This commit adds a method to the EncoderConfigH264 class which sets the profile and level at an early stage in the encoder configuration. This also provides the opportunity to use the codec profile in the construction of the video profile which will be used in physical device queries (currently, this video profile uses a default codec profile). This method gets called from EncoderConfigH264::InitializeParameters(), immediately after the command line parameters have been parsed and is part of the overall encoder config structure initialization process. The profile is more important than the level, so it is essential to set these values in this order, as done within this change. Also, certain level limits are profile-specific, and this ordering makes it possible for a subsequent change to use the profile in the level 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. Signed-off-by: Srinath Kumarapuram <skr@nvidia.com>
The level determination code in EncoderConfigH264::DetermineLevel() uses a multipler of 1200 for the MaxBR and MaxCPB entries in the level limits table, taken from table A-1 of the H.264 specification. However, this multipler is to be used only for the Baseline, Constrained Baseline, Main and Extended profiles. Profiles greater than these use a different (larger) multipler, as specified in table A-2 of the H.264 specification. Due to the use of a smaller multipler, this code selects a greater level than is strictly necessary in some situations, based on the input settings. This commit updates this code to use a multipler dependent on the codec profile. 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>
Currently, the video profile constructed for querying capabilities or quality level properties uses the videoProfileIdc member from the encoder config for the codec profile, or calls GetDefaultVideoProfileIdc() if that member is not initialized. No code initializes videoProfileIdc to a proper value, so GetDefaultVideoProfileIdc() gets called always and returns a fixed value for each codec. However, this fixed codec profile may not support all of the coding tools requested by the user when encoding, or may even be incompatible with the codec profile actually needed for encoding. We already have code in the InitProfileLevel() method to determine the codec profile based on various encoding features (B-frames, CABAC, bit depth, chroma format, etc.). This change makes the video profile construction code use this codec profile, thereby eliminating redundant profile storage and computation. 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.
Description
This series of commits refactors the code related to the determination of the codec profile and level (and tier, as applicable) for all codecs, 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.
Type of change
Bug fixes and refactoring
Tests
NVIDIA L2 / NVIDIA 580.94.17 / Ubuntu 24.04.3 LTS
Total Tests: 70
Passed: 50
Crashed: 0
Failed: 0
Not Supported: 2
Skipped: 18 (in skip list)
Success Rate: 100.0%
Additional Details (optional)
Prior to this series of commits, running the test framework would show 1 unsupported test case, and 51 passing test cases. The unsupported test case was
encode_h265_main10_profile, which is actually supported by the NVIDIA driver. The list of passing tests includedencode_av1_high_profileandencode_av1_professional_profilealthough these profiles are not supported.With the current changes,
encode_av1_high_profileandencode_av1_professional_profileare correctly marked as unsupported andencode_h265_main10_profileexecutes successfully.