From 29226e6a994e829c637f04cfd7f3574f0699885c Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 15 Dec 2015 21:03:34 +0100 Subject: sub: remove sd_movtext.c libavcodec's movtext-to-ass converter does the same and has more features. On Libav, this commit disables mp4 subtitle display. --- TOOLS/old-makefile | 1 - demux/demux_lavf.c | 16 ++++++++++++---- sub/dec_sub.c | 8 +------- sub/sd_movtext.c | 56 ------------------------------------------------------ wscript_build.py | 1 - 5 files changed, 13 insertions(+), 69 deletions(-) delete mode 100644 sub/sd_movtext.c diff --git a/TOOLS/old-makefile b/TOOLS/old-makefile index c1b5079973..cf51483dd5 100644 --- a/TOOLS/old-makefile +++ b/TOOLS/old-makefile @@ -226,7 +226,6 @@ SOURCES = audio/audio.c \ sub/sd_lavc_conv.c \ sub/sd_lavf_srt.c \ sub/sd_microdvd.c \ - sub/sd_movtext.c \ sub/sd_srt.c \ ta/ta.c \ ta/ta_utils.c \ diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 2d12f5cfa2..9aa71fcaf1 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -109,6 +109,7 @@ struct format_hack { bool use_stream_ids : 1; // export the native stream IDs bool fully_read : 1; // set demuxer.fully_read flag bool image_format : 1; // expected to contain exactly 1 frame + bool utf8_subs : 1; // subtitles are (mostly) guaranteed UTF-8 // Do not confuse player's position estimation (position is into external // segment, with e.g. HLS, player knows about the playlist main file only). bool clear_filepos : 1; @@ -116,6 +117,7 @@ struct format_hack { #define BLACKLIST(fmt) {fmt, .ignore = true} #define TEXTSUB(fmt) {fmt, .fully_read = true} +#define TEXTSUB_UTF8(fmt) {fmt, .fully_read = true, .utf8_subs = true} #define IMAGEFMT(fmt) {fmt, .image_format = true} static const struct format_hack format_hacks[] = { @@ -135,10 +137,17 @@ static const struct format_hack format_hacks[] = { {"h264", .if_flags = AVFMT_NOTIMESTAMPS }, {"hevc", .if_flags = AVFMT_NOTIMESTAMPS }, - TEXTSUB("aqtitle"), TEXTSUB("ass"), TEXTSUB("jacosub"), TEXTSUB("microdvd"), + TEXTSUB("aqtitle"), TEXTSUB("jacosub"), TEXTSUB("microdvd"), TEXTSUB("mpl2"), TEXTSUB("mpsub"), TEXTSUB("pjs"), TEXTSUB("realtext"), TEXTSUB("sami"), TEXTSUB("srt"), TEXTSUB("stl"), TEXTSUB("subviewer"), - TEXTSUB("subviewer1"), TEXTSUB("vplayer"), TEXTSUB("webvtt"), + TEXTSUB("subviewer1"), TEXTSUB("vplayer"), + + TEXTSUB_UTF8("webvtt"), + TEXTSUB_UTF8("ass"), + + // Formats which support muxed subtitles, and always use UTF-8 for them. + {"mov", .utf8_subs = true}, + {"mkv", .utf8_subs = true}, // Useless non-sense, sometimes breaks MLP2 subreader.c fallback BLACKLIST("tty"), @@ -613,8 +622,7 @@ static void handle_stream(demuxer_t *demuxer, int i) } } - if (matches_avinputformat_name(priv, "ass")) - sh_sub->is_utf8 = true; + sh_sub->is_utf8 = priv->format_hack.utf8_subs; break; } diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 44c1d0a8a7..dffec03983 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -34,7 +34,6 @@ extern const struct sd_functions sd_ass; extern const struct sd_functions sd_lavc; -extern const struct sd_functions sd_movtext; extern const struct sd_functions sd_srt; extern const struct sd_functions sd_microdvd; extern const struct sd_functions sd_lavf_srt; @@ -45,7 +44,6 @@ static const struct sd_functions *const sd_list[] = { &sd_ass, #endif &sd_lavc, - &sd_movtext, &sd_srt, &sd_lavf_srt, &sd_microdvd, @@ -391,11 +389,7 @@ bool sub_read_all_packets(struct dec_sub *sub, struct sh_stream *sh) talloc_free(pkt); } - // movtext is currently the only subtitle format that has text output, - // but binary input. Skip charset conversion (they're UTF-8 anyway). - bool binary = sub->sd[0]->driver == &sd_movtext; - - if (opts->sub_cp && !sh->sub->is_utf8 && !binary) + if (opts->sub_cp && !sh->sub->is_utf8) sub->charset = guess_sub_cp(sub->log, sub, subs, opts->sub_cp); if (sub->charset && sub->charset[0] && !mp_charset_is_utf8(sub->charset)) diff --git a/sub/sd_movtext.c b/sub/sd_movtext.c deleted file mode 100644 index 3038a4c132..0000000000 --- a/sub/sd_movtext.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see . - */ - -#include -#include - -#include -#include - -#include "sd.h" - -static bool supports_format(const char *format) -{ - return format && strcmp(format, "mov_text") == 0; -} - -static int init(struct sd *sd) -{ - sd->output_codec = "text"; - return 0; -} - -static void decode(struct sd *sd, struct demux_packet *packet) -{ - unsigned char *data = packet->buffer; - int len = packet->len; - if (len < 2) - return; - len = FFMIN(len - 2, AV_RB16(data)); - data += 2; - if (len > 0) - sd_conv_add_packet(sd, data, len, packet->pts, packet->duration); -} - -const struct sd_functions sd_movtext = { - .name = "movtext", - .supports_format = supports_format, - .init = init, - .decode = decode, - .get_converted = sd_conv_def_get_converted, - .reset = sd_conv_def_reset, -}; diff --git a/wscript_build.py b/wscript_build.py index 12199f1e86..7ac33c8764 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -262,7 +262,6 @@ def build(ctx): ( "sub/sd_lavc_conv.c" ), ( "sub/sd_lavf_srt.c" ), ( "sub/sd_microdvd.c" ), - ( "sub/sd_movtext.c" ), ( "sub/sd_srt.c" ), ## Video -- cgit v1.2.3