[libbluray-devel] bitstream parser: use int64_t instead of off_t

hpi1 git at videolan.org
Sun Nov 23 14:47:54 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Nov 23 15:45:40 2014 +0200| [45f00ad56775f829d71de7501e65d1cb63f7089b] | committer: hpi1

bitstream parser: use int64_t instead of off_t

int64_t is used for file offsets in every other place.

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

 src/libbluray/bdj/bdjo_parse.c      |    2 +-
 src/libbluray/bdnav/clpi_parse.c    |    4 ++--
 src/libbluray/bdnav/extdata_parse.c |    8 ++++----
 src/libbluray/bdnav/index_parse.c   |    2 +-
 src/libbluray/bdnav/mpls_parse.c    |   18 +++++++++---------
 src/libbluray/hdmv/mobj_parse.c     |    2 +-
 src/util/bits.c                     |    8 ++++----
 src/util/bits.h                     |   24 ++++++++++++------------
 8 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/src/libbluray/bdj/bdjo_parse.c b/src/libbluray/bdj/bdjo_parse.c
index 79a5839..7ab9e7b 100644
--- a/src/libbluray/bdj/bdjo_parse.c
+++ b/src/libbluray/bdj/bdjo_parse.c
@@ -161,7 +161,7 @@ static int _count_app_strings(BITSTREAM *bs, uint16_t data_length, uint16_t pref
 {
     int      count = 0;
     uint32_t bytes_read = 0;
-    off_t    pos = bs_pos(bs) >> 3;
+    int64_t  pos = bs_pos(bs) >> 3;
 
     while (bytes_read < data_length) {
         bs_skip(bs, prefix_bytes * 8);
diff --git a/src/libbluray/bdnav/clpi_parse.c b/src/libbluray/bdnav/clpi_parse.c
index a1ed531..ca25be1 100644
--- a/src/libbluray/bdnav/clpi_parse.c
+++ b/src/libbluray/bdnav/clpi_parse.c
@@ -51,7 +51,7 @@ _human_readable_sig(char *sig, uint32_t s1, uint32_t s2)
 static int
 _parse_stream_attr(BITSTREAM *bits, CLPI_PROG_STREAM *ss)
 {
-    off_t pos;
+    int64_t pos;
     int len;
 
     if (!bs_is_align(bits, 0x07)) {
@@ -145,7 +145,7 @@ _parse_header(BITSTREAM *bits, CLPI_CL *cl)
 static int
 _parse_clipinfo(BITSTREAM *bits, CLPI_CL *cl)
 {
-    off_t pos;
+    int64_t pos;
     int len;
     int ii;
 
diff --git a/src/libbluray/bdnav/extdata_parse.c b/src/libbluray/bdnav/extdata_parse.c
index 9987108..8c50035 100644
--- a/src/libbluray/bdnav/extdata_parse.c
+++ b/src/libbluray/bdnav/extdata_parse.c
@@ -28,7 +28,7 @@ int bdmv_parse_extension_data(BITSTREAM *bits,
                               int (*handler)(BITSTREAM*, int, int, void*),
                               void *handle)
 {
-    off_t length;
+    int64_t length;
     int num_entries, n;
 
     if (start_address < 1) return 0;
@@ -47,10 +47,10 @@ int bdmv_parse_extension_data(BITSTREAM *bits,
     for (n = 0; n < num_entries; n++) {
         uint16_t id1       = bs_read(bits, 16);
         uint16_t id2       = bs_read(bits, 16);
-        off_t    ext_start = bs_read(bits, 32);
-        off_t    ext_len   = bs_read(bits, 32);
+        int64_t  ext_start = bs_read(bits, 32);
+        int64_t  ext_len   = bs_read(bits, 32);
 
-        off_t    saved_pos = bs_pos(bits) >> 3;
+        int64_t  saved_pos = bs_pos(bits) >> 3;
 
         if (ext_start + start_address + ext_len > bits->end) return 0;
 
diff --git a/src/libbluray/bdnav/index_parse.c b/src/libbluray/bdnav/index_parse.c
index f01e595..544b4fa 100644
--- a/src/libbluray/bdnav/index_parse.c
+++ b/src/libbluray/bdnav/index_parse.c
@@ -86,7 +86,7 @@ static int _parse_index(BITSTREAM *bs, INDX_ROOT *index)
 
     /* TODO: check if goes to extension data area */
 
-    if ((bs_end(bs) - bs_pos(bs))/8 < (off_t)index_len) {
+    if ((bs_end(bs) - bs_pos(bs))/8 < (int64_t)index_len) {
         BD_DEBUG(DBG_NAV | DBG_CRIT, "index.bdmv: invalid index_len %d !\n", index_len);
         return 0;
     }
diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
index 5664bd6..2fa43a4 100644
--- a/src/libbluray/bdnav/mpls_parse.c
+++ b/src/libbluray/bdnav/mpls_parse.c
@@ -103,7 +103,7 @@ _parse_uo(BITSTREAM *bits, BD_UO_MASK *uo)
 static int
 _parse_appinfo(BITSTREAM *bits, MPLS_AI *ai)
 {
-    off_t pos, len;
+    int64_t pos, len;
 
     if (!bs_is_align(bits, 0x07)) {
         BD_DEBUG(DBG_NAV | DBG_CRIT, "_parse_appinfo: alignment error\n");
@@ -173,7 +173,7 @@ static int
 _parse_stream(BITSTREAM *bits, MPLS_STREAM *s)
 {
     int len;
-    off_t pos;
+    int64_t pos;
 
     if (!bs_is_align(bits, 0x07)) {
         BD_DEBUG(DBG_NAV | DBG_CRIT, "_parse_stream: Stream alignment error\n");
@@ -260,7 +260,7 @@ static int
 _parse_stn(BITSTREAM *bits, MPLS_STN *stn)
 {
     int len;
-    off_t pos;
+    int64_t pos;
     MPLS_STREAM    *ss;
     int ii,jj;
 
@@ -433,7 +433,7 @@ static int
 _parse_playitem(BITSTREAM *bits, MPLS_PI *pi)
 {
     int len, ii;
-    off_t pos;
+    int64_t pos;
     char clip_id[6], codec_id[5];
     uint8_t stc_id;
 
@@ -523,7 +523,7 @@ static int
 _parse_subplayitem(BITSTREAM *bits, MPLS_SUB_PI *spi)
 {
     int len, ii;
-    off_t pos;
+    int64_t pos;
     char clip_id[6], codec_id[5];
     uint8_t stc_id;
 
@@ -598,7 +598,7 @@ static int
 _parse_subpath(BITSTREAM *bits, MPLS_SUB *sp)
 {
     int len, ii;
-    off_t pos;
+    int64_t pos;
     MPLS_SUB_PI *spi = NULL;
 
     if (!bs_is_align(bits, 0x07)) {
@@ -645,7 +645,7 @@ _clean_subpath(MPLS_SUB *sp)
 static int
 _parse_playlistmark(BITSTREAM *bits, MPLS_PL *pl)
 {
-    off_t len;
+    int64_t len;
     int ii;
     MPLS_PLM *plm = NULL;
 
@@ -677,7 +677,7 @@ _parse_playlistmark(BITSTREAM *bits, MPLS_PL *pl)
 static int
 _parse_playlist(BITSTREAM *bits, MPLS_PL *pl)
 {
-    off_t len;
+    int64_t len;
     int ii;
     MPLS_PI *pi = NULL;
     MPLS_SUB *sub_path = NULL;
@@ -790,7 +790,7 @@ _parse_pip_metadata_block(BITSTREAM *bits, uint32_t start_address, MPLS_PIP_META
 {
     uint32_t data_address;
     int result;
-    off_t pos;
+    int64_t pos;
 
     data->clip_ref            = bs_read(bits, 16);
     data->secondary_video_ref = bs_read(bits, 8);
diff --git a/src/libbluray/hdmv/mobj_parse.c b/src/libbluray/hdmv/mobj_parse.c
index 3e26e72..e50da33 100644
--- a/src/libbluray/hdmv/mobj_parse.c
+++ b/src/libbluray/hdmv/mobj_parse.c
@@ -150,7 +150,7 @@ static MOBJ_OBJECTS *_mobj_parse(const char *file_name)
 
     data_len = bs_read(&bs, 32);
 
-    if ((bs_end(&bs) - bs_pos(&bs))/8 < (off_t)data_len) {
+    if ((bs_end(&bs) - bs_pos(&bs))/8 < (int64_t)data_len) {
         BD_DEBUG(DBG_NAV | DBG_CRIT, "%s: invalid data_len %d !\n", file_name, data_len);
         goto error;
     }
diff --git a/src/util/bits.c b/src/util/bits.c
index a3f45e2..efee0f9 100644
--- a/src/util/bits.c
+++ b/src/util/bits.c
@@ -54,9 +54,9 @@ void bs_init( BITSTREAM *bs, BD_FILE_H *fp )
     bb_init(&bs->bb, bs->buf, bs->size);
 }
 
-void bb_seek( BITBUFFER *bb, off_t off, int whence)
+void bb_seek( BITBUFFER *bb, int64_t off, int whence)
 {
-    off_t b;
+    int64_t b;
 
     switch (whence) {
         case SEEK_CUR:
@@ -81,9 +81,9 @@ void bb_seek( BITBUFFER *bb, off_t off, int whence)
     }
 }
 
-void bs_seek( BITSTREAM *bs, off_t off, int whence)
+void bs_seek( BITSTREAM *bs, int64_t off, int whence)
 {
-    off_t b;
+    int64_t b;
 
     switch (whence) {
         case SEEK_CUR:
diff --git a/src/util/bits.h b/src/util/bits.h
index 581bb3b..24362b4 100644
--- a/src/util/bits.h
+++ b/src/util/bits.h
@@ -47,31 +47,31 @@ typedef struct {
     BD_FILE_H *fp;
     uint8_t    buf[BF_BUF_SIZE];
     BITBUFFER  bb;
-    off_t      pos;
-    off_t      end;
+    int64_t    pos;
+    int64_t    end;
     size_t     size;
 } BITSTREAM;
 
 BD_PRIVATE void bb_init( BITBUFFER *bb, uint8_t *p_data, size_t i_data );
 BD_PRIVATE void bs_init( BITSTREAM *bs, BD_FILE_H *fp );
-BD_PRIVATE void bb_seek( BITBUFFER *bb, off_t off, int whence);
-BD_PRIVATE void bs_seek( BITSTREAM *bs, off_t off, int whence);
+BD_PRIVATE void bb_seek( BITBUFFER *bb, int64_t off, int whence);
+BD_PRIVATE void bs_seek( BITSTREAM *bs, int64_t off, int whence);
 BD_PRIVATE void bb_skip( BITBUFFER *bb, ssize_t i_count );
 BD_PRIVATE void bs_skip( BITSTREAM *bs, ssize_t i_count );
 BD_PRIVATE uint32_t bb_read( BITBUFFER *bb, int i_count );
 BD_PRIVATE uint32_t bs_read( BITSTREAM *bs, int i_count );
 
-static inline off_t bb_pos( const BITBUFFER *bb )
+static inline int64_t bb_pos( const BITBUFFER *bb )
 {
     return 8 * ( bb->p - bb->p_start ) + 8 - bb->i_left;
 }
 
-static inline off_t bs_pos( const BITSTREAM *bs )
+static inline int64_t bs_pos( const BITSTREAM *bs )
 {
     return bs->pos * 8 + bb_pos(&bs->bb);
 }
 
-static inline off_t bs_end( const BITSTREAM *bs )
+static inline int64_t bs_end( const BITSTREAM *bs )
 {
     return bs->end * 8;
 }
@@ -87,17 +87,17 @@ static inline int bs_eof( const BITSTREAM *bs )
 }
 */
 
-static inline off_t bs_avail( const BITSTREAM *bs )
+static inline int64_t bs_avail( const BITSTREAM *bs )
 {
     return bs_end(bs) - bs_pos(bs);
 }
 
-static inline void bb_seek_byte( BITBUFFER *bb, off_t off)
+static inline void bb_seek_byte( BITBUFFER *bb, int64_t off)
 {
     bb_seek(bb, off << 3, SEEK_SET);
 }
 
-static inline void bs_seek_byte( BITSTREAM *s, off_t off)
+static inline void bs_seek_byte( BITSTREAM *s, int64_t off)
 {
     bs_seek(s, off << 3, SEEK_SET);
 }
@@ -133,14 +133,14 @@ static inline uint32_t bb_show( BITBUFFER *bb, int i_count )
 
 static inline int bb_is_align( BITBUFFER *bb, uint32_t mask )
 {
-    off_t off = bb_pos(bb);
+    int64_t off = bb_pos(bb);
 
     return !(off & mask);
 }
 
 static inline int bs_is_align( BITSTREAM *s, uint32_t mask )
 {
-    off_t off = bs_pos(s);
+    int64_t off = bs_pos(s);
 
     return !(off & mask);
 }



More information about the libbluray-devel mailing list