]> git.sesse.net Git - vlc/commitdiff
Made vlc_memalign public.
authorLaurent Aimar <fenrir@videolan.org>
Sun, 9 May 2010 13:54:30 +0000 (15:54 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 9 May 2010 14:18:40 +0000 (16:18 +0200)
include/vlc_common.h
src/Makefile.am
src/libvlccore.sym
src/misc/cpu.c
src/video_output/video_output.c
src/video_output/vout_pictures.c
src/video_output/vout_pictures.h [deleted file]

index e42bba64329b02b32ed529209d665627800524e6..9cb0273d50902caf5c839ce9dc68086aab1ed7b0 100644 (file)
@@ -829,6 +829,8 @@ static inline uint64_t ntoh64 (uint64_t ll)
 
 VLC_EXPORT( bool, vlc_ureduce, ( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t ) );
 
+VLC_EXPORT( void *, vlc_memalign, ( void **base, size_t alignment, size_t size ) );
+
 /* iconv wrappers (defined in src/extras/libc.c) */
 typedef void *vlc_iconv_t;
 VLC_EXPORT( vlc_iconv_t, vlc_iconv_open, ( const char *, const char * ) LIBVLC_USED );
index bd81fe4096e26c1df7439f05c9bed971eae67c61..25748c2625e5f48eb3390f2f2aae43df7a00253e 100644 (file)
@@ -375,7 +375,6 @@ SOURCES_libvlc_common = \
        video_output/postprocessing.h \
        video_output/video_output.c \
        video_output/vout_pictures.c \
-       video_output/vout_pictures.h \
        video_output/video_text.c \
        video_output/video_epg.c \
        video_output/video_widgets.c \
index 9bc39d3ae2a8cf00d3e991fa37cb8527c06c920e..fa8d962eac2ff9a73f26be3cd137671264efe1e6 100644 (file)
@@ -530,6 +530,7 @@ vlc_list_children
 vlc_list_release
 vlc_memcpy
 vlc_memset
+vlc_memalign
 vlc_meta_AddExtra
 vlc_meta_CopyExtraNames
 vlc_meta_Delete
index a2db2c2f562465bfe4d46574f3503d3f72eec179..83b95603b9982c4ce4b995f1e4d6a0c2e2c05e33 100644 (file)
@@ -41,6 +41,7 @@
 #else
 #include <errno.h>
 #endif
+#include <assert.h>
 
 #include "libvlc.h"
 
@@ -405,3 +406,32 @@ void *vlc_memset (void *tgt, int c, size_t n)
 {
     return pf_vlc_memset (tgt, c, n);
 }
+
+/**
+ * Returned an aligned pointer on newly allocated memory.
+ * \param alignment must be a power of 2 and a multiple of sizeof(void*)
+ * \param size is the size of the usable memory returned.
+ *
+ * It must not be freed directly, *base must.
+ */
+void *vlc_memalign(void **base, size_t alignment, size_t size)
+{
+    assert(alignment >= sizeof(void*));
+    for (size_t t = alignment; t > 1; t >>= 1)
+        assert((t&1) == 0);
+#if defined(HAVE_POSIX_MEMALIGN)
+    if (posix_memalign(base, alignment, size)) {
+        *base = NULL;
+        return NULL;
+    }
+    return *base;
+#elif defined(HAVE_MEMALIGN)
+    return *base = memalign(alignment, size);
+#else
+    unsigned char *p = *base = malloc(size + alignment - 1);
+    if (!p)
+        return NULL;
+    return (void*)((uintptr_t)(p + alignment - 1) & ~(alignment - 1));
+#endif
+}
+
index 79c4ad37e0bea1355bb43163189b643fd86955d5..362e9e31b9bbfb35a19809ceca94e44938df3dbe 100644 (file)
@@ -47,7 +47,6 @@
 
 #include <libvlc.h>
 #include <vlc_input.h>
-#include "vout_pictures.h"
 #include "vout_internal.h"
 #include "interlacing.h"
 #include "postprocessing.h"
index 3519caa70d3924202a54c1ee867a6429f8628e18..8d0b9d3e1e46cfb12fc56c590af230af7a31e8b8 100644 (file)
@@ -41,7 +41,6 @@
 #include <vlc_picture_fifo.h>
 #include <vlc_picture_pool.h>
 
-#include "vout_pictures.h"
 #include "vout_internal.h"
 
 /**
diff --git a/src/video_output/vout_pictures.h b/src/video_output/vout_pictures.h
deleted file mode 100644 (file)
index 8d41545..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * vout_pictures.h : picture management definitions
- *****************************************************************************
- * Copyright (C) 2002-2004 the VideoLAN team
- * $Id$
- *
- * Authors: Samuel Hocevar <sam@zoy.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Fourcc definitions that we can handle internally
- *****************************************************************************/
-
-/* Alignment of critical dynamic data structure
- *
- * Not all platforms support memalign so we provide a vlc_memalign wrapper
- * void *vlc_memalign( size_t align, size_t size, void **pp_orig )
- * *pp_orig is the pointer that has to be freed afterwards.
- */
-static inline
-void *vlc_memalign (void **pp, size_t align, size_t size)
-{
-#if defined (HAVE_POSIX_MEMALIGN)
-    return posix_memalign (pp, align, size) ? NULL : *pp;
-#elif defined (HAVE_MEMALIGN)
-    return *pp = memalign (align, size);
-#else
-    unsigned char *ptr;
-
-    if (align < 1)
-        return NULL;
-
-    align--;
-    ptr = malloc (size + align);
-    if (ptr == NULL)
-        return NULL;
-
-    *pp = ptr;
-    ptr += align;
-    return (void *)(((uintptr_t)ptr) & ~align);
-#endif
-}
-