FFmpeg programming conventions

From MultimediaWiki
Revision as of 11:10, 7 April 2007 by Gatoatigrado (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
please make this page more complete if you can, thanks

Memory allocation

av_malloc / av_free / av_realloc - correspond to malloc functions, currently only used as wrappers
av_fast_realloc - a shortcut to common buffer reallocation functions

Debug printing

av_log(avctx, print_type, [same argument style as printf])

some options for print_type are AV_LOG_VERBOSE / AV_LOG_ERROR.

dprintf(avctx, [same argument style as printf]) is an alias for AV_LOG_DEBUG

Stream and array operations

AV_RB / AV_RL - read little endian or big endian from an array. e.g. int result = AV_RB32(&array[offset])

functions that automatically increment arguments

bytestream_get_buffer(&buffer, destination, length) - copies from buffer. buffer type is uint8_t **.
bytestream_get_le16/24/32(&buffer) - get an int.
get_byte(pb) - get a byte, where pb is the ByteIOContext in a demuxer (typically), in (AVFormatContext) &s->pb
get_be/get_le 16/24/32(pb) - get an integer
get_buffer(pb, buffer, length) - get an array, returns number of bytes read. typically, return if number of bytes read != length

see also