[libbluray-devel] Try backup file if parsing of index.bdmv, MovieObject.bdmv, *.mpls or *. clpi file fails. (BACKUP/index.bdmv, BACKUP/MovieObject.bdmv, ...)

hpi1 git at videolan.org
Wed Oct 19 13:34:31 CEST 2011


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Jul  3 16:22:17 2011 +0300| [154995972c104ab3ddb42a6912bd72db5b58ad18] | committer: hpi1

Try backup file if parsing of index.bdmv, MovieObject.bdmv, *.mpls or *.clpi file fails. (BACKUP/index.bdmv, BACKUP/MovieObject.bdmv, ...)

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=154995972c104ab3ddb42a6912bd72db5b58ad18
---

 src/libbluray/bdnav/clpi_parse.c  |   26 ++++++++++++++++++++++++--
 src/libbluray/bdnav/index_parse.c |   22 +++++++++++++++++++++-
 src/libbluray/bdnav/mpls_parse.c  |   25 +++++++++++++++++++++++--
 src/libbluray/bdnav/mpls_parse.h  |    2 +-
 src/libbluray/hdmv/mobj_parse.c   |   23 ++++++++++++++++++++++-
 5 files changed, 91 insertions(+), 7 deletions(-)

diff --git a/src/libbluray/bdnav/clpi_parse.c b/src/libbluray/bdnav/clpi_parse.c
index 534f462..43d9e2e 100644
--- a/src/libbluray/bdnav/clpi_parse.c
+++ b/src/libbluray/bdnav/clpi_parse.c
@@ -575,8 +575,8 @@ clpi_free(CLPI_CL *cl)
     X_FREE(cl);
 }
 
-CLPI_CL*
-clpi_parse(const char *path, int verbose)
+static CLPI_CL*
+_clpi_parse(const char *path, int verbose)
 {
     BITSTREAM  bits;
     BD_FILE_H *fp;
@@ -627,6 +627,28 @@ clpi_parse(const char *path, int verbose)
 }
 
 CLPI_CL*
+clpi_parse(const char *path, int verbose)
+{
+    CLPI_CL *cl = _clpi_parse(path, verbose);
+
+    /* if failed, try backup file */
+    if (!cl) {
+        int   len    = strlen(path);
+        char *backup = malloc(len + 8);
+
+        strncpy(backup, path, len - 18);
+        strcpy(backup + len - 18, "BACKUP/");
+        strcpy(backup + len - 18 + 7, path + len - 18);
+
+        cl = _clpi_parse(backup, verbose);
+
+        X_FREE(backup);
+    }
+
+    return cl;
+}
+
+CLPI_CL*
 clpi_copy(const CLPI_CL* src_cl)
 {
     CLPI_CL* dest_cl = NULL;
diff --git a/src/libbluray/bdnav/index_parse.c b/src/libbluray/bdnav/index_parse.c
index aa8f5b1..e0faf10 100644
--- a/src/libbluray/bdnav/index_parse.c
+++ b/src/libbluray/bdnav/index_parse.c
@@ -144,7 +144,7 @@ static int _parse_header(BITSTREAM *bs, int *index_start, int *extension_data_st
     return 1;
 }
 
-INDX_ROOT *indx_parse(const char *file_name)
+static INDX_ROOT *_indx_parse(const char *file_name)
 {
     BITSTREAM  bs;
     BD_FILE_H *fp;
@@ -188,6 +188,26 @@ INDX_ROOT *indx_parse(const char *file_name)
     return NULL;
 }
 
+INDX_ROOT *indx_parse(const char *file_name)
+{
+    INDX_ROOT *indx = _indx_parse(file_name);
+
+    /* if failed, try backup file */
+    if (!indx) {
+        int   len    = strlen(file_name);
+        char *backup = malloc(len + 8);
+
+        strcpy(backup, file_name);
+        strcpy(backup + len - 10, "BACKUP/index.bdmv");
+
+        indx = _indx_parse(backup);
+
+        X_FREE(backup);
+    }
+
+    return indx;
+}
+
 void indx_free(INDX_ROOT **p)
 {
     if (p && *p) {
diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
index b27f5a1..5c83532 100644
--- a/src/libbluray/bdnav/mpls_parse.c
+++ b/src/libbluray/bdnav/mpls_parse.c
@@ -726,8 +726,8 @@ mpls_free(MPLS_PL *pl)
     _clean_playlist(pl);
 }
 
-MPLS_PL*
-mpls_parse(char *path, int verbose)
+static MPLS_PL*
+_mpls_parse(const char *path, int verbose)
 {
     BITSTREAM  bits;
     BD_FILE_H *fp;
@@ -767,3 +767,24 @@ mpls_parse(char *path, int verbose)
     return pl;
 }
 
+MPLS_PL*
+mpls_parse(const char *path, int verbose)
+{
+    MPLS_PL *pl = _mpls_parse(path, verbose);
+
+    /* if failed, try backup file */
+    if (!pl) {
+        int   len    = strlen(path);
+        char *backup = malloc(len + 8);
+
+        strncpy(backup, path, len - 19);
+        strcpy(backup + len - 19, "BACKUP/");
+        strcpy(backup + len - 19 + 7, path + len - 19);
+
+        pl = _mpls_parse(backup, verbose);
+
+        X_FREE(backup);
+    }
+
+    return pl;
+}
diff --git a/src/libbluray/bdnav/mpls_parse.h b/src/libbluray/bdnav/mpls_parse.h
index 27d7dca..9518cae 100644
--- a/src/libbluray/bdnav/mpls_parse.h
+++ b/src/libbluray/bdnav/mpls_parse.h
@@ -148,7 +148,7 @@ typedef struct
 } MPLS_PL;
 
 
-BD_PRIVATE MPLS_PL* mpls_parse(char *path, int verbose);
+BD_PRIVATE MPLS_PL* mpls_parse(const char *path, int verbose);
 BD_PRIVATE void mpls_free(MPLS_PL *pl);
 
 BD_PRIVATE int  mpls_parse_uo(uint8_t *buf, BD_UO_MASK *uo);
diff --git a/src/libbluray/hdmv/mobj_parse.c b/src/libbluray/hdmv/mobj_parse.c
index 0b01d05..460461f 100644
--- a/src/libbluray/hdmv/mobj_parse.c
+++ b/src/libbluray/hdmv/mobj_parse.c
@@ -24,6 +24,7 @@
 #include "mobj_parse.h"
 
 #include <stdlib.h>
+#include <string.h>
 
 #define MOBJ_SIG1  ('M' << 24 | 'O' << 16 | 'B' << 8 | 'J')
 #define MOBJ_SIG2A ('0' << 24 | '2' << 16 | '0' << 8 | '0')
@@ -109,7 +110,7 @@ void mobj_free(MOBJ_OBJECTS **p)
     }
 }
 
-MOBJ_OBJECTS *mobj_parse(const char *file_name)
+static MOBJ_OBJECTS *_mobj_parse(const char *file_name)
 {
     BITSTREAM     bs;
     BD_FILE_H    *fp;
@@ -156,3 +157,23 @@ MOBJ_OBJECTS *mobj_parse(const char *file_name)
     file_close(fp);
     return NULL;
 }
+
+MOBJ_OBJECTS *mobj_parse(const char *file_name)
+{
+    MOBJ_OBJECTS *objects = _mobj_parse(file_name);
+
+    /* if failed, try backup file */
+    if (!objects) {
+        int   len    = strlen(file_name);
+        char *backup = malloc(len + 8);
+
+        strcpy(backup, file_name);
+        strcpy(backup + len - 16, "BACKUP/MovieObject.bdmv");
+
+        objects = _mobj_parse(backup);
+
+        X_FREE(backup);
+    }
+
+    return objects;
+}



More information about the libbluray-devel mailing list