From c6b03be894750b4939e79c4a51c11ad0a63589d5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 17 Apr 2013 18:34:11 +0200 Subject: core: display subtitle codec in track listing Also switch the subrip and subviewer names, which obviously have been confused. --- core/mplayer.c | 11 +++++++++-- sub/subreader.c | 5 +++-- sub/subreader.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/mplayer.c b/core/mplayer.c index a7fe7618df..3b6dd3984f 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -275,8 +275,10 @@ static void print_stream(struct MPContext *mpctx, struct track *t, int id) if (t->title) mp_msg(MSGT_CPLAYER, MSGL_INFO, " '%s'", t->title); const char *codec = s ? s->codec : NULL; - if (t->sh_sub) // external subs hack + if (!codec && t->sh_sub) // external subs hack codec = t->sh_sub->gsh->codec; + if (!codec && t->subdata) + codec = t->subdata->codec; mp_msg(MSGT_CPLAYER, MSGL_INFO, " (%s)", codec ? codec : ""); if (t->is_external) mp_msg(MSGT_CPLAYER, MSGL_INFO, " (external)"); @@ -908,16 +910,21 @@ struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename, struct ass_track *asst = mp_ass_read_stream(mpctx->ass_library, filename, sub_cp); bool is_native_ass = asst; + const char *codec = NULL; if (!asst) { subd = sub_read_file(filename, fps, &mpctx->opts); if (subd) { + codec = subd->codec; asst = mp_ass_read_subdata(mpctx->ass_library, opts, subd, fps); talloc_free(subd); subd = NULL; } } - if (asst) + if (asst) { sh = sd_ass_create_from_track(asst, is_native_ass, opts); + if (codec) + sh->gsh->codec = codec; + } #endif } else subd = sub_read_file(filename, fps, &mpctx->opts); diff --git a/sub/subreader.c b/sub/subreader.c index bdcc79a64a..23da4c79e5 100644 --- a/sub/subreader.c +++ b/sub/subreader.c @@ -1324,8 +1324,8 @@ sub_data* sub_read_file(char *filename, float fps, struct MPOpts *opts) static const struct subreader sr[]= { { sub_read_line_microdvd, NULL, "microdvd" }, - { sub_read_line_subrip, NULL, "subrip" }, - { sub_read_line_subviewer, NULL, "subviewer" }, + { sub_read_line_subrip, NULL, "subviewer" }, + { sub_read_line_subviewer, NULL, "subrip" }, { sub_read_line_sami, NULL, "sami" }, { sub_read_line_vplayer, NULL, "vplayer" }, { sub_read_line_rt, NULL, "rt" }, @@ -1684,6 +1684,7 @@ if ((suboverlap_enabled == 2) || if (return_sub == NULL) return NULL; subt_data = talloc_zero(NULL, sub_data); talloc_set_destructor(subt_data, sub_destroy); + subt_data->codec = srp->name; subt_data->filename = strdup(filename); subt_data->sub_uses_time = uses_time; subt_data->sub_num = sub_num; diff --git a/sub/subreader.h b/sub/subreader.h index 4584f2366a..7a2316bdf1 100644 --- a/sub/subreader.h +++ b/sub/subreader.h @@ -72,6 +72,7 @@ typedef struct subtitle { } subtitle; typedef struct sub_data { + const char *codec; subtitle *subtitles; char *filename; int sub_uses_time; -- cgit v1.2.3