changeset 34476:fd5512f5bfe9

Fix -ass-styles with SRT subs and more. The most visible problems are fixed by switching SRT event "Style" value from first style to default_style. To fix issues with overriding "Default" style, this adds a dummy style first, to stop libass from adding a style with the name "Default" (this is a problem since some of the libass code picks the first, some the last style - encoded in default_track - with the name "Default"). If after loading the ass-styles file there still is no default style, MPlayer adds and sets its own.
author reimar
date Sat, 14 Jan 2012 14:06:29 +0000
parents 45e9c10b2f5b
children 980e3cb2a5a8
files sub/ass_mp.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sub/ass_mp.c	Sat Jan 14 13:55:38 2012 +0000
+++ b/sub/ass_mp.c	Sat Jan 14 14:06:29 2012 +0000
@@ -97,12 +97,21 @@
 	track->PlayResY = 288;
 	track->WrapStyle = 0;
 
+	if (track->n_styles == 0) {
+		// stupid hack to stop libass to add a default track
+		// in front in ass_read_styles - this makes it impossible
+		// to completely override the "Default" track.
+		int sid = ass_alloc_style(track);
+		init_style(track->styles + sid, "MPlayerDummy", track->PlayResY);
+	}
+
 	if (ass_styles_file)
 		ass_read_styles(track, ass_styles_file, sub_cp);
 
-	if (track->n_styles == 0) {
+	if (track->default_style <= 0) {
 		int sid = ass_alloc_style(track);
 		init_style(track->styles + sid, "Default", track->PlayResY);
+		track->default_style = sid;
 	}
 
 	ass_process_force_style(track);
@@ -143,7 +152,7 @@
 
 	event->Start = sub->start * 10;
 	event->Duration = (sub->end - sub->start) * 10;
-	event->Style = 0;
+	event->Style = track->default_style;
 
 	for (j = 0; j < sub->lines; ++j)
 		len += sub->text[j] ? strlen(sub->text[j]) : 0;