[MPlayer-cvslog] r34564 - trunk/sub/ass_mp.c

reimar subversion at mplayerhq.hu
Sat Jan 14 15:06:29 CET 2012


Author: reimar
Date: Sat Jan 14 15:06:29 2012
New Revision: 34564

Log:
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.

Modified:
   trunk/sub/ass_mp.c

Modified: trunk/sub/ass_mp.c
==============================================================================
--- trunk/sub/ass_mp.c	Sat Jan 14 14:55:38 2012	(r34563)
+++ trunk/sub/ass_mp.c	Sat Jan 14 15:06:29 2012	(r34564)
@@ -97,12 +97,21 @@ ASS_Track* ass_default_track(ASS_Library
 	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 @@ int ass_process_subtitle(ASS_Track* trac
 
 	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;


More information about the MPlayer-cvslog mailing list