Commit c9aee938 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove block_t->p_sys, which is not really needed either.

parent 3de41162
......@@ -99,11 +99,6 @@ struct block_t
* Don't mess with it now, if you need it the ask on ML
*/
void (*pf_release) ( block_t * );
/* Following fields are private, user should never touch it */
/* XXX never touch that OK !!! the first that access that will
* have Subversion account removed ;) XXX */
block_sys_t *p_sys;
};
/****************************************************************************
......
......@@ -157,6 +157,7 @@ int screen_CloseCapture( demux_t *p_demux )
struct block_sys_t
{
block_t self;
HBITMAP hbmp;
};
......@@ -170,7 +171,7 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
screen_data_t *p_data = p_sys->p_data;
block_t *p_block;
block_sys_t *p_block;
void *p_buffer;
int i_buffer;
HBITMAP hbmp;
......@@ -204,17 +205,16 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
DeleteObject( hbmp );
return NULL;
}
memset( p_block, 0, sizeof( block_t ) );
p_block->p_sys = (block_sys_t *)( (uint8_t *)p_block + sizeof( block_t ) );
memset( &p_block->self, 0, sizeof( block_t->self ) );
/* Fill all fields */
i_buffer = (p_sys->fmt.video.i_bits_per_pixel + 7) / 8 *
p_sys->fmt.video.i_width * p_sys->fmt.video.i_height;
p_block->p_next = NULL;
p_block->i_buffer = i_buffer;
p_block->p_buffer = p_buffer;
p_block->pf_release = CaptureBlockRelease;
p_block->p_sys->hbmp = hbmp;
p_block->self.p_next = NULL;
p_block->self.i_buffer = i_buffer;
p_block->self.p_buffer = p_buffer;
p_block->self.pf_release = CaptureBlockRelease;
p_block->hbmp = hbmp;
return p_block;
}
......
......@@ -33,6 +33,7 @@
/* private */
struct block_sys_t
{
block_t self;
size_t i_allocated_buffer;
uint8_t p_allocated_buffer[0];
};
......@@ -47,40 +48,35 @@ block_t *__block_New( vlc_object_t *p_obj, size_t i_size )
* 16 -> align on 16
* 2 * BLOCK_PADDING_SIZE -> pre + post padding
*/
block_sys_t *p_sys;
const size_t i_alloc = i_size + 2 * BLOCK_PADDING_SIZE + 16;
block_t *p_block =
malloc( sizeof( block_t ) + sizeof( block_sys_t ) + i_alloc );
block_sys_t *p_sys = malloc( sizeof( *p_sys ) + i_alloc );
if( p_block == NULL )
if( p_sys == NULL )
return NULL;
/* Fill opaque data */
p_sys = (block_sys_t*)( (uint8_t*)p_block + sizeof( block_t ) );
p_sys->i_allocated_buffer = i_alloc;
/* Fill all fields */
p_block->p_next = NULL;
p_block->p_prev = NULL;
p_block->i_flags = 0;
p_block->i_pts = 0;
p_block->i_dts = 0;
p_block->i_length = 0;
p_block->i_rate = 0;
p_block->i_buffer = i_size;
p_block->p_buffer =
p_sys->self.p_next = NULL;
p_sys->self.p_prev = NULL;
p_sys->self.i_flags = 0;
p_sys->self.i_pts = 0;
p_sys->self.i_dts = 0;
p_sys->self.i_length = 0;
p_sys->self.i_rate = 0;
p_sys->self.i_buffer = i_size;
p_sys->self.p_buffer =
&p_sys->p_allocated_buffer[BLOCK_PADDING_SIZE +
16 - ((uintptr_t)p_sys->p_allocated_buffer % 16 )];
p_block->pf_release = BlockRelease;
p_sys->self.pf_release = BlockRelease;
/* Is ok, as no comunication between p_vlc */
p_block->p_sys = p_sys;
return p_block;
return &p_sys->self;
}
block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
{
block_sys_t *p_sys = (block_sys_t *)p_block;
ssize_t i_buffer_size;
if( p_block->pf_release != BlockRelease )
......@@ -103,16 +99,16 @@ block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
return NULL;
}
if( p_block->p_buffer - i_prebody > p_block->p_sys->p_allocated_buffer &&
p_block->p_buffer - i_prebody < p_block->p_sys->p_allocated_buffer +
p_block->p_sys->i_allocated_buffer )
if( p_block->p_buffer - i_prebody > p_sys->p_allocated_buffer &&
p_block->p_buffer - i_prebody < p_sys->p_allocated_buffer +
p_sys->i_allocated_buffer )
{
p_block->p_buffer -= i_prebody;
p_block->i_buffer += i_prebody;
i_prebody = 0;
}
if( p_block->p_buffer + i_body < p_block->p_sys->p_allocated_buffer +
p_block->p_sys->i_allocated_buffer )
if( p_block->p_buffer + i_body < p_sys->p_allocated_buffer +
p_sys->i_allocated_buffer )
{
p_block->i_buffer = i_buffer_size;
i_body = 0;
......
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