[libbluray-devel] Accept version 0300 bdjo files

hpi1 git at videolan.org
Wed Sep 13 14:02:51 CEST 2017


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Sep 13 14:55:20 2017 +0300| [1d93273f1636eeaf16451a2451ca3b7443c1204f] | committer: hpi1

Accept version 0300 bdjo files

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

 src/libbluray/bdj/bdjo_data.h  |  1 +
 src/libbluray/bdj/bdjo_parse.c | 31 ++++++-------------------------
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/src/libbluray/bdj/bdjo_data.h b/src/libbluray/bdj/bdjo_data.h
index a7aca01b..05bf2651 100644
--- a/src/libbluray/bdj/bdjo_data.h
+++ b/src/libbluray/bdj/bdjo_data.h
@@ -123,6 +123,7 @@ typedef struct {
 } BDJO_FILE_ACCESS_INFO;
 
 typedef struct bdjo_data {
+    uint32_t                  bdjo_version;
     BDJO_TERMINAL_INFO        terminal_info;
     BDJO_APP_CACHE_INFO       app_cache_info;
     BDJO_ACCESSIBLE_PLAYLISTS accessible_playlists;
diff --git a/src/libbluray/bdj/bdjo_parse.c b/src/libbluray/bdj/bdjo_parse.c
index 0d6f48aa..0618e336 100644
--- a/src/libbluray/bdj/bdjo_parse.c
+++ b/src/libbluray/bdj/bdjo_parse.c
@@ -27,6 +27,7 @@
 #include "bdjo_data.h"
 
 #include "disc/disc.h"
+#include "bdnav/bdmv_parse.h"
 
 #include "file/file.h"
 #include "util/bits.h"
@@ -478,35 +479,15 @@ static void _clean_bdjo(BDJO *p)
     }
 }
 
-static int _get_version(const uint8_t* str)
-{
-    if (memcmp(str, "0100", 4) != 0)
-        return 100;
-    else if (memcmp(str, "0200", 4) != 0)
-        return 200;
-    else
-        return 0;
-}
+#define BDJO_SIG1 ('B' << 24 | 'D' << 16 | 'J' << 8 | 'O')
 
-static int _check_version(BITSTREAM *bs)
+static int _parse_header(BITSTREAM *bs, uint32_t *bdjo_version)
 {
-    // first check magic number
-    uint8_t magic[4];
-    bs_read_bytes(bs, magic, 4);
-
-    if (memcmp(magic, "BDJO", 4) != 0) {
-        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Invalid magic number in BDJO.\n");
+    if (!bdmv_parse_header(bs, BDJO_SIG1, bdjo_version)) {
         return -1;
     }
 
-    // get version string
-    uint8_t version[4];
-    bs_read_bytes(bs, version, 4);
-    if (!_get_version(version)) {
-        BD_DEBUG(DBG_BDJ | DBG_CRIT, "Invalid version of BDJO.\n");
-        return -1;
-    }
-    BD_DEBUG(DBG_BDJ, "[bdj] BDJO > Version: %.4s\n", version);
+    BD_DEBUG(DBG_BDJ, "[bdj] BDJO > Version: %.4s\n", (const char *)bdjo_version);
 
     // skip address table
     bs_skip(bs, 8*40);
@@ -530,7 +511,7 @@ static BDJO *_bdjo_parse(BD_FILE_H *fp)
         return NULL;
     }
 
-    if (_check_version(&bs) < 0 ||
+    if (_parse_header(&bs, &p->bdjo_version) < 0 ||
         _parse_terminal_info(&bs, &p->terminal_info) < 0 ||
         _parse_app_cache_info(&bs, &p->app_cache_info) < 0 ||
         _parse_accessible_playlists(&bs, &p->accessible_playlists) < 0 ||



More information about the libbluray-devel mailing list