summaryrefslogtreecommitdiffstats
path: root/libass/ass.c
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2022-02-20 00:04:23 +0300
committerOneric <oneric@oneric.stub>2022-11-28 19:31:37 +0100
commit1a533e5d5df5dcc7b7238dddfd524d21a72fddbd (patch)
treeac4c0194a367c4b07da284b31aa889570f99c520 /libass/ass.c
parent5b3fe279a65f0881e8ca4b3016accd961e0da511 (diff)
downloadlibass-1a533e5d5df5dcc7b7238dddfd524d21a72fddbd.tar.bz2
libass-1a533e5d5df5dcc7b7238dddfd524d21a72fddbd.tar.xz
Introduce LayoutRes{X,Y} script headers
Rendering ASS depends on the video’s storage resolution for several tags. Thus transferring a subtitle file to a different version of a video, with e.g. higher resolution or anamorphic squeezing undone, requires adjusting all those tags. Affected are \be, \blur, \frx, \fry and if ScaledBorderAndShadow is not set to "yes", also all tags related to border and shadow. This locks all but simple subtitle files to a specific video storage resolution. If one wants to release several different resolution simultaneously, the same source is reencoded to undo anamorphic squeezing, or a new higher resolution source appears, it is required to manually adjust affected tags and each video version needs a different subtitle file. This is a pain point, and resulted in some releases just relying on user overrides of players, or incompatibly patched renderers to avoid the required manual adjustments. By adding new headers, which will replace the original video storage resolution in all calculations, authors will be able to create files which can be reused across different resolutions as long as the display aspect ratio stays the same. Hopefully this will also halt the spread of incomapatible patches and overrides, which just result in broken files and further ASS fragmentation. For simplicity and to avoid surprises, LayoutRes* headers only take effect if both are present and set to values larger than zero. If LayoutRes{X,Y} is set to corresponds to the actual storage resolution of the video the subs are authored and initially released with, at least the initial/main version will also be effectively compatible to older renderers, which do not understand the new headers yet. This will grant users some time to upgrade and minimise friction from this retroactive format addition. The header concept is also approved by some VSFilters and patches for Cyberbeing/xy-VSFilter’s xy-VSFilter and XySubFilter are pending with only implementation details being still up for discussion. Integration into active Aegisub forks and possibly other common editors will be pursued at a later date. libass-specific: Since API-users can initialise PAR, we must recalcute even existing values when LayoutRes{X,Y} is set to ensure the sub-author-provided values take precedence.
Diffstat (limited to 'libass/ass.c')
-rw-r--r--libass/ass.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libass/ass.c b/libass/ass.c
index 99746ee..25eeed3 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -543,6 +543,10 @@ void ass_process_force_style(ASS_Track *track)
track->PlayResX = parse_int_header(token);
else if (!ass_strcasecmp(*fs, "PlayResY"))
track->PlayResY = parse_int_header(token);
+ else if (!ass_strcasecmp(*fs, "LayoutResX"))
+ track->LayoutResX = parse_int_header(token);
+ else if (!ass_strcasecmp(*fs, "LayoutResY"))
+ track->LayoutResY = parse_int_header(token);
else if (!ass_strcasecmp(*fs, "Timer"))
track->Timer = ass_atof(token);
else if (!ass_strcasecmp(*fs, "WrapStyle"))
@@ -848,6 +852,12 @@ static int process_info_line(ASS_Track *track, char *str)
} else if (!strncmp(str, "PlayResY:", 9)) {
check_duplicate_info_line(track, SINFO_PLAYRESY, "PlayResY");
track->PlayResY = parse_int_header(str + 9);
+ } else if (!strncmp(str, "LayoutResX:", 11)) {
+ check_duplicate_info_line(track, SINFO_LAYOUTRESX, "LayoutResX");
+ track->LayoutResX = parse_int_header(str + 11);
+ } else if (!strncmp(str, "LayoutResY:", 11)) {
+ check_duplicate_info_line(track, SINFO_LAYOUTRESY, "LayoutResY");
+ track->LayoutResY = parse_int_header(str + 11);
} else if (!strncmp(str, "Timer:", 6)) {
check_duplicate_info_line(track, SINFO_TIMER, "Timer");
track->Timer = ass_atof(str + 6);