1
mirror of https://github.com/mpv-player/mpv synced 2025-06-10 12:43:44 +02:00

option for sub match fuzziness level

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9894 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
henry 2003-04-09 18:04:29 +00:00
parent 9c0fe0747b
commit a024c7fe90
4 changed files with 32 additions and 11 deletions

@ -1081,9 +1081,19 @@ Tells MPlayer to handle the subtitle file as UTF8.
Disables any kind of text post processing done after loading the subtitles. Disables any kind of text post processing done after loading the subtitles.
Used for debug purposes. Used for debug purposes.
.TP .TP
.B \-subfuzzy .B \-sub-fuzziness
Relax when trying to find matching subtitles. Loads all subtitles in Adjust matching fuzziness when searching for subtitles:
the current directory, allowing to select the right ones during playing. .PD 0
.RSs
.IPs 0
exact match
.IPs 1
load all subs containing movie name
.IPs 2
load all subs in the current directory
.RE
.PD 1
.
.TP .TP
.B \-vobsub <vobsub\ file\ without\ extension> .B \-vobsub <vobsub\ file\ without\ extension>
Specify the VobSub files that are to be used for subtitle. Specify the VobSub files that are to be used for subtitle.

@ -212,7 +212,7 @@
{"sub-bg-color", &sub_bg_color, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, {"sub-bg-color", &sub_bg_color, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL},
{"sub-bg-alpha", &sub_bg_alpha, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL}, {"sub-bg-alpha", &sub_bg_alpha, CONF_TYPE_INT, CONF_RANGE, 0, 255, NULL},
{"sub-no-text-pp", &sub_no_text_pp, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"sub-no-text-pp", &sub_no_text_pp, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"subfuzzy", &subfuzzy_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"sub-fuzziness", &sub_match_fuzziness, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL},
#endif #endif
#ifdef USE_OSD #ifdef USE_OSD
{"font", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"font", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL},

@ -40,7 +40,7 @@ static int sub_slacktime = 20000; //20 sec
int sub_no_text_pp=0; // 1 => do not apply text post-processing int sub_no_text_pp=0; // 1 => do not apply text post-processing
// like {\...} elimination in SSA format. // like {\...} elimination in SSA format.
int subfuzzy_enabled=0; // be _really_ fuzzy when looking for subtitles int sub_match_fuzziness=0; // level of sub name matching fuzziness
/* Use the SUB_* constant defined in the header file */ /* Use the SUB_* constant defined in the header file */
int sub_format=SUB_INVALID; int sub_format=SUB_INVALID;
@ -1574,7 +1574,10 @@ typedef struct _subfn
static int compare_sub_priority(const void *a, const void *b) static int compare_sub_priority(const void *a, const void *b)
{ {
return ((subfn*)a)->priority < ((subfn*)b)->priority; int ret;
ret = ((subfn*)a)->priority < ((subfn*)b)->priority;
if (ret != 0) return ret;
return strcoll(((subfn*)a)->fname, ((subfn*)b)->fname);
} }
char** sub_filenames(char* path, char *fname) char** sub_filenames(char* path, char *fname)
@ -1663,9 +1666,17 @@ char** sub_filenames(char* path, char *fname)
// we have a (likely) subtitle file // we have a (likely) subtitle file
if (found) { if (found) {
if (strcmp(tmp_fname_trim, f_fname_trim) == 0) {
// matches the movie name?
sprintf(tmpresult, "%s%s", f_dir, de->d_name);
if ((f = fopen(tmpresult, "rt"))) {
fclose(f);
result[subcnt].priority = 4;
result[subcnt].fname = strdup(tmpresult);
subcnt++;
}
} else if ((tmp = strstr(tmp_fname_trim, f_fname_trim)) && (sub_match_fuzziness >= 1)) {
// does it contain the movie name? // does it contain the movie name?
tmp = strstr(tmp_fname_trim, f_fname_trim);
if (tmp) {
tmp += strlen(f_fname_trim); tmp += strlen(f_fname_trim);
if (tmp_sub_id && strstr(tmp, tmp_sub_id)) { if (tmp_sub_id && strstr(tmp, tmp_sub_id)) {
// with sub_id specified prefer localized subtitles // with sub_id specified prefer localized subtitles
@ -1698,7 +1709,7 @@ char** sub_filenames(char* path, char *fname)
} else { } else {
// doesn't contain the movie name // doesn't contain the movie name
// don't try in the mplayer subtitle directory // don't try in the mplayer subtitle directory
if ((j == 0) && subfuzzy_enabled) { if ((j == 0) && (sub_match_fuzziness >= 2)) {
sprintf(tmpresult, "%s%s", f_dir, de->d_name); sprintf(tmpresult, "%s%s", f_dir, de->d_name);
if ((f = fopen(tmpresult, "rt"))) { if ((f = fopen(tmpresult, "rt"))) {
fclose(f); fclose(f);

@ -3,7 +3,7 @@
extern int suboverlap_enabled; extern int suboverlap_enabled;
extern int sub_no_text_pp; // disable text post-processing extern int sub_no_text_pp; // disable text post-processing
extern int subfuzzy_enabled; extern int sub_match_fuzziness;
// subtitle formats // subtitle formats
#define SUB_INVALID -1 #define SUB_INVALID -1