[Ffmpeg-devel] [PATCH] cs-test Darwin host issues

Marc Hoffman mmh
Thu Mar 29 14:51:08 CEST 2007

Michael Niedermayer writes:
 > Hi
 > On Thu, Mar 29, 2007 at 08:19:19AM -0400, Marc Hoffman wrote:
 > Content-Description: message body text
 > > 
 > > 1. Darwin doesn't have a malloc.h header file so I have wrapped that with __APPLE__
 > >    actually it shouldn't even be used, considering malloc is defined as please_use_av_malloc.
 > > 2. malloc is defined as av_malloc not malloc.
 > putting #ifdef ANY_OS into c files is unacceptable

No Problem the original code breaks your assertion because it was
originally __APPLE_CC__ would you rather __APPLE_CC__ or what is your
suggestion for solving for this particular problem.

I guess the best way to go about this is as follows:

remove malloc.h inclusion its not needed because it redefined by other

headers to please use blah blah.

The only issue remains is that Apple doesn't include memalign memory
allocator so the module should just use av_malloc instead consistently.

The only issue I see with this is that memory was aligned to 2^7 and
now its aligned to a radix of 2^4. Your call I'm just the messenger.

yoda:~/ffmpeg/ffmpeg-svn/libswscale mmh$ svn diff cs_test.c
Index: cs_test.c
--- cs_test.c   (revision 22819)
+++ cs_test.c   (working copy)
@@ -23,7 +23,6 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include <malloc.h>
 #include "swscale.h"
 #include "rgb2rgb.h"
@@ -32,9 +31,6 @@
 #define srcByte 0x55
 #define dstByte 0xBB
-#ifdef __APPLE_CC__
-#define memalign(x,y) malloc(y)
 static int cpu_caps;
@@ -64,8 +60,8 @@
 int main(int argc, char **argv)
        int i, funcNum;
-       uint8_t *srcBuffer= (uint8_t*)memalign(128, SIZE);
-       uint8_t *dstBuffer= (uint8_t*)memalign(128, SIZE);
+       uint8_t *srcBuffer= (uint8_t*)av_malloc(SIZE);
+       uint8_t *dstBuffer= (uint8_t*)av_malloc(SIZE);
        int failedNum=0;
        int passedNum=0;

Above patch as attachment.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cs-test-darwin.patch-2
Type: application/octet-stream
Size: 763 bytes
Desc: rename memalign to av_malloc
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070329/3a6d002b/attachment.obj>

More information about the ffmpeg-devel mailing list