1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 00:42:57 +00:00

Revert "loadfile: use mp_match_lang_single"

This reverts commit 76009bf7a6192b9eddc8d4c21a17133bf6352b2b.
This commit is contained in:
Kacper Michajłow 2024-04-17 18:10:15 +02:00
parent b7216d5d03
commit 65c71b1643
2 changed files with 11 additions and 12 deletions

View File

@ -5,11 +5,10 @@ Track Selection
---------------
``--alang=<languagecode[,languagecode,...]>``
Specify a priority list of audio languages to use, as IETF language tags.
Equivalent ISO 639-1 two-letter and ISO 639-2 three-letter codes are treated the same.
The first tag in the list whose language matches a track in the file will be used.
A track that matches more subtags will be preferred over one that matches fewer,
with preference given to earlier subtags over later ones. See also ``--aid``.
Specify a priority list of audio languages to use. Different container
formats employ different language codes. DVDs use ISO 639-1 two-letter
language codes, Matroska, MPEG-TS and NUT use ISO 639-2 three-letter
language codes, while OGM uses a free-form identifier. See also ``--aid``.
This is a string list option. See `List Options`_ for details.
@ -21,7 +20,10 @@ Track Selection
audio.
``--slang=<languagecode[,languagecode,...]>``
Equivalent to ``--alang``, for subtitle tracks.
Specify a priority list of subtitle languages to use. Different container
formats employ different language codes. DVDs use ISO 639-1 two letter
language codes, Matroska uses ISO 639-2 three letter language codes while
OGM uses a free-form identifier. See also ``--sid``.
This is a string list option. See `List Options`_ for details.
@ -31,8 +33,6 @@ Track Selection
a DVD and falls back on English if Hungarian is not available.
- ``mpv --slang=jpn example.mkv`` plays a Matroska file with Japanese
subtitles.
- ``mpv --slang=pt-BR example.mkv`` plays a Matroska file with Brazilian
Portuguese subtitles if available, and otherwise any Portuguese subtitles.
``--vlang=<...>``
Equivalent to ``--alang`` and ``--slang``, for video tracks.

View File

@ -455,9 +455,8 @@ static int match_lang(char **langs, const char *lang)
if (!lang)
return 0;
for (int idx = 0; langs && langs[idx]; idx++) {
int score = mp_match_lang_single(langs[idx], lang);
if (score > 0)
return INT_MAX - (idx + 1) * LANGUAGE_SCORE_MAX + score - 1;
if (lang && strcasecmp(langs[idx], lang) == 0)
return INT_MAX - idx;
}
return 0;
}
@ -617,7 +616,7 @@ struct track *select_default_track(struct MPContext *mpctx, int order,
continue;
if (sub) {
// Subtitle specific auto-selecting crap.
bool audio_matches = mp_match_lang_single(audio_lang, track->lang);
bool audio_matches = audio_lang && track->lang && !strcasecmp(audio_lang, track->lang);
bool forced = track->forced_track && (opts->subs_fallback_forced == 2 ||
(audio_matches && opts->subs_fallback_forced == 1));
bool lang_match = !os_langs && match_lang(langs, track->lang) > 0;