From 24ea56a20e760e23c2bfd02377d2d0d1c1523c23 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 6 Mar 2015 13:14:39 +0100 Subject: [PATCH] Refine list of tags that prevent selective style overrides Somewhat stolen from: https://github.com/Cyberbeing/xy-VSFilter/blob/xy_sub_filter_rc3/src/subtitles/RTS.cpp#L2004 (xy-VSFilter started work on this in commit 014da6d9766417d7886eb867c9f2c14038f2a226) --- libass/ass_parse.c | 11 +++++++---- libass/ass_parse.h | 2 +- libass/ass_render.c | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libass/ass_parse.c b/libass/ass_parse.c index 641d42c..a639dc5 100644 --- a/libass/ass_parse.c +++ b/libass/ass_parse.c @@ -1070,9 +1070,9 @@ unsigned get_next_char(ASS_Renderer *render_priv, char **str) return chr; } -// Return 1 if the event contains tags that will put the renderer into the -// EVENT_POSITIONED state. Return 0 otherwise. -int event_is_positioned(char *str) +// Return 1 if the event contains tags that will apply overrides the selective +// style override code should not touch. Return 0 otherwise. +int event_has_hard_overrides(char *str) { // look for \pos and \move tags inside {...} // mirrors get_next_char, but is faster and doesn't change any global state @@ -1084,7 +1084,10 @@ int event_is_positioned(char *str) while (*str && *str != '}') { if (*str == '\\') { char *p = str + 1; - if (mystrcmp(&p, "pos") || mystrcmp(&p, "move")) + if (mystrcmp(&p, "pos") || mystrcmp(&p, "move") || + mystrcmp(&p, "clip") || mystrcmp(&p, "iclip") || + mystrcmp(&p, "org") || mystrcmp(&p, "pbo") || + mystrcmp(&p, "p")) return 1; } str++; diff --git a/libass/ass_parse.h b/libass/ass_parse.h index e932238..e8512b2 100644 --- a/libass/ass_parse.h +++ b/libass/ass_parse.h @@ -35,7 +35,7 @@ void apply_transition_effects(ASS_Renderer *render_priv, ASS_Event *event); void process_karaoke_effects(ASS_Renderer *render_priv); unsigned get_next_char(ASS_Renderer *render_priv, char **str); char *parse_tag(ASS_Renderer *render_priv, char *p, char *end, double pwr); -int event_is_positioned(char *str); +int event_has_hard_overrides(char *str); extern void change_alpha(uint32_t *var, uint32_t new, double pwr); extern uint32_t mult_alpha(uint32_t a, uint32_t b); diff --git a/libass/ass_render.c b/libass/ass_render.c index b03fc30..4774dab 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -756,7 +756,7 @@ static ASS_Style *handle_selective_style_overrides(ASS_Renderer *render_priv, // The user style was set with ass_set_selective_style_override(). ASS_Style *user = &render_priv->user_override_style; ASS_Style *new = &render_priv->state.override_style_temp_storage; - int explicit = event_is_positioned(render_priv->state.event->Text); + int explicit = event_has_hard_overrides(render_priv->state.event->Text); int requested = render_priv->settings.selective_style_overrides; double scale; -- 2.40.0