utils. More...
#include "libavutil/avassert.h"
#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 "avcodec.h"
#include "dsputil.h"
#include "libavutil/opt.h"
#include "imgconvert.h"
#include "thread.h"
#include "internal.h"
#include "bytestream.h"
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <float.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. | |
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. | |
void | avcodec_init (void) |
static av_always_inline int | codec_is_encoder (AVCodec *codec) |
static av_always_inline int | codec_is_decoder (AVCodec *codec) |
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. | |
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. | |
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. | |
AVFrame * | avcodec_alloc_frame (void) |
Allocate an AVFrame and set its fields to default values. | |
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 | ff_alloc_packet (AVPacket *avpkt, int size) |
Check AVPacket size and/or allocate data. | |
int attribute_align_arg | avcodec_encode_audio2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) |
Encode a frame of audio. | |
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 void | apply_param_change (AVCodecContext *avctx, AVPacket *avpkt) |
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) |
Free all allocated data in the given subtitle struct. | |
av_cold int | avcodec_close (AVCodecContext *avctx) |
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself). | |
AVCodec * | avcodec_find_encoder (enum CodecID id) |
Find a registered encoder with a matching codec ID. | |
AVCodec * | avcodec_find_encoder_by_name (const char *name) |
Find a registered encoder with the specified name. | |
AVCodec * | avcodec_find_decoder (enum CodecID id) |
Find a registered decoder with a matching codec ID. | |
AVCodec * | avcodec_find_decoder_by_name (const char *name) |
Find a registered decoder with the specified name. | |
static int | get_bit_rate (AVCodecContext *ctx) |
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) |
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) |
Log 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. | |
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. | |
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. | |
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 | avcodec_thread_init (AVCodecContext *s, int thread_count) |
enum AVMediaType | avcodec_get_type (enum CodecID codec_id) |
Get the type of the given codec. | |
int | avcodec_is_open (AVCodecContext *s) |
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 AVCodec * | first_avcodec = NULL |
static AVHWAccel * | first_hwaccel = NULL |
utils.
Definition in file utils.c.
#define INTERNAL_BUFFER_SIZE (32+1) |
Definition at line 140 of file utils.c.
Referenced by video_get_buffer().
#define LICENSE_PREFIX "libavcodec license: " |
Referenced by avcodec_license(), avdevice_license(), avfilter_license(), avformat_license(), avutil_license(), postproc_license(), and swscale_license().
#define SANE_NB_CHANNELS 128U |
Referenced by avcodec_open2().
static void apply_param_change | ( | AVCodecContext * | avctx, | |
AVPacket * | avpkt | |||
) | [static] |
Definition at line 1092 of file utils.c.
Referenced by avcodec_decode_audio4(), and avcodec_decode_video2().
static void audio_free_buffers | ( | AVCodecContext * | avctx | ) | [static] |
Definition at line 1594 of file utils.c.
Referenced by avcodec_default_free_buffers().
static int audio_get_buffer | ( | AVCodecContext * | avctx, | |
AVFrame * | frame | |||
) | [static] |
Definition at line 289 of file utils.c.
Referenced by avcodec_default_get_buffer().
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 86 of file utils.c.
Referenced by codec_child_class_next(), show_codecs(), and show_help().
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.
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 71 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(), tqi_decode_frame(), truemotion1_decode_header(), and truemotion1_decode_init().
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.
Definition at line 55 of file utils.c.
Referenced by commit_slices(), decode_frame(), dirac_combine_frame(), ff_add_index_entry(), ff_combine_frame(), ff_mms_asf_header_parser(), ff_vdpau_add_data_chunk(), flac_fifo_read_wrap(), get_stats(), mkv_copy_packet(), mxg_update_cache(), read_frame(), read_header(), shorten_decode_frame(), and spdif_header_eac3().
int av_get_bits_per_sample | ( | enum CodecID | codec_id | ) |
Return codec bits per sample.
[in] | codec_id | the codec |
Definition at line 1631 of file utils.c.
Referenced by adpcm_encode_init(), aiff_write_header(), au_read_header(), au_read_packet(), avcodec_encode_audio(), avformat_find_stream_info(), avformat_write_header(), do_audio_out(), ff_alsa_open(), ff_audio_interleave_init(), ff_mov_read_stsd_entries(), ff_put_wav_header(), ff_raw_read_header(), get_aiff_header(), get_audio_frame_size(), get_bit_rate(), gxf_packet(), mkv_write_tracks(), mov_get_codec_tag(), mov_write_audio_tag(), mov_write_header(), mxf_write_generic_sound_common(), oma_read_header(), pcm_decode_frame(), pcm_decode_init(), pcm_encode_frame(), pcm_encode_init(), pcm_read_seek(), pulse_read_header(), raw_read_packet(), rso_read_header(), rso_read_packet(), show_stream(), smjpeg_write_header(), voc_get_packet(), and wav_read_header().
int av_get_bits_per_sample_format | ( | enum AVSampleFormat | sample_fmt | ) |
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.
buf_size | size in bytes of buf |
Definition at line 1403 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.
[in] | pict_type | the picture type |
const char* av_get_profile_name | ( | const AVCodec * | codec, | |
int | profile | |||
) |
Return a name for the specified profile, if available.
codec | the codec that is searched for the given profile | |
profile | the profile value for which a name is requested |
Definition at line 1534 of file utils.c.
Referenced by avcodec_string().
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 1747 of file utils.c.
Referenced by ff_find_hwaccel().
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.
cb | User 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. |
void av_log_ask_for_sample | ( | void * | avc, | |
const char * | msg, | |||
... | ||||
) |
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.
[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 1711 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_seq_header(), decode_slice_header(), decode_subframe(), ff_eac3_parse_header(), ff_h263_decode_frame(), ff_rv34_decode_frame(), 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(), smc_decode_stream(), spdif_get_offset_and_codec(), spdif_read_packet(), synth_superframe(), tta_decode_init(), vc1_parse_frame_header_adv(), video_get_buffer(), and vp6_parse_header().
void av_register_hwaccel | ( | AVHWAccel * | hwaccel | ) |
unsigned int av_xiphlacing | ( | unsigned char * | s, | |
unsigned int | v | |||
) |
Encode extradata length to a buffer.
Used by xiph codecs.
s | buffer to write to; must be at least (v/255+1) bytes long | |
v | size of extradata in bytes |
Definition at line 1691 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 241 of file utils.c.
Referenced by alloc_buffer().
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 142 of file utils.c.
Referenced by avcodec_align_dimensions(), and video_get_buffer().
AVFrame* avcodec_alloc_frame | ( | void | ) |
Allocate an AVFrame and set its fields to default values.
The resulting struct can be deallocated by simply calling av_free().
Definition at line 618 of file utils.c.
Referenced by aac_encode_init(), adpcm_encode_init(), adx_encode_init(), alac_encode_init(), alloc_picture(), amr_nb_encode_init(), amr_wb_encode_init(), audio_decode_example(), audio_decode_frame(), decode_init(), encode_audio_frame(), encode_init(), Faac_encode_init(), ff_ac3_encode_init(), flac_encode_init(), g726_encode_init(), libgsm_encode_init(), movie_init(), MP3lame_encode_init(), MPA_encode_init(), oggvorbis_encode_init(), pcm_encode_init(), roq_dpcm_encode_init(), transcode_audio(), transcode_video(), v410_decode_init(), v410_encode_init(), vble_decode_init(), video_decode_example(), video_encode_example(), video_thread(), vorbis_encode_init(), and vp8_init().
av_cold int avcodec_close | ( | AVCodecContext * | avctx | ) |
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself).
Calling this function on an AVCodecContext that hasn't been opened will free the codec-specific data allocated in avcodec_alloc_context3() / avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will do nothing.
Definition at line 1282 of file utils.c.
Referenced by audio_decode_example(), audio_encode_example(), avformat_find_stream_info(), close_audio(), close_connection(), close_video(), estimate_best_b_count(), stream_component_close(), transcode(), uninit(), video_decode_example(), and video_encode_example().
const char* avcodec_configuration | ( | void | ) |
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.
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.
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).
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. |
Definition at line 1172 of file utils.c.
Referenced by output_packet().
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.
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. |
Definition at line 1218 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.
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 1248 of file utils.c.
Referenced by output_packet(), 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.
In practice, avpkt->data should have 4 byte alignment at minimum.
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. |
Definition at line 1134 of file utils.c.
Referenced by get_video_frame(), movie_get_frame(), output_packet(), 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 583 of file utils.c.
Referenced by 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 | |||
) |
void avcodec_default_free_buffers | ( | AVCodecContext * | avctx | ) |
Definition at line 1611 of file utils.c.
Referenced by avcodec_close(), frame_thread_free(), and MPV_common_end().
int avcodec_default_get_buffer | ( | AVCodecContext * | avctx, | |
AVFrame * | frame | |||
) |
Definition at line 497 of file utils.c.
Referenced by alloc_frame_buffer(), avcodec_decode_audio3(), ff_thread_get_buffer(), and submit_packet().
enum PixelFormat avcodec_default_get_format | ( | struct AVCodecContext * | s, | |
const enum PixelFormat * | fmt | |||
) |
int avcodec_default_reget_buffer | ( | AVCodecContext * | s, | |
AVFrame * | pic | |||
) |
void avcodec_default_release_buffer | ( | AVCodecContext * | s, | |
AVFrame * | pic | |||
) |
Definition at line 509 of file utils.c.
Referenced by free_frame_buffer().
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.
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 codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of samples read from samples is equal to: buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id)) This also implies that av_get_bits_per_sample() must not return 0 for these codecs. |
Definition at line 979 of file utils.c.
Referenced by audio_encode_example(), do_audio_out(), output_packet(), and write_audio_frame().
int attribute_align_arg avcodec_encode_audio2 | ( | AVCodecContext * | avctx, | |
AVPacket * | avpkt, | |||
const AVFrame * | frame, | |||
int * | got_packet_ptr | |||
) |
Encode a frame of audio.
Takes input samples from frame and writes the next output packet, if available, to avpkt. The output packet does not necessarily contain data for the most recent frame, as encoders can delay, split, and combine input frames internally as needed.
avctx | codec context | |
avpkt | output AVPacket. The user can supply an output buffer by setting avpkt->data and avpkt->size prior to calling the function, but if the size of the user-provided data is not large enough, encoding will fail. All other AVPacket fields will be reset by the encoder using av_init_packet(). If avpkt->data is NULL, the encoder will allocate it. The encoder will set avpkt->size to the size of the output packet. | |
[in] | frame | AVFrame containing the raw audio data to be encoded. May be NULL when flushing an encoder that has the CODEC_CAP_DELAY capability set. There are 2 codec capabilities that affect the allowed values of frame->nb_samples. If CODEC_CAP_SMALL_LAST_FRAME is set, then only the final frame may be smaller than avctx->frame_size, and all other frames must be equal to avctx->frame_size. If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame can have any number of samples. If neither is set, frame->nb_samples must be equal to avctx->frame_size for all frames. |
[out] | got_packet_ptr | This field is set to 1 by libavcodec if the output packet is non-empty, and to 0 if it is empty. If the function returns an error, the packet can be assumed to be invalid, and the value of got_packet_ptr is undefined and should not be used. |
Definition at line 865 of file utils.c.
Referenced by encode_audio_frame().
int avcodec_encode_subtitle | ( | AVCodecContext * | avctx, | |
uint8_t * | buf, | |||
int | buf_size, | |||
const AVSubtitle * | sub | |||
) |
Definition at line 1077 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.
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 |
Definition at line 1058 of file utils.c.
Referenced by do_video_out(), estimate_best_b_count(), flush_encoders(), output_packet(), video_encode_example(), and write_video_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 audio frame data and linesize.
AVFrame extended_data channel pointers are allocated if necessary for planar audio.
frame | the 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_channels | channel count | |
sample_fmt | sample format | |
buf | buffer to use for frame data | |
buf_size | size of buffer | |
align | plane size sample alignment |
Definition at line 253 of file utils.c.
Referenced by audio_get_buffer(), avcodec_encode_audio(), and encode_audio_frame().
Find a registered decoder with a matching codec ID.
id | CodecID of the requested decoder |
Definition at line 1354 of file utils.c.
Referenced by assert_codec_experimental(), audio_decode_example(), av_find_best_stream(), avcodec_string(), avformat_find_stream_info(), choose_decoder(), filter_codec_opts(), movie_init(), open_input_file(), sdp_parse_rtpmap(), stream_component_open(), transcode(), try_decode_frame(), and video_decode_example().
AVCodec* avcodec_find_decoder_by_name | ( | const char * | name | ) |
Find a registered decoder with the specified name.
name | name of the requested decoder |
Definition at line 1366 of file utils.c.
Referenced by find_codec_or_die(), opt_input_file(), and v4l2_read_header().
Find a registered encoder with a matching codec ID.
id | CodecID of the requested encoder |
Definition at line 1324 of file utils.c.
Referenced by asf_write_header1(), assert_codec_experimental(), audio_encode_example(), avcodec_string(), avserver_opt_preset(), choose_encoder(), compute_status(), estimate_best_b_count(), filter_codec_opts(), list_formats(), new_audio_stream(), new_subtitle_stream(), new_video_stream(), open_audio(), open_video(), read_avserver_streams(), transcode(), transcode_init(), and video_encode_example().
AVCodec* avcodec_find_encoder_by_name | ( | const char * | name | ) |
Find a registered encoder with the specified name.
name | name of the requested encoder |
Definition at line 1340 of file utils.c.
Referenced by find_codec_or_die(), new_audio_stream(), new_subtitle_stream(), new_video_stream(), 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 1563 of file utils.c.
Referenced by audio_decode_frame(), get_video_frame(), and subtitle_thread().
unsigned avcodec_get_edge_width | ( | void | ) |
void avcodec_get_frame_defaults | ( | AVFrame * | pic | ) |
Set the fields of the given AVFrame to default values.
pic | The AVFrame of which the fields should be set to default values. |
Definition at line 609 of file utils.c.
Referenced by a64multi_init_encoder(), aac_decode_init(), ac3_decode_init(), adpcm_decode_init(), adx_decode_init(), alac_decode_init(), amr_nb_decode_init(), amr_wb_decode_init(), amrnb_decode_init(), amrwb_decode_init(), ape_decode_init(), atrac1_decode_init(), atrac3_decode_init(), audio_decode_example(), audio_decode_frame(), avcodec_alloc_frame(), avcodec_encode_audio(), bmp_decode_init(), bmp_encode_init(), bmv_aud_decode_init(), cdg_init_frame(), cinaudio_decode_init(), cook_decode_init(), dca_decode_init(), decode_init(), dpcm_decode_init(), eightsvx_decode_init(), encode_audio_frame(), encode_init(), estimate_best_b_count(), ff_pnm_init(), flac_decode_init(), frame_worker_thread(), g722_decode_init(), g726_decode_init(), gif_decode_init(), gsm_init(), imc_decode_init(), libgsm_decode_init(), libspeex_decode_init(), mace_decode_init(), mlp_decode_init(), mpc7_decode_init(), mpc8_decode_init(), MPV_common_init(), output_packet(), 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(), ra144_decode_init(), ra288_decode_init(), s302m_decode_init(), sgi_init(), shorten_decode_init(), sipr_decoder_init(), smka_decode_init(), sunrast_init(), targa_encode_init(), targa_init(), tiff_init(), transcode(), transcode_audio(), transcode_init(), transcode_video(), truespeech_decode_init(), try_decode_frame(), tta_decode_init(), twin_decode_init(), txd_init(), vmdaudio_decode_init(), vorbis_decode_init(), wavpack_decode_init(), wma_decode_init(), wmavoice_decode_init(), and ws_snd_decode_init().
enum AVMediaType avcodec_get_type | ( | enum CodecID | codec_id | ) |
Get the type of the given codec.
Definition at line 1845 of file utils.c.
Referenced by mkv_query_codec().
void avcodec_init | ( | void | ) |
Definition at line 94 of file utils.c.
Referenced by avcodec_register(), and main().
int avcodec_is_open | ( | AVCodecContext * | s | ) |
Definition at line 1859 of file utils.c.
Referenced by avcodec_close(), avcodec_copy_context(), avcodec_open2(), and try_decode_frame().
const char* avcodec_license | ( | void | ) |
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.
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);
avctx | The context which will be set up to use the given codec. | |
codec | The codec to use within the context. |
Definition at line 629 of file utils.c.
Referenced by audio_decode_example(), audio_encode_example(), open_audio(), open_video(), 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.
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);
avctx | The context to initialize. | |
codec | The codec to open this context for. If a non-NULL codec has been previously passed to avcodec_alloc_context3() or avcodec_get_context_defaults3() for this context, then this parameter MUST be either NULL or equal to the previously passed codec. | |
options | A dictionary filled with AVCodecContext and codec-private options. On return this object will be filled with options that were not found. |
Definition at line 635 of file utils.c.
Referenced by avcodec_open(), avformat_find_stream_info(), estimate_best_b_count(), init_input_stream(), movie_init(), open_input_file(), stream_component_open(), transcode(), transcode_init(), and try_decode_frame().
void avcodec_register | ( | AVCodec * | codec | ) |
Register the codec codec and initialize libavcodec.
void avcodec_set_dimensions | ( | AVCodecContext * | s, | |
int | width, | |||
int | height | |||
) |
Definition at line 133 of file utils.c.
Referenced by apply_param_change(), av_mpeg4_decode_header(), avcodec_open2(), avpriv_dirac_parse_sequence_header(), avs_decode_init(), cmv_process_header(), decode_frame(), decode_frame_headers(), decode_init(), decode_slice_header(), dnxhd_decode_frame(), dvvideo_decode_frame(), execute_code(), ff_h263_decode_frame(), ff_ivi_decode_frame(), ff_mjpeg_decode_sof(), ff_rv34_decode_frame(), ff_vp56_decode_frame(), gif_decode_frame(), h261_decode_frame(), init_image(), libopenjpeg_decode_frame(), mpeg_decode_postinit(), mpegvideo_extract_headers(), parse_presentation_segment(), pcx_decode_frame(), ptx_decode_frame(), rv20_decode_picture_header(), sunrast_decode_frame(), svq1_decode_frame(), tgq_decode_frame(), tgv_decode_frame(), theora_decode_header(), theora_header(), tqi_decode_frame(), truemotion1_decode_header(), txd_decode_frame(), update_dimensions(), vp56_size_changed(), vp5_parse_header(), vp6_parse_header(), and vp8_decode().
void avcodec_string | ( | char * | buf, | |
int | buf_size, | |||
AVCodecContext * | enc, | |||
int | encode | |||
) |
Definition at line 1418 of file utils.c.
Referenced by avformat_find_stream_info(), and dump_stream_format().
int avcodec_thread_init | ( | AVCodecContext * | s, | |
int | thread_count | |||
) |
unsigned avcodec_version | ( | void | ) |
int avpriv_lock_avformat | ( | void | ) |
Definition at line 1784 of file utils.c.
Referenced by ff_tls_deinit(), and ff_tls_init().
unsigned int avpriv_toupper4 | ( | unsigned int | x | ) |
Definition at line 1802 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 1793 of file utils.c.
Referenced by ff_tls_deinit(), and ff_tls_init().
void avsubtitle_free | ( | AVSubtitle * | sub | ) |
Free all allocated data in the given subtitle struct.
sub | AVSubtitle to free. |
Definition at line 1262 of file utils.c.
Referenced by free_subpicture(), output_packet(), and transcode_subtitles().
static av_always_inline int codec_is_decoder | ( | AVCodec * | codec | ) | [static] |
Definition at line 110 of file utils.c.
Referenced by avcodec_find_decoder(), avcodec_find_decoder_by_name(), and avcodec_open2().
static av_always_inline int codec_is_encoder | ( | AVCodec * | codec | ) | [static] |
Definition at line 105 of file utils.c.
Referenced by avcodec_close(), avcodec_find_encoder(), avcodec_find_encoder_by_name(), and avcodec_open2().
int ff_alloc_packet | ( | AVPacket * | avpkt, | |
int | size | |||
) |
Check AVPacket size and/or allocate data.
Encoders supporting AVCodec.encode2() can use this as a convenience to ensure the output packet data is large enough, whether provided by the user or allocated in this function.
avpkt | the AVPacket If avpkt->data is already set, avpkt->size is checked to ensure it is large enough. If avpkt->data is NULL, a new buffer is allocated. All other AVPacket fields will be reset with av_init_packet(). | |
size | the minimum required packet size |
Definition at line 842 of file utils.c.
Referenced by pcm_encode_frame().
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.
codec_id | the codec to match | |
pix_fmt | the pixel format to match |
Definition at line 1752 of file utils.c.
Referenced by decode_slice_header(), ff_h263_decode_init(), vc1_decode_init(), and vcr2_init_sequence().
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 1705 of file utils.c.
Referenced by ff_h263_encode_picture_header(), MPV_encode_init(), and svq1_write_header().
static int get_bit_rate | ( | AVCodecContext * | ctx | ) | [static] |
Definition at line 1380 of file utils.c.
Referenced by avcodec_string().
static void video_free_buffers | ( | AVCodecContext * | s | ) | [static] |
Definition at line 1571 of file utils.c.
Referenced by avcodec_default_free_buffers().
static int video_get_buffer | ( | AVCodecContext * | s, | |
AVFrame * | pic | |||
) | [static] |
Definition at line 369 of file utils.c.
Referenced by avcodec_default_get_buffer().
void* avformat_mutex [static] |
Definition at line 53 of file utils.c.
Referenced by av_lockmgr_register(), avpriv_lock_avformat(), and avpriv_unlock_avformat().
void* codec_mutex [static] |
Definition at line 52 of file utils.c.
Referenced by av_lockmgr_register(), avcodec_close(), and avcodec_open2().
int volatile entangled_thread_counter = 0 [static] |
Definition at line 50 of file utils.c.
Referenced by avcodec_close(), and avcodec_open2().
int(* ff_lockmgr_cb)(void **mutex, enum AVLockOp op) [static] |
Definition at line 51 of file utils.c.
Referenced by av_lockmgr_register(), avcodec_close(), avcodec_open2(), avpriv_lock_avformat(), and avpriv_unlock_avformat().
AVCodec* first_avcodec = NULL [static] |
AVHWAccel* first_hwaccel = NULL [static] |