]> git.sesse.net Git - vlc/commitdiff
vlc_bits.h: drop len field
authorFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 19 Mar 2015 17:57:44 +0000 (18:57 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 19 Mar 2015 19:52:46 +0000 (20:52 +0100)
include/vlc_bits.h

index 1eba5e9ae655106fb7df9e759849f2c53f953d84..ee3cfedb03935df1fcc96444db5ec3bd037ba664 100644 (file)
@@ -36,7 +36,6 @@
 typedef struct bo_t
 {
     block_t     *b;
-    size_t      len;
     size_t      basesize;
 } bo_t;
 
@@ -212,25 +211,25 @@ static inline int bo_init(bo_t *p_bo, int i_size)
         return VLC_ENOMEM;
 
     p_bo->b->i_buffer = 0;
-    p_bo->len = p_bo->basesize = i_size;
+    p_bo->basesize = i_size;
 
     return VLC_SUCCESS;
 }
 
 static inline void bo_set_8(bo_t *p_bo, size_t i_offset, uint8_t i)
 {
-    if (i_offset >= p_bo->len)
+    size_t i_size = p_bo->b->i_size - (p_bo->b->p_buffer - p_bo->b->p_start);
+    if (i_offset >= i_size)
     {
         int i_growth = p_bo->basesize;
-        while(i_offset >= p_bo->len + i_growth)
+        while(i_offset >= i_size + i_growth)
             i_growth += p_bo->basesize;
 
         int i = p_bo->b->i_buffer; /* Realloc would set payload size == buffer size */
-        p_bo->b = block_Realloc(p_bo->b, 0, p_bo->len + i_growth);
+        p_bo->b = block_Realloc(p_bo->b, 0, i_size + i_growth);
         if (!p_bo->b)
             return;
         p_bo->b->i_buffer = i;
-        p_bo->len += i_growth;
     }
     p_bo->b->p_buffer[i_offset] = i;
 }
@@ -336,12 +335,4 @@ static inline void bo_add_mem(bo_t *p_bo, int i_size, const uint8_t *p_mem)
         bo_add_8(p_bo, p_mem[i]);
 }
 
-static inline void bo_add_mp4_tag_descr(bo_t *p_bo, uint8_t tag, uint32_t size)
-{
-    bo_add_8(p_bo, tag);
-    for (int i = 3; i>0; i--)
-        bo_add_8(p_bo, (size>>(7*i)) | 0x80);
-    bo_add_8(p_bo, size & 0x7F);
-}
-
 #endif