mirror of
https://github.com/mpv-player/mpv
synced 2025-02-02 13:12:05 +00:00
New cmdline option: -ass-force-style.
Allows overriding any style parameter from command line. Idea and original patch by Konstantin G. Khlebnikov { koct9i aT gmail doT com }. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19501 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
ebacc18087
commit
ae7f2be0ab
@ -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},
|
||||
|
75
libass/ass.c
75
libass/ass.c
@ -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 @@ static int numpad2align(int val) {
|
||||
} 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)
|
||||
@ -300,6 +307,68 @@ static int process_event_tail(ass_track_t* track, ass_event_t* event, char* str,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* \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
|
||||
@ -645,6 +714,8 @@ void ass_process_codec_private(ass_track_t* track, char *data, int size)
|
||||
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 @@ ass_track_t* ass_read_file(char* fname)
|
||||
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);
|
||||
|
@ -12,6 +12,7 @@ float ass_line_spacing = 0.;
|
||||
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;
|
||||
|
@ -9,6 +9,7 @@ extern float ass_line_spacing;
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user