fix: h264 level selection algorithm#1049
Open
RebootVanChild wants to merge 1 commit intoUnity-Technologies:mainfrom
Open
fix: h264 level selection algorithm#1049RebootVanChild wants to merge 1 commit intoUnity-Technologies:mainfrom
RebootVanChild wants to merge 1 commit intoUnity-Technologies:mainfrom
Conversation
|
is this related? Really the minimum level should always be h264 42 |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the H.264 level selection algorithm to correctly calculate macroblocks per frame by considering width and height dimensions separately rather than total pixel count. This addresses encoder parameter errors that occur with certain resolutions like 1922x1080.
- Updates the macroblock calculation to use ceiling division of width and height by macroblock side length (16 pixels)
- Changes function signatures to accept separate width and height parameters instead of pixel count
- Updates all test cases and function calls to use the new signature
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| H264ProfileLevelId.cpp | Implements the corrected macroblock calculation algorithm using separate width/height parameters |
| H264ProfileLevelId.h | Updates function signatures to accept width and height separately |
| NvEncoderImpl.cpp | Updates function calls to pass separate width and height values |
| H264ProfileLevelIdTest.cpp | Updates test cases to use new function signature with separate width/height parameters |
|
|
||
| // Returns the max framerate that calclated by maxFramePixelCount. | ||
| int SupportedMaxFramerate(H264Level level, int maxFramePixelCount); | ||
| // Returns the max framerate that calclated by maxFrameWidthPixelCount and maxFrameHeightPixelCount. |
There was a problem hiding this comment.
There is a spelling error in the comment: 'calclated' should be 'calculated'.
Suggested change
| // Returns the max framerate that calclated by maxFrameWidthPixelCount and maxFrameHeightPixelCount. | |
| // Returns the max framerate that calculated by maxFrameWidthPixelCount and maxFrameHeightPixelCount. |
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.
There seems to be a slight issue in the h264 level selection algorithm. Widths and heights of frames and h264 macroblocks should be taken into account when doing the calculation, not only the pixel counts.
This issue can cause encoder invalid param error on certain resolution ranges.
For example, a 1922x1080 30fps video stream:
The correct algorithm should be
Which resides in level 4.2.
However, according to current algorithm
Thus, the algorithm would select level 4, and cause encoder invalid param error.