VLC 4.0.0-dev
vlc_picture_pool.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_picture_pool.h: picture pool definitions
3 *****************************************************************************
4 * Copyright (C) 2009 VLC authors and VideoLAN
5 *
6 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
22
23#ifndef VLC_PICTURE_POOL_H
24#define VLC_PICTURE_POOL_H 1
25
26/**
27 * \file
28 * This file defines picture pool structures and functions in vlc
29 */
30
31#include <vlc_picture.h>
32
33/**
34 * Picture pool handle
35 */
36typedef struct picture_pool_t picture_pool_t;
38/**
39 * Creates a pool of preallocated pictures. Free pictures can be allocated from
40 * the pool, and are returned to the pool when they are no longer referenced.
41 *
42 * This avoids allocating and deallocationg pictures repeatedly, and ensures
43 * that memory consumption remains within limits.
44 *
45 * To obtain a picture from the pool, use picture_pool_Get(). To increase and
46 * decrease the reference count, use picture_Hold() and picture_Release()
47 * respectively.
48 *
49 * @param count number of pictures in the array
50 * @param tab array of pictures
51 *
52 * @return a pointer to the new pool on success, or NULL on error
53 * (pictures are <b>not</b> released on error)
54 */
56 picture_t *const *tab) VLC_USED;
57
58/**
59 * Allocates pictures from the heap and creates a picture pool with them.
60 * This is a convenience wrapper for picture_NewFromFormat() and
61 * picture_pool_New().
62 *
63 * @param fmt video format of pictures to allocate from the heap
64 * @param count number of pictures to allocate
65 *
66 * @return a pointer to the new pool on success, NULL on error
67 */
69 unsigned count) VLC_USED;
70
71/**
72 * Releases a pool created by picture_pool_New()
73 * or picture_pool_NewFromFormat().
74 *
75 * @note If there are no pending references to the pooled pictures, and the
76 * picture_resource_t.pf_destroy callback was not NULL, it will be invoked.
77 * Otherwise the default callback will be used.
78 *
79 * @warning If there are pending references (a.k.a. late pictures), the
80 * pictures will remain valid until the all pending references are dropped by
81 * picture_Release().
82 */
84
85/**
86 * Obtains a picture from a pool if any is immediately available.
87 *
88 * The picture must be released with picture_Release().
89 *
90 * @return a picture, or NULL if all pictures in the pool are allocated
91 *
92 * @note This function is thread-safe.
93 */
95
96/**
97 * Obtains a picture from a pool.
98 *
99 * The picture must be released with picture_Release().
100 *
101 * @return a picture or NULL on memory error
102 *
103 * @note This function is thread-safe.
104 */
106
107/**
108 * Reserves pictures from a pool and creates a new pool with those.
109 *
110 * When the new pool is released, pictures are returned to the master pool.
111 * If the master pool was already released, pictures will be destroyed.
112 *
113 * @param count number of picture to reserve
114 *
115 * @return the new pool, or NULL if there were not enough pictures available
116 * or on error
117 *
118 * @note This function is thread-safe (but it might return NULL if other
119 * threads have already allocated too many pictures).
120 */
123
124/**
125 * @return the total number of pictures in the given pool
126 * @note This function is thread-safe.
127 */
128unsigned picture_pool_GetSize(const picture_pool_t *);
129
130
131#endif /* VLC_PICTURE_POOL_H */
132
size_t count
Definition: core.c:403
#define VLC_USED
Definition: fourcc_gen.c:32
#define VLC_API
Definition: fourcc_gen.c:31
Definition: picture_pool.c:43
Video picture.
Definition: vlc_picture.h:130
video format description
Definition: vlc_es.h:352
This file is a collection of common definitions and types.
This file defines picture structures and functions in vlc.
picture_pool_t * picture_pool_NewFromFormat(const video_format_t *fmt, unsigned count)
Allocates pictures from the heap and creates a picture pool with them.
Definition: picture_pool.c:127
picture_t * picture_pool_Wait(picture_pool_t *)
Obtains a picture from a pool.
Definition: picture_pool.c:203
picture_t * picture_pool_Get(picture_pool_t *)
Obtains a picture from a pool if any is immediately available.
Definition: picture_pool.c:184
void picture_pool_Release(picture_pool_t *)
Releases a pool created by picture_pool_New() or picture_pool_NewFromFormat().
Definition: picture_pool.c:61
picture_pool_t * picture_pool_New(unsigned count, picture_t *const *tab)
Creates a pool of preallocated pictures.
Definition: picture_pool.c:102
unsigned picture_pool_GetSize(const picture_pool_t *)
Definition: picture_pool.c:218
picture_pool_t * picture_pool_Reserve(picture_pool_t *, unsigned count)
Reserves pictures from a pool and creates a new pool with those.
Definition: picture_pool.c:156