summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-01-05 16:15:30 +0100
committerwm4 <wm4@nowhere>2014-01-06 20:22:53 +0100
commitc497b82583fea5350c0e306aee033742dfbee384 (patch)
tree916bb0067566ed2b6f04e6704f40a1459122145c
parent6f5dfb5102a14024bcd76036a1d953214288085d (diff)
downloadmpv-c497b82583fea5350c0e306aee033742dfbee384.tar.bz2
mpv-c497b82583fea5350c0e306aee033742dfbee384.tar.xz
player: don't select subtitles added from quvi by default
Quvi subtitles are considered external subtitles (simply because they're separate from the audio/video stream), but for the sake of subtitle auto-selection, they should not be considered external. Change this so that quvi subtitles are treated like muxed subtitles (with default flag never set). This means subtitles won't be selected by default, unless explicitly requested with --sid or --slang.
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c14
2 files changed, 10 insertions, 5 deletions
diff --git a/player/core.h b/player/core.h
index c016dcf4f7..3285e4848d 100644
--- a/player/core.h
+++ b/player/core.h
@@ -128,6 +128,7 @@ struct track {
// If this track is from an external file (e.g. subtitle file).
bool is_external;
+ bool no_default; // pretend it's not external for auto-selection
char *external_filename;
bool auto_loaded;
diff --git a/player/loadfile.c b/player/loadfile.c
index f35c63fa38..2189bc4130 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -508,7 +508,7 @@ static int match_lang(char **langs, char *lang)
* lang is a string list, NULL is same as empty list
* Sort tracks based on the following criteria, and pick the first:
* 0) track matches tid (always wins)
- * 1) track is external
+ * 1) track is external (no_default cancels this)
* 1b) track was passed explicitly (is not an auto-loaded subtitle)
* 2) earlier match in lang list
* 3) track is marked default
@@ -520,8 +520,10 @@ static int match_lang(char **langs, char *lang)
// Return whether t1 is preferred over t2
static bool compare_track(struct track *t1, struct track *t2, char **langs)
{
- if (t1->is_external != t2->is_external)
- return t1->is_external;
+ bool ext1 = t1->is_external && !t1->no_default;
+ bool ext2 = t2->is_external && !t2->no_default;
+ if (ext1 != ext2)
+ return ext1;
if (t1->auto_loaded != t2->auto_loaded)
return !t1->auto_loaded;
int l1 = match_lang(langs, t1->lang), l2 = match_lang(langs, t2->lang);
@@ -549,7 +551,7 @@ static struct track *select_track(struct MPContext *mpctx,
if (!pick || compare_track(track, pick, langs))
pick = track;
}
- if (pick && !select_fallback && !pick->is_external
+ if (pick && !select_fallback && !(pick->is_external && !pick->no_default)
&& !match_lang(langs, pick->lang) && !pick->default_track)
pick = NULL;
if (pick && pick->attached_picture && !mpctx->opts->audio_display)
@@ -839,8 +841,10 @@ static void open_subtitles_from_resolve(struct MPContext *mpctx)
struct track *t =
open_external_file(mpctx, s, opts->sub_demuxer_name, 0, STREAM_SUB);
talloc_free(s);
- if (t)
+ if (t) {
t->lang = talloc_strdup(t, sub->lang);
+ t->no_default = true;
+ }
}
}