[libbluray-devel] mobj_dump: use public API

hpi1 git at videolan.org
Tue Dec 2 12:40:34 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Dec  2 13:30:45 2014 +0200| [97620e4ee804f793e40e027cb9558f9e48a088b2] | committer: hpi1

mobj_dump: use public API

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

 src/Makefile.am                 |   18 +++---------------
 src/examples/mobj_dump.c        |    9 +++++----
 src/libbluray/bluray.c          |   11 +++++++++++
 src/libbluray/bluray.h          |    3 +++
 src/libbluray/hdmv/hdmv_vm.c    |    2 +-
 src/libbluray/hdmv/mobj_parse.c |    8 ++++----
 src/libbluray/hdmv/mobj_parse.h |    3 ++-
 src/libbluray/hdmv/mobj_print.c |   14 +++++++++++---
 8 files changed, 40 insertions(+), 28 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index bbdfd72..3085b96 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -240,21 +240,9 @@ index_dump_SOURCES = examples/index_dump.c
 index_dump_LDADD = libbluray.la
 
 mobj_dump_CFLAGS = $(AM_CFLAGS)
-mobj_dump_SOURCES = \
-	examples/mobj_dump.c \
-	file/file.c \
-	libbluray/hdmv/mobj_parse.c \
-	libbluray/hdmv/mobj_print.c \
-	util/bits.c \
-	util/logging.c \
-	util/strutl.c
-if HAVE_WIN32
-mobj_dump_SOURCES += \
-	file/file_win32.c
-else
-mobj_dump_SOURCES += \
-	file/file_posix.c
-endif
+mobj_dump_SOURCES = examples/mobj_dump.c \
+	libbluray/hdmv/mobj_print.c
+mobj_dump_LDADD = libbluray.la
 
 bdjo_dump_CFLAGS = $(AM_CFLAGS)
 bdjo_dump_SOURCES = \
diff --git a/src/examples/mobj_dump.c b/src/examples/mobj_dump.c
index 613b261..3eaf9f4 100644
--- a/src/examples/mobj_dump.c
+++ b/src/examples/mobj_dump.c
@@ -17,8 +17,9 @@
  * <http://www.gnu.org/licenses/>.
  */
 
+#include "libbluray/bluray.h"
+
 #include "libbluray/hdmv/mobj_data.h"
-#include "libbluray/hdmv/mobj_parse.h"
 #include "libbluray/hdmv/mobj_print.h"
 
 #include <stdio.h>
@@ -60,7 +61,7 @@ int main(int argc, const char *argv[])
 
     if (argc < 2) {
         fprintf(stderr,
-                "usage: %s [-d] <disc_root>\n"
+                "usage: %s [-d] <file>\n"
                 "Options:\n"
                 "    d         disassemble object code\n",
                 argv[0]);
@@ -70,12 +71,12 @@ int main(int argc, const char *argv[])
         disasm = !strcmp(argv[1], "-d");
     }
 
-    mobj = mobj_parse(argv[argc-1]);
+    mobj = bd_read_mobj(argv[argc-1]);
 
     if (mobj) {
         _mobj_print(mobj, disasm);
 
-        mobj_free(&mobj);
+        bd_free_mobj(mobj);
     }
 
     return 0;
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 2b23781..6afbe00 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -39,6 +39,7 @@
 #include "bdnav/clpi_parse.h"
 #include "bdnav/sound_parse.h"
 #include "hdmv/hdmv_vm.h"
+#include "hdmv/mobj_parse.h"
 #include "decoders/graphics_controller.h"
 #include "decoders/m2ts_filter.h"
 #include "decoders/overlay.h"
@@ -3511,3 +3512,13 @@ void bd_free_mpls(struct mpls_pl *pl)
 {
     mpls_free(pl);
 }
+
+struct mobj_objects *bd_read_mobj(const char *mobj_file)
+{
+    return mobj_parse(mobj_file);
+}
+
+void bd_free_mobj(struct mobj_objects *obj)
+{
+    mobj_free(&obj);
+}
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index a546531..4e28175 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -887,6 +887,9 @@ struct mpls_pl;
 struct mpls_pl *bd_read_mpls(const char *mpls_file);
 void bd_free_mpls(struct mpls_pl *);
 
+struct mobj_objects;
+struct mobj_objects *bd_read_mobj(const char *mobj_file);
+void bd_free_mobj(struct mobj_objects *);
 
 /* BD-J testing */
 
diff --git a/src/libbluray/hdmv/hdmv_vm.c b/src/libbluray/hdmv/hdmv_vm.c
index 020799f..ec5fa2e 100644
--- a/src/libbluray/hdmv/hdmv_vm.c
+++ b/src/libbluray/hdmv/hdmv_vm.c
@@ -253,7 +253,7 @@ HDMV_VM *hdmv_vm_init(const char *disc_root, BD_REGISTERS *regs,
     }
 
     /* read movie objects */
-    p->movie_objects = mobj_parse(disc_root);
+    p->movie_objects = mobj_get(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 01b8b46..c88f557 100644
--- a/src/libbluray/hdmv/mobj_parse.c
+++ b/src/libbluray/hdmv/mobj_parse.c
@@ -122,7 +122,7 @@ void mobj_free(MOBJ_OBJECTS **p)
     }
 }
 
-static MOBJ_OBJECTS *_mobj_parse(const char *file_name)
+MOBJ_OBJECTS *mobj_parse(const char *file_name)
 {
     BITSTREAM     bs;
     BD_FILE_H    *fp;
@@ -190,13 +190,13 @@ static MOBJ_OBJECTS *_mobj_parse(const char *file_name)
     return NULL;
 }
 
-MOBJ_OBJECTS *mobj_parse(const char *disc_root)
+MOBJ_OBJECTS *mobj_get(const char *disc_root)
 {
     MOBJ_OBJECTS *objects;
     char *file;
 
     file = str_printf("%s"DIR_SEP "BDMV" DIR_SEP "MovieObject.bdmv", disc_root);
-    objects = _mobj_parse(file);
+    objects = mobj_parse(file);
     X_FREE(file);
     if (objects) {
         return objects;
@@ -204,7 +204,7 @@ MOBJ_OBJECTS *mobj_parse(const char *disc_root)
 
     /* if failed, try backup file */
     file = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "BACKUP" DIR_SEP "MovieObject.bdmv", disc_root);
-    objects = _mobj_parse(file);
+    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 43749d8..b938748 100644
--- a/src/libbluray/hdmv/mobj_parse.h
+++ b/src/libbluray/hdmv/mobj_parse.h
@@ -27,7 +27,8 @@
 struct mobj_objects;
 struct mobj_cmd;
 
-BD_PRIVATE struct mobj_objects* mobj_parse(const char *disc_root) BD_ATTR_MALLOC; /* parse MovieObject.bdmv */
+BD_PRIVATE struct mobj_objects* mobj_parse(const char *file) BD_ATTR_MALLOC; /* parse MovieObject.bdmv */
+BD_PRIVATE struct mobj_objects* mobj_get(const char *disc_root);             /* parse MovieObject.bdmv */
 BD_PRIVATE void                 mobj_parse_cmd(uint8_t *buf, struct mobj_cmd *cmd);
 BD_PRIVATE void                 mobj_free(struct mobj_objects **index);
 
diff --git a/src/libbluray/hdmv/mobj_print.c b/src/libbluray/hdmv/mobj_print.c
index f6822ba..4ff6bba 100644
--- a/src/libbluray/hdmv/mobj_print.c
+++ b/src/libbluray/hdmv/mobj_print.c
@@ -22,8 +22,6 @@
 #include "mobj_data.h"
 #include "hdmv_insn.h"
 
-#include "util/macro.h"
-
 #include <stdio.h>
 
 static const char * const psr_info[128] = {
@@ -310,12 +308,22 @@ static int _sprint_operands_hex(char *buf, MOBJ_CMD *cmd)
     return buf - start;
 }
 
+static uint32_t _cmd_to_u32(HDMV_INSN *insn)
+{
+    union {
+        HDMV_INSN insn;
+        uint8_t u8[4];
+    } tmp;
+    tmp.insn = *insn;
+    return (tmp.u8[0] << 24) | (tmp.u8[1] << 16) | (tmp.u8[2] << 8) | tmp.u8[3];
+}
+
 int mobj_sprint_cmd(char *buf, MOBJ_CMD *cmd)
 {
     char *start = buf;
     HDMV_INSN *insn = &cmd->insn;
 
-    buf += sprintf(buf, "%08x %08x,%08x  ", MKINT_BE32((uint8_t*)&cmd->insn), cmd->dst, cmd->src);
+    buf += sprintf(buf, "%08x %08x,%08x  ", _cmd_to_u32(&cmd->insn), cmd->dst, cmd->src);
 
     switch(insn->grp) {
         case INSN_GROUP_BRANCH:



More information about the libbluray-devel mailing list