FFmpeg programming conventions

From MultimediaWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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