[libbluray-devel] Parse subpath entries extension from playlist files

hpi1 git at videolan.org
Tue Sep 4 14:22:35 CEST 2012


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Sep  4 15:20:42 2012 +0300| [c57f5b78a8a0a09090df1b99082c4e03b22fe234] | committer: hpi1

Parse subpath entries extension from playlist files

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

 src/examples/mpls_dump.c         |   17 ++++++++++++
 src/libbluray/bdnav/mpls_parse.c |   56 ++++++++++++++++++++++++++++++++++++++
 src/libbluray/bdnav/mpls_parse.h |    4 +++
 3 files changed, 77 insertions(+)

diff --git a/src/examples/mpls_dump.c b/src/examples/mpls_dump.c
index f66e975..24c7f6c 100644
--- a/src/examples/mpls_dump.c
+++ b/src/examples/mpls_dump.c
@@ -112,6 +112,7 @@ const VALUE_MAP audio_rate_map[] = {
 const VALUE_MAP subpath_type_map[] = {
   {3, "Interactive Graphics presentation menu"},
   {4, "Text Subtitle"},
+  {8, "SS Video"},
   {0,NULL}
 };
 
@@ -372,6 +373,21 @@ _show_sub_paths(MPLS_PL *pl, int level)
     }
 }
 
+static void
+_show_sub_paths_ss(MPLS_PL *pl, int level)
+{
+    int ss;
+
+    for (ss = 0; ss < pl->ext_sub_count; ss++) {
+        MPLS_SUB *sub;
+
+        sub = &pl->ext_sub_path[ss];
+
+        indent_printf(level, "Extension Sub Path %d:", ss);
+        _show_sub_path(sub, level+1);
+    }
+}
+
 static uint32_t
 _pl_duration(MPLS_PL *pl)
 {
@@ -515,6 +531,7 @@ _process_file(char *name, MPLS_PL *pl_list[], int pl_count)
     }
     if (sub_paths) {
         _show_sub_paths(pl, 1);
+        _show_sub_paths_ss(pl, 1);
     }
     return pl;
 }
diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
index d868452..8a78ea5 100644
--- a/src/libbluray/bdnav/mpls_parse.c
+++ b/src/libbluray/bdnav/mpls_parse.c
@@ -20,6 +20,7 @@
 #include "util/macro.h"
 #include "file/file.h"
 #include "util/bits.h"
+#include "extdata_parse.h"
 #include "mpls_parse.h"
 
 #include <stdlib.h>
@@ -724,6 +725,12 @@ _clean_playlist(MPLS_PL *pl)
         }
         X_FREE(pl->sub_path);
     }
+    if (pl->ext_sub_path != NULL) {
+        for (ii = 0; ii < pl->ext_sub_count; ii++) {
+            _clean_subpath(&pl->ext_sub_path[ii]);
+        }
+        X_FREE(pl->ext_sub_path);
+    }
     X_FREE(pl->play_mark);
     X_FREE(pl);
 }
@@ -734,6 +741,48 @@ mpls_free(MPLS_PL *pl)
     _clean_playlist(pl);
 }
 
+static int
+_parse_subpath_extension(BITSTREAM *bits, MPLS_PL *pl)
+{
+    MPLS_SUB *sub_path;
+    int ii;
+
+    uint32_t len       = bs_read(bits, 32);
+    int      sub_count = bs_read(bits, 16);
+
+    if (len < 1 || sub_count < 1) {
+        return 0;
+    }
+
+    sub_path = calloc(sub_count,  sizeof(MPLS_SUB));
+    for (ii = 0; ii < sub_count; ii++) {
+        if (!_parse_subpath(bits, &sub_path[ii])) {
+            X_FREE(sub_path);
+            fprintf(stderr, "error parsing extension subpath\n");
+            return 0;
+        }
+    }
+    pl->ext_sub_path  = sub_path;
+    pl->ext_sub_count = sub_count;
+
+    return 1;
+}
+
+static int
+_parse_mpls_extension(BITSTREAM *bits, int id1, int id2, void *handle)
+{
+    MPLS_PL *pl = handle;
+
+    if (id1 == 2) {
+        if (id2 == 2) {
+            // SubPath entries extension
+            return _parse_subpath_extension(bits, pl);
+        }
+    }
+
+    return 0;
+}
+
 static MPLS_PL*
 _mpls_parse(const char *path, int verbose)
 {
@@ -771,6 +820,13 @@ _mpls_parse(const char *path, int verbose)
         _clean_playlist(pl);
         return NULL;
     }
+    if (pl->ext_pos > 0) {
+        bdmv_parse_extension_data(&bits,
+                                  pl->ext_pos,
+                                  _parse_mpls_extension,
+                                  pl);
+    }
+
     file_close(fp);
     return pl;
 }
diff --git a/src/libbluray/bdnav/mpls_parse.h b/src/libbluray/bdnav/mpls_parse.h
index 9518cae..549fa2e 100644
--- a/src/libbluray/bdnav/mpls_parse.h
+++ b/src/libbluray/bdnav/mpls_parse.h
@@ -145,6 +145,10 @@ typedef struct
     MPLS_PI        *play_item;
     MPLS_SUB       *sub_path;
     MPLS_PLM       *play_mark;
+
+    // extension data (profile 5, version 2.4)
+    uint16_t        ext_sub_count;
+    MPLS_SUB       *ext_sub_path;  // sub path entries extension
 } MPLS_PL;
 
 



More information about the libbluray-devel mailing list