[MPlayer-cvslog] r19501 - in trunk: cfg-common.h libass/ass.c libass/ass_mp.c libass/ass_mp.h

eugeni subversion at mplayerhq.hu
Wed Aug 23 01:20:05 CEST 2006


Author: eugeni
Date: Wed Aug 23 01:20:05 2006
New Revision: 19501

Modified:
   trunk/cfg-common.h
   trunk/libass/ass.c
   trunk/libass/ass_mp.c
   trunk/libass/ass_mp.h

Log:
New cmdline option: -ass-force-style.
Allows overriding any style parameter from command line.
Idea and original patch by Konstantin G. Khlebikov { koct9i aT gmail doT com }.


Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	(original)
+++ trunk/cfg-common.h	Wed Aug 23 01:20:05 2006
@@ -305,6 +305,7 @@
 	{"ass-bottom-margin", &ass_bottom_margin, CONF_TYPE_INT, CONF_RANGE, 0, 2000, NULL},
 	{"embeddedfonts", &extract_embedded_fonts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"noembeddedfonts", &extract_embedded_fonts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+	{"ass-force-style", &ass_force_style_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
 #endif
 #ifdef HAVE_FONTCONFIG
 	{"fontconfig", &font_fontconfig, CONF_TYPE_FLAG, 0, 0, 1, NULL},

Modified: trunk/libass/ass.c
==============================================================================
--- trunk/libass/ass.c	(original)
+++ trunk/libass/ass.c	Wed Aug 23 01:20:05 2006
@@ -19,6 +19,7 @@
 extern char *sub_cp;
 #endif
 extern int extract_embedded_fonts;
+extern char** ass_force_style_list;
 
 #include "mp_msg.h"
 #include "ass.h"
@@ -209,7 +210,13 @@
 	} else if (strcasecmp(tname, #name) == 0) { \
 		target->name = func(token); \
 		mp_msg(MSGT_GLOBAL, MSGL_DBG2, "%s = %s\n", #name, token);
-#define STRVAL(name) ANYVAL(name,strdup)
+
+#define STRVAL(name) \
+	} else if (strcasecmp(tname, #name) == 0) { \
+		if (target->name != NULL) free(target->name); \
+		target->name = strdup(token); \
+		mp_msg(MSGT_GLOBAL, MSGL_DBG2, "%s = %s\n", #name, token);
+		
 #define COLORVAL(name) ANYVAL(name,string2color)
 #define INTVAL(name) ANYVAL(name,atoi)
 #define FPVAL(name) ANYVAL(name,atof)
@@ -301,6 +308,68 @@
 }
 
 /**
+ * \brief Parse command line style overrides (--ass-force-style option)
+ * \param track track to apply overrides to
+ * The format for overrides is [StyleName.]Field=Value
+ */
+static void process_force_style(ass_track_t* track) {
+	char **fs, *eq, *dt, *style, *tname, *token;
+	ass_style_t* target;
+	int sid;
+	
+	if (!ass_force_style_list) return;
+	
+	for (fs = ass_force_style_list; *fs; ++fs) {
+		eq = strchr(*fs, '=');
+		if (!eq)
+			continue;
+		*eq = '\0';
+		token = eq + 1;
+
+		dt = strchr(*fs, '.');
+		if (dt) {
+			*dt = '\0';
+			style = *fs;
+			tname = dt + 1;
+		} else {
+			style = NULL;
+			tname = *fs;
+		}
+		for (sid = 0; sid < track->n_styles; ++sid) {
+			if (style == NULL || strcasecmp(track->styles[sid].Name, style) == 0) {
+				target = track->styles + sid;
+				if (0) {
+					STRVAL(FontName)
+					COLORVAL(PrimaryColour)
+					COLORVAL(SecondaryColour)
+					COLORVAL(OutlineColour)
+					COLORVAL(BackColour)
+					INTVAL(FontSize)
+					INTVAL(Bold)
+					INTVAL(Italic)
+					INTVAL(Underline)
+					INTVAL(StrikeOut)
+					INTVAL(Spacing)
+					INTVAL(Angle)
+					INTVAL(BorderStyle)
+					INTVAL(Alignment)
+					INTVAL(MarginL)
+					INTVAL(MarginR)
+					INTVAL(MarginV)
+					INTVAL(Encoding)
+					FPVAL(ScaleX)
+					FPVAL(ScaleY)
+					FPVAL(Outline)
+					FPVAL(Shadow)
+				}
+			}
+		}
+		*eq = '=';
+		if (dt) *dt = '.';
+	}
+}
+
+/**
  * \brief Parse the Style line
  * \param track track
  * \param str string to parse, zero-terminated
@@ -645,6 +714,8 @@
 		else
 			track->event_format = strdup("Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text");
 	}
+
+	process_force_style(track);
 }
 
 static int check_duplicate_event(ass_track_t* track, int ReadOrder)
@@ -862,6 +933,8 @@
 		return 0;
 	}
 
+	process_force_style(track);
+
 	mp_msg(MSGT_GLOBAL, MSGL_INFO, "LIBASS: added subtitle file: %s (%d styles, %d events)\n", fname, track->n_styles, track->n_events);
 	
 	sort_events(track);

Modified: trunk/libass/ass_mp.c
==============================================================================
--- trunk/libass/ass_mp.c	(original)
+++ trunk/libass/ass_mp.c	Wed Aug 23 01:20:05 2006
@@ -12,6 +12,7 @@
 int ass_top_margin = 0;
 int ass_bottom_margin = 0;
 int extract_embedded_fonts = 0;
+char **ass_force_style_list = NULL;
 
 extern int font_fontconfig;
 extern char* font_name;

Modified: trunk/libass/ass_mp.h
==============================================================================
--- trunk/libass/ass_mp.h	(original)
+++ trunk/libass/ass_mp.h	Wed Aug 23 01:20:05 2006
@@ -9,6 +9,7 @@
 extern int ass_top_margin;
 extern int ass_bottom_margin;
 extern int extract_embedded_fonts;
+extern char **ass_force_style_list;
 
 ass_track_t* ass_read_subdata(sub_data* subdata, double fps);
 



More information about the MPlayer-cvslog mailing list