FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
utils.c File Reference

utils. More...

#include "config.h"
#include "libavutil/atomic.h"
#include "libavutil/attributes.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/dict.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "libavutil/opt.h"
#include "me_cmp.h"
#include "mpegvideo.h"
#include "thread.h"
#include "frame_thread_encoder.h"
#include "internal.h"
#include "raw.h"
#include "bytestream.h"
#include "version.h"
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include <float.h>
#include "libavutil/ffversion.h"

Go to the source code of this file.

Macros

#define UTF8_MAX_BYTES   4 /* 5 and 6 bytes sequences should not be used */
 
#define TAG_PRINT(x)
 
#define LICENSE_PREFIX   "libavcodec license: "
 

Functions

void av_fast_padded_malloc (void *ptr, unsigned int *size, size_t min_size)
 Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. More...
 
void av_fast_padded_mallocz (void *ptr, unsigned int *size, size_t min_size)
 Same behaviour av_fast_padded_malloc except that buffer will always be 0-initialized after call. More...
 
AVCodecav_codec_next (const 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. More...
 
static av_cold void avcodec_init (void)
 
int av_codec_is_encoder (const AVCodec *codec)
 
int av_codec_is_decoder (const AVCodec *codec)
 
av_cold void avcodec_register (AVCodec *codec)
 Register the codec codec and initialize libavcodec. More...
 
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. More...
 
void avcodec_set_dimensions (AVCodecContext *s, int width, int height)
 
int ff_set_dimensions (AVCodecContext *s, int width, int height)
 Check that the provided frame dimensions are valid and set them on the codec context. More...
 
int ff_set_sar (AVCodecContext *avctx, AVRational sar)
 Check that the provided sample aspect ratio is valid and set it on the codec context. More...
 
int ff_side_data_update_matrix_encoding (AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
 Add or update AV_FRAME_DATA_MATRIXENCODING side data. More...
 
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]. More...
 
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. More...
 
int avcodec_enum_to_chroma_pos (int *xpos, int *ypos, enum AVChromaLocation pos)
 Converts AVChromaLocation to swscale x/y chroma position. More...
 
enum AVChromaLocation avcodec_chroma_pos_to_enum (int xpos, int ypos)
 Converts swscale x/y chroma position to AVChromaLocation. More...
 
int avcodec_fill_audio_frame (AVFrame *frame, int nb_channels, enum AVSampleFormat sample_fmt, const uint8_t *buf, int buf_size, int align)
 Fill AVFrame audio data and linesize pointers. More...
 
static int update_frame_pool (AVCodecContext *avctx, AVFrame *frame)
 
static int audio_get_buffer (AVCodecContext *avctx, AVFrame *frame)
 
static int video_get_buffer (AVCodecContext *s, AVFrame *pic)
 
void ff_color_frame (AVFrame *frame, const int c[4])
 
int avcodec_default_get_buffer2 (AVCodecContext *avctx, AVFrame *frame, int flags)
 The default callback for AVCodecContext.get_buffer2(). More...
 
static int add_metadata_from_side_data (const AVPacket *avpkt, AVFrame *frame)
 
int ff_init_buffer_info (AVCodecContext *avctx, AVFrame *frame)
 does needed setup of pkt_pts/pos and such for (re)get_buffer(); More...
 
int ff_decode_frame_props (AVCodecContext *avctx, AVFrame *frame)
 Set various frame properties from the codec context / packet data. More...
 
static void validate_avframe_allocation (AVCodecContext *avctx, AVFrame *frame)
 
static int get_buffer_internal (AVCodecContext *avctx, AVFrame *frame, int flags)
 
int ff_get_buffer (AVCodecContext *avctx, AVFrame *frame, int flags)
 Get a buffer for a frame. More...
 
static int reget_buffer_internal (AVCodecContext *avctx, AVFrame *frame)
 
int ff_reget_buffer (AVCodecContext *avctx, AVFrame *frame)
 Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buffer when needed. 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 jobnr, int threadnr), void *arg, int *ret, int count)
 
enum AVPixelFormat avpriv_find_pix_fmt (const PixelFormatTag *tags, unsigned int fourcc)
 
static int is_hwaccel_pix_fmt (enum AVPixelFormat pix_fmt)
 
enum AVPixelFormat avcodec_default_get_format (struct AVCodecContext *s, const enum AVPixelFormat *fmt)
 
static AVHWAccelfind_hwaccel (enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
 
static int setup_hwaccel (AVCodecContext *avctx, const enum AVPixelFormat fmt, const char *name)
 
int ff_get_format (AVCodecContext *avctx, const enum AVPixelFormat *fmt)
 Select the (possibly hardware accelerated) pixel format. More...
 
unsigned av_codec_get_codec_properties (const AVCodecContext *codec)
 
int av_codec_get_max_lowres (const AVCodec *codec)
 
int avpriv_codec_get_cap_skip_frame_fill_param (const AVCodec *codec)
 
static void get_subtitle_defaults (AVSubtitle *sub)
 
static int64_t get_bit_rate (AVCodecContext *ctx)
 
int attribute_align_arg ff_codec_open2_recursive (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
 Call avcodec_open2 recursively by decrementing counter, unlocking mutex, calling the function and then restoring again. More...
 
int attribute_align_arg avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
 Initialize the AVCodecContext to use the given AVCodec. More...
 
int ff_alloc_packet2 (AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
 Check AVPacket size and/or allocate data. More...
 
int ff_alloc_packet (AVPacket *avpkt, int size)
 
static int pad_last_frame (AVCodecContext *s, AVFrame **dst, const AVFrame *src)
 Pad last frame with silence. More...
 
int attribute_align_arg avcodec_encode_audio2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 Encode a frame of audio. More...
 
int attribute_align_arg avcodec_encode_video2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 Encode a frame of video. More...
 
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. More...
 
static int apply_param_change (AVCodecContext *avctx, const AVPacket *avpkt)
 
static int unrefcount_frame (AVCodecInternal *avci, AVFrame *frame)
 
int attribute_align_arg avcodec_decode_video2 (AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
 Decode the video frame of size avpkt->size from avpkt->data into picture. More...
 
int attribute_align_arg avcodec_decode_audio4 (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, const AVPacket *avpkt)
 Decode the audio frame of size avpkt->size from avpkt->data into frame. More...
 
static int recode_subtitle (AVCodecContext *avctx, AVPacket *outpkt, const AVPacket *inpkt)
 
static int utf8_check (const uint8_t *str)
 
static void insert_ts (AVBPrint *buf, int ts)
 
static int convert_sub_to_old_ass_form (AVSubtitle *sub, const AVPacket *pkt, AVRational tb)
 
int avcodec_decode_subtitle2 (AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
 Decode a subtitle message. More...
 
void avsubtitle_free (AVSubtitle *sub)
 Free all allocated data in the given subtitle struct. More...
 
static int do_decode (AVCodecContext *avctx, AVPacket *pkt)
 
int attribute_align_arg avcodec_send_packet (AVCodecContext *avctx, const AVPacket *avpkt)
 Supply raw packet data as input to a decoder. More...
 
int attribute_align_arg avcodec_receive_frame (AVCodecContext *avctx, AVFrame *frame)
 Return decoded output data from a decoder. More...
 
static int do_encode (AVCodecContext *avctx, const AVFrame *frame, int *got_packet)
 
int attribute_align_arg avcodec_send_frame (AVCodecContext *avctx, const AVFrame *frame)
 Supply a raw video or audio frame to the encoder. More...
 
int attribute_align_arg avcodec_receive_packet (AVCodecContext *avctx, AVPacket *avpkt)
 Read encoded data from the encoder. More...
 
av_cold int avcodec_close (AVCodecContext *avctx)
 Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext itself). More...
 
static enum AVCodecID remap_deprecated_codec_id (enum AVCodecID id)
 
static AVCodecfind_encdec (enum AVCodecID id, int encoder)
 
AVCodecavcodec_find_encoder (enum AVCodecID id)
 Find a registered encoder with a matching codec ID. More...
 
AVCodecavcodec_find_encoder_by_name (const char *name)
 Find a registered encoder with the specified name. More...
 
AVCodecavcodec_find_decoder (enum AVCodecID id)
 Find a registered decoder with a matching codec ID. More...
 
AVCodecavcodec_find_decoder_by_name (const char *name)
 Find a registered decoder with the specified name. More...
 
const char * avcodec_get_name (enum AVCodecID id)
 Get the name of a codec. More...
 
size_t av_get_codec_tag_string (char *buf, size_t buf_size, unsigned int codec_tag)
 Put a string representing the codec tag codec_tag in buf. More...
 
void avcodec_string (char *buf, int buf_size, AVCodecContext *enc, int encode)
 
const char * av_get_profile_name (const AVCodec *codec, int profile)
 Return a name for the specified profile, if available. More...
 
const char * avcodec_profile_name (enum AVCodecID codec_id, int profile)
 Return a name for the specified profile, if available. More...
 
unsigned avcodec_version (void)
 Return the LIBAVCODEC_VERSION_INT constant. More...
 
const char * avcodec_configuration (void)
 Return the libavcodec build-time configuration. More...
 
const char * avcodec_license (void)
 Return the libavcodec license. More...
 
void avcodec_flush_buffers (AVCodecContext *avctx)
 Reset the internal decoder state / flush internal buffers. More...
 
int av_get_exact_bits_per_sample (enum AVCodecID codec_id)
 Return codec bits per sample. More...
 
enum AVCodecID av_get_pcm_codec (enum AVSampleFormat fmt, int be)
 Return the PCM codec associated with a sample format. More...
 
int av_get_bits_per_sample (enum AVCodecID codec_id)
 Return codec bits per sample. More...
 
static int get_audio_frame_duration (enum AVCodecID id, int sr, int ch, int ba, uint32_t tag, int bits_per_coded_sample, int64_t bitrate, uint8_t *extradata, int frame_size, int frame_bytes)
 
int av_get_audio_frame_duration (AVCodecContext *avctx, int frame_bytes)
 Return audio frame duration. More...
 
int av_get_audio_frame_duration2 (AVCodecParameters *par, int frame_bytes)
 This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters instead of an AVCodecContext. More...
 
int ff_thread_init (AVCodecContext *s)
 
unsigned int av_xiphlacing (unsigned char *s, unsigned int v)
 Encode extradata length to a buffer. More...
 
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. More...
 
FF_DISABLE_DEPRECATION_WARNINGS
void 
av_log_missing_feature (void *avc, const char *feature, int want_sample)
 Log a generic warning message about a missing feature. More...
 
void av_log_ask_for_sample (void *avc, const char *msg,...)
 
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...
 
int ff_lock_avcodec (AVCodecContext *log_ctx, const AVCodec *codec)
 
int ff_unlock_avcodec (const AVCodec *codec)
 
int avpriv_lock_avformat (void)
 
int avpriv_unlock_avformat (void)
 
unsigned int avpriv_toupper4 (unsigned int x)
 
int ff_thread_ref_frame (ThreadFrame *dst, ThreadFrame *src)
 
enum AVPixelFormat ff_thread_get_format (AVCodecContext *avctx, const enum AVPixelFormat *fmt)
 Wrapper around get_format() for frame-multithreaded codecs. More...
 
int ff_thread_get_buffer (AVCodecContext *avctx, ThreadFrame *f, int flags)
 Wrapper around get_buffer() for frame-multithreaded codecs. More...
 
void ff_thread_release_buffer (AVCodecContext *avctx, ThreadFrame *f)
 Wrapper around release_buffer() frame-for multithreaded codecs. More...
 
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. More...
 
void ff_thread_report_progress (ThreadFrame *f, int progress, int field)
 Notify later decoding threads when part of their reference picture is ready. More...
 
void ff_thread_await_progress (ThreadFrame *f, int progress, int field)
 Wait for earlier decoding threads to finish reference pictures. More...
 
int ff_thread_can_start_frame (AVCodecContext *avctx)
 
int ff_alloc_entries (AVCodecContext *avctx, int count)
 
void ff_reset_entries (AVCodecContext *avctx)
 
void ff_thread_await_progress2 (AVCodecContext *avctx, int field, int thread, int shift)
 
void ff_thread_report_progress2 (AVCodecContext *avctx, int field, int thread, int n)
 
int avcodec_is_open (AVCodecContext *s)
 
int avpriv_bprint_to_extradata (AVCodecContext *avctx, struct AVBPrint *buf)
 Finalize buf into extradata and set its size appropriately. More...
 
const uint8_tavpriv_find_start_code (const uint8_t *av_restrict p, const uint8_t *end, uint32_t *av_restrict state)
 
AVCPBPropertiesav_cpb_properties_alloc (size_t *size)
 Allocate a CPB properties structure and initialize its fields to default values. More...
 
AVCPBPropertiesff_add_cpb_side_data (AVCodecContext *avctx)
 Add a CPB properties side data to an encoding context. More...
 
static void codec_parameters_reset (AVCodecParameters *par)
 
AVCodecParametersavcodec_parameters_alloc (void)
 Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0). More...
 
void avcodec_parameters_free (AVCodecParameters **ppar)
 Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied pointer. More...
 
int avcodec_parameters_copy (AVCodecParameters *dst, const AVCodecParameters *src)
 Copy the contents of src to dst. More...
 
int avcodec_parameters_from_context (AVCodecParameters *par, const AVCodecContext *codec)
 Fill the parameters struct based on the values from the supplied codec context. More...
 
int avcodec_parameters_to_context (AVCodecContext *codec, const AVCodecParameters *par)
 Fill the codec context based on the values from the supplied codec parameters. More...
 
int ff_alloc_a53_sei (const AVFrame *frame, size_t prefix_len, void **data, size_t *sei_size)
 Check AVFrame for A53 side data and allocate and fill SEI message with A53 info. More...
 
int64_t ff_guess_coded_bitrate (AVCodecContext *avctx)
 Get an estimated video bitrate based on frame size, frame rate and coded bits per pixel. More...
 

Variables

const char av_codec_ffversion [] = "FFmpeg version " FFMPEG_VERSION
 
static int(* lockmgr_cb )(void **mutex, enum AVLockOp op) = NULL
 
volatile int ff_avcodec_locked
 
static int volatile entangled_thread_counter = 0
 
static voidcodec_mutex
 
static voidavformat_mutex
 
static AVCodecfirst_avcodec = NULL
 
static AVCodec ** last_avcodec = &first_avcodec
 
static
FF_ENABLE_DEPRECATION_WARNINGS
AVHWAccel
first_hwaccel = NULL
 
static AVHWAccel ** last_hwaccel = &first_hwaccel
 

Detailed Description

utils.

Definition in file utils.c.

Macro Definition Documentation

#define UTF8_MAX_BYTES   4 /* 5 and 6 bytes sequences should not be used */

Definition at line 2518 of file utils.c.

Referenced by recode_subtitle().

#define TAG_PRINT (   x)
Value:
(((x) >= '0' && (x) <= '9') || \
((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))

Referenced by av_get_codec_tag_string().

#define LICENSE_PREFIX   "libavcodec license: "

Referenced by avcodec_license().

Function Documentation

static av_cold void avcodec_init ( void  )
static

Definition at line 156 of file utils.c.

Referenced by avcodec_register().

int ff_set_dimensions ( AVCodecContext s,
int  width,
int  height 
)

Check that the provided frame dimensions are valid and set them on the codec context.

Definition at line 210 of file utils.c.

Referenced by alloc_buffers(), apply_param_change(), avcodec_open2(), avcodec_set_dimensions(), avs_decode_init(), bmp_decode_frame(), cdxl_decode_frame(), cfhd_decode(), cmv_process_header(), decode_frame(), decode_frame_headers(), decode_header(), decode_idat_chunk(), decode_init(), decode_seq_header(), dirac_decode_data_unit(), dnxhd_decode_frame(), dvdsub_parse_extradata(), dvvideo_decode_frame(), execute_code(), ff_h263_decode_frame(), ff_ivi_decode_frame(), ff_mjpeg_decode_sof(), ff_pnm_decode_header(), ff_rv34_decode_frame(), ff_vc1_decode_entry_point(), ff_vc1_decode_sequence_header(), ff_vp56_decode_frame(), ffmal_update_format(), flashsv_decode_frame(), g2m_decode_frame(), get_siz(), gif_decode_frame(), h261_decode_frame(), init_image(), libopenjpeg_decode_frame(), magy_decode_frame(), mediacodec_dec_parse_format(), mimic_decode_frame(), mpeg4_decode_header(), mpegvideo_extract_headers(), mvc_decode_init(), parse_presentation_segment(), pcx_decode_frame(), pix_decode_frame(), pixlet_decode_frame(), process_frame_obj(), ptx_decode_frame(), rv20_decode_picture_header(), seqvideo_decode_init(), smvjpeg_decode_frame(), sunrast_decode_frame(), svc_decode_frame(), svq1_decode_frame(), tdsc_parse_tdsf(), tgq_decode_frame(), tgv_decode_frame(), tqi_decode_frame(), truemotion1_decode_header(), truemotion2rt_decode_header(), txd_decode_frame(), update_dimensions(), update_size(), vp56_size_changed(), vp5_parse_header(), vp6_parse_header(), vp8_lossless_decode_frame(), vpx_decode(), xbm_decode_frame(), and xpm_decode_frame().

int ff_set_sar ( AVCodecContext avctx,
AVRational  sar 
)

Check that the provided sample aspect ratio is valid and set it on the codec context.

Definition at line 225 of file utils.c.

Referenced by decode_frame(), decode_header(), decode_sequence_header_adv(), dirac_decode_data_unit(), dvvideo_decode_frame(), export_stream_params(), ff_h263_decode_frame(), h264_slice_header_init(), and truemotion1_decode_header().

int ff_side_data_update_matrix_encoding ( AVFrame frame,
enum AVMatrixEncoding  matrix_encoding 
)

Add or update AV_FRAME_DATA_MATRIXENCODING side data.

Definition at line 240 of file utils.c.

Referenced by ac3_decode_frame(), ff_dca_core_filter_frame(), ff_dca_lbr_filter_frame(), ff_dca_xll_filter_frame(), and output_data().

static int update_frame_pool ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 511 of file utils.c.

Referenced by avcodec_default_get_buffer2().

static int audio_get_buffer ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 613 of file utils.c.

Referenced by avcodec_default_get_buffer2().

static int video_get_buffer ( AVCodecContext s,
AVFrame pic 
)
static

Definition at line 658 of file utils.c.

Referenced by avcodec_default_get_buffer2().

void ff_color_frame ( AVFrame frame,
const int  c[4] 
)

Definition at line 705 of file utils.c.

Referenced by h264_frame_start().

static int add_metadata_from_side_data ( const AVPacket avpkt,
AVFrame frame 
)
static

Definition at line 748 of file utils.c.

Referenced by ff_init_buffer_info().

int ff_init_buffer_info ( AVCodecContext avctx,
AVFrame frame 
)

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

Definition at line 760 of file utils.c.

Referenced by ff_decode_frame_props(), reget_buffer_internal(), and thread_get_buffer_internal().

int ff_decode_frame_props ( AVCodecContext avctx,
AVFrame frame 
)

Set various frame properties from the codec context / packet data.

Definition at line 876 of file utils.c.

Referenced by cuvid_output_frame(), ffmal_copy_frame(), get_buffer_internal(), raw_decode(), and reget_buffer_internal().

static void validate_avframe_allocation ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 881 of file utils.c.

Referenced by get_buffer_internal().

static int get_buffer_internal ( AVCodecContext avctx,
AVFrame frame,
int  flags 
)
static

Definition at line 905 of file utils.c.

Referenced by ff_get_buffer().

int ff_get_buffer ( AVCodecContext avctx,
AVFrame frame,
int  flags 
)

Get a buffer for a frame.

This is a wrapper around AVCodecContext.get_buffer() and should be used instead calling get_buffer() directly.

Definition at line 953 of file utils.c.

Referenced by ac3_decode_frame(), adpcm_decode_frame(), adx_decode_frame(), alloc_frame(), amrnb_decode_frame(), amrwb_decode_frame(), ape_decode_frame(), atrac1_decode_frame(), atrac3_decode_frame(), atrac3al_decode_frame(), atrac3p_decode_frame(), aura_decode_frame(), avui_decode_frame(), bfi_decode_frame(), bmp_decode_frame(), bmv_aud_decode_frame(), cdg_decode_frame(), cdxl_decode_frame(), cinaudio_decode_frame(), cllc_decode_frame(), cmv_decode_frame(), cng_decode_frame(), cook_decode_frame(), copy_frame(), copy_output(), cuvid_output_frame(), cyuv_decode_frame(), dds_decode(), decode_frame(), decode_pic(), decode_tag(), dfa_decode_frame(), dpcm_decode_frame(), dss_sp_decode_frame(), dvvideo_decode_frame(), dxtory_decode_v1_410(), dxtory_decode_v1_420(), dxtory_decode_v1_444(), dxtory_decode_v1_rgb(), dxtory_decode_v2(), eightsvx_decode_frame(), escape124_decode_frame(), escape130_decode_frame(), evrc_decode_frame(), execute_code(), fdk_aac_decode_frame(), ff_create_schro_frame(), ff_dca_lbr_filter_frame(), ff_dca_xll_filter_frame(), ff_ivi_decode_frame(), ff_mjpeg_decode_sof(), ff_snow_common_init_after_header(), ff_snow_get_buffer(), ff_thread_get_buffer(), ff_twinvq_decode_frame(), ff_vp56_decode_frame(), ffat_decode(), ffmal_copy_frame(), filter_frame_fixed(), filter_frame_float(), frame_configure_elements(), g2m_decode_frame(), g722_decode_frame(), g723_1_decode_frame(), get_buffer(), get_buffer_with_edge(), gif_decode_frame(), gsm_decode_frame(), hnm_decode_frame(), hq_decode_frame(), hqa_decode_frame(), hqx_decode_frame(), idcin_decode_frame(), ilbc_decode_frame(), imc_decode_frame(), ipvideo_decode_frame(), libcelt_dec_decode(), libgsm_decode_frame(), libopus_decode(), libschroedinger_decode_frame(), libspeex_decode_frame(), m101_decode_frame(), mace_decode_frame(), mediacodec_wrap_sw_buffer(), mp_decode_frame(), mpc7_decode_frame(), mpc8_decode_frame(), mss2_decode_frame(), mvc_decode_frame(), mxpeg_decode_frame(), oggvorbis_decode_frame(), on2avc_decode_frame(), opus_decode_packet(), output_data(), paf_audio_decode(), pcm_bluray_decode_frame(), pcm_decode_frame(), pcm_dvd_decode_frame(), pcx_decode_frame(), pix_decode_frame(), pnm_decode_frame(), ptx_decode_frame(), qcelp_decode_frame(), qdm2_decode_frame(), qdmc_decode_frame(), ra144_decode_frame(), ra288_decode_frame(), reget_buffer_internal(), rl2_decode_frame(), roq_encode_frame(), s302m_decode_frame(), sgirle_decode_frame(), shorten_decode_frame(), sipr_decode_frame(), smka_decode_frame(), speedhq_decode_frame(), submit_frame(), submit_packet(), sunrast_decode_frame(), svc_decode_frame(), svq1_decode_frame(), svq1_encode_frame(), synth_superframe(), tdsc_decode_frame(), tgq_decode_frame(), tgv_decode_frame(), thread_get_buffer_internal(), tmv_decode_frame(), tqi_decode_frame(), truemotion2rt_decode_frame(), truespeech_decode_frame(), txd_decode_frame(), v308_decode_frame(), v408_decode_frame(), v410_decode_frame(), vcr1_decode_frame(), vmdaudio_decode_frame(), vmdvideo_decode_frame(), vorbis_decode_frame(), vpx_decode(), vqa_decode_frame(), wavesynth_decode(), wma_decode_superframe(), wmapro_decode_packet(), ws_snd_decode_frame(), xan_decode_frame(), xbm_decode_frame(), xface_decode_frame(), xma_decode_init(), xma_decode_packet(), xpm_decode_frame(), xwd_decode_frame(), y216_decode_frame(), y41p_decode_frame(), yuv4_decode_frame(), zero12v_decode_frame(), and zerocodec_decode_frame().

static int reget_buffer_internal ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 963 of file utils.c.

Referenced by ff_reget_buffer().

int ff_reget_buffer ( AVCodecContext avctx,
AVFrame frame 
)
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 1023 of file utils.c.

enum AVPixelFormat avpriv_find_pix_fmt ( const PixelFormatTag tags,
unsigned int  fourcc 
)
static int is_hwaccel_pix_fmt ( enum AVPixelFormat  pix_fmt)
static

Definition at line 1047 of file utils.c.

Referenced by avcodec_default_get_format(), and ff_get_format().

static AVHWAccel* find_hwaccel ( enum AVCodecID  codec_id,
enum AVPixelFormat  pix_fmt 
)
static

Definition at line 1060 of file utils.c.

Referenced by setup_hwaccel().

static int setup_hwaccel ( AVCodecContext avctx,
const enum AVPixelFormat  fmt,
const char *  name 
)
static

Definition at line 1072 of file utils.c.

Referenced by ff_get_format().

int ff_get_format ( AVCodecContext avctx,
const enum AVPixelFormat fmt 
)

Select the (possibly hardware accelerated) pixel format.

This is a wrapper around AVCodecContext.get_format() and should be used instead of calling get_format() directly.

Definition at line 1112 of file utils.c.

Referenced by cuvid_decode_init(), decode_init(), ff_mediacodec_dec_init(), ff_qsv_process_data(), ff_thread_get_format(), ffmmal_init_decoder(), h263_get_format(), submit_packet(), and vc1_decode_init().

int avpriv_codec_get_cap_skip_frame_fill_param ( const AVCodec codec)

Definition at line 1197 of file utils.c.

Referenced by try_decode_frame(), and try_decode_video_frame().

static void get_subtitle_defaults ( AVSubtitle sub)
static

Definition at line 1201 of file utils.c.

Referenced by avcodec_decode_subtitle2().

static int64_t get_bit_rate ( AVCodecContext ctx)
static

Definition at line 1207 of file utils.c.

Referenced by avcodec_open2(), and avcodec_string().

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

Call avcodec_open2 recursively by decrementing counter, unlocking mutex, calling the function and then restoring again.

Assumes the mutex is already locked

Definition at line 1230 of file utils.c.

Referenced by init(), smvjpeg_decode_init(), and tdsc_init().

int ff_alloc_packet2 ( AVCodecContext avctx,
AVPacket avpkt,
int64_t  size,
int64_t  min_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.

Parameters
avctxthe AVCodecContext of the encoder
avpktthe 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. avpkt->size is set to the specified size. All other AVPacket fields will be reset with av_init_packet().
sizethe minimum required packet size
min_sizeThis is a hint to the allocation algorithm, which indicates to what minimal size the caller might later shrink the packet to. Encoders often allocate packets which are larger than the amount of data that is written into them as the exact amount is not known at the time of allocation. min_size represents the size a packet might be shrunk to by the caller. Can be set to 0. setting this roughly correctly allows the allocation code to choose between several allocation strategies to improve speed slightly.
Returns
non negative on success, negative error code on failure

Definition at line 1736 of file utils.c.

Referenced by a64multi_encode_frame(), aac_encode_frame(), adpcm_encode_frame(), adx_encode_frame(), alac_encode_frame(), amr_wb_encode_frame(), avui_encode_frame(), bmp_encode_frame(), cinepak_encode_frame(), cng_encode_frame(), dnxhd_encode_picture(), dvvideo_encode_frame(), encode_apng(), encode_frame(), encode_nals(), encode_picture_ls(), encode_png(), encode_superframe(), ff_alloc_packet(), ff_mpv_encode_picture(), ffat_encode(), flac_encode_frame(), flashsv2_encode_frame(), flashsv_encode_frame(), g722_encode_frame(), g723_1_encode_frame(), gif_encode_frame(), hap_encode(), ilbc_encode_frame(), libgsm_encode_frame(), libopenjpeg_encode_frame(), libopus_encode(), libschroedinger_encode_frame(), libshine_encode_frame(), libvorbis_encode_frame(), libwebp_anim_encode_frame(), libwebp_encode_frame(), ljpeg_encode_frame(), mlp_encode_frame(), mp3lame_encode_frame(), MPA_encode_frame(), omx_encode_frame(), opus_encode_frame(), pam_encode_frame(), pcm_encode_frame(), pcx_encode_frame(), pnm_encode_frame(), process_output_surface(), prores_encode_frame(), qtrle_encode_frame(), ra144_encode_frame(), raw_encode(), roq_dpcm_encode_frame(), roq_encode_frame(), s302m_encode2_frame(), storeframe(), sunrast_encode_frame(), svc_encode_frame(), svq1_encode_frame(), targa_encode_frame(), tta_encode_frame(), twolame_encode_frame(), utvideo_encode_frame(), v308_encode_frame(), v408_encode_frame(), v410_encode_frame(), vorbis_encode_frame(), vtenc_cm_to_avpacket(), wavpack_encode_frame(), XAVS_frame(), xbm_encode_frame(), xface_encode_frame(), xvid_encode_frame(), xwd_encode_frame(), y41p_encode_frame(), and yuv4_encode_frame().

int ff_alloc_packet ( AVPacket avpkt,
int  size 
)

Definition at line 1777 of file utils.c.

Referenced by libkvazaar_encode(), and libx265_encode_frame().

static int pad_last_frame ( AVCodecContext s,
AVFrame **  dst,
const AVFrame src 
)
static

Pad last frame with silence.

Definition at line 1785 of file utils.c.

Referenced by avcodec_encode_audio2().

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
ptsthe pts field of the decoded AVPacket, as passed through AVFrame.pts
dtsthe dts field of the decoded AVPacket
Returns
one of the input values, may be AV_NOPTS_VALUE

Definition at line 2077 of file utils.c.

Referenced by avcodec_decode_audio4(), avcodec_decode_video2(), and avcodec_receive_frame().

static int apply_param_change ( AVCodecContext avctx,
const AVPacket avpkt 
)
static

Definition at line 2103 of file utils.c.

Referenced by avcodec_decode_audio4(), avcodec_decode_video2(), and avcodec_send_packet().

static int unrefcount_frame ( AVCodecInternal avci,
AVFrame frame 
)
static

Definition at line 2181 of file utils.c.

Referenced by avcodec_decode_video2().

static int recode_subtitle ( AVCodecContext avctx,
AVPacket outpkt,
const AVPacket inpkt 
)
static

Definition at line 2519 of file utils.c.

Referenced by avcodec_decode_subtitle2().

static int utf8_check ( const uint8_t str)
static

Definition at line 2577 of file utils.c.

Referenced by avcodec_decode_subtitle2().

static void insert_ts ( AVBPrint *  buf,
int  ts 
)
static

Definition at line 2597 of file utils.c.

Referenced by convert_sub_to_old_ass_form().

static int convert_sub_to_old_ass_form ( AVSubtitle sub,
const AVPacket pkt,
AVRational  tb 
)
static

Definition at line 2611 of file utils.c.

Referenced by avcodec_decode_subtitle2().

static int do_decode ( AVCodecContext avctx,
AVPacket pkt 
)
static

Definition at line 2801 of file utils.c.

Referenced by avcodec_receive_frame(), and avcodec_send_packet().

static int do_encode ( AVCodecContext avctx,
const AVFrame frame,
int got_packet 
)
static

Definition at line 2970 of file utils.c.

Referenced by avcodec_receive_packet(), and avcodec_send_frame().

static enum AVCodecID remap_deprecated_codec_id ( enum AVCodecID  id)
static

Definition at line 3122 of file utils.c.

Referenced by find_encdec().

static AVCodec* find_encdec ( enum AVCodecID  id,
int  encoder 
)
static

Definition at line 3131 of file utils.c.

Referenced by avcodec_find_decoder(), and avcodec_find_encoder().

static int get_audio_frame_duration ( enum AVCodecID  id,
int  sr,
int  ch,
int  ba,
uint32_t  tag,
int  bits_per_coded_sample,
int64_t  bitrate,
uint8_t extradata,
int  frame_size,
int  frame_bytes 
)
static

Definition at line 3593 of file utils.c.

Referenced by av_get_audio_frame_duration(), and av_get_audio_frame_duration2().

int ff_thread_init ( AVCodecContext s)

Definition at line 3796 of file utils.c.

Referenced by avcodec_open2().

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

Referenced by ff_h263_encode_picture_header(), ff_mpv_encode_init(), and svq1_write_header().

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

Definition at line 3836 of file utils.c.

Referenced by av_log_missing_feature().

int ff_lock_avcodec ( AVCodecContext log_ctx,
const AVCodec codec 
)

Definition at line 3902 of file utils.c.

Referenced by avcodec_open2(), and ff_codec_open2_recursive().

int ff_unlock_avcodec ( const AVCodec codec)

Definition at line 3928 of file utils.c.

Referenced by avcodec_open2(), ff_codec_open2_recursive(), and ff_lock_avcodec().

int avpriv_lock_avformat ( void  )
int avpriv_unlock_avformat ( void  )
unsigned int avpriv_toupper4 ( unsigned int  x)
int ff_thread_ref_frame ( ThreadFrame dst,
ThreadFrame src 
)
enum AVPixelFormat ff_thread_get_format ( AVCodecContext avctx,
const enum AVPixelFormat fmt 
)

Wrapper around get_format() for frame-multithreaded codecs.

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

Parameters
avctxThe current context.
fmtThe list of available formats.

Definition at line 3994 of file utils.c.

int ff_thread_get_buffer ( AVCodecContext avctx,
ThreadFrame f,
int  flags 
)

Wrapper around get_buffer() for frame-multithreaded codecs.

Call this function instead of ff_get_buffer(f). Cannot be called after the codec has called ff_thread_finish_setup().

Parameters
avctxThe current context.
fThe frame to write into.

Definition at line 3999 of file utils.c.

void ff_thread_release_buffer ( AVCodecContext avctx,
ThreadFrame 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
avctxThe current context.
fThe picture being released.

Definition at line 4005 of file utils.c.

Referenced by ff_thread_ref_frame().

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
avctxThe context.

Definition at line 4011 of file utils.c.

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

Notify 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
fThe picture being decoded.
progressValue, in arbitrary units, of how much of the picture has decoded.
fieldThe field being decoded, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field.

Definition at line 4015 of file utils.c.

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

Wait 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
fThe picture being referenced.
progressValue, in arbitrary units, to wait for.
fieldThe field being referenced, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field.

Definition at line 4019 of file utils.c.

int ff_thread_can_start_frame ( AVCodecContext avctx)

Definition at line 4023 of file utils.c.

Referenced by ff_mpv_frame_start(), and h264_frame_start().

int ff_alloc_entries ( AVCodecContext avctx,
int  count 
)

Definition at line 4028 of file utils.c.

void ff_reset_entries ( AVCodecContext avctx)

Definition at line 4033 of file utils.c.

void ff_thread_await_progress2 ( AVCodecContext avctx,
int  field,
int  thread,
int  shift 
)

Definition at line 4037 of file utils.c.

void ff_thread_report_progress2 ( AVCodecContext avctx,
int  field,
int  thread,
int  n 
)

Definition at line 4041 of file utils.c.

int avpriv_bprint_to_extradata ( AVCodecContext avctx,
struct AVBPrint *  buf 
)

Finalize buf into extradata and set its size appropriately.

Definition at line 4052 of file utils.c.

Referenced by dvdsub_init().

const uint8_t* avpriv_find_start_code ( const uint8_t *av_restrict  p,
const uint8_t end,
uint32_t *av_restrict  state 
)

Definition at line 4075 of file utils.c.

AVCPBProperties* ff_add_cpb_side_data ( AVCodecContext avctx)

Add a CPB properties side data to an encoding context.

Definition at line 4122 of file utils.c.

Referenced by ff_mpv_encode_init(), nvenc_setup_encoder(), qsv_retrieve_enc_params(), svc_encode_init(), vpx_init(), and X264_init().

static void codec_parameters_reset ( AVCodecParameters par)
static
int ff_alloc_a53_sei ( const AVFrame frame,
size_t  prefix_len,
void **  data,
size_t *  sei_size 
)

Check AVFrame for A53 side data and allocate and fill SEI message with A53 info.

Parameters
frameRaw frame to get A53 side data from
prefix_lenNumber of bytes to allocate before SEI message
dataPointer to a variable to store allocated memory Upon return the variable will hold NULL on error or if frame has no A53 info. Otherwise it will point to prefix_len uninitialized bytes followed by *sei_size SEI message
sei_sizePointer to a variable to store generated SEI message length
Returns
Zero on success, negative error code on failure

'GA94' is standard in North America for ATSC, but hard coding this style may not be the right thing to do – other formats do exist. This information is not available in the side_data so we are going with this right now.

Definition at line 4321 of file utils.c.

Referenced by qsv_h264_set_encode_ctrl(), vtenc_send_frame(), and X264_frame().

int64_t ff_guess_coded_bitrate ( AVCodecContext avctx)

Get an estimated video bitrate based on frame size, frame rate and coded bits per pixel.

Definition at line 4364 of file utils.c.

Referenced by encode_init(), raw_encode_init(), v308_encode_init(), v408_encode_init(), v410_encode_init(), and y41p_encode_init().

Variable Documentation

const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION

Definition at line 65 of file utils.c.

int(* lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL
static
volatile int ff_avcodec_locked

Definition at line 115 of file utils.c.

Referenced by ff_lock_avcodec(), and ff_unlock_avcodec().

int volatile entangled_thread_counter = 0
static

Definition at line 116 of file utils.c.

Referenced by ff_lock_avcodec(), and ff_unlock_avcodec().

void* codec_mutex
static

Definition at line 117 of file utils.c.

Referenced by av_lockmgr_register(), ff_lock_avcodec(), and ff_unlock_avcodec().

void* avformat_mutex
static

Definition at line 118 of file utils.c.

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

AVCodec* first_avcodec = NULL
static
AVCodec** last_avcodec = &first_avcodec
static

Definition at line 146 of file utils.c.

Referenced by avcodec_register().

Definition at line 3853 of file utils.c.

Referenced by av_hwaccel_next().

AVHWAccel** last_hwaccel = &first_hwaccel
static

Definition at line 3854 of file utils.c.

Referenced by av_register_hwaccel().