VLC 4.0.0-dev
Loading...
Searching...
No Matches
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#endif /* VLC_PICTURE_POOL_H */
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:356
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:167
picture_t * picture_pool_Wait(picture_pool_t *)
Obtains a picture from a pool.
Definition picture_pool.c:227
picture_t * picture_pool_Get(picture_pool_t *)
Obtains a picture from a pool if any is immediately available.
Definition picture_pool.c:208
void picture_pool_Release(picture_pool_t *)
Releases a pool created by picture_pool_New() or picture_pool_NewFromFormat().
Definition picture_pool.c:64
picture_pool_t * picture_pool_New(unsigned count, picture_t *const *tab)
Creates a pool of preallocated pictures.
Definition picture_pool.c:153