changeset 23539:790efaddf175

Make sure there is at least one style in ass_track when parsing events. Before it was only checked for embedded subtitles.
author eugeni
date Fri, 15 Jun 2007 22:15:27 +0000
parents d8982d45ce61
children d655edc9d107
files libass/ass.c
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass.c	Fri Jun 15 14:38:12 2007 +0000
+++ b/libass/ass.c	Fri Jun 15 22:15:27 2007 +0000
@@ -271,6 +271,14 @@
 	char* format = strdup(track->event_format);
 	char* q = format; // format scanning pointer
 
+	if (track->n_styles == 0) {
+		// add "Default" style to the end
+		// will be used if track does not contain a default style (or even does not contain styles at all)
+		int sid = ass_alloc_style(track);
+		track->styles[sid].Name = strdup("Default");
+		track->styles[sid].FontName = strdup("Arial");
+	}
+
 	for (i = 0; i < n_ignored; ++i) {
 		NEXT(q, tname);
 	}
@@ -697,7 +705,6 @@
 void ass_process_codec_private(ass_track_t* track, char *data, int size)
 {
 	char* str = malloc(size + 1);
-	int sid;
 
 	memcpy(str, data, size);
 	str[size] = '\0';
@@ -705,12 +712,6 @@
 	process_text(track, str);
 	free(str);
 
-	// add "Default" style to the end
-	// will be used if track does not contain a default style (or even does not contain styles at all)
-	sid = ass_alloc_style(track);
-	track->styles[sid].Name = strdup("Default");
-	track->styles[sid].FontName = strdup("Arial");
-	
 	if (!track->event_format) {
 		// probably an mkv produced by ancient mkvtoolnix
 		// such files don't have [Events] and Format: headers