]> git.sesse.net Git - vlc/commitdiff
Privatize the memalign replacement
authorRémi Denis-Courmont <rem@videolan.org>
Fri, 25 Jan 2008 16:38:14 +0000 (16:38 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Fri, 25 Jan 2008 16:38:14 +0000 (16:38 +0000)
include/vlc_common.h
modules/gui/macosx/voutqt.m
src/video_output/vout_pictures.h

index c9211be106eab555625be5979538f424c90a5edd..7df93cd856b4d4c221286b00915fa18223dfce28 100644 (file)
@@ -818,34 +818,6 @@ static inline void _SetQWBE( uint8_t *p, uint64_t i_qw )
 /* */
 #define VLC_UNUSED(x) (void)(x)
 
-/* 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.
- */
-#if 0
-#ifdef HAVE_POSIX_MEMALIGN
-#   define vlc_memalign(align,size,pp_orig) \
-    ( !posix_memalign( pp_orig, align, size ) ? *(pp_orig) : NULL )
-#endif
-#endif
-#ifdef HAVE_MEMALIGN
-    /* Some systems have memalign() but no declaration for it */
-    void * memalign( size_t align, size_t size );
-
-#   define vlc_memalign(pp_orig,align,size) \
-    ( *(pp_orig) = memalign( align, size ) )
-
-#else /* We don't have any choice but to align manually */
-#   define vlc_memalign(pp_orig,align,size) \
-    (( *(pp_orig) = malloc( size + align - 1 )) \
-        ? (void *)( (((unsigned long)*(pp_orig)) + (unsigned long)(align-1) ) \
-                       & (~(unsigned long)(align-1)) ) \
-        : NULL )
-
-#endif
-
 /* Stuff defined in src/extras/libc.c */
 #ifndef HAVE_STRDUP
 #   define strdup vlc_strdup
index 6f80948a9f782a5edd6028c6b6f222fe2e9f6f40..aeb878468fb45f18649da5651fdf30d7c0cb5865 100644 (file)
@@ -29,9 +29,9 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <string.h>
+#include <assert.h>
 
 #include <QuickTime/QuickTime.h>
 
@@ -704,8 +704,11 @@ static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
             p_pic->p_sys->i_size = p_vout->output.i_width * p_vout->output.i_height * 2;
 
             /* Allocate the memory buffer */
-            p_pic->p_data = vlc_memalign( &p_pic->p_data_orig,
-                                          16, p_pic->p_sys->i_size );
+            p_pic->p_orig_data =
+            p_pic->p_data = malloc( p_pic->p_sys->i_size );
+            /* Memory is always 16-bytes aligned on OSX, so it does not
+             * posix_memalign() */
+            assert( (((uintptr_t)p_pic->p_data) % 16) == 0 );
 
             p_pic->p[0].p_pixels = p_pic->p_data;
             p_pic->p[0].i_lines = p_vout->output.i_height;
@@ -724,8 +727,12 @@ static int QTNewPicture( vout_thread_t *p_vout, picture_t *p_pic )
             p_pic->p_sys->i_size = sizeof(PlanarPixmapInfoYUV420);
  
             /* Allocate the memory buffer */
-            p_pic->p_data = vlc_memalign( &p_pic->p_data_orig,
-                                          16, p_vout->output.i_width * p_vout->output.i_height * 3 / 2 );
+            p_pic->p_orig_data =
+            p_pic->p_data = malloc( p_vout->output.i_width
+                                     * p_vout->output.i_height * 3 / 2 );
+            /* Memory is always 16-bytes aligned on OSX, so it does not
+             * posix_memalign() */
+            assert( (((uintptr_t)p_pic->p_data) % 16) == 0 );
 
             /* Y buffer */
             p_pic->Y_PIXELS = p_pic->p_data;
index 511fa5665d619c4e047ccc917fb9395623922e48..1b73003c28aab535b86f4fdd8b4766e6682ebd85 100644 (file)
 
 /* Planar 8-bit grayscale */
 #define FOURCC_GREY         VLC_FOURCC('G','R','E','Y')
+
+/* 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.
+ */
+#if 0
+#ifdef HAVE_POSIX_MEMALIGN
+#   define vlc_memalign(align,size,pp_orig) \
+    ( !posix_memalign( pp_orig, align, size ) ? *(pp_orig) : NULL )
+#endif
+#endif
+#ifdef HAVE_MEMALIGN
+    /* Some systems have memalign() but no declaration for it */
+    void * memalign( size_t align, size_t size );
+
+#   define vlc_memalign(pp_orig,align,size) \
+    ( *(pp_orig) = memalign( align, size ) )
+
+#else /* We don't have any choice but to align manually */
+#   define vlc_memalign(pp_orig,align,size) \
+    (( *(pp_orig) = malloc( size + align - 1 )) \
+        ? (void *)( (((unsigned long)*(pp_orig)) + (unsigned long)(align-1) ) \
+                       & (~(unsigned long)(align-1)) ) \
+        : NULL )
+
+#endif
+