diff options
author | wm4 <wm4@nowhere> | 2013-04-15 21:25:21 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-04-20 23:28:27 +0200 |
commit | 331982b99ce3b50b95ac340eb17c6116913480f3 (patch) | |
tree | b0e0c14521f509a883c0420d9e6277c0329eb773 /sub/sd_ass.c | |
parent | 5ac50f88c90167e9ade0c998ac62e935e259acee (diff) | |
download | mpv-331982b99ce3b50b95ac340eb17c6116913480f3.tar.bz2 mpv-331982b99ce3b50b95ac340eb17c6116913480f3.tar.xz |
sub, demux: identify subtitle types with the codec name
Get rid of the 1-char subtitle type field. Use sh_stream->codec instead
just like audio and video do. Use codec names as defined by libavcodec
for simplicity, even if they're somewhat verbose and annoying.
Note that ffmpeg might switch to "ass" as codec name for ASS, so we
don't bother with the current silly "ssa" name.
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r-- | sub/sd_ass.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 00f2f8d796..8d17835809 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -41,6 +41,11 @@ struct sd_ass_priv { bool flush_on_seek; }; +static bool probe(struct sh_sub *sh) +{ + return is_text_sub(sh->gsh->codec); +} + static void free_last_event(ASS_Track *track) { assert(track->n_events > 0); @@ -51,13 +56,14 @@ static void free_last_event(ASS_Track *track) static int init(struct sh_sub *sh, struct osd_state *osd) { struct sd_ass_priv *ctx; + bool ass = is_ass_sub(sh->gsh->codec); if (sh->initialized) { ctx = sh->context; } else { ctx = talloc_zero(NULL, struct sd_ass_priv); sh->context = ctx; - if (sh->type == 'a') { + if (ass) { ctx->ass_track = ass_new_track(osd->ass_library); if (sh->extradata) ass_process_codec_private(ctx->ass_track, sh->extradata, @@ -66,7 +72,7 @@ static int init(struct sh_sub *sh, struct osd_state *osd) ctx->ass_track = mp_ass_default_track(osd->ass_library, sh->opts); } - ctx->vsfilter_aspect = sh->type == 'a'; + ctx->vsfilter_aspect = ass; return 0; } @@ -77,7 +83,7 @@ static void decode(struct sh_sub *sh, struct osd_state *osd, void *data, struct sd_ass_priv *ctx = sh->context; ASS_Track *track = ctx->ass_track; - if (sh->type == 'a') { // ssa/ass subs + if (is_ass_sub(sh->gsh->codec)) { if (bstr_startswith0((bstr){data, data_len}, "Dialogue: ")) { // broken ffmpeg ASS packet format ctx->flush_on_seek = true; @@ -177,6 +183,7 @@ static void uninit(struct sh_sub *sh) } const struct sd_functions sd_ass = { + .probe = probe, .init = init, .decode = decode, .get_bitmaps = get_bitmaps, @@ -199,7 +206,9 @@ struct sh_sub *sd_ass_create_from_track(struct ass_track *track, talloc_set_destructor(sh, sd_ass_track_destructor); *sh = (struct sh_sub) { .opts = opts, - .type = 'a', + .gsh = talloc_struct(sh, struct sh_stream, { + .codec = "ass", + }), .sd_driver = &sd_ass, .context = talloc_struct(sh, struct sd_ass_priv, { .ass_track = track, |