Libav
Modules | Data Structures | Enumerations | Functions
Utility functions

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

Modules

 Pixel formats
 Functions for working with pixel formats.
 
 FFT functions
 

Data Structures

struct  AVBitStreamFilterContext
 
struct  AVBitStreamFilter
 

Enumerations

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

Functions

attribute_deprecated void avcodec_set_dimensions (AVCodecContext *s, int width, int height)
 
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...
 
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 audio frame data and linesize. More...
 
void avcodec_flush_buffers (AVCodecContext *avctx)
 Reset the internal decoder state / flush internal buffers. More...
 
int av_get_bits_per_sample (enum AVCodecID codec_id)
 Return codec bits per sample. 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...
 
void av_register_bitstream_filter (AVBitStreamFilter *bsf)
 
AVBitStreamFilterContextav_bitstream_filter_init (const char *name)
 
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)
 
void av_bitstream_filter_close (AVBitStreamFilterContext *bsf)
 
AVBitStreamFilterav_bitstream_filter_next (const AVBitStreamFilter *f)
 
void av_fast_padded_malloc (void *ptr, unsigned int *size, size_t min_size)
 Allocate a buffer with padding, reusing the given one if large enough. More...
 
unsigned int av_xiphlacing (unsigned char *s, unsigned int v)
 Encode extradata length to a buffer. More...
 
attribute_deprecated void av_log_missing_feature (void *avc, const char *feature, int want_sample)
 Log a generic warning message about a missing feature. More...
 
attribute_deprecated void av_log_ask_for_sample (void *avc, const char *msg,...) av_printf_format(2
 Log a generic warning message asking for a sample. More...
 
attribute_deprecated void void av_register_hwaccel (AVHWAccel *hwaccel)
 Register the hardware accelerator hwaccel. More...
 
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...
 
int av_lockmgr_register (int(*cb)(void **mutex, enum AVLockOp op))
 Register a user provided lock manager supporting the operations specified by AVLockOp. More...
 
enum AVMediaType avcodec_get_type (enum AVCodecID codec_id)
 Get the type of the given codec. More...
 
int avcodec_is_open (AVCodecContext *s)
 
int av_codec_is_encoder (const AVCodec *codec)
 
int av_codec_is_decoder (const AVCodec *codec)
 
const AVCodecDescriptoravcodec_descriptor_get (enum AVCodecID id)
 
const AVCodecDescriptoravcodec_descriptor_next (const AVCodecDescriptor *prev)
 Iterate over all codec descriptors known to libavcodec. More...
 
const AVCodecDescriptoravcodec_descriptor_get_by_name (const char *name)
 

Detailed Description

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

Enumeration Type Documentation

enum AVLockOp

Lock operation used by lockmgr.

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 4399 of file avcodec.h.

Function Documentation

attribute_deprecated void avcodec_set_dimensions ( AVCodecContext s,
int  width,
int  height 
)
Deprecated:
this function is not supposed to be used from outside of lavc

Definition at line 127 of file utils.c.

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

Definition at line 1843 of file utils.c.

Referenced by avcodec_string(), init_muxer(), mov_write_hdlr_tag(), and show_stream().

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

Definition at line 1863 of file utils.c.

Referenced by avformat_find_stream_info(), and dump_stream_format().

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 1979 of file utils.c.

Referenced by avcodec_string(), and show_stream().

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

Definition at line 873 of file utils.c.

Referenced by avcodec_get_context_defaults3(), and thread_execute().

int avcodec_default_execute2 ( AVCodecContext c,
int(*)(AVCodecContext *c2, void *arg2, int, int)  func,
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 audio frame data and linesize.

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

Definition at line 305 of file utils.c.

Referenced by audio_encode_example().

void avcodec_flush_buffers ( AVCodecContext avctx)

Reset the internal decoder state / flush internal buffers.

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

Note
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.

Definition at line 2008 of file utils.c.

Referenced by audio_decode_frame(), get_video_frame(), and subtitle_thread().

int av_get_bits_per_sample ( enum AVCodecID  codec_id)
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 2019 of file utils.c.

Referenced by av_get_audio_frame_duration(), and av_get_bits_per_sample().

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 2082 of file utils.c.

Referenced by ff_get_audio_frame_size(), ff_parse_specific_params(), ff_put_wav_header(), get_aiff_header(), rtp_send_ilbc(), rtp_write_header(), and swf_write_audio().

void av_register_bitstream_filter ( AVBitStreamFilter bsf)

Definition at line 36 of file bitstream_filter.c.

AVBitStreamFilterContext* av_bitstream_filter_init ( const char *  name)

Definition at line 42 of file bitstream_filter.c.

Referenced by new_output_stream().

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 
)

Definition at line 69 of file bitstream_filter.c.

Referenced by write_frame().

void av_bitstream_filter_close ( AVBitStreamFilterContext bsf)

Definition at line 60 of file bitstream_filter.c.

Referenced by avconv_cleanup().

AVBitStreamFilter* av_bitstream_filter_next ( const AVBitStreamFilter f)

Definition at line 28 of file bitstream_filter.c.

Referenced by show_bsfs().

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

Allocate a buffer with padding, reusing the given one if large enough.

Same behaviour av_fast_malloc but the buffer has additional FF_INPUT_PADDING_SIZE at the end which will always memset to 0.

Definition at line 59 of file utils.c.

Referenced by cdxl_decode_frame(), cllc_decode_frame(), decode_block(), decode_frame(), ff_mjpeg_find_marker(), init_buffers(), mimic_decode_frame(), mpc7_decode_frame(), svq1_decode_frame(), and tqi_decode_frame().

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 2237 of file utils.c.

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

attribute_deprecated void av_log_missing_feature ( void avc,
const char *  feature,
int  want_sample 
)

Log a generic warning message about a missing feature.

This function is intended to be used internally by Libav (libavcodec, libavformat, etc.) only, and would normally not be used by applications.

Parameters
[in]avca pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct
[in]featurestring containing the name of the missing feature
[in]want_sampleindicates if samples are wanted which exhibit this feature. If want_sample is non-zero, additional verbage will be added to the log message which tells the user how to report samples to the development mailing list.
Deprecated:
Use avpriv_report_missing_feature() instead.

Definition at line 2260 of file utils.c.

attribute_deprecated void av_log_ask_for_sample ( void avc,
const char *  msg,
  ... 
)

Log a generic warning message asking for a sample.

This function is intended to be used internally by Libav (libavcodec, libavformat, etc.) only, and would normally not be used by applications.

Parameters
[in]avca pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct
[in]msgstring containing an optional message, or NULL if no message
Deprecated:
Use avpriv_request_sample() instead.
attribute_deprecated void void av_register_hwaccel ( AVHWAccel hwaccel)

Register the hardware accelerator hwaccel.

Definition at line 2289 of file utils.c.

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.

Definition at line 2298 of file utils.c.

Referenced by find_hwaccel().

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

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

mutex points to a (void *) where the lockmgr should store/get a pointer to a user allocated mutex. It's NULL upon AV_LOCK_CREATE and != NULL for all other ops.

Parameters
cbUser defined callback. Note: Libav may invoke calls to this callback during the call to av_lockmgr_register(). Thus, the application must be prepared to handle that. If cb is set to NULL the lockmgr will be unregistered. Also note that during unregistration the previously registered lockmgr callback may also be invoked.

Definition at line 2303 of file utils.c.

enum AVMediaType avcodec_get_type ( enum AVCodecID  codec_id)

Get the type of the given codec.

Definition at line 2396 of file utils.c.

Referenced by mkv_query_codec().

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 2410 of file utils.c.

Referenced by avcodec_close(), avcodec_copy_context(), avcodec_open2(), and try_decode_frame().

int av_codec_is_encoder ( const AVCodec codec)
Returns
a non-zero number if codec is an encoder, zero otherwise

Definition at line 95 of file utils.c.

Referenced by alloc_frame_buffer(), avcodec_close(), avcodec_find_encoder_by_name(), avcodec_open2(), ff_jpeg2000_init_component(), find_encdec(), next_codec_for_id(), and print_codec().

int av_codec_is_decoder ( const AVCodec codec)
Returns
a non-zero number if codec is a decoder, zero otherwise

Definition at line 100 of file utils.c.

Referenced by avcodec_find_decoder_by_name(), avcodec_open2(), find_encdec(), and next_codec_for_id().

const AVCodecDescriptor* avcodec_descriptor_get ( enum AVCodecID  id)
Returns
descriptor for given codec ID or NULL if no descriptor exists.

Definition at line 2353 of file codec_desc.c.

Referenced by asf_write_header1(), is_intra_only(), show_help_muxer(), transcode_init(), and wav_write_header().

const AVCodecDescriptor* avcodec_descriptor_next ( const AVCodecDescriptor prev)

Iterate over all codec descriptors known to libavcodec.

Parameters
prevprevious descriptor. NULL to get the first descriptor.
Returns
next descriptor or NULL after the last descriptor

Definition at line 2363 of file codec_desc.c.

Referenced by avcodec_descriptor_get_by_name(), print_codecs(), and show_codecs().

const AVCodecDescriptor* avcodec_descriptor_get_by_name ( const char *  name)
Returns
codec descriptor with the given name or NULL if no such descriptor exists.

Definition at line 2372 of file codec_desc.c.

Referenced by find_codec_or_die(), and show_help_codec().