FFmpeg
Classes | Macros | Typedefs | Functions | Variables
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.

Classes

struct  FramePool
 
struct  DecodeSimpleContext
 
struct  DecodeFilterContext
 
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.
 
#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_CODEC_CAP_SKIP_FRAME_FILL_PARAM   (1 << 3)
 The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame setting.
 
#define FF_CODEC_CAP_EXPORTS_CROPPING   (1 << 4)
 The decoder sets the cropping fields in the output frames manually. More...
 
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF   (1 << 5)
 Codec initializes slice-based threading with a main function.
 
#define ff_tlog(ctx, ...)   do { } while(0)
 
#define FF_DEFAULT_QUANT_BIAS   999999
 
#define FF_QSCALE_TYPE_MPEG1   0
 
#define FF_QSCALE_TYPE_MPEG2   1
 
#define FF_QSCALE_TYPE_H264   2
 
#define FF_QSCALE_TYPE_VP56   3
 
#define FF_SANE_NB_CHANNELS   64U
 
#define FF_SIGNBIT(x)   ((x) >> CHAR_BIT * sizeof(x) - 1)
 
#define STRIDE_ALIGN   8
 
#define FF_MAX_EXTRADATA_SIZE   ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
 Maximum size in bytes of extradata. More...
 
#define av_export_avcodec
 

Typedefs

typedef struct FramePool FramePool
 
typedef struct DecodeSimpleContext DecodeSimpleContext
 
typedef struct DecodeFilterContext DecodeFilterContext
 
typedef struct AVCodecInternal AVCodecInternal
 

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)
 
void ff_color_frame (AVFrame *frame, const int color[4])
 
int ff_alloc_packet2 (AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
 Check AVPacket size and/or allocate data. More...
 
attribute_deprecated int ff_alloc_packet (AVPacket *avpkt, int size)
 
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.
 
int ff_thread_can_start_frame (AVCodecContext *avctx)
 
int avpriv_h264_has_num_reorder_frames (AVCodecContext *avctx)
 
int 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 avpriv_bprint_to_extradata (AVCodecContext *avctx, struct AVBPrint *buf)
 Finalize buf into extradata and set its size appropriately.
 
const uint8_t * avpriv_find_start_code (const uint8_t *p, const uint8_t *end, uint32_t *state)
 
int avpriv_codec_get_cap_skip_frame_fill_param (const AVCodec *codec)
 
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.
 
int ff_set_sar (AVCodecContext *avctx, AVRational sar)
 Check that the provided sample aspect ratio is valid and set it on the codec context.
 
int ff_side_data_update_matrix_encoding (AVFrame *frame, enum AVMatrixEncoding matrix_encoding)
 Add or update AV_FRAME_DATA_MATRIXENCODING side data.
 
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.
 
AVCPBPropertiesff_add_cpb_side_data (AVCodecContext *avctx)
 Add a CPB properties side data to an encoding context.
 
int ff_side_data_set_encoder_stats (AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
 
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.
 

Variables

const uint8_t ff_log2_run [41]
 

Detailed Description

common internal api header.

Macro Definition Documentation

§ FF_CODEC_CAP_EXPORTS_CROPPING

#define FF_CODEC_CAP_EXPORTS_CROPPING   (1 << 4)

The decoder sets the cropping fields in the output frames manually.

If this cap is set, the generic code will initialize output frame dimensions to coded rather than display values.

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

§ 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, decode.c won't overwrite this field. If it's unset, decode.c tries to guess the pkt_dts field from the input AVPacket.

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

Function Documentation

§ ff_alloc_a53_sei()

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.

§ ff_alloc_packet2()

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

§ ff_codec_open2_recursive()

int 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

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

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

The list of pixel formats must contain at least one valid entry, and is terminated with AV_PIX_FMT_NONE. If it is possible to decode to software, the last entry in the list must be the most accurate software format. If it is not possible to decode to software, AVCodecContext.sw_pix_fmt must be set before calling this function.

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