33 #include <sys/types.h>
55 #define BLOCK_FLAG_DISCONTINUITY 0x0001
57 #define BLOCK_FLAG_TYPE_I 0x0002
59 #define BLOCK_FLAG_TYPE_P 0x0004
61 #define BLOCK_FLAG_TYPE_B 0x0008
63 #define BLOCK_FLAG_TYPE_PB 0x0010
65 #define BLOCK_FLAG_HEADER 0x0020
67 #define BLOCK_FLAG_END_OF_FRAME 0x0040
69 #define BLOCK_FLAG_NO_KEYFRAME 0x0080
71 #define BLOCK_FLAG_END_OF_SEQUENCE 0x0100
73 #define BLOCK_FLAG_CLOCK 0x0200
75 #define BLOCK_FLAG_SCRAMBLED 0x0400
77 #define BLOCK_FLAG_PREROLL 0x0800
79 #define BLOCK_FLAG_CORRUPTED 0x1000
81 #define BLOCK_FLAG_TOP_FIELD_FIRST 0x2000
83 #define BLOCK_FLAG_BOTTOM_FIELD_FIRST 0x4000
86 #define BLOCK_FLAG_INTERLACED_MASK \
87 (BLOCK_FLAG_TOP_FIELD_FIRST|BLOCK_FLAG_BOTTOM_FIELD_FIRST)
89 #define BLOCK_FLAG_TYPE_MASK \
90 (BLOCK_FLAG_TYPE_I|BLOCK_FLAG_TYPE_P|BLOCK_FLAG_TYPE_B|BLOCK_FLAG_TYPE_PB)
93 #define BLOCK_FLAG_CORE_PRIVATE_MASK 0x00ff0000
94 #define BLOCK_FLAG_CORE_PRIVATE_SHIFT 16
97 #define BLOCK_FLAG_PRIVATE_MASK 0xff000000
98 #define BLOCK_FLAG_PRIVATE_SHIFT 24
100 typedef void (*block_free_t) (
block_t *);
112 unsigned i_nb_samples;
119 block_free_t pf_release;
138 VLC_API
void block_Init(
block_t *,
void *,
size_t );
139 VLC_API
block_t *block_Alloc(
size_t ) VLC_USED VLC_MALLOC;
140 VLC_API
block_t *block_Realloc(
block_t *, ssize_t i_pre,
size_t i_body ) VLC_USED;
142 static inline
void block_CopyProperties( block_t *dst, block_t *src )
144 dst->i_flags = src->i_flags;
145 dst->i_nb_samples = src->i_nb_samples;
146 dst->i_dts = src->i_dts;
147 dst->i_pts = src->i_pts;
148 dst->i_length = src->i_length;
158 block_CopyProperties( p_dup, p_block );
164 static inline void block_Release(
block_t *p_block )
166 p_block->pf_release( p_block );
169 VLC_API
block_t *block_heap_Alloc(
void *,
size_t) VLC_USED VLC_MALLOC;
170 VLC_API
block_t *block_mmap_Alloc(
void *addr,
size_t length) VLC_USED VLC_MALLOC;
171 VLC_API
block_t * block_shm_Alloc(
void *addr,
size_t length) VLC_USED VLC_MALLOC;
172 VLC_API
block_t *block_File(
int fd) VLC_USED VLC_MALLOC;
173 VLC_API
block_t *block_FilePath(const
char *) VLC_USED VLC_MALLOC;
175 static inline
void block_Cleanup (
void *block)
177 block_Release ((
block_t *)block);
179 #define block_cleanup_push( block ) vlc_cleanup_push (block_Cleanup, block)
193 static inline void block_ChainAppend(
block_t **pp_list,
block_t *p_block )
195 if( *pp_list == NULL )
203 while( p->p_next ) p = p->p_next;
208 static inline void block_ChainLastAppend(
block_t ***ppp_last,
block_t *p_block )
212 **ppp_last = p_block;
214 while( p_last->p_next ) p_last = p_last->p_next;
215 *ppp_last = &p_last->p_next;
218 static inline void block_ChainRelease(
block_t *p_block )
222 block_t *p_next = p_block->p_next;
223 block_Release( p_block );
228 static size_t block_ChainExtract(
block_t *p_list,
void *p_data,
size_t i_max )
231 uint8_t *p = (uint8_t*)p_data;
233 while( p_list && i_max )
235 size_t i_copy = __MIN( i_max, p_list->
i_buffer );
236 memcpy( p, p_list->
p_buffer, i_copy );
241 p_list = p_list->p_next;
246 static inline void block_ChainProperties(
block_t *p_list,
int *pi_count,
size_t *pi_size,
mtime_t *pi_length )
255 i_length += p_list->i_length;
258 p_list = p_list->p_next;
264 *pi_length = i_length;
275 if( p_list->p_next == NULL )
278 block_ChainProperties( p_list, NULL, &i_total, &i_length );
280 g = block_Alloc( i_total );
283 g->i_flags = p_list->i_flags;
284 g->i_pts = p_list->i_pts;
285 g->i_dts = p_list->i_dts;
286 g->i_length = i_length;
289 block_ChainRelease( p_list );
310 VLC_API block_fifo_t *block_FifoNew(
void ) VLC_USED VLC_MALLOC;
311 VLC_API
void block_FifoRelease( block_fifo_t * );
312 VLC_API
void block_FifoPace( block_fifo_t *fifo,
size_t max_depth,
size_t max_size );
313 VLC_API
void block_FifoEmpty( block_fifo_t * );
314 VLC_API
size_t block_FifoPut( block_fifo_t *,
block_t * );
315 void block_FifoWake( block_fifo_t * );
316 VLC_API block_t * block_FifoGet( block_fifo_t * ) VLC_USED;
317 VLC_API block_t * block_FifoShow( block_fifo_t * );
318 size_t block_FifoSize( const block_fifo_t *p_fifo ) VLC_USED;
319 VLC_API
size_t block_FifoCount( const block_fifo_t *p_fifo ) VLC_USED;
size_t i_buffer
Definition: vlc_block.h:107
uint8_t * p_start
Definition: vlc_block.h:108
size_t i_size
Definition: vlc_block.h:109
int64_t mtime_t
Definition: vlc_common.h:153
Definition: vlc_block.h:102
uint8_t * p_buffer
Definition: vlc_block.h:106