Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
9353736b
Commit
9353736b
authored
Nov 26, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup custom block allocation
parent
3ade296d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
34 deletions
+47
-34
include/vlc_block.h
include/vlc_block.h
+13
-7
modules/access/screen/win32.c
modules/access/screen/win32.c
+1
-5
src/libvlc.sym
src/libvlc.sym
+2
-1
src/misc/block.c
src/misc/block.c
+31
-21
No files found.
include/vlc_block.h
View file @
9353736b
...
@@ -78,6 +78,8 @@ typedef struct block_sys_t block_sys_t;
...
@@ -78,6 +78,8 @@ typedef struct block_sys_t block_sys_t;
#define BLOCK_FLAG_PRIVATE_MASK 0xffff0000
#define BLOCK_FLAG_PRIVATE_MASK 0xffff0000
#define BLOCK_FLAG_PRIVATE_SHIFT 16
#define BLOCK_FLAG_PRIVATE_SHIFT 16
typedef
void
(
*
block_free_t
)
(
block_t
*
);
struct
block_t
struct
block_t
{
{
block_t
*
p_next
;
block_t
*
p_next
;
...
@@ -95,10 +97,8 @@ struct block_t
...
@@ -95,10 +97,8 @@ struct block_t
size_t
i_buffer
;
size_t
i_buffer
;
uint8_t
*
p_buffer
;
uint8_t
*
p_buffer
;
/* This way the block_Release can be overloaded
/* Rudimentary support for overloading block (de)allocation. */
* Don't mess with it now, if you need it the ask on ML
block_free_t
pf_release
;
*/
void
(
*
pf_release
)
(
block_t
*
);
};
};
/****************************************************************************
/****************************************************************************
...
@@ -117,9 +117,15 @@ struct block_t
...
@@ -117,9 +117,15 @@ struct block_t
* and decrease are supported). Use it as it is optimised.
* and decrease are supported). Use it as it is optimised.
* - block_Duplicate : create a copy of a block.
* - block_Duplicate : create a copy of a block.
****************************************************************************/
****************************************************************************/
#define block_New( a, b ) __block_New( NULL, b )
VLC_EXPORT
(
void
,
block_Init
,
(
block_t
*
,
void
*
,
size_t
)
);
VLC_EXPORT
(
block_t
*
,
__block_New
,
(
vlc_object_t
*
,
size_t
)
);
VLC_EXPORT
(
block_t
*
,
block_Alloc
,
(
size_t
)
);
VLC_EXPORT
(
block_t
*
,
block_Realloc
,
(
block_t
*
,
ssize_t
i_pre
,
size_t
i_body
)
);
VLC_EXPORT
(
block_t
*
,
block_Realloc
,
(
block_t
*
,
ssize_t
i_pre
,
size_t
i_body
)
);
static
inline
block_t
*
block_New
(
void
*
dummy
,
size_t
size
)
{
(
void
)
dummy
;
return
block_Alloc
(
size
);
}
static
inline
block_t
*
block_Duplicate
(
block_t
*
p_block
)
static
inline
block_t
*
block_Duplicate
(
block_t
*
p_block
)
{
{
...
...
modules/access/screen/win32.c
View file @
9353736b
...
@@ -205,14 +205,10 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
...
@@ -205,14 +205,10 @@ static block_t *CaptureBlockNew( demux_t *p_demux )
DeleteObject
(
hbmp
);
DeleteObject
(
hbmp
);
return
NULL
;
return
NULL
;
}
}
memset
(
&
p_block
->
self
,
0
,
sizeof
(
block_t
->
self
)
);
/* Fill all fields */
/* Fill all fields */
i_buffer
=
(
p_sys
->
fmt
.
video
.
i_bits_per_pixel
+
7
)
/
8
*
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_sys
->
fmt
.
video
.
i_width
*
p_sys
->
fmt
.
video
.
i_height
;
p_block
->
self
.
p_next
=
NULL
;
block_Init
(
&
p_block
->
self
,
p_buffer
,
i_buffer
);
p_block
->
self
.
i_buffer
=
i_buffer
;
p_block
->
self
.
p_buffer
=
p_buffer
;
p_block
->
self
.
pf_release
=
CaptureBlockRelease
;
p_block
->
self
.
pf_release
=
CaptureBlockRelease
;
p_block
->
hbmp
=
hbmp
;
p_block
->
hbmp
=
hbmp
;
...
...
src/libvlc.sym
View file @
9353736b
...
@@ -71,7 +71,8 @@ block_FifoRelease
...
@@ -71,7 +71,8 @@ block_FifoRelease
block_FifoShow
block_FifoShow
block_FifoCount
block_FifoCount
block_FifoSize
block_FifoSize
__block_New
block_Init
block_Alloc
block_Realloc
block_Realloc
config_ChainCreate
config_ChainCreate
config_ChainDestroy
config_ChainDestroy
...
...
src/misc/block.c
View file @
9353736b
...
@@ -38,10 +38,36 @@ struct block_sys_t
...
@@ -38,10 +38,36 @@ struct block_sys_t
uint8_t
p_allocated_buffer
[
0
];
uint8_t
p_allocated_buffer
[
0
];
};
};
#ifndef NDEBUG
static
void
BlockNoRelease
(
block_t
*
b
)
{
fprintf
(
stderr
,
"block %p has no release callback! This is a bug!
\n
"
,
b
);
abort
();
}
#endif
void
block_Init
(
block_t
*
restrict
b
,
void
*
buf
,
size_t
size
)
{
/* Fill all fields to their default */
b
->
p_next
=
b
->
p_prev
=
NULL
;
b
->
i_flags
=
0
;
b
->
i_pts
=
b
->
i_dts
=
b
->
i_length
=
0
;
b
->
i_rate
=
0
;
b
->
p_buffer
=
buf
;
b
->
i_buffer
=
size
;
#ifndef NDEBUG
b
->
pf_release
=
BlockNoRelease
;
#endif
}
static
void
BlockRelease
(
block_t
*
p_block
)
{
free
(
p_block
);
}
#define BLOCK_PADDING_SIZE 32
#define BLOCK_PADDING_SIZE 32
static
void
BlockRelease
(
block_t
*
);
block_t
*
__block_New
(
vlc_object_t
*
p_obj
,
size_t
i_size
)
block_t
*
block_Alloc
(
size_t
i_size
)
{
{
/* We do only one malloc
/* We do only one malloc
* TODO bench if doing 2 malloc but keeping a pool of buffer is better
* TODO bench if doing 2 malloc but keeping a pool of buffer is better
...
@@ -57,19 +83,9 @@ block_t *__block_New( vlc_object_t *p_obj, size_t i_size )
...
@@ -57,19 +83,9 @@ block_t *__block_New( vlc_object_t *p_obj, size_t i_size )
/* Fill opaque data */
/* Fill opaque data */
p_sys
->
i_allocated_buffer
=
i_alloc
;
p_sys
->
i_allocated_buffer
=
i_alloc
;
/* Fill all fields */
block_Init
(
&
p_sys
->
self
,
p_sys
->
p_allocated_buffer
+
BLOCK_PADDING_SIZE
p_sys
->
self
.
p_next
=
NULL
;
+
16
-
((
uintptr_t
)
p_sys
->
p_allocated_buffer
%
16
),
i_size
);
p_sys
->
self
.
p_prev
=
NULL
;
p_sys
->
self
.
pf_release
=
BlockRelease
;
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_sys
->
self
.
pf_release
=
BlockRelease
;
return
&
p_sys
->
self
;
return
&
p_sys
->
self
;
}
}
...
@@ -139,12 +155,6 @@ block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
...
@@ -139,12 +155,6 @@ block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
return
p_block
;
return
p_block
;
}
}
static
void
BlockRelease
(
block_t
*
p_block
)
{
free
(
p_block
);
}
/*****************************************************************************
/*****************************************************************************
* block_fifo_t management
* block_fifo_t management
*****************************************************************************/
*****************************************************************************/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment