Changeset bb352cd558ddf3729b06511bddd002c922c05914
- Timestamp:
- 25/01/08 17:38:14
(9 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1201279094 +0000
- git-parent:
[0370021454ba3f18bf12bb8d3426cf0fcabece7c]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1201279094 +0000
- Message:
Privatize the memalign replacement
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra82fd8f |
rbb352cd |
|
| 819 | 819 | #define VLC_UNUSED(x) (void)(x) |
|---|
| 820 | 820 | |
|---|
| 821 | | /* Alignment of critical dynamic data structure |
|---|
| 822 | | * |
|---|
| 823 | | * Not all platforms support memalign so we provide a vlc_memalign wrapper |
|---|
| 824 | | * void *vlc_memalign( size_t align, size_t size, void **pp_orig ) |
|---|
| 825 | | * *pp_orig is the pointer that has to be freed afterwards. |
|---|
| 826 | | */ |
|---|
| 827 | | #if 0 |
|---|
| 828 | | #ifdef HAVE_POSIX_MEMALIGN |
|---|
| 829 | | # define vlc_memalign(align,size,pp_orig) \ |
|---|
| 830 | | ( !posix_memalign( pp_orig, align, size ) ? *(pp_orig) : NULL ) |
|---|
| 831 | | #endif |
|---|
| 832 | | #endif |
|---|
| 833 | | #ifdef HAVE_MEMALIGN |
|---|
| 834 | | /* Some systems have memalign() but no declaration for it */ |
|---|
| 835 | | void * memalign( size_t align, size_t size ); |
|---|
| 836 | | |
|---|
| 837 | | # define vlc_memalign(pp_orig,align,size) \ |
|---|
| 838 | | ( *(pp_orig) = memalign( align, size ) ) |
|---|
| 839 | | |
|---|
| 840 | | #else /* We don't have any choice but to align manually */ |
|---|
| 841 | | # define vlc_memalign(pp_orig,align,size) \ |
|---|
| 842 | | (( *(pp_orig) = malloc( size + align - 1 )) \ |
|---|
| 843 | | ? (void *)( (((unsigned long)*(pp_orig)) + (unsigned long)(align-1) ) \ |
|---|
| 844 | | & (~(unsigned long)(align-1)) ) \ |
|---|
| 845 | | : NULL ) |
|---|
| 846 | | |
|---|
| 847 | | #endif |
|---|
| 848 | | |
|---|
| 849 | 821 | /* Stuff defined in src/extras/libc.c */ |
|---|
| 850 | 822 | #ifndef HAVE_STRDUP |
|---|
| rf25e0c7 |
rbb352cd |
|
| 30 | 30 | * Preamble |
|---|
| 31 | 31 | *****************************************************************************/ |
|---|
| 32 | | #include <errno.h> /* ENOMEM */ |
|---|
| 33 | 32 | #include <stdlib.h> /* free() */ |
|---|
| 34 | 33 | #include <string.h> |
|---|
| | 34 | #include <assert.h> |
|---|
| 35 | 35 | |
|---|
| 36 | 36 | #include <QuickTime/QuickTime.h> |
|---|
| … | … | |
| 705 | 705 | |
|---|
| 706 | 706 | /* Allocate the memory buffer */ |
|---|
| 707 | | p_pic->p_data = vlc_memalign( &p_pic->p_data_orig, |
|---|
| 708 | | 16, p_pic->p_sys->i_size ); |
|---|
| | 707 | p_pic->p_orig_data = |
|---|
| | 708 | p_pic->p_data = malloc( p_pic->p_sys->i_size ); |
|---|
| | 709 | /* Memory is always 16-bytes aligned on OSX, so it does not |
|---|
| | 710 | * posix_memalign() */ |
|---|
| | 711 | assert( (((uintptr_t)p_pic->p_data) % 16) == 0 ); |
|---|
| 709 | 712 | |
|---|
| 710 | 713 | p_pic->p[0].p_pixels = p_pic->p_data; |
|---|
| … | … | |
| 725 | 728 | |
|---|
| 726 | 729 | /* Allocate the memory buffer */ |
|---|
| 727 | | p_pic->p_data = vlc_memalign( &p_pic->p_data_orig, |
|---|
| 728 | | 16, p_vout->output.i_width * p_vout->output.i_height * 3 / 2 ); |
|---|
| | 730 | p_pic->p_orig_data = |
|---|
| | 731 | p_pic->p_data = malloc( p_vout->output.i_width |
|---|
| | 732 | * p_vout->output.i_height * 3 / 2 ); |
|---|
| | 733 | /* Memory is always 16-bytes aligned on OSX, so it does not |
|---|
| | 734 | * posix_memalign() */ |
|---|
| | 735 | assert( (((uintptr_t)p_pic->p_data) % 16) == 0 ); |
|---|
| 729 | 736 | |
|---|
| 730 | 737 | /* Y buffer */ |
|---|
| r3a9ae14 |
rbb352cd |
|
| 103 | 103 | /* Planar 8-bit grayscale */ |
|---|
| 104 | 104 | #define FOURCC_GREY VLC_FOURCC('G','R','E','Y') |
|---|
| | 105 | |
|---|
| | 106 | /* Alignment of critical dynamic data structure |
|---|
| | 107 | * |
|---|
| | 108 | * Not all platforms support memalign so we provide a vlc_memalign wrapper |
|---|
| | 109 | * void *vlc_memalign( size_t align, size_t size, void **pp_orig ) |
|---|
| | 110 | * *pp_orig is the pointer that has to be freed afterwards. |
|---|
| | 111 | */ |
|---|
| | 112 | #if 0 |
|---|
| | 113 | #ifdef HAVE_POSIX_MEMALIGN |
|---|
| | 114 | # define vlc_memalign(align,size,pp_orig) \ |
|---|
| | 115 | ( !posix_memalign( pp_orig, align, size ) ? *(pp_orig) : NULL ) |
|---|
| | 116 | #endif |
|---|
| | 117 | #endif |
|---|
| | 118 | #ifdef HAVE_MEMALIGN |
|---|
| | 119 | /* Some systems have memalign() but no declaration for it */ |
|---|
| | 120 | void * memalign( size_t align, size_t size ); |
|---|
| | 121 | |
|---|
| | 122 | # define vlc_memalign(pp_orig,align,size) \ |
|---|
| | 123 | ( *(pp_orig) = memalign( align, size ) ) |
|---|
| | 124 | |
|---|
| | 125 | #else /* We don't have any choice but to align manually */ |
|---|
| | 126 | # define vlc_memalign(pp_orig,align,size) \ |
|---|
| | 127 | (( *(pp_orig) = malloc( size + align - 1 )) \ |
|---|
| | 128 | ? (void *)( (((unsigned long)*(pp_orig)) + (unsigned long)(align-1) ) \ |
|---|
| | 129 | & (~(unsigned long)(align-1)) ) \ |
|---|
| | 130 | : NULL ) |
|---|
| | 131 | |
|---|
| | 132 | #endif |
|---|
| | 133 | |
|---|