Mercurial > mplayer.hg
comparison mplayer.c @ 32724:732cd2afae10
Replace hacky vobsub loading with a new clean one.
author | cboesch |
---|---|
date | Sun, 23 Jan 2011 13:04:15 +0000 |
parents | d39425c8fe53 |
children | 736b22f11e00 |
comparison
equal
deleted
inserted
replaced
32723:5310794ef052 | 32724:732cd2afae10 |
---|---|
28 #include <stdio.h> | 28 #include <stdio.h> |
29 #include <stdlib.h> | 29 #include <stdlib.h> |
30 #include <string.h> | 30 #include <string.h> |
31 #include <time.h> | 31 #include <time.h> |
32 #include <unistd.h> | 32 #include <unistd.h> |
33 #include <assert.h> | |
33 #include <sys/stat.h> | 34 #include <sys/stat.h> |
34 #include <sys/time.h> | 35 #include <sys/time.h> |
35 #include <sys/types.h> | 36 #include <sys/types.h> |
36 | 37 |
37 #if defined(__MINGW32__) || defined(__CYGWIN__) | 38 #if defined(__MINGW32__) || defined(__CYGWIN__) |
1077 ++mpctx->set_of_sub_size; | 1078 ++mpctx->set_of_sub_size; |
1078 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, mpctx->set_of_sub_size, | 1079 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AddedSubtitleFile, mpctx->set_of_sub_size, |
1079 filename_recode(filename)); | 1080 filename_recode(filename)); |
1080 } | 1081 } |
1081 | 1082 |
1083 static int add_vob_subtitle(const char *vobname, const char * const ifo, int force, void *spu) | |
1084 { | |
1085 if (!vobname) | |
1086 return 0; | |
1087 | |
1088 assert(!vo_vobsub); | |
1089 | |
1090 vo_vobsub = vobsub_open(vobname, ifo, force, spu); | |
1091 | |
1092 if (!vo_vobsub && force) | |
1093 mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_CantLoadSub, | |
1094 filename_recode(vobname)); | |
1095 | |
1096 return !!vo_vobsub; | |
1097 } | |
1098 | |
1082 // FIXME: if/when the GUI calls this, global sub numbering gets (potentially) broken. | 1099 // FIXME: if/when the GUI calls this, global sub numbering gets (potentially) broken. |
1083 void update_set_of_subtitles(void) | 1100 void update_set_of_subtitles(void) |
1084 // subdata was changed, set_of_sub... have to be updated. | 1101 // subdata was changed, set_of_sub... have to be updated. |
1085 { | 1102 { |
1086 sub_data ** const set_of_subtitles = mpctx->set_of_subtitles; | 1103 sub_data ** const set_of_subtitles = mpctx->set_of_subtitles; |
3132 } | 3149 } |
3133 | 3150 |
3134 //==================== Open VOB-Sub ============================ | 3151 //==================== Open VOB-Sub ============================ |
3135 | 3152 |
3136 current_module="vobsub"; | 3153 current_module="vobsub"; |
3137 if (vobsub_name){ | 3154 load_vob_subtitle(filename, spudec_ifo, &vo_spudec, add_vob_subtitle); |
3138 vo_vobsub=vobsub_open(vobsub_name,spudec_ifo,1,&vo_spudec); | |
3139 if(vo_vobsub==NULL) | |
3140 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub, | |
3141 filename_recode(vobsub_name)); | |
3142 } else if (sub_auto && filename){ | |
3143 /* try to autodetect vobsub from movie filename ::atmos */ | |
3144 char *buf = strdup(filename), *psub; | |
3145 char *pdot = strrchr(buf, '.'); | |
3146 char *pslash = strrchr(buf, '/'); | |
3147 #if defined(__MINGW32__) || defined(__CYGWIN__) | |
3148 if (!pslash) pslash = strrchr(buf, '\\'); | |
3149 #endif | |
3150 if (pdot && (!pslash || pdot > pslash)) | |
3151 *pdot = '\0'; | |
3152 vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec); | |
3153 /* try from ~/.mplayer/sub */ | |
3154 if(!vo_vobsub && (psub = get_path( "sub/" ))) { | |
3155 const char *bname = mp_basename(buf); | |
3156 int l; | |
3157 l = strlen(psub) + strlen(bname) + 1; | |
3158 psub = realloc(psub,l); | |
3159 strcat(psub,bname); | |
3160 vo_vobsub=vobsub_open(psub,spudec_ifo,0,&vo_spudec); | |
3161 free(psub); | |
3162 } | |
3163 free(buf); | |
3164 } | |
3165 if(vo_vobsub){ | 3155 if(vo_vobsub){ |
3166 initialized_flags|=INITIALIZED_VOBSUB; | 3156 initialized_flags|=INITIALIZED_VOBSUB; |
3167 vobsub_set_from_lang(vo_vobsub, dvdsub_lang); | 3157 vobsub_set_from_lang(vo_vobsub, dvdsub_lang); |
3168 mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, mpctx); | 3158 mp_property_do("sub_forced_only", M_PROPERTY_SET, &forced_subs_only, mpctx); |
3169 | 3159 |