Commit e2d1ee3c authored by Francois Cartegnie's avatar Francois Cartegnie

vlc_bits.h: drop len field

parent 6cb8c31a
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
typedef struct bo_t typedef struct bo_t
{ {
block_t *b; block_t *b;
size_t len;
size_t basesize; size_t basesize;
} bo_t; } bo_t;
...@@ -212,25 +211,25 @@ static inline int bo_init(bo_t *p_bo, int i_size) ...@@ -212,25 +211,25 @@ static inline int bo_init(bo_t *p_bo, int i_size)
return VLC_ENOMEM; return VLC_ENOMEM;
p_bo->b->i_buffer = 0; p_bo->b->i_buffer = 0;
p_bo->len = p_bo->basesize = i_size; p_bo->basesize = i_size;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static inline void bo_set_8(bo_t *p_bo, size_t i_offset, uint8_t i) 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; 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; i_growth += p_bo->basesize;
int i = p_bo->b->i_buffer; /* Realloc would set payload size == buffer size */ 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) if (!p_bo->b)
return; return;
p_bo->b->i_buffer = i; p_bo->b->i_buffer = i;
p_bo->len += i_growth;
} }
p_bo->b->p_buffer[i_offset] = i; 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) ...@@ -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]); 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 #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment