Mercurial > mplayer.hg
comparison sub/subreader.c @ 32642:7b135236a44a
Factorize subtitles loading between mplayer and mencoder.
author | cboesch |
---|---|
date | Fri, 24 Dec 2010 23:02:24 +0000 |
parents | b39155e98ac3 |
children | 651299b70463 |
comparison
equal
deleted
inserted
replaced
32641:a2822f8f5e6d | 32642:7b135236a44a |
---|---|
31 | 31 |
32 #include "ass_mp.h" | 32 #include "ass_mp.h" |
33 #include "config.h" | 33 #include "config.h" |
34 #include "mp_msg.h" | 34 #include "mp_msg.h" |
35 #include "mpcommon.h" | 35 #include "mpcommon.h" |
36 #include "path.h" | |
36 #include "subreader.h" | 37 #include "subreader.h" |
37 #include "subassconvert.h" | 38 #include "subassconvert.h" |
38 #include "sub.h" | 39 #include "sub.h" |
39 #include "stream/stream.h" | 40 #include "stream/stream.h" |
40 #include "libavutil/common.h" | 41 #include "libavutil/common.h" |
1887 } else { | 1888 } else { |
1888 return strcoll(((const subfn*)a)->fname, ((const subfn*)b)->fname); | 1889 return strcoll(((const subfn*)a)->fname, ((const subfn*)b)->fname); |
1889 } | 1890 } |
1890 } | 1891 } |
1891 | 1892 |
1892 char** sub_filenames(const char* path, char *fname) | 1893 static char **sub_filenames(const char *path, const char *fname) |
1893 { | 1894 { |
1894 char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp, *tmp_sub_id; | 1895 char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp, *tmp_sub_id; |
1895 char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult; | 1896 char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult; |
1896 | 1897 |
1897 int len, pos, found, i, j; | 1898 int len, pos, found, i, j; |
2066 result2[subcnt] = NULL; | 2067 result2[subcnt] = NULL; |
2067 | 2068 |
2068 free(result); | 2069 free(result); |
2069 | 2070 |
2070 return result2; | 2071 return result2; |
2072 } | |
2073 | |
2074 /** | |
2075 * @brief Load all subtitles matching the subtitle filename | |
2076 * | |
2077 * @param fname Path to subtitle filename | |
2078 * @param fps FPS parameter for the add subtitle function | |
2079 * @param add_f Add subtitle function to call for each sub | |
2080 */ | |
2081 void load_subtitles(const char *fname, int fps, void add_f(char *, float, int)) | |
2082 { | |
2083 int i; | |
2084 if (sub_name) | |
2085 for (i = 0; sub_name[i]; i++) | |
2086 add_f(sub_name[i], fps, 0); | |
2087 if (sub_auto && fname) { | |
2088 char *psub = get_path("sub/"); | |
2089 char **tmp = sub_filenames((psub ? psub : ""), fname); | |
2090 free(psub); | |
2091 for (i = 0; tmp[i]; i++) { | |
2092 add_f(tmp[i], fps, 1); | |
2093 free(tmp[i]); | |
2094 } | |
2095 free(tmp); | |
2096 } | |
2071 } | 2097 } |
2072 | 2098 |
2073 void list_sub_file(sub_data* subd){ | 2099 void list_sub_file(sub_data* subd){ |
2074 int i,j; | 2100 int i,j; |
2075 subtitle *subs = subd->subtitles; | 2101 subtitle *subs = subd->subtitles; |