@@ -154,11 +154,19 @@ static int _is_animated_tag(char *begin, char *end) {
154
154
return 0 ;
155
155
}
156
156
157
- static int _is_event_animated (ASS_Event *event) {
157
+ static void _remove_tag (char *begin, char *end) {
158
+ // overwrite the tag with whitespace so libass won't see it
159
+ for (; begin < end; begin++) *begin = ' ' ;
160
+ }
161
+
162
+ static int _is_event_animated (ASS_Event *event, bool drop_animations) {
158
163
// event is complex if it's animated in any way,
159
164
// either by having non-empty Effect or
160
165
// by having tags (enclosed in '{}' in Text)
161
- if (event->Effect && event->Effect [0 ] != ' \0 ' ) return 1 ;
166
+ if (event->Effect && event->Effect [0 ] != ' \0 ' ) {
167
+ if (!drop_animations) return 1 ;
168
+ event->Effect [0 ] = ' \0 ' ;
169
+ }
162
170
163
171
int escaped = 0 ;
164
172
char *tagStart = NULL ;
@@ -172,13 +180,19 @@ static int _is_event_animated(ASS_Event *event) {
172
180
break ;
173
181
case ' }' :
174
182
if (!escaped && tagStart != NULL ) {
175
- if (_is_animated_tag (tagStart, p)) return 1 ;
183
+ if (_is_animated_tag (tagStart, p)) {
184
+ if (!drop_animations) return 1 ;
185
+ _remove_tag (tagStart, p);
186
+ }
176
187
tagStart = NULL ;
177
188
}
178
189
break ;
179
190
case ' ;' :
180
191
if (tagStart != NULL ) {
181
- if (_is_animated_tag (tagStart, p)) return 1 ;
192
+ if (_is_animated_tag (tagStart, p)) {
193
+ if (!drop_animations) return 1 ;
194
+ _remove_tag (tagStart, p + 1 /* +1 is because we want to drop ';' as well */ );
195
+ }
182
196
}
183
197
tagStart = p + 1 ;
184
198
break ;
@@ -537,7 +551,7 @@ class SubtitleOctopus {
537
551
ASS_Event *cur = track->events ;
538
552
int *animated = m_is_event_animated;
539
553
for (int i = 0 ; i < track->n_events ; i++, cur++, animated++) {
540
- *animated = _is_event_animated (cur);
554
+ *animated = _is_event_animated (cur, m_drop_animations );
541
555
}
542
556
}
543
557
0 commit comments