[Mplayer-cvslog] CVS: main vobsub.c,1.4,1.5 vobsub.h,1.2,1.3 mplayer.c,1.399,1.400

Atmosfear atmos4 at mplayer.dev.hu
Thu Feb 21 16:44:54 CET 2002


Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv3957

Modified Files:
	vobsub.c vobsub.h mplayer.c 
Log Message:
Fix automatic vobsub detection and make it silent.


Index: vobsub.c
===================================================================
RCS file: /cvsroot/mplayer/main/vobsub.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- vobsub.c	21 Feb 2002 14:34:52 -0000	1.4
+++ vobsub.c	21 Feb 2002 15:44:51 -0000	1.5
@@ -589,7 +589,7 @@
 }
 
 void *
-vobsub_open(const char *const name)
+vobsub_open(const char *const name, const int force)
 {
     vobsub_t *vob = malloc(sizeof(vobsub_t));
     if (vob) {
@@ -605,9 +605,10 @@
 	    strcpy(buf, name);
 	    strcat(buf, ".ifo");
 	    fd = fopen(buf, "rb");
-	    if (fd == NULL)
-		perror("VobSub: Can't open IFO file");
-	    else {
+	    if (fd == NULL) {
+		if(force)
+                    perror("VobSub: Can't open IFO file");
+	    } else {
 		// parse IFO header
 		unsigned char block[0x800];
 		const char *const ifo_magic = "DVDVIDEO-VTS";
@@ -660,9 +661,12 @@
 	    strcpy(buf, name);
 	    strcat(buf, ".idx");
 	    fd = fopen(buf, "rb");
-	    if (fd == NULL)
-		perror("VobSub: Can't open IDX file");
-	    else {
+	    if (fd == NULL) {
+		if(force)
+                    perror("VobSub: Can't open IDX file");
+                else
+                    return NULL;
+	    } else {
 		while (vobsub_parse_one_line(vob, fd) >= 0)
 		    /* NOOP */ ;
 		fclose(fd);
@@ -672,9 +676,10 @@
 	    strcpy(buf, name);
 	    strcat(buf, ".sub");
 	    mpg = mpeg_open(buf);
-	    if (mpg == NULL)
-		perror("VobSub: Can't open SUB file");
-	    else {
+	    if (mpg == NULL) {
+                if(force)
+		    perror("VobSub: Can't open SUB file");
+	    } else {
 		long last_pts_diff = 0;
 		while (!mpeg_eof(mpg)) {
 		    off_t pos = mpeg_tell(mpg);

Index: vobsub.h
===================================================================
RCS file: /cvsroot/mplayer/main/vobsub.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vobsub.h	27 Jan 2002 17:21:20 -0000	1.2
+++ vobsub.h	21 Feb 2002 15:44:51 -0000	1.3
@@ -1,7 +1,7 @@
 #ifndef 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_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));

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.399
retrieving revision 1.400
diff -u -r1.399 -r1.400
--- mplayer.c	20 Feb 2002 22:41:06 -0000	1.399
+++ mplayer.c	21 Feb 2002 15:44:51 -0000	1.400
@@ -766,7 +766,7 @@
 
     current_module="vobsub";
     if (vobsub_name){
-      vo_vobsub=vobsub_open(vobsub_name);
+      vo_vobsub=vobsub_open(vobsub_name,1);
       if(vo_vobsub==NULL)
         mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,vobsub_name);
     }else if(sub_auto && filename && (strlen(filename)>=5)){
@@ -774,7 +774,7 @@
       char *buf = malloc((strlen(filename)-3) * sizeof(char));
       memset(buf,0,strlen(filename)-3); // make sure string is terminated
       strncpy(buf, filename, strlen(filename)-4); 
-      vo_vobsub=vobsub_open(buf);
+      vo_vobsub=vobsub_open(buf,0);
       free(buf);
     }
     if(vo_vobsub)




More information about the MPlayer-cvslog mailing list