Fix automatic vobsub detection and make it silent.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4788 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
atmos4 2002-02-21 15:44:51 +00:00
parent 49a76c3a0d
commit ea1d758009
3 changed files with 18 additions and 13 deletions

View File

@ -766,7 +766,7 @@ play_dvd:
current_module="vobsub"; current_module="vobsub";
if (vobsub_name){ if (vobsub_name){
vo_vobsub=vobsub_open(vobsub_name); vo_vobsub=vobsub_open(vobsub_name,1);
if(vo_vobsub==NULL) if(vo_vobsub==NULL)
mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name); mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name);
}else if(sub_auto && filename && (strlen(filename)>=5)){ }else if(sub_auto && filename && (strlen(filename)>=5)){
@ -774,7 +774,7 @@ play_dvd:
char *buf = malloc((strlen(filename)-3) * sizeof(char)); char *buf = malloc((strlen(filename)-3) * sizeof(char));
memset(buf,0,strlen(filename)-3); // make sure string is terminated memset(buf,0,strlen(filename)-3); // make sure string is terminated
strncpy(buf, filename, strlen(filename)-4); strncpy(buf, filename, strlen(filename)-4);
vo_vobsub=vobsub_open(buf); vo_vobsub=vobsub_open(buf,0);
free(buf); free(buf);
} }
if(vo_vobsub) if(vo_vobsub)

View File

@ -589,7 +589,7 @@ vobsub_parse_one_line(vobsub_t *vob, FILE *fd)
} }
void * void *
vobsub_open(const char *const name) vobsub_open(const char *const name, const int force)
{ {
vobsub_t *vob = malloc(sizeof(vobsub_t)); vobsub_t *vob = malloc(sizeof(vobsub_t));
if (vob) { if (vob) {
@ -605,9 +605,10 @@ vobsub_open(const char *const name)
strcpy(buf, name); strcpy(buf, name);
strcat(buf, ".ifo"); strcat(buf, ".ifo");
fd = fopen(buf, "rb"); fd = fopen(buf, "rb");
if (fd == NULL) if (fd == NULL) {
perror("VobSub: Can't open IFO file"); if(force)
else { perror("VobSub: Can't open IFO file");
} else {
// parse IFO header // parse IFO header
unsigned char block[0x800]; unsigned char block[0x800];
const char *const ifo_magic = "DVDVIDEO-VTS"; const char *const ifo_magic = "DVDVIDEO-VTS";
@ -660,9 +661,12 @@ vobsub_open(const char *const name)
strcpy(buf, name); strcpy(buf, name);
strcat(buf, ".idx"); strcat(buf, ".idx");
fd = fopen(buf, "rb"); fd = fopen(buf, "rb");
if (fd == NULL) if (fd == NULL) {
perror("VobSub: Can't open IDX file"); if(force)
else { perror("VobSub: Can't open IDX file");
else
return NULL;
} else {
while (vobsub_parse_one_line(vob, fd) >= 0) while (vobsub_parse_one_line(vob, fd) >= 0)
/* NOOP */ ; /* NOOP */ ;
fclose(fd); fclose(fd);
@ -672,9 +676,10 @@ vobsub_open(const char *const name)
strcpy(buf, name); strcpy(buf, name);
strcat(buf, ".sub"); strcat(buf, ".sub");
mpg = mpeg_open(buf); mpg = mpeg_open(buf);
if (mpg == NULL) if (mpg == NULL) {
perror("VobSub: Can't open SUB file"); if(force)
else { perror("VobSub: Can't open SUB file");
} else {
long last_pts_diff = 0; long last_pts_diff = 0;
while (!mpeg_eof(mpg)) { while (!mpeg_eof(mpg)) {
off_t pos = mpeg_tell(mpg); off_t pos = mpeg_tell(mpg);

View File

@ -1,7 +1,7 @@
#ifndef MPLAYER_VOBSUB_H #ifndef MPLAYER_VOBSUB_H
#define MPLAYER_VOBSUB_H #define MPLAYER_VOBSUB_H
extern void *vobsub_open(const char *subname); extern void *vobsub_open(const char *subname, const int force);
extern void vobsub_process(void *vob, float pts); extern void vobsub_process(void *vob, float pts);
extern void vobsub_reset(void *vob); extern void vobsub_reset(void *vob);
extern void vobsub_draw(void *vob, int dxs, int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)); extern void vobsub_draw(void *vob, int dxs, int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));