ActiveAE: compensate error for TrueHD passthrough #25229
Merged
+8
−2
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
ActiveAE: compensate error for TrueHD passthrough
Motivation and context
Apply what has been found in: https://forum.kodi.tv/showthread.php?tid=377117&pid=3198021#pid3198021
Basically due nature of TrueHD compressed audio, data is not received at regular intervals then the delay is not constant while handling TrueHD frames but it is once decoded to PCM. Since AE is handling compressed data, even it's not aware of this, is need a corrective factor in the error.
This is a very basic form of correction but effective since the variability is well limited.
We can try to find the correction value theoretically:
There is usually a maximum of 5 MAT frames queued, that is 5 * 20 ms = 100 ms plus another 100 ms due
maxpassthroughoffsyncduration
. In total is 200 ms.This is the worst case and should be inside AE threshold of 100 ms. Then is need scale 200 ms to 100 ms
error = error * 0.50
0.45 is used to have some margin.
Another way to justify this value is empirically:
Normal error oscillation (noise) should be less than frame time (~42 ms at 23.976) to avoid accidental a/v sync corrections.
0.45 factor seems meets the two conditions in various videos tested. It may not be perfect but it is a great improvement over the current situation.
In a follow up PR should be revised self-learning algo to not exceed 2* frame time as this broke a/v sync correction.
Ideally error noise < frame time
self-learning or
maxpassthroughoffsyncduration
> error noise but less 2 * frame time.Probably we can use constant value of 1.8 * frame time and remove "self-learning"....
How has this been tested?
Runtime Shield.
What is the effect on users?
Tested Blu-Ray folder and also tested MKV created with MakeMKV v1.17.7
and
Blu-Ray to .m2ts with tsMuxer and .m2ts to MKV with mkvmerge v82.0
Screenshots (if appropriate):
No dropouts in 20 minutes of playback:
Types of change
Checklist: