From f7b9b92179333e5bf399cbb6289b66ed3439445c Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 1 Jun 2013 19:40:09 +0200 Subject: sub: various minor subtitle related changes Just pushing some code around. --- sub/dec_sub.c | 20 -------------------- sub/dec_sub.h | 4 ---- sub/sd_ass.c | 14 ++++++++++++++ sub/sd_lavc.c | 13 +++++-------- sub/sd_spu.c | 6 ++++++ 5 files changed, 25 insertions(+), 32 deletions(-) (limited to 'sub') diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 36ba25edd2..2cc02efb79 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -40,26 +40,6 @@ static const struct sd_functions *sd_list[] = { NULL }; -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 || - strcmp(t, "dvd_subtitle_mpg") == 0); -} - void sub_init(struct sh_sub *sh, struct osd_state *osd) { sh->sd_driver = NULL; diff --git a/sub/dec_sub.h b/sub/dec_sub.h index 52fa05eebc..263df19bc0 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -10,10 +10,6 @@ struct sh_sub; struct ass_track; struct MPOpts; -bool is_text_sub(const char *t); -bool is_ass_sub(const char *t); -bool is_dvd_sub(const char *t); - bool sub_accept_packets_in_advance(struct sh_sub *sh); void sub_decode(struct sh_sub *sh, struct osd_state *osd, void *data, int data_len, double pts, double duration); diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 3dfbbd05fb..02d0ed15bf 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -43,6 +43,20 @@ struct sd_ass_priv { char last_text[500]; }; +static bool is_ass_sub(const char *t) +{ + return t && (strcmp(t, "ass") == 0 || + strcmp(t, "ssa") == 0); +} + +static 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); +} + static bool supports_format(const char *format) { return is_text_sub(format); diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index 4e1d80d8ce..4c7dfd12a5 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -43,21 +43,18 @@ struct sd_lavc_priv { static bool supports_format(const char *format) { - // lavc dvdsubdec doesn't read color/resolution on Libav 9.1 and below, - // so fall back to sd_spu in this case. Never use sd_spu with new ffmpeg; - // spudec can't handle ffmpeg .idx demuxing (added to lavc in 54.79.100). -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 40, 0) - if (is_dvd_sub(format)) - return false; -#endif - enum AVCodecID cid = mp_codec_to_av_codec_id(format); // Supported codecs must be known to decode to paletted bitmaps switch (cid) { case AV_CODEC_ID_DVB_SUBTITLE: case AV_CODEC_ID_HDMV_PGS_SUBTITLE: case AV_CODEC_ID_XSUB: + // lavc dvdsubdec doesn't read color/resolution on Libav 9.1 and below, + // so fall back to sd_spu in this case. Never use sd_spu with new ffmpeg; + // spudec can't handle ffmpeg .idx demuxing (added to lavc in 54.79.100). +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 40, 0) case AV_CODEC_ID_DVD_SUBTITLE: +#endif return true; default: return false; diff --git a/sub/sd_spu.c b/sub/sd_spu.c index fc4e4701dc..8b87b7a0dc 100644 --- a/sub/sd_spu.c +++ b/sub/sd_spu.c @@ -29,6 +29,12 @@ struct sd_spu_priv { void *spudec; }; +static bool is_dvd_sub(const char *t) +{ + return t && (strcmp(t, "dvd_subtitle") == 0 || + strcmp(t, "dvd_subtitle_mpg") == 0); +} + static bool supports_format(const char *format) { return is_dvd_sub(format); -- cgit v1.2.3