Repository navigation
VSFilter mangled colors - #94
Merged
Merged
Conversation
Do the mangling as described in libass: https://github.com/libass/libass/blob/5b44c4d690254a7bd8de2e048fa23820036b671b/libass/ass_types.h#L157-L262 - A missing or unparsable header means TV.601. "None" leaves colors untouched. - The video's color space comes from its track format. When the video doesn't specify its matrix, it's guessed from its size, like Aegisub: BT.709 above 1024x600, BT.601 below. A video that doesn't specify its range is limited. - The colors are mangled once per atlas piece, when the quads are built. The quads are rebuilt when the header or the video's color space changes. The conversion gives the same result as androidx/media's ASS decoder (androidx/media#2324). AssColorTest runs the test cases from that PR.
With adaptive streams, the track format from onTracksChanged is the first track of the group, not the variant being played. So the color space could be guessed from the wrong resolution and colorInfo. The color space now comes from onVideoInputFormatChanged. That format is the played variant's, and it carries the colorInfo read from the stream. The onTracksChanged guess is only used until the decoder gets a format: CUES bakes subtitle bitmaps during extraction, before the decoder has received any format. Later onTracksChanged calls (e.g. a subtitle track switch) keep the decoder's format, since onVideoInputFormatChanged won't fire again. The guess also now uses a selected track instead of track 0.
The Player.Listener and the AnalyticsListener added in init() were never removed. After release(), the player kept a reference to the handler, which leaked it and kept it updating its state on player events.
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.
Fix #93
To test this, I wrote a script that generates one video per color space libass supports (BT.601, BT.709, SMPTE 240M and FCC, each in limited and full range, plus an untagged video).
Without mangling the color, we could see the difference between the video and the ass draw.
With the video ycbcr-matrix-bt601-pc.mkv and the subtitle track "ycbcr matrix: TV.709"

Before
After

Here are the video generated with the script: ycbcr-matrix-videos.tar.gz