Fixed Length Array Syntax in extern(C) Function Signatures

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 9 08:19:40 PDT 2015


Given

     extern(C):

     struct AVFrame
     {
         uint8_t*[AV_NUM_DATA_POINTERS] data;
         int[AV_NUM_DATA_POINTERS] linesize;
         int width, height;
         ...
     }

     void av_image_copy(ubyte *[4] dst_data, int[4] dst_linesizes,
                        const ubyte *[4] src_data, const int[4] 
src_linesizes,
                        AVPixelFormat pix_fmt, int width, int 
height)


will `dst_data` will be C-ABI-fed to `image_copy()` as a C-style 
single pointer in constrast to what happens in D which calls it 
as fixed-size (4) array of ubyte-pointers?

Further, is it correct to use it in D as

     void copyVideo(const AVFrame* source,
                    AVFrame* target)
     {
         av_image_copy(target.data[0 .. 4], target.linesize[0 .. 
4],
                       source.data[0 .. 4], source.linesize[0 .. 
4],
                       format, source.width, source.height);
     }

?

It compiles without warnings, at least. I haven't been able to 
test it yet, though.


More information about the Digitalmars-d-learn mailing list