Skip to content

Support LayoutRes and rework YCbCr Matrix handling#594

Open
arch1t3cht wants to merge 23 commits into
masterfrom
layoutres
Open

Support LayoutRes and rework YCbCr Matrix handling#594
arch1t3cht wants to merge 23 commits into
masterfrom
layoutres

Conversation

@arch1t3cht
Copy link
Copy Markdown
Member

These two seemingly different properties end up needing to be handled fairly similarly (ultimately because both of them specify properties of the video file the subtitles were authored for), which is why this ended up being one combined branch.

This is a big rework involving some tricky UX decisions so I will let people test this over at arch1t3cht/Aegisub for a while.

The main remaining thing to do is to properly support LayoutRes in the resolution resampler. The main difficulty here is figuring out what this is even supposed to mean, since the resolution resampler (mainly) resamples PlayRes, which is orthogonal to resampling LayoutRes. But the resolution resampler also offers some aspect ratio resampling, which is supposed to be LayoutRes's domain now.
I'll have to carefully think about all the cases involved here before tackling this, so I'll postpone it for now so that the remaining changes can be tested.

@arch1t3cht arch1t3cht force-pushed the layoutres branch 3 times, most recently from c335253 to d5f64b1 Compare May 3, 2026 18:37
@arch1t3cht arch1t3cht mentioned this pull request May 9, 2026
1 task
@arch1t3cht arch1t3cht force-pushed the layoutres branch 3 times, most recently from 771d9a0 to 733e272 Compare May 14, 2026 13:08
arch1t3cht added 23 commits May 14, 2026 18:01
No longer needed after 372b9fe.
Initial support for LayoutRes. Allow editing the values in the
properties and respect them in the visual tools. However, resolution
resampling and the resolution mismatch dialogs still need to be
adjusted.
Add a class agi::ycbcr::Header for all the color matrix/space/YCbCr
Matrix header juggling, and move it outside of the ffms2 video provider.

Respect all YCbCr Matrix values rather than only a 601 matrix,
and stop erroring out on unknown video color spaces.

The override logic in the ffms2 video provider follows the color
mangling rules to the letter, in particular also enforcing a BT.601
matrix when the YCbCr Matrix header is unset. Following commits will
then warn the user when this happens.
Unify the two YCbCrMatrix types as far as possible and improve the
defaults for resampling the YCbCr Matrix: Only suggest to resample if
the video's color space is known and the script's matrix is not None.
...and add an explicit "Leave the file as is" option.

"Set to video resolution" apparently never worked in the first place and
just also resampled the subtitles. Since changing PlayRes without
adjusting any subtitles is never ever correct except when the input file
is already broken in some way (in which case it can still be emulated by
selecting "Leave the file as is" and then manually setting the PlayRes
in the script properties), so just remove that option. Instead, add an
explicit option to leave the file as is (which previously could only be
achieved with "Cancel"), which should confuse users slightly less.
Following the previous commit, also remove the "Always Set" option in
the preferences.

Rename the relevant options to avoid any user settings changing due to
the renumbering.
This is the last big part of the rework of the YCbCr Matrix handling.
The general theme of the changes (and the incoming analogous additions
of LayoutRes handling) is:
- Do not (at least not by default) automatically change *any* fields
  of the file without notifying the user.
- Select the "recommended" action (as far as we can tell with out
  limited information) as a default.
- Show prompts for everything (which also has the benefit of teaching
  the user about these topics), but allow disabling them in the
  settings.

Once Aegisub's website gets some love, there will hopefully be a more
detailed guide on how to handle the YCbCr Matrix header there.

The various different prompts add a fair bit of similar-looking
boilerplate code (which will only get worse when additional prompts are
added to handle LayoutRes), but I do believe that it is better to keep
it this way instead of trying to add some common abstraction: This
subject is enough of a headache as it is, and the current organization
helps treat each case separately and reason better about which options
should be available where.
And make the resolution box use a GridBagSizer in the process.
Now that opening a video file no longer automatically sets the YCbCr
Matrix, this is no longer correct.
Now that Aegisub encourages setting LayoutRes (which will make subtitles
scale sanely with aspect ratio differences), using the display
resolution rather than the storage resolution will work without issues
and result in saner coordinates, For example, text no longer needs to be
horizontally scaled on anamorphic video to match the sample aspect
ratio.
With LayoutRes being properly supported and handled now, resolution
mismatches are no longer an issue most of the time.
Users that want to be warned on mismatches can still enable the prompt
in the settings.

Similarly, default to "Leave resolution as is" rather than "Resample
script" on the first invocation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant