Set the codec level for AMF encoders #11548
Open
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
The default "level" setting was being used for each codec (AVC, HEVC, AV1) supported by AMF. For example, all HEVC encoders were using level 6.2 and this caused some playback devices to reject decoding the bitstream because the device reported a maximum decode level lower than 6.2.
This PR adds functionality to determine the best match for the codec level instead of relying on the defaults, for AMF encoders.
Motivation and Context
The default behaviour of setting the codec level to the maximum resulted in several Android-based devices failing to decode HEVC streams in the TEB (Twitch Enhanced Broadcasting) beta program, which is currently testing HEVC compatibility. Adjusting the level appropriately instantly fixed the decode failures.
Also, most APIs (such as NVENC and VAAPI) have an "Auto" option for setting the codec level, in which case the driver or library code adjust the level. This Auto option doesn't seem to be available for AMF, hence the need to implement something at the application layer.
How Has This Been Tested?
Several local unit tests were carried out by using a configuration override with Enhanced Broadcasting to verify the selected level is accurate. The code has been (and continues to be) tested in the TEB beta builds.
Types of changes
Checklist: