Libav
Data Structures | Macros | Functions
internal.h File Reference

common internal api header. More...

#include <stdint.h>
#include "libavutil/buffer.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "config.h"

Go to the source code of this file.

Data Structures

struct  FramePool
 
struct  AVCodecInternal
 
struct  AVCodecDefault
 

Macros

#define FF_CODEC_CAP_INIT_THREADSAFE   (1 << 0)
 The codec does not modify any global variables in the init function, allowing to call the init function without locking any global mutexes. More...
 
#define FF_CODEC_CAP_INIT_CLEANUP   (1 << 1)
 The codec allows calling the close function for deallocation even if the init function returned a failure. More...
 
#define FF_CODEC_CAP_SETS_PKT_DTS   (1 << 2)
 Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually. More...
 
#define ff_dlog(ctx, ...)   do { } while (0)
 
#define ff_tlog(ctx, ...)   do { } while (0)
 
#define FF_SANE_NB_CHANNELS   63U
 
#define FF_SIGNBIT(x)   (x >> CHAR_BIT * sizeof(x) - 1)
 
#define FF_MAX_EXTRADATA_SIZE   ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
 Maximum size in bytes of extradata. More...
 

Functions

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...
 
unsigned int avpriv_toupper4 (unsigned int x)
 
int avpriv_lock_avformat (void)
 
int avpriv_unlock_avformat (void)
 
int ff_alloc_packet (AVPacket *avpkt, int size)
 Check AVPacket size and/or allocate data. More...
 
static av_always_inline int64_t ff_samples_to_time_base (AVCodecContext *avctx, int64_t samples)
 Rescale from sample rate to AVCodecContext.time_base. More...
 
int ff_get_buffer (AVCodecContext *avctx, AVFrame *frame, int flags)
 Get a buffer for a frame. More...
 
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...
 
const uint8_tavpriv_find_start_code (const uint8_t *restrict p, const uint8_t *end, uint32_t *restrict state)
 
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...
 
int ff_get_format (AVCodecContext *avctx, const enum AVPixelFormat *fmt)
 Select the (possibly hardware accelerated) pixel format. More...
 
int ff_decode_frame_props (AVCodecContext *avctx, AVFrame *frame)
 Set various frame properties from the codec context / packet data. More...
 
AVCPBPropertiesff_add_cpb_side_data (AVCodecContext *avctx)
 Add a CPB properties side data to an encoding context. More...
 

Detailed Description

common internal api header.

Definition in file internal.h.

Macro Definition Documentation

◆ FF_CODEC_CAP_INIT_THREADSAFE

#define FF_CODEC_CAP_INIT_THREADSAFE   (1 << 0)

The codec does not modify any global variables in the init function, allowing to call the init function without locking any global mutexes.

Definition at line 40 of file internal.h.

Referenced by avcodec_open2(), and encode_init().

◆ FF_CODEC_CAP_INIT_CLEANUP

#define FF_CODEC_CAP_INIT_CLEANUP   (1 << 1)

The codec allows calling the close function for deallocation even if the init function returned a failure.

Without this capability flag, a codec does such cleanup internally when returning failures from the init function and does not expect the close function to be called at all.

Definition at line 48 of file internal.h.

Referenced by avcodec_open2().

◆ FF_CODEC_CAP_SETS_PKT_DTS

#define FF_CODEC_CAP_SETS_PKT_DTS   (1 << 2)

Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.

If the flag is set, utils.c won't overwrite this field. If it's unset, utils.c tries to guess the pkt_dts field from the input AVPacket.

Definition at line 55 of file internal.h.

Referenced by avcodec_decode_video2().

◆ ff_dlog

#define ff_dlog (   ctx,
  ... 
)    do { } while (0)

Definition at line 60 of file internal.h.

Referenced by amr_decode_fix_avctx(), avpriv_mpegaudio_decode_header(), build_table(), compute_bit_allocation(), compute_scale_factors(), cook_decode_frame(), create_map(), dca_subframe_header(), decode(), decode_audio_specific_config(), decode_band(), decode_coeffs(), decode_dvd_subtitles(), decode_format80(), decode_frame(), decode_frame_headers(), decode_init(), decode_init_static(), decode_line(), decode_packet(), decode_pic_hdr(), decode_rle(), decode_slice(), decode_subframe(), decode_tilehdr(), dnxhd_decode_frame(), dnxhd_decode_header(), dprint_options(), dprint_specific_config(), dv_decode_ac(), dv_decode_video_segment(), dvbsub_decode(), dvbsub_parse(), dvbsub_parse_clut_segment(), dvbsub_parse_page_segment(), dvbsub_parse_pixel_data_block(), dvbsub_parse_region_segment(), dvdsub_decode(), encode_bitstream(), encode_line(), encode_picture(), encode_thread(), escape130_decode_frame(), ff_af_queue_close(), ff_combine_frame(), ff_estimate_b_frame_motion(), ff_h263_decode_picture_header(), ff_h264_decode_mb_cabac(), ff_init_vlc_sparse(), ff_jpegls_decode_lse(), ff_jpegls_decode_picture(), ff_jpegls_reset_coding_parameters(), ff_mjpeg_decode_sof(), ff_mjpeg_decode_sos(), ff_mpv_frame_start(), ff_msmpeg4_decode_block(), ff_msmpeg4_decode_picture_header(), ff_msmpeg4_encode_picture_header(), ff_rate_estimate_qscale(), ff_vbv_update(), ff_vc1_parse_frame_header(), ff_wma_init(), ff_wmv2_decode_mb(), find_marker(), flashsv_decode_frame(), flashsv_encode_frame(), flic_decode_frame_15_16BPP(), get_vlc_symbol(), gif_parse_next_image(), gif_read_extension(), gif_read_header1(), gif_read_image(), h261_decode_frame(), h263p_decode_umotion(), huffman_decode(), imc_get_coeffs(), init_pass2(), ipvideo_decode_block_opcode_0x2(), ipvideo_decode_block_opcode_0x3(), ipvideo_decode_block_opcode_0x4(), ipvideo_decode_block_opcode_0x5(), ipvideo_decode_block_opcode_0x6_16(), ipvideo_decode_opcodes(), ivi_decode_coded_blocks(), load_input_picture(), mjpeg_decode_scan(), modify_qscale(), mp3lame_encode_frame(), mp_decode_layer2(), mp_decode_layer3(), MPA_encode_init(), mpeg2_decode_block_intra(), mpeg_decode_frame(), mpeg_decode_mb(), mpeg_decode_picture_coding_extension(), mpeg_decode_postinit(), mpeg_decode_quant_matrix_extension(), mpeg_decode_sequence_extension(), mpeg_decode_slice(), mpegvideo_parse(), msmpeg4v2_decode_motion(), msmpeg4v34_decode_mb(), parse_palette_segment(), parse_presentation_segment(), pcm_bluray_decode_frame(), pcm_bluray_parse_header(), pcm_dvd_parse_header(), put_vlc_symbol(), read_header(), read_huffman_tree(), realloc_buffer(), rscc_decode_frame(), rv10_decode_frame(), rv10_decode_packet(), rv10_decode_picture_header(), set_channel_layout(), setup_classifs(), slice_decode_thread(), svq1_decode_block_intra(), svq1_decode_block_non_intra(), svq1_decode_delta_block(), svq1_decode_frame(), svq1_decode_frame_header(), vc1_decode_frame(), vorbis_decode_frame(), vorbis_floor0_decode(), vorbis_floor1_decode(), vorbis_parse_audio_packet(), vorbis_parse_id_hdr(), vorbis_parse_setup_hdr_codebooks(), vorbis_parse_setup_hdr_floors(), vorbis_parse_setup_hdr_mappings(), vorbis_parse_setup_hdr_modes(), vorbis_parse_setup_hdr_residues(), vorbis_parse_setup_hdr_tdtransforms(), vorbis_residue_decode_internal(), and wma_decode_superframe().

◆ ff_tlog

#define ff_tlog (   ctx,
  ... 
)    do { } while (0)

◆ FF_SANE_NB_CHANNELS

#define FF_SANE_NB_CHANNELS   63U

Definition at line 74 of file internal.h.

Referenced by avcodec_open2(), and ff_get_buffer().

◆ FF_SIGNBIT

#define FF_SIGNBIT (   x)    (x >> CHAR_BIT * sizeof(x) - 1)

Definition at line 76 of file internal.h.

Referenced by dnxhd_10bit_dct_quantize(), inter_predict(), mv_pred_direct(), and scale_mv().

◆ FF_MAX_EXTRADATA_SIZE

#define FF_MAX_EXTRADATA_SIZE   ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)

Maximum size in bytes of extradata.

This value was chosen such that every bit of the buffer is addressable by a 32-bit signed integer as used by get_bits.

Definition at line 179 of file internal.h.

Referenced by avcodec_open2(), and avformat_find_stream_info().

Function Documentation

◆ ff_match_2uint16()

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

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

◆ avpriv_toupper4()

unsigned int avpriv_toupper4 ( unsigned int  x)

Definition at line 2647 of file utils.c.

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

◆ avpriv_lock_avformat()

int avpriv_lock_avformat ( void  )

◆ avpriv_unlock_avformat()

int avpriv_unlock_avformat ( void  )

◆ ff_alloc_packet()

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.

Parameters
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
Returns
0 on success, negative error code on failure

Definition at line 1211 of file utils.c.

Referenced by a64multi_encode_frame(), aac_encode_frame(), adpcm_encode_frame(), adx_encode_frame(), alac_encode_frame(), amr_decode_fix_avctx(), amr_wb_encode_frame(), bmp_encode_frame(), cng_encode_frame(), dnxhd_encode_picture(), dvvideo_encode_frame(), encode_frame(), encode_nals(), encode_picture_ls(), encode_superframe(), Faac_encode_frame(), ff_mpv_encode_picture(), ffv1_encode_frame(), flac_encode_frame(), flashsv_encode_frame(), g722_encode_frame(), g723_1_encode_frame(), g726_reset(), gif_encode_frame(), hap_encode(), ilbc_encode_frame(), libgsm_encode_frame(), libkvazaar_encode(), libopenjpeg_encode_frame(), libopus_encode(), libschroedinger_encode_frame(), libvorbis_encode_frame(), libwebp_encode_frame(), libx265_encode_frame(), ljpeg_encode_frame(), mp3lame_encode_frame(), MPA_encode_frame(), nvenc_get_output(), omx_encode_frame(), pam_encode_frame(), pcm_encode_frame(), pcx_encode_frame(), pnm_encode_frame(), qtrle_encode_frame(), ra144_encode_frame(), raw_encode(), roq_dpcm_encode_frame(), roq_encode_frame(), storeframe(), sunrast_encode_frame(), svc_encode_frame(), targa_encode_frame(), twolame_encode_frame(), utvideo_encode_frame(), v410_encode_frame(), vorbis_encode_frame(), XAVS_frame(), xbm_encode_frame(), and xwd_encode_frame().

◆ ff_samples_to_time_base()

static av_always_inline int64_t ff_samples_to_time_base ( AVCodecContext avctx,
int64_t  samples 
)
static

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

Referenced by ac3_decode_frame(), adpcm_decode_frame(), adx_decode_frame(), alloc_frame(), amr_decode_fix_avctx(), amrnb_decode_frame(), amrwb_decode_frame(), ape_decode_frame(), atrac1_decode_frame(), atrac3_decode_frame(), atrac3p_decode_frame(), aura_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_output(), cyuv_decode_frame(), dca_decode_frame(), dcadec_decode_frame(), dds_decode(), decode_element(), 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(), execute_code(), fdk_aac_decode_frame(), ff_create_schro_frame(), ff_ivi_decode_frame(), ff_mjpeg_decode_sof(), ff_reget_buffer(), ff_samples_to_time_base(), ff_thread_get_buffer(), ff_twinvq_decode_frame(), ff_vp56_decode_frame(), ffmal_copy_frame(), ffv1_decode_frame(), flac_decode_frame(), flush(), frame_configure_elements(), g2m_decode_frame(), g722_decode_frame(), g723_1_decode_frame(), g726_reset(), get_buffer(), 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(), init_image(), ipvideo_decode_frame(), libgsm_decode_frame(), libopus_decode(), libschroedinger_decode_frame(), libspeex_decode_frame(), mace_decode_frame(), mp_decode_frame(), mpc7_decode_frame(), mpc8_decode_frame(), mss2_decode_frame(), mxpeg_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(), ra144_decode_frame(), ra288_decode_frame(), rl2_decode_frame(), roq_encode_frame(), s302m_decode_frame(), set_sps(), sgirle_decode_frame(), shorten_decode_frame(), sipr_decode_frame(), smka_decode_frame(), submit_frame(), submit_packet(), sunrast_decode_frame(), svc_decode_frame(), svq1_decode_frame(), svq1_encode_frame(), synth_superframe(), tak_decode_frame(), tdsc_decode_frame(), tgq_decode_frame(), tgv_decode_frame(), tmv_decode_frame(), tqi_decode_frame(), truemotion2rt_decode_frame(), truespeech_decode_frame(), tta_decode_frame(), txd_decode_frame(), v410_decode_frame(), vble_decode_frame(), vcr1_decode_frame(), vmdaudio_decode_frame(), vmdvideo_decode_frame(), vorbis_decode_frame(), vp8_decode(), vqa_decode_frame(), wavpack_decode_block(), wma_decode_superframe(), ws_snd_decode_frame(), xan_decode_frame(), xbm_decode_frame(), xwd_decode_frame(), yop_decode_frame(), and zerocodec_decode_frame().

◆ ff_reget_buffer()

int ff_reget_buffer ( AVCodecContext avctx,
AVFrame frame 
)

◆ avpriv_find_start_code()

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

◆ ff_set_dimensions()

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

◆ ff_set_sar()

int ff_set_sar ( AVCodecContext avctx,
AVRational  sar 
)

◆ ff_side_data_update_matrix_encoding()

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

Referenced by ac3_decode_frame(), dca_decode_frame(), ff_samples_to_time_base(), and output_data().

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

Referenced by decode_init(), ff_qsv_process_data(), ff_samples_to_time_base(), ffmmal_init_decoder(), get_format(), get_pixel_format(), h263_get_format(), mpeg_get_pixelformat(), and vc1_decode_init().

◆ ff_decode_frame_props()

int ff_decode_frame_props ( AVCodecContext avctx,
AVFrame frame 
)

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

Definition at line 534 of file utils.c.

Referenced by ff_get_buffer(), ff_reget_buffer(), ff_samples_to_time_base(), ffmal_copy_frame(), and raw_decode().

◆ ff_add_cpb_side_data()

AVCPBProperties* ff_add_cpb_side_data ( AVCodecContext avctx)

Add a CPB properties side data to an encoding context.

Definition at line 2754 of file utils.c.

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