]> git.sesse.net Git - vlc/blob - src/video_output/vout_pictures.h
Merge branch 1.0-bugfix
[vlc] / src / video_output / vout_pictures.h
1 /*****************************************************************************
2  * vout_pictures.h : picture management definitions
3  *****************************************************************************
4  * Copyright (C) 2002-2004 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Fourcc definitions that we can handle internally
26  *****************************************************************************/
27
28 /* Alignment of critical dynamic data structure
29  *
30  * Not all platforms support memalign so we provide a vlc_memalign wrapper
31  * void *vlc_memalign( size_t align, size_t size, void **pp_orig )
32  * *pp_orig is the pointer that has to be freed afterwards.
33  */
34 static inline
35 void *vlc_memalign (void **pp, size_t align, size_t size)
36 {
37 #if defined (HAVE_POSIX_MEMALIGN)
38     return posix_memalign (pp, align, size) ? NULL : *pp;
39 #elif defined (HAVE_MEMALIGN)
40     return *pp = memalign (align, size);
41 #else
42     unsigned char *ptr;
43
44     if (align < 1)
45         return NULL;
46
47     align--;
48     ptr = malloc (size + align);
49     if (ptr == NULL)
50         return NULL;
51
52     *pp = ptr;
53     ptr += align;
54     return (void *)(((uintptr_t)ptr) & ~align);
55 #endif
56 }
57