1
mirror of https://github.com/mpv-player/mpv synced 2024-08-04 14:59:58 +02:00

options: Move ass_enabled to options struct

This commit is contained in:
Uoti Urpala 2009-12-02 17:36:59 +02:00
parent 6da77386e9
commit 9afcdab694
8 changed files with 17 additions and 16 deletions

View File

@ -37,7 +37,6 @@
// libass-related command line options
ASS_Library *ass_library;
int ass_enabled = 0;
float ass_font_scale = 1.;
float ass_line_spacing = 0.;
int ass_top_margin = 0;

View File

@ -32,7 +32,6 @@
#include <ass/ass_types.h>
extern ASS_Library *ass_library;
extern int ass_enabled;
extern float ass_font_scale;
extern float ass_line_spacing;
extern int ass_top_margin;

View File

@ -320,8 +320,8 @@
{"subfont-autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
#endif
#ifdef CONFIG_ASS
{"ass", &ass_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noass", &ass_enabled, CONF_TYPE_FLAG, 0, 1, 0, NULL},
OPT_FLAG_ON("ass", ass_enabled, 0),
OPT_FLAG_OFF("noass", ass_enabled, 0),
{"ass-font-scale", &ass_font_scale, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL},
{"ass-line-spacing", &ass_line_spacing, CONF_TYPE_FLOAT, CONF_RANGE, -1000, 1000, NULL},
{"ass-top-margin", &ass_top_margin, CONF_TYPE_INT, CONF_RANGE, 0, 2000, NULL},

View File

@ -1524,7 +1524,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
mpctx->set_of_sub_pos =
mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_SUBS];
#ifdef CONFIG_ASS
if (ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos])
if (opts->ass_enabled && mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos])
ass_track = mpctx->set_of_ass_tracks[mpctx->set_of_sub_pos];
else
#endif
@ -1554,7 +1554,7 @@ static int mp_property_sub(m_option_t *prop, int action, void *arg,
if (sh->type == 'v')
init_vo_spudec(mpctx);
#ifdef CONFIG_ASS
else if (ass_enabled)
else if (opts->ass_enabled)
ass_track = sh->ass_track;
#endif
} else {
@ -1862,6 +1862,7 @@ static int mp_property_sub_forced_only(m_option_t *prop, int action,
static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
struct MPOpts *opts = &mpctx->opts;
switch (action) {
case M_PROPERTY_SET:
@ -1869,7 +1870,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
return M_PROPERTY_ERROR;
M_PROPERTY_CLAMP(prop, *(float *) arg);
#ifdef CONFIG_ASS
if (ass_enabled) {
if (opts->ass_enabled) {
ass_font_scale = *(float *) arg;
ass_force_reload = 1;
}
@ -1880,7 +1881,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
#ifdef CONFIG_ASS
if (ass_enabled) {
if (opts->ass_enabled) {
ass_font_scale += (arg ? *(float *) arg : 0.1)*
(action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
M_PROPERTY_CLAMP(prop, ass_font_scale);
@ -1894,7 +1895,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
return M_PROPERTY_OK;
default:
#ifdef CONFIG_ASS
if (ass_enabled)
if (opts->ass_enabled)
return m_property_float_ro(prop, action, arg, ass_font_scale);
else
#endif

View File

@ -923,7 +923,7 @@ static demuxer_t *demux_open_stream(struct MPOpts *opts, stream_t *stream,
sh_video->i_bps / 1024.0f);
}
#ifdef CONFIG_ASS
if (ass_enabled && ass_library) {
if (opts->ass_enabled && ass_library) {
for (i = 0; i < MAX_S_STREAMS; ++i) {
sh_sub_t *sh = demuxer->s_streams[i];
if (sh && sh->type == 'a') {

View File

@ -183,7 +183,7 @@ void update_subtitles(struct MPContext *mpctx, struct MPOpts *opts,
continue;
}
#ifdef CONFIG_ASS
if (ass_enabled) {
if (opts->ass_enabled) {
sh_sub_t* sh = d_dvdsub->sh;
ass_track = sh ? sh->ass_track : NULL;
if (!ass_track) continue;

View File

@ -1041,6 +1041,7 @@ static int playtree_add_playlist(struct MPContext *mpctx, play_tree_t* entry)
void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr)
{
struct MPOpts *opts = &mpctx->opts;
sub_data *subd;
#ifdef CONFIG_ASS
ASS_Track *asst = 0;
@ -1052,13 +1053,13 @@ void add_subtitles(struct MPContext *mpctx, char *filename, float fps, int noerr
subd = sub_read_file(filename, fps);
#ifdef CONFIG_ASS
if (ass_enabled)
if (opts->ass_enabled)
#ifdef CONFIG_ICONV
asst = ass_read_file(ass_library, filename, sub_cp);
#else
asst = ass_read_file(ass_library, filename, 0);
#endif
if (ass_enabled && subd && !asst)
if (opts->ass_enabled && subd && !asst)
asst = ass_read_subdata(ass_library, subd, fps);
if (!asst && !subd)
@ -2193,7 +2194,7 @@ int reinit_video_chain(struct MPContext *mpctx)
#endif
#ifdef CONFIG_ASS
if(ass_enabled) {
if(opts->ass_enabled) {
int i;
int insert = 1;
if (opts->vf_settings)
@ -2218,7 +2219,7 @@ int reinit_video_chain(struct MPContext *mpctx)
sh_video->vfilter = append_filters(sh_video->vfilter, opts->vf_settings);
#ifdef CONFIG_ASS
if (ass_enabled)
if (opts->ass_enabled)
sh_video->vfilter->control(sh_video->vfilter, VFCTRL_INIT_EOSD, ass_library);
#endif
@ -3634,7 +3635,7 @@ if (mpctx->global_sub_size <= mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts
mpctx->global_sub_size = mpctx->global_sub_indices[SUB_SOURCE_DEMUX] + opts->sub_id + 1;
#ifdef CONFIG_ASS
if (ass_enabled && ass_library) {
if (opts->ass_enabled && ass_library) {
for (int j = 0; j < mpctx->num_sources; j++) {
struct demuxer *d = mpctx->sources[j].demuxer;
for (int i = 0; i < d->num_attachments; i++) {

View File

@ -44,6 +44,7 @@ typedef struct MPOpts {
float screen_size_xy;
int flip;
int vd_use_slices;
int ass_enabled;
struct lavc_param {
int workaround_bugs;
int error_resilience;