[libbluray-devel] Use bs_read_string()

hpi1 git at videolan.org
Tue Oct 28 14:26:00 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Oct 27 11:58:24 2014 +0200| [cee5e02fe1f7d1cd5fe486f567e95dcb7109f370] | committer: hpi1

Use bs_read_string()

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

 src/libbluray/bdnav/clpi_parse.c  |   18 +++++++-----------
 src/libbluray/bdnav/index_parse.c |    3 +--
 src/libbluray/bdnav/mpls_parse.c  |   30 +++++++++++-------------------
 3 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/src/libbluray/bdnav/clpi_parse.c b/src/libbluray/bdnav/clpi_parse.c
index 8fbc0b6..a963ec0 100644
--- a/src/libbluray/bdnav/clpi_parse.c
+++ b/src/libbluray/bdnav/clpi_parse.c
@@ -89,18 +89,18 @@ _parse_stream_attr(BITSTREAM *bits, CLPI_PROG_STREAM *ss)
         case 0xa2:
             ss->format = bs_read(bits, 4);
             ss->rate   = bs_read(bits, 4);
-            bs_read_bytes(bits, ss->lang, 3);
+            bs_read_string(bits, ss->lang, 3);
             break;
 
         case 0x90:
         case 0x91:
         case 0xa0:
-            bs_read_bytes(bits, ss->lang, 3);
+            bs_read_string(bits, ss->lang, 3);
             break;
 
         case 0x92:
             ss->char_code = bs_read(bits, 8);
-            bs_read_bytes(bits, ss->lang, 3);
+            bs_read_string(bits, ss->lang, 3);
             break;
 
         default:
@@ -168,8 +168,7 @@ _parse_clipinfo(BITSTREAM *bits, CLPI_CL *cl)
     pos = bs_pos(bits) >> 3;
     if (len) {
         cl->clip.ts_type_info.validity = bs_read(bits, 8);
-        bs_read_bytes(bits, cl->clip.ts_type_info.format_id, 4);
-        cl->clip.ts_type_info.format_id[4] = '\0';
+        bs_read_string(bits, cl->clip.ts_type_info.format_id, 4);
         // Seek past the stuff we don't know anything about
         bs_seek_byte(bits, pos + len);
     }
@@ -181,10 +180,8 @@ _parse_clipinfo(BITSTREAM *bits, CLPI_CL *cl)
             malloc(cl->clip.atc_delta_count * sizeof(CLPI_ATC_DELTA));
         for (ii = 0; ii < cl->clip.atc_delta_count; ii++) {
             cl->clip.atc_delta[ii].delta = bs_read(bits, 32);
-            bs_read_bytes(bits, cl->clip.atc_delta[ii].file_id, 5);
-            cl->clip.atc_delta[ii].file_id[5] = '\0';
-            bs_read_bytes(bits, cl->clip.atc_delta[ii].file_code, 4);
-            cl->clip.atc_delta[ii].file_code[4] = '\0';
+            bs_read_string(bits, cl->clip.atc_delta[ii].file_id, 5);
+            bs_read_string(bits, cl->clip.atc_delta[ii].file_code, 4);
             bs_skip(bits, 8);
         }
     }
@@ -196,8 +193,7 @@ _parse_clipinfo(BITSTREAM *bits, CLPI_CL *cl)
         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_read_string(bits, cl->font_info.font[ii].file_id, 5);
                 bs_skip(bits, 8);
             }
         }
diff --git a/src/libbluray/bdnav/index_parse.c b/src/libbluray/bdnav/index_parse.c
index a8a6c49..f01e595 100644
--- a/src/libbluray/bdnav/index_parse.c
+++ b/src/libbluray/bdnav/index_parse.c
@@ -49,8 +49,7 @@ static int _parse_bdj_obj(BITSTREAM *bs, INDX_BDJ_OBJ *bdj)
 {
     bdj->playback_type = bs_read(bs, 2);
     bs_skip(bs, 14);
-    bs_read_bytes(bs, (uint8_t*)bdj->name, 5);
-    bdj->name[5] = 0;
+    bs_read_string(bs, bdj->name, 5);
     bs_skip(bs, 8);
 
     if (bdj->playback_type != indx_bdj_playback_type_movie &&
diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
index 9376ac1..5664bd6 100644
--- a/src/libbluray/bdnav/mpls_parse.c
+++ b/src/libbluray/bdnav/mpls_parse.c
@@ -233,17 +233,17 @@ _parse_stream(BITSTREAM *bits, MPLS_STREAM *s)
         case 0xa2:
             s->format = bs_read(bits, 4);
             s->rate   = bs_read(bits, 4);
-            bs_read_bytes(bits, s->lang, 3);
+            bs_read_string(bits, s->lang, 3);
             break;
 
         case 0x90:
         case 0x91:
-            bs_read_bytes(bits, s->lang, 3);
+            bs_read_string(bits, s->lang, 3);
             break;
 
         case 0x92:
             s->char_code = bs_read(bits, 8);
-            bs_read_bytes(bits, s->lang, 3);
+            bs_read_string(bits, s->lang, 3);
             break;
 
         default:
@@ -446,11 +446,9 @@ _parse_playitem(BITSTREAM *bits, MPLS_PI *pi)
     pos = bs_pos(bits) >> 3;
 
     // Primary Clip identifer
-    bs_read_bytes(bits, (uint8_t*)clip_id, 5);
-    clip_id[5] = '\0';
+    bs_read_string(bits, clip_id, 5);
 
-    bs_read_bytes(bits, (uint8_t*)codec_id, 4);
-    codec_id[4] = '\0';
+    bs_read_string(bits, codec_id, 4);
     if (memcmp(codec_id, "M2TS", 4) != 0) {
         BD_DEBUG(DBG_NAV | DBG_CRIT, "Incorrect CodecIdentifier (%s)\n", codec_id);
     }
@@ -498,11 +496,9 @@ _parse_playitem(BITSTREAM *bits, MPLS_PI *pi)
     strcpy(pi->clip[0].codec_id, codec_id);
     pi->clip[0].stc_id = stc_id;
     for (ii = 1; ii < pi->angle_count; ii++) {
-        bs_read_bytes(bits, (uint8_t*)pi->clip[ii].clip_id, 5);
-        pi->clip[ii].clip_id[5] = '\0';
+        bs_read_string(bits, pi->clip[ii].clip_id, 5);
 
-        bs_read_bytes(bits, (uint8_t*)pi->clip[ii].codec_id, 4);
-        pi->clip[ii].codec_id[4] = '\0';
+        bs_read_string(bits, pi->clip[ii].codec_id, 4);
         if (memcmp(pi->clip[ii].codec_id, "M2TS", 4) != 0) {
             BD_DEBUG(DBG_NAV | DBG_CRIT, "Incorrect CodecIdentifier (%s)\n", pi->clip[ii].codec_id);
         }
@@ -540,11 +536,9 @@ _parse_subplayitem(BITSTREAM *bits, MPLS_SUB_PI *spi)
     pos = bs_pos(bits) >> 3;
 
     // Primary Clip identifer
-    bs_read_bytes(bits, (uint8_t*)clip_id, 5);
-    clip_id[5] = '\0';
+    bs_read_string(bits, clip_id, 5);
 
-    bs_read_bytes(bits, (uint8_t*)codec_id, 4);
-    codec_id[4] = '\0';
+    bs_read_string(bits, codec_id, 4);
     if (memcmp(codec_id, "M2TS", 4) != 0) {
         BD_DEBUG(DBG_NAV | DBG_CRIT, "Incorrect CodecIdentifier (%s)\n", codec_id);
     }
@@ -579,11 +573,9 @@ _parse_subplayitem(BITSTREAM *bits, MPLS_SUB_PI *spi)
     spi->clip[0].stc_id = stc_id;
     for (ii = 1; ii < spi->clip_count; ii++) {
         // Primary Clip identifer
-        bs_read_bytes(bits, (uint8_t*)spi->clip[ii].clip_id, 5);
-        spi->clip[ii].clip_id[5] = '\0';
+        bs_read_string(bits, spi->clip[ii].clip_id, 5);
 
-        bs_read_bytes(bits, (uint8_t*)spi->clip[ii].codec_id, 4);
-        spi->clip[ii].codec_id[4] = '\0';
+        bs_read_string(bits, spi->clip[ii].codec_id, 4);
         if (memcmp(spi->clip[ii].codec_id, "M2TS", 4) != 0) {
             BD_DEBUG(DBG_NAV | DBG_CRIT, "Incorrect CodecIdentifier (%s)\n", spi->clip[ii].codec_id);
         }



More information about the libbluray-devel mailing list