[libbluray-devel] reduce inter-module deps: hdmv vm does not need disc index

hpi1 git at videolan.org
Thu Mar 27 14:55:38 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Mar 27 12:53:16 2014 +0200| [a7ecf972dc00f90176cb132b3276f58a5cccef04] | committer: hpi1

reduce inter-module deps: hdmv vm does not need disc index

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

 src/libbluray/bluray.c       |    3 ++-
 src/libbluray/hdmv/hdmv_vm.c |   29 +++++++++++++++--------------
 src/libbluray/hdmv/hdmv_vm.h |    4 ++--
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 6a17026..6ff98ed 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -2814,7 +2814,8 @@ static int _play_hdmv(BLURAY *bd, unsigned id_ref)
     bd->title_type = title_hdmv;
 
     if (!bd->hdmv_vm) {
-        bd->hdmv_vm = hdmv_vm_init(bd->device_path, bd->regs, bd->index);
+        bd->hdmv_vm = hdmv_vm_init(bd->device_path, bd->regs, bd->disc_info.num_titles,
+                                   bd->disc_info.first_play_supported, bd->disc_info.top_menu_supported);
     }
 
     if (hdmv_vm_select_object(bd->hdmv_vm, id_ref)) {
diff --git a/src/libbluray/hdmv/hdmv_vm.c b/src/libbluray/hdmv/hdmv_vm.c
index 5bfc883..008ba47 100644
--- a/src/libbluray/hdmv/hdmv_vm.c
+++ b/src/libbluray/hdmv/hdmv_vm.c
@@ -23,7 +23,6 @@
 #include "hdmv_insn.h"
 #include "../register.h"
 
-#include "../bdnav/index_parse.h"
 #include "util/macro.h"
 #include "util/strutl.h"
 #include "util/logging.h"
@@ -64,8 +63,10 @@ struct hdmv_vm_s {
     MOBJ_OBJECT *suspended_object;
     uint32_t     suspended_pc;
 
-    /* disc index (used to verify CALL_TITLE/JUMP_TITLE) */
-    INDX_ROOT   *indx;
+    /* Available titles. Used to validate CALL_TITLE/JUMP_TITLE. */
+    uint8_t  have_top_menu;
+    uint8_t  have_first_play;
+    uint16_t num_titles;
 };
 
 /*
@@ -239,7 +240,8 @@ static int _queue_event(HDMV_VM *p, hdmv_event_e event, uint32_t param)
  * vm init
  */
 
-HDMV_VM *hdmv_vm_init(const char *disc_root, BD_REGISTERS *regs, INDX_ROOT *indx)
+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;
@@ -259,7 +261,9 @@ HDMV_VM *hdmv_vm_init(const char *disc_root, BD_REGISTERS *regs, INDX_ROOT *indx
     }
 
     p->regs         = regs;
-    p->indx         = indx;
+    p->num_titles      = num_titles;
+    p->have_top_menu   = top_menu_available;
+    p->have_first_play = first_play_available;
 
     bd_mutex_init(&p->mutex);
 
@@ -426,17 +430,14 @@ static int _resume_object(HDMV_VM *p, int psr_restore)
 
 static int _is_valid_title(HDMV_VM *p, uint32_t title)
 {
-    if (title == 0 || title == 0xffff) {
-        INDX_PLAY_ITEM *pi = (!title) ? &p->indx->top_menu : &p->indx->first_play;
-
-        if (pi->object_type == indx_object_type_hdmv &&  pi->hdmv.id_ref == 0xffff) {
-            /* no top menu or first play title (5.2.3.3) */
-            return 0;
-        }
-        return 1;
+    if (title == 0) {
+        return p->have_top_menu;
+    }
+    if (title == 0xffff) {
+        return p->have_first_play;
     }
 
-    return title > 0 && title <= p->indx->num_titles;
+    return title > 0 && title <= p->num_titles;
 }
 
 static int _jump_object(HDMV_VM *p, uint32_t object)
diff --git a/src/libbluray/hdmv/hdmv_vm.h b/src/libbluray/hdmv/hdmv_vm.h
index fea28ac..956277c 100644
--- a/src/libbluray/hdmv/hdmv_vm.h
+++ b/src/libbluray/hdmv/hdmv_vm.h
@@ -65,7 +65,6 @@ typedef struct hdmv_vm_event_s {
  */
 
 struct bd_registers_s;
-struct indx_root_s;
 
 /*
  *
@@ -73,7 +72,8 @@ struct indx_root_s;
 
 typedef struct hdmv_vm_s HDMV_VM;
 
-BD_PRIVATE HDMV_VM *hdmv_vm_init(const char *disc_root, struct bd_registers_s *regs, struct indx_root_s *indx);
+BD_PRIVATE HDMV_VM *hdmv_vm_init(const char *disc_root, struct bd_registers_s *regs,
+                                 unsigned num_titles, unsigned first_play_available, unsigned top_menu_available);
 BD_PRIVATE void     hdmv_vm_free(HDMV_VM **p);
 
 BD_PRIVATE int      hdmv_vm_select_object(HDMV_VM *p, uint32_t object);



More information about the libbluray-devel mailing list