aboutsummaryrefslogtreecommitdiffhomepage
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/command.c5
-rw-r--r--core/mp_core.h3
-rw-r--r--core/mplayer.c83
-rw-r--r--core/options.c1
-rw-r--r--core/options.h1
5 files changed, 15 insertions, 78 deletions
diff --git a/core/command.c b/core/command.c
index 4da0653425..c39bb3c16d 100644
--- a/core/command.c
+++ b/core/command.c
@@ -2281,7 +2281,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_SUB_ADD:
if (sh_video) {
- mp_add_subtitles(mpctx, cmd->args[0].v.s, sh_video->fps, 0);
+ mp_add_subtitles(mpctx, cmd->args[0].v.s, 0);
}
break;
@@ -2296,8 +2296,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
struct track *sub = mp_track_by_tid(mpctx, STREAM_SUB, cmd->args[0].v.i);
if (sh_video && sub && sub->is_external && sub->external_filename)
{
- struct track *nsub = mp_add_subtitles(mpctx, sub->external_filename,
- sh_video->fps, 0);
+ struct track *nsub = mp_add_subtitles(mpctx, sub->external_filename, 0);
if (nsub) {
mp_remove_track(mpctx, sub);
mp_switch_track(mpctx, nsub->type, nsub);
diff --git a/core/mp_core.h b/core/mp_core.h
index a327e43822..c958132700 100644
--- a/core/mp_core.h
+++ b/core/mp_core.h
@@ -290,8 +290,7 @@ extern int forced_subs_only;
void uninit_player(struct MPContext *mpctx, unsigned int mask);
void reinit_audio_chain(struct MPContext *mpctx);
double playing_audio_pts(struct MPContext *mpctx);
-struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename,
- float fps, int noerr);
+struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename, int noerr);
int reinit_video_chain(struct MPContext *mpctx);
int reinit_video_filters(struct MPContext *mpctx);
void pause_player(struct MPContext *mpctx);
diff --git a/core/mplayer.c b/core/mplayer.c
index 67d82fdb35..6e453278f0 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -196,9 +196,6 @@ static const char av_desync_help_text[] = _(
static void reset_subtitles(struct MPContext *mpctx);
static void reinit_subs(struct MPContext *mpctx);
-static struct track *open_external_file(struct MPContext *mpctx, char *filename,
- char *demuxer_name, int stream_cache,
- enum stream_type filter);
static double get_relative_time(struct MPContext *mpctx)
{
@@ -981,6 +978,9 @@ static struct track *add_stream_track(struct MPContext *mpctx,
};
MP_TARRAY_APPEND(mpctx, mpctx->tracks, mpctx->num_tracks, track);
+ if (stream->type == STREAM_SUB)
+ track->preloaded = !!stream->sub->track;
+
// Needed for DVD and Blu-ray.
if (!track->lang) {
struct stream_lang_req req = {
@@ -1027,65 +1027,6 @@ static void add_dvd_tracks(struct MPContext *mpctx)
#endif
}
-#ifdef CONFIG_ASS
-static int free_sub_data(void *ptr)
-{
- struct sh_sub *sh_sub = *(struct sh_sub **)ptr;
- if (sh_sub->track)
- ass_free_track(sh_sub->track);
- talloc_free(sh_sub->sub_data);
- return 1;
-}
-#endif
-
-struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename,
- float fps, int noerr)
-{
- struct MPOpts *opts = &mpctx->opts;
- struct ass_track *asst = NULL;
-
- if (filename == NULL)
- return NULL;
-
- // Note: no text subtitles without libass. This is mainly because sd_ass is
- // used for rendering. Even when showing subtitles with term-osd, going
- // through sd_ass makes the code much simpler, as sd_ass can handle all
- // the weird special-cases.
-#ifdef CONFIG_ASS
- asst = mp_ass_read_stream(mpctx->ass_library, filename, opts->sub_cp);
- if (asst) {
- struct demuxer *d = new_sub_pseudo_demuxer(opts);
- assert(d->num_streams == 1);
- struct sh_stream *s = d->streams[0];
- assert(s->type == STREAM_SUB);
-
- s->codec = "ass";
- s->sub->track = asst;
-
- struct sh_sub **pptr = talloc(d, struct sh_sub*);
- *pptr = s->sub;
- talloc_set_destructor(pptr, free_sub_data);
-
- struct track *t = add_stream_track(mpctx, s, false);
- t->is_external = true;
- t->preloaded = true;
- t->title = talloc_strdup(t, filename);
- t->external_filename = talloc_strdup(t, filename);
- MP_TARRAY_APPEND(NULL, mpctx->sources, mpctx->num_sources, d);
- return t;
- }
-#endif
-
- // Used with libavformat subtitles.
- struct track *ext = open_external_file(mpctx, filename, NULL, 0, STREAM_SUB);
- if (ext)
- return ext;
-
- mp_tmsg(MSGT_CPLAYER, noerr ? MSGL_WARN : MSGL_ERR,
- "Cannot load subtitles: %s\n", filename);
- return NULL;
-}
-
int mp_get_cache_percent(struct MPContext *mpctx)
{
if (mpctx->stream) {
@@ -3916,16 +3857,15 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
// after reading video params we should load subtitles because
// we know fps so now we can adjust subtitle time to ~6 seconds AST
// check .sub
- double sub_fps = mpctx->sh_video ? mpctx->sh_video->fps : 25;
if (mpctx->opts.sub_name) {
for (int i = 0; mpctx->opts.sub_name[i] != NULL; ++i)
- mp_add_subtitles(mpctx, mpctx->opts.sub_name[i], sub_fps, 0);
+ mp_add_subtitles(mpctx, mpctx->opts.sub_name[i], 0);
}
if (mpctx->opts.sub_auto) { // auto load sub file ...
char **tmp = find_text_subtitles(&mpctx->opts, mpctx->filename);
int nsub = MP_TALLOC_ELEMS(tmp);
for (int i = 0; i < nsub; i++) {
- struct track *track = mp_add_subtitles(mpctx, tmp[i], sub_fps, 1);
+ struct track *track = mp_add_subtitles(mpctx, tmp[i], 1);
if (track)
track->auto_loaded = true;
}
@@ -3955,9 +3895,12 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename,
case STREAM_SUB: ss = -1; break;
}
vs = -1; // avi can't go without video
+ struct demuxer_params params = {
+ .ass_library = mpctx->ass_library, // demux_libass requires it
+ };
struct demuxer *demuxer =
demux_open_withparams(&mpctx->opts, stream, format, demuxer_name,
- as, vs, ss, filename, NULL);
+ as, vs, ss, filename, &params);
if (!demuxer) {
free_stream(stream);
goto err_out;
@@ -3995,12 +3938,11 @@ static void open_audiofiles_from_options(struct MPContext *mpctx)
opts->audio_stream_cache, STREAM_AUDIO);
}
-// Just for -subfile. open_subtitles_from_options handles -sub text sub files.
-static void open_subfiles_from_options(struct MPContext *mpctx)
+struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename, int noerr)
{
struct MPOpts *opts = &mpctx->opts;
- open_external_file(mpctx, opts->sub_stream, opts->sub_demuxer_name,
- 0, STREAM_SUB);
+ return open_external_file(mpctx, filename, opts->sub_demuxer_name, 0,
+ STREAM_SUB);
}
static void print_timeline(struct MPContext *mpctx)
@@ -4303,7 +4245,6 @@ goto_reopen_demuxer: ;
open_subtitles_from_options(mpctx);
open_audiofiles_from_options(mpctx);
- open_subfiles_from_options(mpctx);
check_previous_track_selection(mpctx);
diff --git a/core/options.c b/core/options.c
index 2e0d32bb60..3ce4315572 100644
--- a/core/options.c
+++ b/core/options.c
@@ -406,7 +406,6 @@ const m_option_t mp_opts[] = {
// demuxer.c - select audio/sub file/demuxer
OPT_STRING("audiofile", audio_stream, 0),
OPT_INTRANGE("audiofile-cache", audio_stream_cache, 0, 50, 65536),
- OPT_STRING("subfile", sub_stream, 0),
OPT_STRING("demuxer", demuxer_name, 0),
OPT_STRING("audio-demuxer", audio_demuxer_name, 0),
OPT_STRING("sub-demuxer", sub_demuxer_name, 0),
diff --git a/core/options.h b/core/options.h
index c31d2063c9..6ec051ddca 100644
--- a/core/options.h
+++ b/core/options.h
@@ -150,7 +150,6 @@ typedef struct MPOpts {
char *audio_stream;
int audio_stream_cache;
- char *sub_stream;
char *demuxer_name;
char *audio_demuxer_name;
char *sub_demuxer_name;