From 331982b99ce3b50b95ac340eb17c6116913480f3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 15 Apr 2013 21:25:21 +0200 Subject: 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. --- sub/dec_sub.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'sub/dec_sub.c') diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 4e703e7dc0..d3cedea80d 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -30,17 +30,36 @@ extern const struct sd_functions sd_ass; extern const struct sd_functions sd_lavc; +bool is_text_sub(const char *t) +{ + return t && (is_ass_sub(t) || + strcmp(t, "text") == 0 || + strcmp(t, "subrip") == 0 || + strcmp(t, "mov_text") == 0); +} + +bool is_ass_sub(const char *t) +{ + return t && (strcmp(t, "ass") == 0 || + strcmp(t, "ssa") == 0); +} + +bool is_dvd_sub(const char *t) +{ + return t && strcmp(t, "dvd_subtitle") == 0; +} + void sub_init(struct sh_sub *sh, struct osd_state *osd) { struct MPOpts *opts = sh->opts; assert(!osd->sh_sub); + if (sd_lavc.probe(sh)) + sh->sd_driver = &sd_lavc; #ifdef CONFIG_ASS - if (opts->ass_enabled && is_text_sub(sh->type)) + if (opts->ass_enabled && sd_ass.probe(sh)) sh->sd_driver = &sd_ass; #endif - if (strchr("bpxv", sh->type)) - sh->sd_driver = &sd_lavc; if (sh->sd_driver) { if (sh->sd_driver->init(sh, osd) < 0) return; -- cgit v1.2.3