[PATCH] check backup IFO files
Keith Lyon <[email protected]> Thu, 1 Apr 2004 11:51:03 -0700
| Newsgroups | gmane.comp.video.ogle.devel |
|---|---|
| Message-ID | <[email protected]> |
in case there are any errors reading the IFO files, this patch will check the backups. its pretty uncommon, but i've found several discs that won't play without this. -- Keith Lyon <[email protected]>
ifo_read.diff
(text/x-diff, 6 KB)
Index: ifo_read.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/input/libdvdnav/ifo_read.c,v
retrieving revision 1.4
diff -u -r1.4 ifo_read.c
--- ifo_read.c 23 Feb 2004 18:15:11 -0000 1.4
+++ ifo_read.c 1 Apr 2004 18:05:32 -0000
@@ -88,6 +88,9 @@
static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl);
static void ifoFree_PGCIT_internal(pgcit_t *pgcit);
+ifo_handle_t *ifoOpen_File(ifo_handle_t *ifofile, int title, char *suffix);
+ifo_handle_t *ifoOpenVMGI_File(ifo_handle_t *ifofile, char *suffix);
+ifo_handle_t *ifoOpenVTSI_File(ifo_handle_t *ifofile, int title, char *suffix);
static inline int DVDFileSeek_( dvd_file_t *dvd_file, uint32_t offset ) {
return (DVDFileSeek(dvd_file, (int)offset) == (int)offset);
@@ -104,13 +107,27 @@
memset(ifofile, 0, sizeof(ifo_handle_t));
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE);
- if(!ifofile->file) /* Should really catch any error and try to fallback */
+ if(!ifoOpen_File(ifofile, title, "IFO")) {
+ /* lower functions free the pointer, reallocate */
+ ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t));
+ if(!ifofile)
+ return 0;
+
+ memset(ifofile, 0, sizeof(ifo_handle_t));
+
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE);
+ if(!ifoOpen_File(ifofile, title, "BUP"))
+ return 0;
+ }
+ return ifofile;
+}
+
+ifo_handle_t *ifoOpen_File(ifo_handle_t *ifofile, int title, char *suffix) {
if(!ifofile->file) {
if(title) {
- fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title);
+ fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.%s.\n", title, suffix);
} else {
- fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n");
+ fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.%s.\n", suffix);
}
free(ifofile);
return 0;
@@ -121,7 +138,7 @@
/* These are both mandatory. */
if(!ifoRead_FP_PGC(ifofile) || !ifoRead_TT_SRPT(ifofile)) {
- fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n");
+ fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.%s).\n", suffix);
ifoClose(ifofile);
return 0;
}
@@ -131,7 +148,7 @@
/* This is also mandatory. */
if(!ifoRead_VTS_ATRT(ifofile)) {
- fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n");
+ fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.%s).\n", suffix);
ifoClose(ifofile);
return 0;
}
@@ -146,8 +163,8 @@
if(ifoRead_VTS(ifofile)) {
if(!ifoRead_VTS_PTT_SRPT(ifofile) || !ifoRead_PGCIT(ifofile)) {
- fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.IFO).\n",
- title);
+ fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.%s).\n",
+ title, suffix);
ifoClose(ifofile);
return 0;
}
@@ -159,8 +176,8 @@
ifoRead_VOBU_ADMAP(ifofile);
if(!ifoRead_TITLE_C_ADT(ifofile) || !ifoRead_TITLE_VOBU_ADMAP(ifofile)) {
- fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.IFO).\n",
- title);
+ fprintf(stderr, "libdvdread: Invalid title IFO (VTS_%02d_0.%s).\n",
+ title, suffix);
ifoClose(ifofile);
return 0;
}
@@ -169,10 +186,10 @@
}
if(title) {
- fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.IFO).\n",
- title, title);
+ fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.%s).\n",
+ title, title, suffix);
} else {
- fprintf(stderr, "libdvdread: Invalid IFO for VMGM (VIDEO_TS.IFO).\n");
+ fprintf(stderr, "libdvdread: Invalid IFO for VMGM (VIDEO_TS.%s).\n", suffix);
}
ifoClose(ifofile);
return 0;
@@ -189,10 +206,24 @@
memset(ifofile, 0, sizeof(ifo_handle_t));
ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_FILE);
- if(!ifofile->file) /* Should really catch any error and try to fallback */
+ if(!ifoOpenVMGI_File(ifofile, "IFO")) {
+ /* lower functions free the pointer, reallocate */
+ ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t));
+ if(!ifofile)
+ return 0;
+
+ memset(ifofile, 0, sizeof(ifo_handle_t));
+
ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_BACKUP_FILE);
+ if(!ifoOpenVMGI_File(ifofile, "BUP"))
+ return 0;
+ }
+ return ifofile;
+}
+
+ifo_handle_t *ifoOpenVMGI_File(ifo_handle_t *ifofile, char *suffix) {
if(!ifofile->file) {
- fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.IFO.\n");
+ fprintf(stderr, "libdvdread: Can't open file VIDEO_TS.%s.\n", suffix);
free(ifofile);
return 0;
}
@@ -200,7 +231,7 @@
if(ifoRead_VMG(ifofile))
return ifofile;
- fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.IFO).\n");
+ fprintf(stderr, "libdvdread: Invalid main menu IFO (VIDEO_TS.%s).\n", suffix);
ifoClose(ifofile);
return 0;
}
@@ -222,10 +253,24 @@
}
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE);
- if(!ifofile->file) /* Should really catch any error and try to fallback */
+ if(!ifoOpenVTSI_File(ifofile, title, "IFO")) {
+ /* lower functions free the pointer, reallocate */
+ ifofile = (ifo_handle_t *)malloc(sizeof(ifo_handle_t));
+ if(!ifofile)
+ return 0;
+
+ memset(ifofile, 0, sizeof(ifo_handle_t));
+
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE);
+ if(!ifoOpenVTSI_File(ifofile, title, "BUP"))
+ return 0;
+ }
+ return ifofile;
+}
+
+ifo_handle_t *ifoOpenVTSI_File(ifo_handle_t* ifofile, int title, char *suffix) {
if(!ifofile->file) {
- fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.IFO.\n", title);
+ fprintf(stderr, "libdvdread: Can't open file VTS_%02d_0.%s.\n", title, suffix);
free(ifofile);
return 0;
}
@@ -234,8 +279,8 @@
if(ifofile->vtsi_mat)
return ifofile;
- fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.IFO).\n",
- title, title);
+ fprintf(stderr, "libdvdread: Invalid IFO for title %d (VTS_%02d_0.%s).\n",
+ title, title, suffix);
ifoClose(ifofile);
return 0;
}