Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
0a3c6b71
Commit
0a3c6b71
authored
Apr 20, 2010
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added picture_pool_Reserve helper.
parent
47c001b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
16 deletions
+82
-16
include/vlc_picture_pool.h
include/vlc_picture_pool.h
+11
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/misc/picture_pool.c
src/misc/picture_pool.c
+70
-16
No files found.
include/vlc_picture_pool.h
View file @
0a3c6b71
...
...
@@ -106,5 +106,16 @@ VLC_EXPORT( picture_t *, picture_pool_Get, ( picture_pool_t * ) );
*/
VLC_EXPORT
(
void
,
picture_pool_NonEmpty
,
(
picture_pool_t
*
,
bool
reset
)
);
/**
* It reserves picture_count pictures from the given pool and returns
* a new pool with thoses pictures.
*
* The master pool must be full.
* The returned pool must be deleted before the master pool.
* When deleted, all pictures return to the master pool.
*/
VLC_EXPORT
(
picture_pool_t
*
,
picture_pool_Reserve
,
(
picture_pool_t
*
,
int
picture_count
)
);
#endif
/* VLC_PICTURE_POOL_H */
src/libvlccore.sym
View file @
0a3c6b71
...
...
@@ -314,6 +314,7 @@ picture_pool_New
picture_pool_NewExtended
picture_pool_NewFromFormat
picture_pool_NonEmpty
picture_pool_Reserve
picture_Reset
picture_Setup
plane_CopyPixels
...
...
src/misc/picture_pool.c
View file @
0a3c6b71
...
...
@@ -52,29 +52,43 @@ struct picture_release_sys_t {
struct
picture_pool_t
{
/* */
int64_t
tick
;
picture_pool_t
*
master
;
int64_t
tick
;
/* */
int
picture_count
;
picture_t
**
picture
;
int
picture_count
;
picture_t
**
picture
;
bool
*
picture_reserved
;
};
static
void
Release
(
picture_t
*
);
static
int
Lock
(
picture_t
*
);
static
void
Unlock
(
picture_t
*
);
picture_pool_t
*
picture_pool_NewExtended
(
const
picture_pool_configuration_t
*
cfg
)
static
picture_pool_t
*
Create
(
picture_pool_t
*
master
,
int
picture_count
)
{
picture_pool_t
*
pool
=
calloc
(
1
,
sizeof
(
*
pool
));
if
(
!
pool
)
return
NULL
;
pool
->
tick
=
1
;
pool
->
picture_count
=
cfg
->
picture_count
;
pool
->
master
=
master
;
pool
->
tick
=
master
?
master
->
tick
:
1
;
pool
->
picture_count
=
picture_count
;
pool
->
picture
=
calloc
(
pool
->
picture_count
,
sizeof
(
*
pool
->
picture
));
if
(
!
pool
->
picture
)
{
pool
->
picture_reserved
=
calloc
(
pool
->
picture_count
,
sizeof
(
*
pool
->
picture_reserved
));
if
(
!
pool
->
picture
||
!
pool
->
picture_reserved
)
{
free
(
pool
->
picture
);
free
(
pool
->
picture_reserved
);
free
(
pool
);
return
NULL
;
}
return
pool
;
}
picture_pool_t
*
picture_pool_NewExtended
(
const
picture_pool_configuration_t
*
cfg
)
{
picture_pool_t
*
pool
=
Create
(
NULL
,
cfg
->
picture_count
);
if
(
!
pool
)
return
NULL
;
for
(
int
i
=
0
;
i
<
cfg
->
picture_count
;
i
++
)
{
picture_t
*
picture
=
cfg
->
picture
[
i
];
...
...
@@ -99,6 +113,7 @@ picture_pool_t *picture_pool_NewExtended(const picture_pool_configuration_t *cfg
/* */
pool
->
picture
[
i
]
=
picture
;
pool
->
picture_reserved
[
i
]
=
false
;
}
return
pool
;
...
...
@@ -139,23 +154,57 @@ error:
return
NULL
;
}
picture_pool_t
*
picture_pool_Reserve
(
picture_pool_t
*
master
,
int
count
)
{
picture_pool_t
*
pool
=
Create
(
master
,
count
);
if
(
!
pool
)
return
NULL
;
int
found
=
0
;
for
(
int
i
=
0
;
i
<
master
->
picture_count
&&
found
<
count
;
i
++
)
{
if
(
master
->
picture_reserved
[
i
])
continue
;
assert
(
master
->
picture
[
i
]
->
i_refcount
==
0
);
master
->
picture_reserved
[
i
]
=
true
;
pool
->
picture
[
found
]
=
master
->
picture
[
i
];
pool
->
picture_reserved
[
found
]
=
false
;
found
++
;
}
if
(
found
<
count
)
{
picture_pool_Delete
(
pool
);
return
NULL
;
}
return
pool
;
}
void
picture_pool_Delete
(
picture_pool_t
*
pool
)
{
for
(
int
i
=
0
;
i
<
pool
->
picture_count
;
i
++
)
{
picture_t
*
picture
=
pool
->
picture
[
i
];
picture_release_sys_t
*
release_sys
=
picture
->
p_release_sys
;
if
(
pool
->
master
)
{
for
(
int
j
=
0
;
j
<
pool
->
master
->
picture_count
;
j
++
)
{
if
(
pool
->
master
->
picture
[
j
]
==
picture
)
pool
->
master
->
picture_reserved
[
j
]
=
false
;
}
}
else
{
picture_release_sys_t
*
release_sys
=
picture
->
p_release_sys
;
assert
(
picture
->
i_refcount
==
0
);
assert
(
picture
->
i_refcount
==
0
);
assert
(
!
pool
->
picture_reserved
[
i
]);
/* Restore old release callback */
picture
->
i_refcount
=
1
;
picture
->
pf_release
=
release_sys
->
release
;
picture
->
p_release_sys
=
release_sys
->
release_sys
;
/* Restore old release callback */
picture
->
i_refcount
=
1
;
picture
->
pf_release
=
release_sys
->
release
;
picture
->
p_release_sys
=
release_sys
->
release_sys
;
picture_Release
(
picture
);
picture_Release
(
picture
);
free
(
release_sys
);
free
(
release_sys
);
}
}
free
(
pool
->
picture_reserved
);
free
(
pool
->
picture
);
free
(
pool
);
}
...
...
@@ -163,6 +212,9 @@ void picture_pool_Delete(picture_pool_t *pool)
picture_t
*
picture_pool_Get
(
picture_pool_t
*
pool
)
{
for
(
int
i
=
0
;
i
<
pool
->
picture_count
;
i
++
)
{
if
(
pool
->
picture_reserved
[
i
])
continue
;
picture_t
*
picture
=
pool
->
picture
[
i
];
if
(
picture
->
i_refcount
>
0
)
continue
;
...
...
@@ -183,8 +235,10 @@ void picture_pool_NonEmpty(picture_pool_t *pool, bool reset)
picture_t
*
old
=
NULL
;
for
(
int
i
=
0
;
i
<
pool
->
picture_count
;
i
++
)
{
picture_t
*
picture
=
pool
->
picture
[
i
];
if
(
pool
->
picture_reserved
[
i
])
continue
;
picture_t
*
picture
=
pool
->
picture
[
i
];
if
(
reset
)
{
if
(
picture
->
i_refcount
>
0
)
Unlock
(
picture
);
...
...
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