24 #ifndef VLC_BLOCK_HELPER_H
25 #define VLC_BLOCK_HELPER_H 1
50 block_t *p_next = block->p_next;
52 block_Release( block );
62 block_BytestreamRelease( p_bytestream );
63 block_BytestreamInit( p_bytestream );
73 while( block != p_bytestream->
p_block )
75 block_t *p_next = block->p_next;
77 block_Release( block );
83 block_t *p_next = block->p_next;
85 block_Release( block );
96 block_ChainAppend( &p_bytestream->
p_chain, p_block );
105 block_BytestreamFlush( p_bytestream );
107 p_block = p_bytestream->
p_block;
108 if( p_block == NULL )
112 else if( !p_block->p_next )
121 while( p_block->p_next && p_block->p_next->p_next )
122 p_block = p_block->p_next;
124 block_t *p_block_old = p_block;
125 p_block = p_block->p_next;
126 p_block_old->p_next = NULL;
144 for( p_block = p_bytestream->
p_block->p_next;
145 p_block != NULL; p_block = p_block->p_next )
150 p_bytestream->
p_block = p_block;
174 for( p_block = p_bytestream->
p_block->p_next;
175 p_block != NULL; p_block = p_block->p_next )
204 for( p_block = p_bytestream->
p_block->p_next;
205 p_block != NULL; p_block = p_block->p_next )
211 p_bytestream->
p_block = p_block;
225 size_t i_offset, i_copy, i_size;
231 for( p_block = p_bytestream->
p_block;
232 p_block != NULL; p_block = p_block->p_next )
234 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
253 size_t i_offset, i_copy;
258 for( p_block = p_bytestream->
p_block;
259 p_block != NULL; p_block = p_block->p_next )
261 i_copy = __MIN( i_data, p_block->
i_buffer - i_offset );
275 p_bytestream->
p_block = p_block;
276 p_bytestream->
i_offset = i_offset + i_copy;
281 uint8_t *p_data,
size_t i_data )
284 size_t i_offset, i_copy, i_size;
290 for( p_block = p_bytestream->
p_block;
291 p_block != NULL; p_block = p_block->p_next )
293 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
310 for( p_block = p_bytestream->
p_block;
311 p_block != NULL; p_block = p_block->p_next )
313 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
318 memcpy( p_data, p_block->
p_buffer + i_offset, i_copy );
331 uint8_t *p_data,
size_t i_data )
334 size_t i_offset, i_copy, i_size;
340 for( p_block = p_bytestream->
p_block;
341 p_block != NULL; p_block = p_block->p_next )
343 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
360 for( p_block = p_bytestream->
p_block;
361 p_block != NULL; p_block = p_block->p_next )
363 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
368 memcpy( p_data, p_block->
p_buffer + i_offset, i_copy );
377 p_bytestream->
p_block = p_block;
378 p_bytestream->
i_offset = i_offset + i_copy;
384 size_t i_peek_offset, uint8_t *p_data,
size_t i_data )
387 size_t i_offset, i_copy, i_size;
391 i_size = i_data + i_peek_offset;
393 for( p_block = p_bytestream->
p_block;
394 p_block != NULL; p_block = p_block->p_next )
396 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
411 i_size = i_peek_offset;
413 for( p_block = p_bytestream->
p_block;
414 p_block != NULL; p_block = p_block->p_next )
416 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
428 for( ; p_block != NULL; p_block = p_block->p_next )
430 i_copy = __MIN( i_size, p_block->
i_buffer - i_offset );
435 memcpy( p_data, p_block->
p_buffer + i_offset, i_copy );
447 static inline int block_FindStartcodeFromOffset(
449 const uint8_t *p_startcode,
int i_startcode_length )
451 block_t *p_block, *p_block_backup = 0;
453 size_t i_offset, i_offset_backup = 0;
454 int i_caller_offset_backup = 0, i_match;
457 i_size = *pi_offset + p_bytestream->
i_offset;
458 for( p_block = p_bytestream->
p_block;
459 p_block != NULL; p_block = p_block->p_next )
462 if( i_size < 0 )
break;
475 *pi_offset -= i_size;
477 for( ; p_block != NULL; p_block = p_block->p_next )
479 for( i_offset = i_size; i_offset < p_block->
i_buffer; i_offset++ )
481 if( p_block->
p_buffer[i_offset] == p_startcode[i_match] )
485 p_block_backup = p_block;
486 i_offset_backup = i_offset;
487 i_caller_offset_backup = *pi_offset;
490 if( i_match + 1 == i_startcode_length )
493 *pi_offset += i_offset - i_match;
502 p_block = p_block_backup;
503 i_offset = i_offset_backup;
504 *pi_offset = i_caller_offset_backup;
510 *pi_offset += i_offset;
513 *pi_offset -= i_match;
Definition: vlc_block_helper.h:29
size_t i_buffer
Definition: vlc_block.h:107
#define VLC_SUCCESS
Definition: vlc_common.h:373
block_t * p_chain
Definition: vlc_block_helper.h:31
size_t i_offset
Definition: vlc_block_helper.h:33
#define VLC_EGENERIC
Definition: vlc_common.h:374
Definition: vlc_block.h:102
uint8_t * p_buffer
Definition: vlc_block.h:106
block_t * p_block
Definition: vlc_block_helper.h:32