Linspire Video Binary API
Linspire is a Linux distribution that aims to rival Microsoft in desktop ease of use for the end-user. To that end, they have licensed certain of Microsoft's audio and video codecs that are not yet supported in open source.
The decoders for these codecs link into FFmpeg's libavcodec library. The video codecs supported by this method are Microsoft's Windows Media Video versions 8 and 9 (henceforth WMV8 and WMV9, respectively). Each binary module has an initialization function, packet decoding function, and cleanup function.
Initialization
The initialization function has the following declaration:
int init(void *private_data, unsigned char *extradata, int extradata_size, int codec_tag, int width, int height);
- private_data: A private data structure used to store the internal decoder state. The libavcodec glue code declares this as an array of 1024 bytes.
- extradata: The extradata bytes at the end of the BITMAPINFO header from the Microsoft media file (AVI or ASF).
- extradata_size: The size of the buffer indicated by extradata.
- codec_tag: The 32-bit four-character code (FOURCC) of the codec data.
- width: The width in pixels of the video frames to be decoded.
- height: The height in pixels of the video frames to be decoded.
The initialization function returns 0 on success, non-zero if there was a problem.
Decoding
The packet decoding functions have the following declaration:
int packet_decode(void *private_data, void *data, int *data_size, unsigned char *buf, int buf_size, Bits *bit_structure, unsigned char *work_buffer);
- private_data: A private data structure used to store the internal decoder state. The libavcodec glue code declares this as an array of 1024 bytes.
- data: The void *data parameter passed into the libavcodec decoding function.
- data_size: The int data_size parameter passed into the libavcodec decoding function.
- buf: The encoded bytestream passed in from libavcodec.
- buf_size: The size of the encoded bytestream.
- bit_structure: A structure of type Bits that has the following declaration:
typedef struct { unsigned char *data[4]; int linesize[4]; } Bits;
The data and linesize fields are the size as those in a libavcodec AVFrame structure.
- work_buffer: A buffer provided by the libavcodec and allocated to be (width * height * 4) bytes large.
The packet_decode function returns a negative number in the event of an error. Whatever integer is returned can be returned from the libavcodec decode function as part of the normal libavcodec API.
Cleanup
The cleanup (end) function has the following declaration:
int end(void *private_data);
- private_data: A private data structure used to store the internal decoder state. The libavcodec glue code declares this as an array of 1024 bytes.
The end function returns an integer that can be returned from the libavcodec end function as part of the normal libavcodec API.
Original Source
Download the reference source here [1]. Any mplayer package should do, the relevant files are libavcodec/wma3dec.c and libavcodec/wmv3dec.c.