Commit bb352cd5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Privatize the memalign replacement

parent 03700214
......@@ -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
......
......@@ -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;
......
......@@ -102,3 +102,32 @@
/* 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment