FFI and complex data structures

Martin Kuball MartinKuball at web.de
Sun Apr 10 10:20:00 UTC 2005


Hi!

I'm trying to write an interface to the xvid library using ffi. Now 
I'm stuck with the problem that I have to pass a pointer to a 
ByteArray inside an ExternalStructure. Here is my fields definition 
for XvidDecodeStructure:

 ^ #(
  (version 'long')  "input"
  (general 'long')  "input, optional, general flags"
  (bitstream 'byte*')  "input"
  (length  'long')  "input, size of bitstream"
  (csp   'long')  "input, colorspace"
  (plane1  'byte*')  "input"
  (plane2  'byte*')  "input"
  (plane3  'byte*')  "input"
  (plane4  'byte*')  "input"
  (stride1  'long')  "input"
  (stride2  'long')
  (stride3  'long')
  (stride4  'long')
 )

I want to initialize bitstream with the ByteArray containing the data 
of an encoded frame. Obviously I can't copy the content into the 
structure. It must be the address. But this does not seem to work. At 
least not using something like:

 decodeStructure bitstream: (ExternalData fromHandle: aFrameBuffer
    type: ExternalType byte asPointerType).

This triggers the error: Only external addresses can be stored.
So Is this just impossible? Do I have to write a real plugin?

Martin



More information about the Squeak-dev mailing list