On Sunday, 6 January 2013 at 12:46:05 UTC, Johannes Pfau wrote:
Am Sun, 06 Jan 2013 10:48:25 +0100
schrieb "MrOrdinaire" <[email protected]>:
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
According to this (http://c-faq.com/decl/spiral.anderson.html), I
think pointers is an array of 4 pointers to uint8_t.
So in D, you read declarations from right to left?
- Minh