FFmpeg
Modules | Data Structures | Enumerations | Functions
Utility functions

Modules

 Pixel formats
 Functions for working with pixel formats.
 
 FFT functions
 

Data Structures

struct  AVBitStreamFilterContext
 

Enumerations

enum  AVLockOp { AV_LOCK_CREATE, AV_LOCK_OBTAIN, AV_LOCK_RELEASE, AV_LOCK_DESTROY }
 Lock operation used by lockmgr. More...
 

Functions

attribute_deprecated size_t av_get_codec_tag_string (char *buf, size_t buf_size, unsigned int codec_tag)
 Put a string representing the codec tag codec_tag in buf. More...
 
void avcodec_string (char *buf, int buf_size, AVCodecContext *enc, int encode)
 
const char * av_get_profile_name (const AVCodec *codec, int profile)
 Return a name for the specified profile, if available. More...
 
const char * avcodec_profile_name (enum AVCodecID codec_id, int profile)
 Return a name for the specified profile, if available. More...
 
int avcodec_default_execute (AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
 
int avcodec_default_execute2 (AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2, int, int), void *arg, int *ret, int count)
 
int avcodec_fill_audio_frame (AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align)
 Fill AVFrame audio data and linesize pointers. More...
 
void avcodec_flush_buffers (AVCodecContext *avctx)
 Reset the internal codec state / flush internal buffers. More...
 
int av_get_bits_per_sample (enum AVCodecID codec_id)
 Return codec bits per sample. More...
 
enum AVCodecID av_get_pcm_codec (enum AVSampleFormat fmt, int be)
 Return the PCM codec associated with a sample format. More...
 
int av_get_exact_bits_per_sample (enum AVCodecID codec_id)
 Return codec bits per sample. More...
 
int av_get_audio_frame_duration (AVCodecContext *avctx, int frame_bytes)
 Return audio frame duration. More...
 
int av_get_audio_frame_duration2 (AVCodecParameters *par, int frame_bytes)
 This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters instead of an AVCodecContext. More...
 
attribute_deprecated void av_register_bitstream_filter (AVBitStreamFilter *bsf)
 
attribute_deprecated AVBitStreamFilterContextav_bitstream_filter_init (const char *name)
 
attribute_deprecated int av_bitstream_filter_filter (AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
 
attribute_deprecated void av_bitstream_filter_close (AVBitStreamFilterContext *bsf)
 
const attribute_deprecated AVBitStreamFilterav_bitstream_filter_next (const AVBitStreamFilter *f)
 
const attribute_deprecated AVBitStreamFilterav_bsf_next (void **opaque)
 
void av_fast_padded_malloc (void *ptr, unsigned int *size, size_t min_size)
 Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. More...
 
void av_fast_padded_mallocz (void *ptr, unsigned int *size, size_t min_size)
 Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call. More...
 
unsigned int av_xiphlacing (unsigned char *s, unsigned int v)
 Encode extradata length to a buffer. More...
 
attribute_deprecated void av_register_hwaccel (AVHWAccel *hwaccel)
 Register the hardware accelerator hwaccel. More...
 
attribute_deprecated AVHWAccelav_hwaccel_next (const AVHWAccel *hwaccel)
 If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL, returns the next registered hardware accelerator after hwaccel, or NULL if hwaccel is the last one. More...
 
attribute_deprecated int av_lockmgr_register (int(*cb)(void **mutex, enum AVLockOp op))
 Register a user provided lock manager supporting the operations specified by AVLockOp. More...
 
int avcodec_is_open (AVCodecContext *s)
 
AVCPBPropertiesav_cpb_properties_alloc (size_t *size)
 Allocate a CPB properties structure and initialize its fields to default values. More...
 

Detailed Description

Miscellaneous utility functions related to both encoding and decoding (or neither).

Enumeration Type Documentation

◆ AVLockOp

enum AVLockOp

Lock operation used by lockmgr.

Deprecated:
Deprecated together with av_lockmgr_register().
Enumerator
AV_LOCK_CREATE 

Create a mutex.

AV_LOCK_OBTAIN 

Lock the mutex.

AV_LOCK_RELEASE 

Unlock the mutex.

AV_LOCK_DESTROY 

Free mutex resources.

Definition at line 4126 of file avcodec.h.

Function Documentation

◆ av_get_codec_tag_string()

attribute_deprecated size_t av_get_codec_tag_string ( char *  buf,
size_t  buf_size,
unsigned int  codec_tag 
)

Put a string representing the codec tag codec_tag in buf.

Parameters
bufbuffer to place codec tag in
buf_sizesize in bytes of buf
codec_tagcodec tag to assign
Returns
the length of the string that would have been generated if enough space had been available, excluding the trailing null
Deprecated:
see av_fourcc_make_string() and av_fourcc2str().

Definition at line 492 of file utils.c.

◆ avcodec_string()

void avcodec_string ( char *  buf,
int  buf_size,
AVCodecContext enc,
int  encode 
)

Definition at line 652 of file avcodec.c.

Referenced by avformat_find_stream_info(), and dump_stream_format().

◆ av_get_profile_name()

const char* av_get_profile_name ( const AVCodec codec,
int  profile 
)

Return a name for the specified profile, if available.

Parameters
codecthe codec that is searched for the given profile
profilethe profile value for which a name is requested
Returns
A name for the profile if found, NULL otherwise.

Definition at line 513 of file utils.c.

◆ avcodec_profile_name()

const char* avcodec_profile_name ( enum AVCodecID  codec_id,
int  profile 
)

Return a name for the specified profile, if available.

Parameters
codec_idthe ID of the codec to which the requested profile belongs
profilethe profile value for which a name is requested
Returns
A name for the profile if found, NULL otherwise.
Note
unlike av_get_profile_name(), which searches a list of profiles supported by a specific decoder or encoder implementation, this function searches the list of profiles from the AVCodecDescriptor

Definition at line 526 of file utils.c.

Referenced by avcodec_string(), and show_stream().

◆ avcodec_default_execute()

int avcodec_default_execute ( AVCodecContext c,
int(*)(AVCodecContext *c2, void *arg2)  func,
void *  arg,
int ret,
int  count,
int  size 
)

Definition at line 67 of file avcodec.c.

Referenced by init_context_defaults(), and thread_execute().

◆ avcodec_default_execute2()

int avcodec_default_execute2 ( AVCodecContext c,
int(*)(AVCodecContext *c2, void *arg2, int, int func,
void *  arg,
int ret,
int  count 
)

◆ avcodec_fill_audio_frame()

int avcodec_fill_audio_frame ( AVFrame frame,
int  nb_channels,
enum AVSampleFormat  sample_fmt,
const uint8_t buf,
int  buf_size,
int  align 
)

Fill AVFrame audio data and linesize pointers.

The buffer buf must be a preallocated buffer with a size big enough to contain the specified samples amount. The filled AVFrame data pointers will point to this buffer.

AVFrame extended_data channel pointers are allocated if necessary for planar audio.

Parameters
framethe AVFrame frame->nb_samples must be set prior to calling the function. This function fills in frame->data, frame->extended_data, frame->linesize[0].
nb_channelschannel count
sample_fmtsample format
bufbuffer to use for frame data
buf_sizesize of buffer
alignplane size sample alignment (0 = default)
Returns
>=0 on success, negative error code on failure
Todo:
return the size in bytes required to store the samples in case of success, at the next libavutil bump

Definition at line 373 of file utils.c.

◆ avcodec_flush_buffers()

void avcodec_flush_buffers ( AVCodecContext avctx)

Reset the internal codec state / flush internal buffers.

Should be called e.g. when seeking or when switching to a different stream.

Note
for decoders, when refcounted frames are not used (i.e. avctx->refcounted_frames is 0), this invalidates the frames previously returned from the decoder. When refcounted frames are used, the decoder just releases any references it might keep internally, but the caller's reference remains valid.
for encoders, this function will only do something if the encoder declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder will drain any remaining packets, and can then be re-used for a different stream (as opposed to sending a null frame which will leave the encoder in a permanent EOF state after draining). This can be desirable if the cost of tearing down and replacing the encoder instance is high.

Definition at line 491 of file avcodec.c.

Referenced by compat_decode(), compute_crc_of_packets(), decoder_decode_frame(), imm5_flush(), LLVMFuzzerTestOneInput(), process_command(), process_input(), and rewind_file().

◆ av_get_bits_per_sample()

int av_get_bits_per_sample ( enum AVCodecID  codec_id)

◆ av_get_pcm_codec()

enum AVCodecID av_get_pcm_codec ( enum AVSampleFormat  fmt,
int  be 
)

Return the PCM codec associated with a sample format.

Parameters
beendianness, 0 for little, 1 for big, -1 (or anything else) for native
Returns
AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE

Definition at line 608 of file utils.c.

Referenced by lavfi_read_header(), and main().

◆ av_get_exact_bits_per_sample()

int av_get_exact_bits_per_sample ( enum AVCodecID  codec_id)

Return codec bits per sample.

Only return non-zero if the bits per sample is exactly correct, not an approximation.

Parameters
[in]codec_idthe codec
Returns
Number of bits per sample or zero if unknown for the given codec.

Definition at line 541 of file utils.c.

Referenced by av_get_bits_per_sample(), get_audio_frame_duration(), and new_output_stream().

◆ av_get_audio_frame_duration()

int av_get_audio_frame_duration ( AVCodecContext avctx,
int  frame_bytes 
)

Return audio frame duration.

Parameters
avctxcodec context
frame_bytessize of the frame, or 0 if unknown
Returns
frame duration, in samples, if known. 0 if not able to determine.

Definition at line 855 of file utils.c.

Referenced by do_streamcopy(), and ff_compute_frame_duration().

◆ av_get_audio_frame_duration2()

int av_get_audio_frame_duration2 ( AVCodecParameters par,
int  frame_bytes 
)

◆ av_register_bitstream_filter()

attribute_deprecated void av_register_bitstream_filter ( AVBitStreamFilter bsf)
Deprecated:
the old bitstream filtering API (using AVBitStreamFilterContext) is deprecated.

Use the new bitstream filtering API (using AVBSFContext).

Definition at line 42 of file bitstream_filter.c.

◆ av_bitstream_filter_init()

attribute_deprecated AVBitStreamFilterContext* av_bitstream_filter_init ( const char *  name)
Deprecated:
the old bitstream filtering API (using AVBitStreamFilterContext) is deprecated.

Use av_bsf_get_by_name(), av_bsf_alloc(), and av_bsf_init() from the new bitstream filtering API (using AVBSFContext).

Definition at line 51 of file bitstream_filter.c.

◆ av_bitstream_filter_filter()

attribute_deprecated int av_bitstream_filter_filter ( AVBitStreamFilterContext bsfc,
AVCodecContext avctx,
const char *  args,
uint8_t **  poutbuf,
int poutbuf_size,
const uint8_t buf,
int  buf_size,
int  keyframe 
)
Deprecated:
the old bitstream filtering API (using AVBitStreamFilterContext) is deprecated.

Use av_bsf_send_packet() and av_bsf_receive_packet() from the new bitstream filtering API (using AVBSFContext).

Definition at line 97 of file bitstream_filter.c.

◆ av_bitstream_filter_close()

attribute_deprecated void av_bitstream_filter_close ( AVBitStreamFilterContext bsf)
Deprecated:
the old bitstream filtering API (using AVBitStreamFilterContext) is deprecated.

Use av_bsf_free() from the new bitstream filtering API (using AVBSFContext).

Definition at line 83 of file bitstream_filter.c.

◆ av_bitstream_filter_next()

const attribute_deprecated AVBitStreamFilter* av_bitstream_filter_next ( const AVBitStreamFilter f)
Deprecated:
the old bitstream filtering API (using AVBitStreamFilterContext) is deprecated.

Use av_bsf_iterate() from the new bitstream filtering API (using AVBSFContext).

Definition at line 31 of file bitstream_filter.c.

◆ av_bsf_next()

const attribute_deprecated AVBitStreamFilter* av_bsf_next ( void **  opaque)

Definition at line 79 of file bitstream_filters.c.

◆ av_fast_padded_malloc()

void av_fast_padded_malloc ( void *  ptr,
unsigned int size,
size_t  min_size 
)

◆ av_fast_padded_mallocz()

void av_fast_padded_mallocz ( void *  ptr,
unsigned int size,
size_t  min_size 
)

Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call.

Definition at line 62 of file utils.c.

Referenced by decode_idat_chunk(), encode_frame(), and init_buffers().

◆ av_xiphlacing()

unsigned int av_xiphlacing ( unsigned char *  s,
unsigned int  v 
)

Encode extradata length to a buffer.

Used by xiph codecs.

Parameters
sbuffer to write to; must be at least (v/255+1) bytes long
vsize of extradata in bytes
Returns
number of bytes written to the buffer.

Definition at line 883 of file utils.c.

Referenced by fixup_vorbis_headers(), libvorbis_encode_init(), parse_packed_headers(), put_main_header(), and track_header().

◆ av_register_hwaccel()

attribute_deprecated void av_register_hwaccel ( AVHWAccel hwaccel)

Register the hardware accelerator hwaccel.

Deprecated:
This function doesn't do anything.

Definition at line 921 of file utils.c.

◆ av_hwaccel_next()

attribute_deprecated AVHWAccel* av_hwaccel_next ( const AVHWAccel hwaccel)

If hwaccel is NULL, returns the first registered hardware accelerator, if hwaccel is non-NULL, returns the next registered hardware accelerator after hwaccel, or NULL if hwaccel is the last one.

Deprecated:
AVHWaccel structures contain no user-serviceable parts, so this function should not be used.

Definition at line 916 of file utils.c.

◆ av_lockmgr_register()

attribute_deprecated int av_lockmgr_register ( int(*)(void **mutex, enum AVLockOp op cb)

Register a user provided lock manager supporting the operations specified by AVLockOp.

The "mutex" argument to the function points to a (void *) where the lockmgr should store/get a pointer to a user allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the value left by the last call for all other ops. If the lock manager is unable to perform the op then it should leave the mutex in the same state as when it was called and return a non-zero value. However, when called with AV_LOCK_DESTROY the mutex will always be assumed to have been successfully destroyed. If av_lockmgr_register succeeds it will return a non-negative value, if it fails it will return a negative value and destroy all mutex and unregister all callbacks. av_lockmgr_register is not thread-safe, it must be called from a single thread before any calls which make use of locking are used.

Parameters
cbUser defined callback. av_lockmgr_register invokes calls to this callback and the previously registered callback. The callback will be used to create more than one mutex each of which must be backed by its own underlying locking mechanism (i.e. do not use a single static object to implement your lock manager). If cb is set to NULL the lockmgr will be unregistered.
Deprecated:
This function does nothing, and always returns 0. Be sure to build with thread support to get basic thread safety.

Definition at line 108 of file avcodec.c.

◆ avcodec_is_open()

int avcodec_is_open ( AVCodecContext s)
Returns
a positive value if s is open (i.e. avcodec_open2() was called on it with no corresponding avcodec_close()), 0 otherwise.

Definition at line 848 of file avcodec.c.

Referenced by avcodec_close(), avcodec_copy_context(), avcodec_open2(), avcodec_receive_frame(), avcodec_receive_packet(), avcodec_send_frame(), avcodec_send_packet(), mpegts_set_stream_info(), read_frame_internal(), and try_decode_frame().

◆ av_cpb_properties_alloc()

AVCPBProperties* av_cpb_properties_alloc ( size_t *  size)

Allocate a CPB properties structure and initialize its fields to default values.

Parameters
sizeif non-NULL, the size of the allocated struct will be written here. This is useful for embedding it in side data.
Returns
the newly allocated struct or NULL on failure

Definition at line 1044 of file utils.c.

Referenced by ff_add_cpb_side_data(), and ff_mpv_encode_picture().