diff options
author | wm4 <wm4@nowhere> | 2013-06-01 19:43:11 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-06-01 19:43:11 +0200 |
commit | 27d383918a3d63559c85ca96b2162a13234f2abc (patch) | |
tree | daac6d3fbbfece956e72189a032866f093b42764 /sub/sd_ass.c | |
parent | f7b9b92179333e5bf399cbb6289b66ed3439445c (diff) | |
download | mpv-27d383918a3d63559c85ca96b2162a13234f2abc.tar.bz2 mpv-27d383918a3d63559c85ca96b2162a13234f2abc.tar.xz |
core: add demux_sub pseudo demuxer
Subtitle files are opened in mplayer.c, not using the demuxer
infrastructure in general. Pretend that this is not the case (outside of
the loading code) by opening a pseudo demuxer that does nothing. One
advantage is that the initialization code is now the same, and there's
no confusion about what the difference between track->stream,
track->sh_sub and mpctx->sh_sub is supposed to be.
This is a bit stupid, and it would be much better if there were proper
subtitle demuxers (there are many in recent FFmpeg, but not Libav). So
for now this is just a transition to a more proper architecture. Look
at demux_sub like an artifical limb: it's ugly, but don't hate it - it
helps you to get on with your life.
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r-- | sub/sd_ass.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 02d0ed15bf..b107e0438f 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -79,7 +79,9 @@ static int init(struct sh_sub *sh, struct osd_state *osd) } else { ctx = talloc_zero(NULL, struct sd_ass_priv); sh->context = ctx; - if (ass) { + if (sh->track) { + ctx->ass_track = sh->track; + } else if (ass) { ctx->ass_track = ass_new_track(osd->ass_library); if (sh->extradata) ass_process_codec_private(ctx->ass_track, sh->extradata, @@ -277,7 +279,8 @@ static void uninit(struct sh_sub *sh) { struct sd_ass_priv *ctx = sh->context; - ass_free_track(ctx->ass_track); + if (sh->track != ctx->ass_track) + ass_free_track(ctx->ass_track); talloc_free(ctx); } @@ -293,31 +296,6 @@ const struct sd_functions sd_ass = { .uninit = uninit, }; -static int sd_ass_track_destructor(void *ptr) -{ - uninit(ptr); - return 1; -} - -struct sh_sub *sd_ass_create_from_track(struct ass_track *track, - const char *codec, struct MPOpts *opts) -{ - struct sh_sub *sh = talloc(NULL, struct sh_sub); - talloc_set_destructor(sh, sd_ass_track_destructor); - *sh = (struct sh_sub) { - .opts = opts, - .gsh = talloc_struct(sh, struct sh_stream, { - .codec = codec, - }), - .context = talloc_struct(sh, struct sd_ass_priv, { - .ass_track = track, - .vsfilter_aspect = is_ass_sub(codec), - }), - .initialized = true, - }; - return sh; -} - struct ass_track *sub_get_ass_track(struct osd_state *osd) { struct sh_sub *sh = osd ? osd->sh_sub : NULL; |