libavcodec/utils.c File Reference

utils. More...

#include "libavutil/avstring.h"
#include "libavutil/crc.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/audioconvert.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/dict.h"
#include "libavutil/avassert.h"
#include "avcodec.h"
#include "dsputil.h"
#include "libavutil/opt.h"
#include "imgconvert.h"
#include "thread.h"
#include "audioconvert.h"
#include "internal.h"
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <float.h>
#include "libavcodec/codec_names.h"

Go to the source code of this file.

Defines

#define INTERNAL_BUFFER_SIZE   (32+1)
#define SANE_NB_CHANNELS   128U
#define LICENSE_PREFIX   "libavcodec license: "

Functions

void * av_fast_realloc (void *ptr, unsigned int *size, size_t min_size)
 Reallocate the given block if it is not large enough, otherwise do nothing.
void av_fast_malloc (void *ptr, unsigned int *size, size_t min_size)
 Allocate a buffer, reusing the given one if large enough.
AVCodecav_codec_next (AVCodec *c)
 If c is NULL, returns the first registered codec, if c is non-NULL, returns the next registered codec after c, or NULL if c is the last one.
void avcodec_init (void)
void avcodec_register (AVCodec *codec)
 Register the codec codec and initialize libavcodec.
unsigned avcodec_get_edge_width (void)
 Return the amount of padding in pixels which the get_buffer callback must provide around the edge of the image for codecs which do not have the CODEC_FLAG_EMU_EDGE flag.
void avcodec_set_dimensions (AVCodecContext *s, int width, int height)
void avcodec_align_dimensions2 (AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS])
 Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you also ensure that all line sizes are a multiple of the respective linesize_align[i].
void avcodec_align_dimensions (AVCodecContext *s, int *width, int *height)
 Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you do not use any horizontal padding.
void ff_init_buffer_info (AVCodecContext *s, AVFrame *pic)
 does needed setup of pkt_pts/pos and such for (re)get_buffer();
static int audio_get_buffer (AVCodecContext *avctx, AVFrame *frame)
static int video_get_buffer (AVCodecContext *s, AVFrame *pic)
int avcodec_default_get_buffer (AVCodecContext *avctx, AVFrame *frame)
void avcodec_default_release_buffer (AVCodecContext *s, AVFrame *pic)
int avcodec_default_reget_buffer (AVCodecContext *s, AVFrame *pic)
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 jobnr, int threadnr), void *arg, int *ret, int count)
enum PixelFormat avcodec_default_get_format (struct AVCodecContext *s, const enum PixelFormat *fmt)
void avcodec_get_frame_defaults (AVFrame *pic)
 Set the fields of the given AVFrame to default values.
AVFrameavcodec_alloc_frame (void)
 Allocate an AVFrame and set its fields to default values.
static void avcodec_get_subtitle_defaults (AVSubtitle *sub)
int attribute_align_arg avcodec_open (AVCodecContext *avctx, AVCodec *codec)
 Initialize the AVCodecContext to use the given AVCodec.
int attribute_align_arg avcodec_open2 (AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
 Initialize the AVCodecContext to use the given AVCodec.
int attribute_align_arg avcodec_encode_audio (AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)
 Encode an audio frame from samples into buf.
int attribute_align_arg avcodec_encode_video (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVFrame *pict)
 Encode a video frame from pict into buf.
int avcodec_encode_subtitle (AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
static int64_t guess_correct_pts (AVCodecContext *ctx, int64_t reordered_pts, int64_t dts)
 Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect times.
int attribute_align_arg avcodec_decode_video2 (AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
 Decode the video frame of size avpkt->size from avpkt->data into picture.
int attribute_align_arg avcodec_decode_audio3 (AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt)
 Wrapper function which calls avcodec_decode_audio4.
int attribute_align_arg avcodec_decode_audio4 (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 Decode the audio frame of size avpkt->size from avpkt->data into frame.
int avcodec_decode_subtitle2 (AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
 Decode a subtitle message.
void avsubtitle_free (AVSubtitle *sub)
 Frees all allocated data in the given subtitle struct.
av_cold int avcodec_close (AVCodecContext *avctx)
static enum CodecID remap_deprecated_codec_id (enum CodecID id)
AVCodecavcodec_find_encoder (enum CodecID id)
 Find a registered encoder with a matching codec ID.
AVCodecavcodec_find_encoder_by_name (const char *name)
 Find a registered encoder with the specified name.
AVCodecavcodec_find_decoder (enum CodecID id)
 Find a registered decoder with a matching codec ID.
AVCodecavcodec_find_decoder_by_name (const char *name)
 Find a registered decoder with the specified name.
static int get_bit_rate (AVCodecContext *ctx)
const char * avcodec_get_name (enum CodecID id)
 Get the name of a codec.
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.
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.
unsigned avcodec_version (void)
 Return the LIBAVCODEC_VERSION_INT constant.
const char * avcodec_configuration (void)
 Return the libavcodec build-time configuration.
const char * avcodec_license (void)
 Return the libavcodec license.
void avcodec_flush_buffers (AVCodecContext *avctx)
 Flush buffers, should be called when seeking or when switching to a different stream.
static void video_free_buffers (AVCodecContext *s)
static void audio_free_buffers (AVCodecContext *avctx)
void avcodec_default_free_buffers (AVCodecContext *avctx)
char av_get_pict_type_char (int pict_type)
 Return a single letter to describe the given picture type pict_type.
int av_get_bits_per_sample (enum CodecID codec_id)
 Return codec bits per sample.
int av_get_bits_per_sample_format (enum AVSampleFormat sample_fmt)
int ff_thread_init (AVCodecContext *s)
unsigned int av_xiphlacing (unsigned char *s, unsigned int v)
 Encode extradata length to a buffer.
int ff_match_2uint16 (const uint16_t(*tab)[2], int size, int a, int b)
 Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
void av_log_missing_feature (void *avc, const char *feature, int want_sample)
 Logs a generic warning message about a missing feature.
void av_log_ask_for_sample (void *avc, const char *msg,...)
void av_register_hwaccel (AVHWAccel *hwaccel)
 Register the hardware accelerator hwaccel.
AVHWAccelav_hwaccel_next (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.
AVHWAccelff_find_hwaccel (enum CodecID codec_id, enum PixelFormat pix_fmt)
 Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.
int av_lockmgr_register (int(*cb)(void **mutex, enum AVLockOp op))
 Register a user provided lock manager supporting the operations specified by AVLockOp.
int avpriv_lock_avformat (void)
int avpriv_unlock_avformat (void)
unsigned int avpriv_toupper4 (unsigned int x)
int ff_thread_get_buffer (AVCodecContext *avctx, AVFrame *f)
 Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_release_buffer (AVCodecContext *avctx, AVFrame *f)
 Wrapper around release_buffer() frame-for multithreaded codecs.
void ff_thread_finish_setup (AVCodecContext *avctx)
 If the codec defines update_thread_context(), call this when they are ready for the next thread to start decoding the next frame.
void ff_thread_report_progress (AVFrame *f, int progress, int field)
 Notifies later decoding threads when part of their reference picture is ready.
void ff_thread_await_progress (AVFrame *f, int progress, int field)
 Waits for earlier decoding threads to finish reference pictures Call this before accessing some part of a picture, with a given value for progress, and it will return after the responsible decoding thread calls ff_thread_report_progress() with the same or higher value for progress.
int avcodec_thread_init (AVCodecContext *s, int thread_count)
enum AVMediaType avcodec_get_type (enum CodecID codec_id)
 Get the type of the given codec.

Variables

static int volatile entangled_thread_counter = 0
static int(* ff_lockmgr_cb )(void **mutex, enum AVLockOp op)
static void * codec_mutex
static void * avformat_mutex
static AVCodecfirst_avcodec = NULL
static AVHWAccelfirst_hwaccel = NULL


Detailed Description

utils.

Definition in file utils.c.


Define Documentation

#define INTERNAL_BUFFER_SIZE   (32+1)

Definition at line 129 of file utils.c.

Referenced by video_free_buffers(), and video_get_buffer().

#define LICENSE_PREFIX   "libavcodec license: "

#define SANE_NB_CHANNELS   128U

Referenced by avcodec_open2().


Function Documentation

static void audio_free_buffers ( AVCodecContext avctx  )  [static]

Definition at line 1427 of file utils.c.

Referenced by avcodec_default_free_buffers().

static int audio_get_buffer ( AVCodecContext avctx,
AVFrame frame 
) [static]

Definition at line 262 of file utils.c.

Referenced by avcodec_default_get_buffer().

AVCodec* av_codec_next ( AVCodec c  ) 

If c is NULL, returns the first registered codec, if c is non-NULL, returns the next registered codec after c, or NULL if c is the last one.

Definition at line 85 of file utils.c.

Referenced by codec_child_class_next(), opt_codecs(), and show_codec_opts().

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

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

Contrary to av_fast_realloc the current buffer contents might not be preserved and on error the old buffer is freed, thus no special handling to avoid memleaks is necessary.

Parameters:
ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
size size of the buffer *ptr points to
min_size minimum size of *ptr buffer after returning, *ptr will be NULL and *size 0 if an error occurred.

Definition at line 70 of file utils.c.

Referenced by codec_reinit(), decode_frame(), decode_i_frame(), decode_p_frame(), do_audio_out(), ff_h263_decode_frame(), ff_h264_decode_nal(), ff_id3v2_parse(), ff_mpeg_update_thread_context(), ljpeg_decode_rgb_scan(), mimic_decode_frame(), mp_decode_frame(), parse_picture_segment(), pmp_packet(), spdif_header_dts4(), spdif_write_packet(), submit_packet(), svq3_decode_frame(), tqi_decode_frame(), truemotion1_decode_header(), and truemotion1_decode_init().

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

int av_get_bits_per_sample ( enum CodecID  codec_id  ) 

int av_get_bits_per_sample_format ( enum AVSampleFormat  sample_fmt  ) 

Deprecated:
Use av_get_bytes_per_sample() instead.

Definition at line 1513 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:
buf_size size in bytes of buf
Returns:
the length of the string that would have been generated if enough space had been available, excluding the trailing null

Definition at line 1252 of file utils.c.

Referenced by avcodec_string(), avformat_write_header(), and show_stream().

char av_get_pict_type_char ( int  pict_type  ) 

Return a single letter to describe the given picture type pict_type.

Parameters:
[in] pict_type the picture type
Returns:
A single character representing the picture type.
Deprecated:
Use av_get_picture_type_char() instead.

Definition at line 1459 of file utils.c.

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

Return a name for the specified profile, if available.

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

Definition at line 1361 of file utils.c.

Referenced by avcodec_string().

AVHWAccel* av_hwaccel_next ( 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 1580 of file utils.c.

Referenced by ff_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:
cb User defined callback. Note: FFmpeg 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 1597 of file utils.c.

Referenced by do_exit(), ff_vda_create_decoder(), and main().

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

Definition at line 1554 of file utils.c.

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

Logs a generic warning message about a missing feature.

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

Parameters:
[in] avc a pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct
[in] feature string containing the name of the missing feature
[in] want_sample indicates 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.

Definition at line 1544 of file utils.c.

Referenced by aac_adtstoasc_filter(), amrnb_decode_frame(), amrwb_decode_frame(), decode_audio_block(), decode_frame_header(), decode_ga_specific_config(), decode_ics(), decode_slice_header(), decode_subframe(), ff_eac3_parse_header(), flashsv_decode_frame(), latm_decode_audio_specific_config(), mpc8_decode_init(), parse_adts_frame_header(), parse_fmtp(), parse_MP4SLDescrTag(), qt_rtp_parse_packet(), read_sbr_extension(), read_stream_mux_config(), rv10_decode_init(), spdif_get_offset_and_codec(), spdif_read_packet(), synth_superframe(), tta_decode_init(), vc1_parse_frame_header_adv(), and video_get_buffer().

void av_register_hwaccel ( AVHWAccel hwaccel  ) 

Register the hardware accelerator hwaccel.

Definition at line 1571 of file utils.c.

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

Encode extradata length to a buffer.

Used by xiph codecs.

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

Definition at line 1524 of file utils.c.

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

void avcodec_align_dimensions ( AVCodecContext s,
int *  width,
int *  height 
)

Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you do not use any horizontal padding.

May only be used if a codec with CODEC_CAP_DR1 has been opened. If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased according to avcodec_get_edge_width() before.

Definition at line 234 of file utils.c.

void avcodec_align_dimensions2 ( AVCodecContext s,
int *  width,
int *  height,
int  linesize_align[AV_NUM_DATA_POINTERS] 
)

Modify width and height values so that they will result in a memory buffer that is acceptable for the codec if you also ensure that all line sizes are a multiple of the respective linesize_align[i].

May only be used if a codec with CODEC_CAP_DR1 has been opened. If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased according to avcodec_get_edge_width() before.

Definition at line 131 of file utils.c.

Referenced by avcodec_align_dimensions(), and video_get_buffer().

AVFrame* avcodec_alloc_frame ( void   ) 

av_cold int avcodec_close ( AVCodecContext avctx  ) 

const char* avcodec_configuration ( void   ) 

Return the libavcodec build-time configuration.

Definition at line 1385 of file utils.c.

int attribute_align_arg avcodec_decode_audio3 ( AVCodecContext avctx,
int16_t samples,
int *  frame_size_ptr,
AVPacket avpkt 
)

Wrapper function which calls avcodec_decode_audio4.

Deprecated:
Use avcodec_decode_audio4 instead.
Decode the audio frame of size avpkt->size from avpkt->data into samples. Some decoders may support multiple frames in a single AVPacket, such decoders would then just decode the first frame. In this case, avcodec_decode_audio3 has to be called again with an AVPacket that contains the remaining data in order to decode the second frame etc. If no frame could be outputted, frame_size_ptr is zero. Otherwise, it is the decompressed frame size in bytes.

Warning:
You must set frame_size_ptr to the allocated size of the output buffer before calling avcodec_decode_audio3().

The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end.

The end of the input buffer avpkt->data should be set to 0 to ensure that no overreading happens for damaged MPEG streams.

Note:
You might have to align the input buffer avpkt->data and output buffer samples. The alignment requirements depend on the CPU: On some CPUs it isn't necessary at all, on others it won't work at all if not aligned and on others it will work but it will have an impact on performance.
In practice, avpkt->data should have 4 byte alignment at minimum and samples should be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do).

Note:
Codecs which have the CODEC_CAP_DELAY capability set have a delay between input and output, these need to be fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
Parameters:
avctx the codec context
[out] samples the output buffer, sample type in avctx->sample_fmt If the sample format is planar, each channel plane will be the same size, with no padding between channels.
[in,out] frame_size_ptr the output buffer size in bytes
[in] avpkt The input AVPacket containing the input buffer. You can create such packet with av_init_packet() and by then setting data and size, some decoders might in addition need other fields. All decoders are designed to use the least fields possible though.
Returns:
On error a negative value is returned, otherwise the number of bytes used or zero if no frame data was decompressed (used) from the input AVPacket.

Definition at line 993 of file utils.c.

int attribute_align_arg avcodec_decode_audio4 ( AVCodecContext avctx,
AVFrame frame,
int *  got_frame_ptr,
AVPacket avpkt 
)

Decode the audio frame of size avpkt->size from avpkt->data into frame.

Some decoders may support multiple frames in a single AVPacket. Such decoders would then just decode the first frame. In this case, avcodec_decode_audio4 has to be called again with an AVPacket containing the remaining data in order to decode the second frame, etc... Even if no frames are returned, the packet needs to be fed to the decoder with remaining data until it is completely consumed or an error occurs.

Warning:
The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end.
Note:
You might have to align the input buffer. The alignment requirements depend on the CPU and the decoder.
Parameters:
avctx the codec context
[out] frame The AVFrame in which to store decoded audio samples. Decoders request a buffer of a particular size by setting AVFrame.nb_samples prior to calling get_buffer(). The decoder may, however, only utilize part of the buffer by setting AVFrame.nb_samples to a smaller value in the output frame.
[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is non-zero.
[in] avpkt The input AVPacket containing the input buffer. At least avpkt->data and avpkt->size should be set. Some decoders might also require additional fields to be set.
Returns:
A negative error code is returned if an error occurred during decoding, otherwise the number of bytes consumed from the input AVPacket is returned.

Definition at line 1038 of file utils.c.

Referenced by audio_decode_example(), audio_decode_frame(), avcodec_decode_audio3(), transcode_audio(), and try_decode_frame().

int avcodec_decode_subtitle2 ( AVCodecContext avctx,
AVSubtitle sub,
int *  got_sub_ptr,
AVPacket avpkt 
)

Decode a subtitle message.

Return a negative value on error, otherwise return the number of bytes used. If no subtitle could be decompressed, got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for simplicity, because the performance difference is expect to be negligible and reusing a get_buffer written for video codecs would probably perform badly due to a potentially very different allocation pattern.

Parameters:
avctx the codec context
[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be freed with avsubtitle_free if *got_sub_ptr is set.
[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
[in] avpkt The input AVPacket containing the input buffer.

Definition at line 1064 of file utils.c.

Referenced by subtitle_thread(), and transcode_subtitles().

int attribute_align_arg avcodec_decode_video2 ( AVCodecContext avctx,
AVFrame picture,
int *  got_picture_ptr,
AVPacket avpkt 
)

Decode the video frame of size avpkt->size from avpkt->data into picture.

Some decoders may support multiple frames in a single AVPacket, such decoders would then just decode the first frame.

Warning:
The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end.

The end of the input buffer buf should be set to 0 to ensure that no overreading happens for damaged MPEG streams.

Note:
You might have to align the input buffer avpkt->data. The alignment requirements depend on the CPU: on some CPUs it isn't necessary at all, on others it won't work at all if not aligned and on others it will work but it will have an impact on performance.
In practice, avpkt->data should have 4 byte alignment at minimum.

Note:
Codecs which have the CODEC_CAP_DELAY capability set have a delay between input and output, these need to be fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames.
Parameters:
avctx the codec context
[out] picture The AVFrame in which the decoded video frame will be stored. Use avcodec_alloc_frame to get an AVFrame, the codec will allocate memory for the actual bitmap. with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit. with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder decodes and the decoder tells the user once it does not need the data anymore, the user app can at this point free/reuse/keep the memory as it sees fit.
[in] avpkt The input AVpacket containing the input buffer. You can create such packet with av_init_packet() and by then setting data and size, some decoders might in addition need other fields like flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least fields possible.
[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
Returns:
On error a negative value is returned, otherwise the number of bytes used or zero if no frame could be decompressed.

Definition at line 942 of file utils.c.

Referenced by get_video_frame(), main(), transcode_video(), try_decode_frame(), and video_decode_example().

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

Definition at line 598 of file utils.c.

Referenced by avcodec_get_context_defaults3(), and avcodec_thread_execute().

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

Definition at line 608 of file utils.c.

void avcodec_default_free_buffers ( AVCodecContext avctx  ) 

Definition at line 1444 of file utils.c.

Referenced by avcodec_close(), frame_thread_free(), and MPV_common_end().

int avcodec_default_get_buffer ( AVCodecContext avctx,
AVFrame frame 
)

enum PixelFormat avcodec_default_get_format ( struct AVCodecContext s,
const enum PixelFormat fmt 
)

Definition at line 618 of file utils.c.

Referenced by avcodec_get_context_defaults3().

int avcodec_default_reget_buffer ( AVCodecContext s,
AVFrame pic 
)

Definition at line 560 of file utils.c.

Referenced by avcodec_get_context_defaults3().

void avcodec_default_release_buffer ( AVCodecContext s,
AVFrame pic 
)

int attribute_align_arg avcodec_encode_audio ( AVCodecContext avctx,
uint8_t *  buf,
int  buf_size,
const short *  samples 
)

Encode an audio frame from samples into buf.

Note:
The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. However, for PCM audio the user will know how much space is needed because it depends on the value passed in buf_size as described below. In that case a lower value can be used.
Parameters:
avctx the codec context
[out] buf the output buffer
[in] buf_size the output buffer size
[in] samples the input buffer containing the samples The number of samples read from this buffer is frame_size*channels, both of which are defined in avctx. For PCM audio the number of samples read from samples is equal to buf_size * input_sample_size / output_sample_size.
Returns:
On error a negative value is returned, on success zero or the number of bytes used to encode the data read from the input buffer.

Definition at line 862 of file utils.c.

Referenced by audio_encode_example(), do_audio_out(), flush_encoders(), and write_audio_frame().

int avcodec_encode_subtitle ( AVCodecContext avctx,
uint8_t *  buf,
int  buf_size,
const AVSubtitle sub 
)

Definition at line 896 of file utils.c.

Referenced by do_subtitle_out().

int attribute_align_arg avcodec_encode_video ( AVCodecContext avctx,
uint8_t *  buf,
int  buf_size,
const AVFrame pict 
)

Encode a video frame from pict into buf.

The input picture should be stored using a specific format, namely avctx.pix_fmt.

Parameters:
avctx the codec context
[out] buf the output buffer for the bitstream of encoded frame
[in] buf_size the size of the output buffer in bytes
[in] pict the input picture to encode
Returns:
On error a negative value is returned, on success zero or the number of bytes used from the output buffer.

Definition at line 877 of file utils.c.

Referenced by do_video_out(), estimate_best_b_count(), filter(), flush_encoders(), video_encode_example(), write_png(), and write_video_frame().

AVCodec* avcodec_find_decoder ( enum CodecID  id  ) 

Find a registered decoder with a matching codec ID.

Parameters:
id CodecID of the requested decoder
Returns:
A decoder if one was found, NULL otherwise.

Definition at line 1179 of file utils.c.

Referenced by add_input_streams(), assert_codec_experimental(), audio_decode_example(), av_find_best_stream(), avcodec_get_name(), avcodec_get_type(), avcodec_string(), avformat_find_stream_info(), choose_decoder(), movie_common_init(), open_input_file(), open_parser(), setup_find_stream_info_opts(), stream_component_open(), try_decode_frame(), and video_decode_example().

AVCodec* avcodec_find_decoder_by_name ( const char *  name  ) 

Find a registered decoder with the specified name.

Parameters:
name name of the requested decoder
Returns:
A decoder if one was found, NULL otherwise.

Definition at line 1196 of file utils.c.

Referenced by find_codec_or_die(), and stream_component_open().

AVCodec* avcodec_find_encoder ( enum CodecID  id  ) 

Find a registered encoder with a matching codec ID.

Parameters:
id CodecID of the requested encoder
Returns:
An encoder if one was found, NULL otherwise.

Definition at line 1148 of file utils.c.

Referenced by add_video_stream(), asf_write_header1(), assert_codec_experimental(), audio_encode_example(), avcodec_get_name(), avcodec_get_type(), avcodec_string(), choose_encoder(), compute_status(), config(), estimate_best_b_count(), ffserver_opt_preset(), open_audio(), open_video(), read_ffserver_streams(), transcode_init(), vf_open(), and video_encode_example().

AVCodec* avcodec_find_encoder_by_name ( const char *  name  ) 

Find a registered encoder with the specified name.

Parameters:
name name of the requested encoder
Returns:
An encoder if one was found, NULL otherwise.

Definition at line 1165 of file utils.c.

Referenced by find_codec_or_die(), opt_audio_codec(), and opt_video_codec().

void avcodec_flush_buffers ( AVCodecContext avctx  ) 

Flush buffers, should be called when seeking or when switching to a different stream.

Definition at line 1396 of file utils.c.

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

unsigned avcodec_get_edge_width ( void   ) 

Return the amount of padding in pixels which the get_buffer callback must provide around the edge of the image for codecs which do not have the CODEC_FLAG_EMU_EDGE flag.

Returns:
Required padding in pixels.

Definition at line 117 of file utils.c.

void avcodec_get_frame_defaults ( AVFrame pic  ) 

Set the fields of the given AVFrame to default values.

Parameters:
pic The AVFrame of which the fields should be set to default values.

Definition at line 624 of file utils.c.

Referenced by a64multi_init_encoder(), aac_decode_init(), aasc_decode_init(), ac3_decode_init(), adpcm_decode_init(), adx_decode_init(), alac_decode_init(), amrnb_decode_init(), amrwb_decode_init(), ape_decode_init(), atrac1_decode_init(), atrac3_decode_init(), audio_decode_example(), audio_decode_frame(), aura_decode_init(), avcodec_alloc_frame(), avs_decode_init(), bethsoftvid_decode_init(), bfi_decode_init(), bmp_decode_init(), bmp_encode_init(), bmv_aud_decode_init(), cdg_init_frame(), cinaudio_decode_init(), cinepak_decode_init(), cinvideo_decode_init(), cmv_decode_init(), common_init(), cook_decode_init(), cyuv_decode_init(), dca_decode_init(), decode_init(), decoder_init(), dirac_decode_data_unit(), dnxhd_decode_init(), do_video_resample(), dpcm_decode_init(), eightsvx_decode_init(), encode_init(), escape124_decode_frame(), escape124_decode_init(), estimate_best_b_count(), ff_mjpeg_decode_init(), ff_pnm_init(), ff_vp56_init(), flac_decode_init(), flashsv_decode_init(), flic_decode_init(), frame_worker_thread(), g722_decode_init(), g723_1_decode_init(), gif_decode_init(), gsm_init(), idcin_decode_init(), imc_decode_init(), ipvideo_decode_init(), ir2_decode_init(), j2kdec_init(), libcelt_dec_init(), libgsm_decode_init(), libopenjpeg_decode_init(), libspeex_decode_init(), mace_decode_init(), main(), mdec_common_init(), mlp_decode_init(), mm_decode_init(), mp_decode_init(), mpc7_decode_init(), mpc8_decode_init(), MPV_common_init(), msrle_decode_init(), msvideo1_decode_init(), pcm_bluray_decode_init(), pcm_decode_init(), pcx_encode_init(), pcx_init(), png_dec_init(), png_enc_init(), ptx_init(), qcelp_decode_init(), qdm2_decode_init(), qtrle_decode_init(), ra144_decode_init(), ra288_decode_init(), rl2_decode_init(), roq_decode_init(), rpza_decode_init(), s302m_decode_init(), seqvideo_decode_init(), sgi_init(), shorten_decode_init(), sipr_decoder_init(), smc_decode_init(), smka_decode_init(), sunrast_init(), targa_encode_init(), targa_init(), tgv_decode_init(), tiff_init(), tmv_decode_init(), transcode_audio(), transcode_video(), truemotion1_decode_init(), truespeech_decode_init(), try_decode_frame(), tta_decode_init(), twin_decode_init(), txd_init(), ulti_decode_init(), vmdaudio_decode_init(), vmdvideo_decode_init(), vorbis_decode_init(), vqa_decode_init(), wavpack_decode_init(), wma_decode_init(), wmavoice_decode_init(), ws_snd_decode_init(), xan_decode_init(), and yop_decode_init().

const char* avcodec_get_name ( enum CodecID  id  ) 

Get the name of a codec.

Returns:
a static string identifying the codec; never NULL

Definition at line 1233 of file utils.c.

Referenced by avcodec_string(), flv_write_packet(), init_input_stream(), read_frame_internal(), rtp_write_header(), and transcode_init().

static void avcodec_get_subtitle_defaults ( AVSubtitle sub  )  [static]

Definition at line 644 of file utils.c.

Referenced by avcodec_decode_subtitle2().

enum AVMediaType avcodec_get_type ( enum CodecID  codec_id  ) 

Get the type of the given codec.

Definition at line 1681 of file utils.c.

Referenced by mkv_query_codec().

void avcodec_init ( void   ) 

Deprecated:
this function is called automatically from avcodec_register() and avcodec_register_all(), there is no need to call it manually

Definition at line 93 of file utils.c.

Referenced by avcodec_register(), and main().

const char* avcodec_license ( void   ) 

Return the libavcodec license.

Definition at line 1390 of file utils.c.

int attribute_align_arg avcodec_open ( AVCodecContext avctx,
AVCodec codec 
)

Initialize the AVCodecContext to use the given AVCodec.

Prior to using this function the context has to be allocated.

The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for retrieving a codec.

Warning:
This function is not thread safe!
 avcodec_register_all();
 codec = avcodec_find_decoder(CODEC_ID_H264);
 if (!codec)
     exit(1);

 context = avcodec_alloc_context3(codec);

 if (avcodec_open(context, codec) < 0)
     exit(1);

Parameters:
avctx The context which will be set up to use the given codec.
codec The codec to use within the context.
Returns:
zero on success, a negative value on error
See also:
avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
Deprecated:
use avcodec_open2

Definition at line 651 of file utils.c.

Referenced by audio_decode_example(), audio_encode_example(), config(), open_audio(), open_input_file(), open_video(), vf_open(), video_decode_example(), and video_encode_example().

int attribute_align_arg avcodec_open2 ( AVCodecContext avctx,
AVCodec codec,
AVDictionary **  options 
)

Initialize the AVCodecContext to use the given AVCodec.

Prior to using this function the context has to be allocated with avcodec_alloc_context3().

The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for retrieving a codec.

Warning:
This function is not thread safe!
 avcodec_register_all();
 av_dict_set(&opts, "b", "2.5M", 0);
 codec = avcodec_find_decoder(CODEC_ID_H264);
 if (!codec)
     exit(1);

 context = avcodec_alloc_context3(codec);

 if (avcodec_open2(context, codec, opts) < 0)
     exit(1);

Parameters:
avctx The context to initialize.
options A dictionary filled with AVCodecContext and codec-private options. On return this object will be filled with options that were not found.
Returns:
zero on success, a negative value on error
See also:
avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), av_dict_set(), av_opt_find().

Definition at line 657 of file utils.c.

Referenced by avcodec_open(), avformat_find_stream_info(), estimate_best_b_count(), init_input_stream(), movie_common_init(), open_input_file(), open_parser(), stream_component_open(), transcode_init(), and try_decode_frame().

void avcodec_register ( AVCodec codec  ) 

Register the codec codec and initialize libavcodec.

Warning:
either this function or avcodec_register_all() must be called before any other libavcodec functions.
See also:
avcodec_register_all()

Definition at line 104 of file utils.c.

void avcodec_set_dimensions ( AVCodecContext s,
int  width,
int  height 
)

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

Definition at line 1267 of file utils.c.

Referenced by avformat_find_stream_info(), and dump_stream_format().

int avcodec_thread_init ( AVCodecContext s,
int  thread_count 
)

Deprecated:
Set s->thread_count before calling avcodec_open2() instead of calling this.

Definition at line 1674 of file utils.c.

unsigned avcodec_version ( void   ) 

Return the LIBAVCODEC_VERSION_INT constant.

Definition at line 1374 of file utils.c.

int avpriv_lock_avformat ( void   ) 

Definition at line 1617 of file utils.c.

Referenced by ff_tls_deinit(), and ff_tls_init().

unsigned int avpriv_toupper4 ( unsigned int  x  ) 

Definition at line 1635 of file utils.c.

Referenced by ff_codec_get_id(), MPV_common_init(), and validate_codec_tag().

int avpriv_unlock_avformat ( void   ) 

Definition at line 1626 of file utils.c.

Referenced by ff_tls_deinit(), and ff_tls_init().

void avsubtitle_free ( AVSubtitle sub  ) 

Frees all allocated data in the given subtitle struct.

Parameters:
sub AVSubtitle to free.

Definition at line 1079 of file utils.c.

Referenced by free_subpicture(), and transcode_subtitles().

AVHWAccel* ff_find_hwaccel ( enum CodecID  codec_id,
enum PixelFormat  pix_fmt 
)

Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.

Parameters:
codec_id the codec to match
pix_fmt the pixel format to match
Returns:
the hardware accelerated codec, or NULL if none was found.

Definition at line 1585 of file utils.c.

Referenced by decode_slice_header(), ff_h263_decode_init(), vc1_decode_init(), and vcr2_init_sequence().

void ff_init_buffer_info ( AVCodecContext s,
AVFrame pic 
)

does needed setup of pkt_pts/pos and such for (re)get_buffer();

Definition at line 246 of file utils.c.

Referenced by ff_thread_get_buffer().

int ff_match_2uint16 ( const uint16_t(*)  tab[2],
int  size,
int  a,
int  b 
)

Return the index into tab at which {a,b} match elements {[0],[1]} of tab.

If there is no such matching pair then size is returned.

Definition at line 1538 of file utils.c.

Referenced by h263_encode_picture_header(), MPV_encode_init(), and svq1_write_header().

void ff_thread_await_progress ( AVFrame f,
int  progress,
int  field 
)

Waits for earlier decoding threads to finish reference pictures Call this before accessing some part of a picture, with a given value for progress, and it will return after the responsible decoding thread calls ff_thread_report_progress() with the same or higher value for progress.

Parameters:
f The picture being referenced.
progress Value, in arbitrary units, to wait for.
field The field being referenced, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field.

Definition at line 1667 of file utils.c.

void ff_thread_finish_setup ( AVCodecContext avctx  ) 

If the codec defines update_thread_context(), call this when they are ready for the next thread to start decoding the next frame.

After calling it, do not change any variables read by the update_thread_context() method, or call ff_thread_get_buffer().

Parameters:
avctx The context.

Definition at line 1659 of file utils.c.

int ff_thread_get_buffer ( AVCodecContext avctx,
AVFrame f 
)

Wrapper around get_buffer() for frame-multithreaded codecs.

Call this function instead of avctx->get_buffer(f). Cannot be called after the codec has called ff_thread_finish_setup().

Parameters:
avctx The current context.
f The frame to write into.

Definition at line 1645 of file utils.c.

int ff_thread_init ( AVCodecContext s  ) 

Definition at line 1519 of file utils.c.

void ff_thread_release_buffer ( AVCodecContext avctx,
AVFrame f 
)

Wrapper around release_buffer() frame-for multithreaded codecs.

Call this function instead of avctx->release_buffer(f). The AVFrame will be copied and the actual release_buffer() call will be performed later. The contents of data pointed to by the AVFrame should not be changed until ff_thread_get_buffer() is called on it.

Parameters:
avctx The current context.
f The picture being released.

Definition at line 1654 of file utils.c.

void ff_thread_report_progress ( AVFrame f,
int  progress,
int  field 
)

Notifies later decoding threads when part of their reference picture is ready.

Call this when some part of the picture is finished decoding. Later calls with lower values of progress have no effect.

Parameters:
f The picture being decoded.
progress Value, in arbitrary units, of how much of the picture has decoded.
field The field being decoded, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field.

Definition at line 1663 of file utils.c.

static int get_bit_rate ( AVCodecContext ctx  )  [static]

Definition at line 1210 of file utils.c.

Referenced by avcodec_string().

static int64_t guess_correct_pts ( AVCodecContext ctx,
int64_t  reordered_pts,
int64_t  dts 
) [static]

Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect times.

Input timestamps may wrap around, in which case the output will as well.

Parameters:
pts the pts field of the decoded AVPacket, as passed through AVFrame.pkt_pts
dts the dts field of the decoded AVPacket
Returns:
one of the input values, may be AV_NOPTS_VALUE

Definition at line 920 of file utils.c.

Referenced by avcodec_decode_video2().

static enum CodecID remap_deprecated_codec_id ( enum CodecID  id  )  [static]

Definition at line 1138 of file utils.c.

Referenced by avcodec_find_decoder(), and avcodec_find_encoder().

static void video_free_buffers ( AVCodecContext s  )  [static]

Definition at line 1404 of file utils.c.

Referenced by avcodec_default_free_buffers().

static int video_get_buffer ( AVCodecContext s,
AVFrame pic 
) [static]

Definition at line 368 of file utils.c.

Referenced by avcodec_default_get_buffer().


Variable Documentation

void* avformat_mutex [static]

Definition at line 52 of file utils.c.

Referenced by av_lockmgr_register(), avpriv_lock_avformat(), and avpriv_unlock_avformat().

void* codec_mutex [static]

Definition at line 51 of file utils.c.

Referenced by av_lockmgr_register(), avcodec_close(), and avcodec_open2().

int volatile entangled_thread_counter = 0 [static]

Definition at line 49 of file utils.c.

Referenced by avcodec_close(), and avcodec_open2().

int(* ff_lockmgr_cb)(void **mutex, enum AVLockOp op) [static]

AVCodec* first_avcodec = NULL [static]

Definition at line 83 of file utils.c.

Definition at line 1569 of file utils.c.


Generated on Fri Oct 26 02:43:49 2012 for FFmpeg by  doxygen 1.5.8