[libbluray-devel] Parse TextST stream font info from .clpi files

hpi1 git at videolan.org
Mon Jun 17 11:39:22 CEST 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Jun 12 11:34:10 2013 +0300| [7809c25c95413580a94ee175b468b9bdad8eea09] | committer: hpi1

Parse TextST stream font info from .clpi files

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

 src/examples/clpi_dump.c         |   14 ++++++++++++--
 src/libbluray/bdnav/clpi_data.h  |   16 ++++++++++++++++
 src/libbluray/bdnav/clpi_parse.c |   25 ++++++++++++++++++++++++-
 src/libbluray/bdnav/mpls_parse.h |    1 +
 4 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/src/examples/clpi_dump.c b/src/examples/clpi_dump.c
index ebc4e74..e0d45d1 100644
--- a/src/examples/clpi_dump.c
+++ b/src/examples/clpi_dump.c
@@ -1,6 +1,7 @@
 /*
  * This file is part of libbluray
  * Copyright (C) 2009-2010  John Stebbins
+ * Copyright (C) 2012-2013  Petri Hintukainen <phintuka at users.sourceforge.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -195,8 +196,9 @@ _show_stream(CLPI_PROG_STREAM *ss, int level)
 }
 
 static void
-_show_clip_info(CLPI_CLIP_INFO *ci, int level)
+_show_clip_info(CLPI_CL *cl, int level)
 {
+    CLPI_CLIP_INFO *ci = &cl->clip;
     int ii;
 
     indent_printf(level, "Clip Info");
@@ -218,6 +220,14 @@ _show_clip_info(CLPI_CLIP_INFO *ci, int level)
         indent_printf(level+2, "File Id %s", ci->atc_delta[ii].file_id);
         indent_printf(level+2, "File Code %s", ci->atc_delta[ii].file_code);
     }
+    // show fonts
+    if (cl->font_info.font_count) {
+        indent_printf(level+1, "Font files");
+        for (ii = 0; ii < cl->font_info.font_count; ii++) {
+            indent_printf(level+2, "Font file %d: %s.otf", ii+1, cl->font_info.font[ii].file_id);
+        }
+    }
+
     printf("\n");
 }
 
@@ -435,7 +445,7 @@ main(int argc, char *argv[])
         }
         if (opt_clip_info) {
             // Show clip info
-            _show_clip_info(&cl->clip, 1);
+            _show_clip_info(cl, 1);
         }
         if (opt_seq_info) {
             // Show sequence info
diff --git a/src/libbluray/bdnav/clpi_data.h b/src/libbluray/bdnav/clpi_data.h
index 25f32b6..e3fc4c8 100644
--- a/src/libbluray/bdnav/clpi_data.h
+++ b/src/libbluray/bdnav/clpi_data.h
@@ -1,6 +1,7 @@
 /*
  * This file is part of libbluray
  * Copyright (C) 2009-2010  John Stebbins
+ * Copyright (C) 2012-2013  Petri Hintukainen <phintuka at users.sourceforge.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -57,6 +58,15 @@ typedef struct
     uint8_t           file_code[5];
 } CLPI_ATC_DELTA;
 
+typedef struct {
+    uint8_t           file_id[6];
+} CLPI_FONT;
+
+typedef struct {
+    uint8_t           font_count;
+    CLPI_FONT        *font;
+} CLPI_FONT_INFO;
+
 typedef struct
 {
     uint8_t           clip_stream_type;
@@ -67,6 +77,10 @@ typedef struct
     CLPI_TS_TYPE      ts_type_info;
     uint8_t           atc_delta_count;
     CLPI_ATC_DELTA   *atc_delta;
+
+    /* breaks ABI if added here ...
+    CLPI_FONT_INFO    font_info;
+    */
 } CLPI_CLIP_INFO;
 
 typedef struct
@@ -156,6 +170,8 @@ typedef struct clpi_cl {
     CLPI_PROG_INFO    program_ss;
     CLPI_CPI          cpi_ss;
 
+    /* Text subtitle stream font files */
+    CLPI_FONT_INFO    font_info;
 } CLPI_CL;
 
 #endif // _CLPI_DATA_H_
diff --git a/src/libbluray/bdnav/clpi_parse.c b/src/libbluray/bdnav/clpi_parse.c
index 5cbb788..b8e956d 100644
--- a/src/libbluray/bdnav/clpi_parse.c
+++ b/src/libbluray/bdnav/clpi_parse.c
@@ -1,6 +1,7 @@
 /*
  * This file is part of libbluray
  * Copyright (C) 2009-2010  John Stebbins
+ * Copyright (C) 2012-2013  Petri Hintukainen <phintuka at users.sourceforge.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -184,6 +185,21 @@ _parse_clipinfo(BITSTREAM *bits, CLPI_CL *cl)
             bs_skip(bits, 8);
         }
     }
+
+    // font info
+    if (cl->clip.application_type == 6 /* Sub TS for a sub-path of Text subtitle */) {
+        bs_skip(bits, 8);
+        cl->font_info.font_count = bs_read(bits, 8);
+        if (cl->font_info.font_count) {
+            cl->font_info.font = malloc(cl->font_info.font_count * sizeof(CLPI_FONT));
+            for (ii = 0; ii < cl->font_info.font_count; ii++) {
+                bs_read_bytes(bits, cl->font_info.font[ii].file_id, 5);
+                cl->font_info.font[ii].file_id[5] = '\0';
+                bs_skip(bits, 8);
+            }
+        }
+    }
+
     return 1;
 }
 
@@ -642,6 +658,8 @@ clpi_free(CLPI_CL *cl)
     _clean_program(&cl->program_ss);
     _clean_cpi(&cl->cpi_ss);
 
+    X_FREE(cl->font_info.font);
+
     X_FREE(cl);
 }
 
@@ -732,7 +750,6 @@ clpi_copy(const CLPI_CL* src_cl)
 
     if (src_cl) {
         dest_cl = (CLPI_CL*) calloc(1, sizeof(CLPI_CL));
-
         dest_cl->clip.clip_stream_type = src_cl->clip.clip_stream_type;
         dest_cl->clip.application_type = src_cl->clip.application_type;
         dest_cl->clip.is_atc_delta = src_cl->clip.is_atc_delta;
@@ -805,6 +822,12 @@ clpi_copy(const CLPI_CL* src_cl)
                 dest_cl->cpi.entry[ii].fine[jj].spn_ep = src_cl->cpi.entry[ii].fine[jj].spn_ep;
             }
         }
+
+        dest_cl->font_info.font_count = src_cl->font_info.font_count;
+        if (dest_cl->font_info.font_count) {
+            dest_cl->font_info.font = malloc(dest_cl->font_info.font_count * sizeof(CLPI_FONT));
+            memcpy(dest_cl->font_info.font, src_cl->font_info.font, dest_cl->font_info.font_count * sizeof(CLPI_FONT));
+        }
     }
 
     return dest_cl;
diff --git a/src/libbluray/bdnav/mpls_parse.h b/src/libbluray/bdnav/mpls_parse.h
index cff1081..ac65edd 100644
--- a/src/libbluray/bdnav/mpls_parse.h
+++ b/src/libbluray/bdnav/mpls_parse.h
@@ -1,6 +1,7 @@
 /*
  * This file is part of libbluray
  * Copyright (C) 2009-2010  John Stebbins
+ * Copyright (C) 2012       Petri Hintukainen <phintuka at users.sourceforge.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public



More information about the libbluray-devel mailing list