[libbluray-devel] mobj_parse(): take disc root path instead of MovieObject.bdmv file path
hpi1
git at videolan.org
Tue Apr 1 15:01:41 CEST 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr 1 12:03:23 2014 +0300| [8ed5ea47d7df9fb02a531acc0629fbfa79fefe58] | committer: hpi1
mobj_parse(): take disc root path instead of MovieObject.bdmv file path
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=8ed5ea47d7df9fb02a531acc0629fbfa79fefe58
---
src/Makefile.am | 3 ++-
src/examples/mobj_dump.c | 5 +----
src/libbluray/hdmv/hdmv_vm.c | 6 +-----
src/libbluray/hdmv/mobj_parse.c | 32 +++++++++++++++-----------------
src/libbluray/hdmv/mobj_parse.h | 2 +-
5 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 9daeef9..65a87ae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -252,7 +252,8 @@ mobj_dump_SOURCES = \
libbluray/hdmv/mobj_parse.c \
libbluray/hdmv/mobj_print.c \
util/bits.c \
- util/logging.c
+ util/logging.c \
+ util/strutl.c
if HAVE_WIN32
mobj_dump_SOURCES += \
file/file_win32.c
diff --git a/src/examples/mobj_dump.c b/src/examples/mobj_dump.c
index f61a96a..9ae05cd 100644
--- a/src/examples/mobj_dump.c
+++ b/src/examples/mobj_dump.c
@@ -53,7 +53,6 @@ static void _mobj_print(MOBJ_OBJECTS *objects, int disasm)
int main(int argc, const char *argv[])
{
- char file[1024];
int disasm = 0;
MOBJ_OBJECTS *mobj = NULL;
@@ -69,9 +68,7 @@ int main(int argc, const char *argv[])
disasm = !strcmp(argv[1], "-d");
}
- sprintf(file, "%s/BDMV/MovieObject.bdmv", argv[argc-1]);
-
- mobj = mobj_parse(file);
+ mobj = mobj_parse(argv[argc-1]);
if (mobj) {
_mobj_print(mobj, disasm);
diff --git a/src/libbluray/hdmv/hdmv_vm.c b/src/libbluray/hdmv/hdmv_vm.c
index 008ba47..60e5a77 100644
--- a/src/libbluray/hdmv/hdmv_vm.c
+++ b/src/libbluray/hdmv/hdmv_vm.c
@@ -24,7 +24,6 @@
#include "../register.h"
#include "util/macro.h"
-#include "util/strutl.h"
#include "util/logging.h"
#include "util/mutex.h"
@@ -244,7 +243,6 @@ HDMV_VM *hdmv_vm_init(const char *disc_root, BD_REGISTERS *regs,
unsigned num_titles, unsigned first_play_available, unsigned top_menu_available)
{
HDMV_VM *p = calloc(1, sizeof(HDMV_VM));
- char *file;
if (!p) {
BD_DEBUG(DBG_CRIT, "out of memory\n");
@@ -252,9 +250,7 @@ HDMV_VM *hdmv_vm_init(const char *disc_root, BD_REGISTERS *regs,
}
/* read movie objects */
- file = str_printf("%s/BDMV/MovieObject.bdmv", disc_root);
- p->movie_objects = mobj_parse(file);
- X_FREE(file);
+ p->movie_objects = mobj_parse(disc_root);
if (!p->movie_objects) {
X_FREE(p);
return NULL;
diff --git a/src/libbluray/hdmv/mobj_parse.c b/src/libbluray/hdmv/mobj_parse.c
index d9db0b0..dafaf6c 100644
--- a/src/libbluray/hdmv/mobj_parse.c
+++ b/src/libbluray/hdmv/mobj_parse.c
@@ -21,6 +21,8 @@
#include "util/bits.h"
#include "util/logging.h"
#include "util/macro.h"
+#include "util/strutl.h"
+
#include "mobj_parse.h"
#include <stdlib.h>
@@ -182,25 +184,21 @@ static MOBJ_OBJECTS *_mobj_parse(const char *file_name)
return NULL;
}
-MOBJ_OBJECTS *mobj_parse(const char *file_name)
+MOBJ_OBJECTS *mobj_parse(const char *disc_root)
{
- MOBJ_OBJECTS *objects = _mobj_parse(file_name);
-
- /* if failed, try backup file */
- if (!objects) {
- size_t len = strlen(file_name);
- char *backup = malloc(len + 8);
- if (!backup) {
- return NULL;
- }
-
- strcpy(backup, file_name);
- strcpy(backup + len - 16, "BACKUP/MovieObject.bdmv");
-
- objects = _mobj_parse(backup);
-
- X_FREE(backup);
+ MOBJ_OBJECTS *objects;
+ char *file;
+
+ file = str_printf("%s/BDMV/MovieObject.bdmv", disc_root);
+ objects = _mobj_parse(file);
+ X_FREE(file);
+ if (objects) {
+ return objects;
}
+ /* if failed, try backup file */
+ file = str_printf("%s/BDMV/BACKUP/MovieObject.bdmv", disc_root);
+ objects = _mobj_parse(file);
+ X_FREE(file);
return objects;
}
diff --git a/src/libbluray/hdmv/mobj_parse.h b/src/libbluray/hdmv/mobj_parse.h
index ecb625a..123c511 100644
--- a/src/libbluray/hdmv/mobj_parse.h
+++ b/src/libbluray/hdmv/mobj_parse.h
@@ -62,7 +62,7 @@ typedef struct {
} MOBJ_OBJECTS;
-BD_PRIVATE MOBJ_OBJECTS* mobj_parse(const char *path) BD_ATTR_MALLOC; /* parse MovieObject.bdmv */
+BD_PRIVATE MOBJ_OBJECTS* mobj_parse(const char *disc_root) BD_ATTR_MALLOC; /* parse MovieObject.bdmv */
BD_PRIVATE void mobj_parse_cmd(uint8_t *buf, MOBJ_CMD *cmd);
BD_PRIVATE void mobj_free(MOBJ_OBJECTS **index);
More information about the libbluray-devel
mailing list