vlc_picture_pool.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_picture_pool.h: picture pool definitions
00003  *****************************************************************************
00004  * Copyright (C) 2009 VLC authors and VideoLAN
00005  * $Id: d4574dc5a1dfd2d873c6f286ee612462f886bb33 $
00006  *
00007  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify it
00010  * under the terms of the GNU Lesser General Public License as published by
00011  * the Free Software Foundation; either version 2.1 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  * GNU Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef VLC_PICTURE_POOL_H
00025 #define VLC_PICTURE_POOL_H 1
00026 
00027 /**
00028  * \file
00029  * This file defines picture pool structures and functions in vlc
00030  */
00031 
00032 #include <vlc_picture.h>
00033 
00034 /**
00035  * Picture pool handle
00036  *
00037  * XXX it is not thread safe, all pool manipulations and picture_Release
00038  * must be properly locked if needed.
00039  */
00040 typedef struct picture_pool_t picture_pool_t;
00041 
00042 /**
00043  * Picture pool configuration
00044  */
00045 typedef struct {
00046     int       picture_count;
00047     picture_t **picture;
00048 
00049     int       (*lock)(picture_t *);
00050     void      (*unlock)(picture_t *);
00051 } picture_pool_configuration_t;
00052 
00053 /**
00054  * It creates a picture_pool_t wrapping the given configuration.
00055  *
00056  * It avoids useless picture creations/destructions.
00057  * The given picture must not have a reference count greater than 1.
00058  * The pool takes ownership of the picture and MUST not be used directly.
00059  * When deleted, the pool will release the pictures using picture_Release.
00060  * If defined, picture_pool_configuration_t::lock will be called before
00061  * a picture is used, and picture_pool_configuration_t::unlock will be called
00062  * as soon as a picture is unused. They are allowed to modify picture_t::p and
00063  * access picture_t::p_sys.
00064  */
00065 VLC_API picture_pool_t * picture_pool_NewExtended( const picture_pool_configuration_t * ) VLC_USED;
00066 
00067 /**
00068  * It creates a picture_pool_t wrapping the given arrays of picture.
00069  *
00070  * It is provided as convenience.
00071  */
00072 VLC_API picture_pool_t * picture_pool_New( int picture_count, picture_t *picture[] ) VLC_USED;
00073 
00074 /**
00075  * It creates a picture_pool_t creating images using the given format.
00076  *
00077  * Provided for convenience.
00078  */
00079 VLC_API picture_pool_t * picture_pool_NewFromFormat( const video_format_t *, int picture_count ) VLC_USED;
00080 
00081 /**
00082  * It destroys a pool created by picture_pool_New.
00083  *
00084  * All pictures must already be released to the pool. The pool will then
00085  * released them.
00086  */
00087 VLC_API void picture_pool_Delete( picture_pool_t * );
00088 
00089 /**
00090  * It retreives a picture_t from a pool.
00091  *
00092  * The picture must be release by using picture_Release.
00093  */
00094 VLC_API picture_t * picture_pool_Get( picture_pool_t * ) VLC_USED;
00095 
00096 /**
00097  * It forces the next picture_pool_Get to return a picture even if no
00098  * pictures are free.
00099  *
00100  * If b_reset is true, all pictures will be marked as free.
00101  *
00102  * It does it by releasing itself the oldest used picture if none is
00103  * available.
00104  * XXX it should be used with great care, the only reason you may need
00105  * it is to workaround a bug.
00106  */
00107 VLC_API void picture_pool_NonEmpty( picture_pool_t *, bool reset );
00108 
00109 /**
00110  * It reserves picture_count pictures from the given pool and returns
00111  * a new pool with thoses pictures.
00112  *
00113  * The master pool must be full.
00114  * The returned pool must be deleted before the master pool.
00115  * When deleted, all pictures return to the master pool.
00116  */
00117 VLC_API picture_pool_t * picture_pool_Reserve(picture_pool_t *, int picture_count) VLC_USED;
00118 
00119 /**
00120  * It returns the size of the given pool.
00121  */
00122 VLC_API int picture_pool_GetSize(picture_pool_t *);
00123 
00124 
00125 #endif /* VLC_PICTURE_POOL_H */
00126 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines