Linking with FFmpeg

Johannes Pfau nospam at example.com
Sun Jan 6 04:46:04 PST 2013


Am Sun, 06 Jan 2013 10:48:25 +0100
schrieb "MrOrdinaire" <mrordinaire at gmail.com>:

> Hi,
> 
> I am working on D bindings for FFmpeg. I am trying to port the 
> official examples of FFmpeg to D so that the bindings can be 
> tested.
> 
> My question is how this function declaration is written in D.
> int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
>                     int w, int h, enum AVPixelFormat pix_fmt, int 
> align);
> 

My C is pretty bad, is uint8_t *pointers[4] a static array with 4
elements of uint8_t* or is it a pointer to a static array with 4
uint8_t elements?

I guess it's the former, so in D it's (uint8_t*)[4] or better
(ubyte*)[4]. In D static arrays are passed by value, in C by reference,
so you have to do this:

extern(C) int av_image_alloc(ref (ubyte*)[4] pointers, ref int[4]
linesizes, int w, int h, AVPixelFormat pix_fmt, int align_);


Some more information is here:
http://dlang.org/interfaceToC.html


More information about the Digitalmars-d-learn mailing list