FFmpeg
Macros | Functions | Variables
avcodec.c File Reference
#include <assert.h>
#include "config.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/emms.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "avcodec_internal.h"
#include "bsf.h"
#include "codec_desc.h"
#include "codec_internal.h"
#include "decode.h"
#include "frame_thread_encoder.h"
#include "hwconfig.h"
#include "internal.h"
#include "libavutil/refstruct.h"

Go to the source code of this file.

Macros

#define FF_MAX_EXTRADATA_SIZE   ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
 Maximum size in bytes of extradata. More...
 
#define WRAP_CONFIG(allowed_type, field, var, field_type, sentinel_check)
 

Functions

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)
 
static void lock_avcodec (const FFCodec *codec)
 
static void unlock_avcodec (const FFCodec *codec)
 
static int64_t get_bit_rate (AVCodecContext *ctx)
 
int attribute_align_arg avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
 Initialize the AVCodecContext to use the given AVCodec. More...
 
void avcodec_flush_buffers (AVCodecContext *avctx)
 Reset the internal codec state / flush internal buffers. More...
 
void avsubtitle_free (AVSubtitle *sub)
 Free all allocated data in the given subtitle struct. More...
 
av_cold void ff_codec_close (AVCodecContext *avctx)
 
static const char * unknown_if_null (const char *str)
 
void avcodec_string (char *buf, int buf_size, AVCodecContext *enc, int encode)
 
int avcodec_is_open (AVCodecContext *s)
 
int attribute_align_arg avcodec_receive_frame (AVCodecContext *avctx, AVFrame *frame)
 Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used). More...
 
int ff_default_get_supported_config (const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out_configs, int *out_num_configs)
 
int avcodec_get_supported_config (const AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out, int *out_num)
 Retrieve a list of all supported values for a given configuration type. More...
 
int av_packet_side_data_from_frame (AVPacketSideData **psd, int *pnb_sd, const AVFrameSideData *src, unsigned int flags)
 
int av_packet_side_data_to_frame (AVFrameSideData ***psd, int *pnb_sd, const AVPacketSideData *src, unsigned int flags)
 Add a new frame side data entry to an array based on existing packet side data, if a matching type exists for frame side data. More...
 

Variables

const SideDataMap ff_sd_global_map []
 A map between packet and frame side data types. More...
 
static AVMutex codec_mutex = AV_MUTEX_INITIALIZER
 
static enum AVColorRange color_range_tab []
 
static enum AVAlphaMode alpha_mode_tab []
 
static const uint8_t offset_tab []
 

Detailed Description

AVCodecContext functions for libavcodec

Definition in file avcodec.c.

Macro Definition Documentation

◆ 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 55 of file avcodec.c.

◆ WRAP_CONFIG

#define WRAP_CONFIG (   allowed_type,
  field,
  var,
  field_type,
  sentinel_check 
)
Value:
do { \
if (codec->type != (allowed_type)) \
return AVERROR(EINVAL); \
const field_type *ptr = codec->field; \
*out_configs = ptr; \
if (ptr) { \
for (int i = 0;; i++) { \
const field_type var = ptr[i]; \
if (sentinel_check) { \
*out_num_configs = i; \
break; \
} \
} \
} else \
*out_num_configs = 0; \
return 0; \
} while (0)

Definition at line 719 of file avcodec.c.

Function Documentation

◆ avcodec_default_execute2()

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 87 of file avcodec.c.

Referenced by init_context_defaults().

◆ lock_avcodec()

static void lock_avcodec ( const FFCodec codec)
static

Definition at line 102 of file avcodec.c.

Referenced by avcodec_open2().

◆ unlock_avcodec()

static void unlock_avcodec ( const FFCodec codec)
static

Definition at line 108 of file avcodec.c.

Referenced by avcodec_open2().

◆ get_bit_rate()

static int64_t get_bit_rate ( AVCodecContext ctx)
static

Definition at line 114 of file avcodec.c.

Referenced by avcodec_open2(), and avcodec_string().

◆ ff_codec_close()

av_cold void ff_codec_close ( AVCodecContext avctx)

Definition at line 433 of file avcodec.c.

Referenced by avcodec_free_context(), and avcodec_open2().

◆ unknown_if_null()

static const char* unknown_if_null ( const char *  str)
static

Definition at line 498 of file avcodec.c.

Referenced by avcodec_string().

◆ ff_default_get_supported_config()

int ff_default_get_supported_config ( const AVCodecContext avctx,
const AVCodec codec,
enum AVCodecConfig  config,
unsigned  flags,
const void **  out_configs,
int *  out_num_configs 
)

◆ av_packet_side_data_from_frame()

int av_packet_side_data_from_frame ( AVPacketSideData **  psd,
int *  pnb_sd,
const AVFrameSideData src,
unsigned int  flags 
)

Definition at line 833 of file avcodec.c.

Variable Documentation

◆ ff_sd_global_map

const SideDataMap ff_sd_global_map[]

◆ codec_mutex

AVMutex codec_mutex = AV_MUTEX_INITIALIZER
static

Definition at line 100 of file avcodec.c.

Referenced by lock_avcodec(), and unlock_avcodec().

◆ color_range_tab

enum AVColorRange color_range_tab[]
static

◆ alpha_mode_tab

enum AVAlphaMode alpha_mode_tab[]
static

◆ offset_tab

const uint8_t offset_tab[]
static
Initial value:

Definition at line 753 of file avcodec.c.

Referenced by ff_default_get_supported_config().

AV_PKT_DATA_DISPLAYMATRIX
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:105
AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT
@ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition: packet.h:327
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVALPHA_MODE_STRAIGHT
@ AVALPHA_MODE_STRAIGHT
Alpha channel is independent of color values.
Definition: pixfmt.h:813
AVALPHA_MODE_PREMULTIPLIED
@ AVALPHA_MODE_PREMULTIPLIED
Alpha channel is multiplied into color values.
Definition: pixfmt.h:812
AV_PKT_DATA_MASTERING_DISPLAY_METADATA
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Definition: packet.h:219
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:777
AV_FRAME_DATA_DISPLAYMATRIX
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:85
AV_PKT_DATA_REPLAYGAIN
@ AV_PKT_DATA_REPLAYGAIN
This side data should be associated with an audio stream and contains ReplayGain information in form ...
Definition: packet.h:96
AV_FRAME_DATA_AUDIO_SERVICE_TYPE
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
Definition: frame.h:114
AV_PKT_DATA_STEREO3D
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
Definition: packet.h:111
AV_FRAME_DATA_3D_REFERENCE_DISPLAYS
@ AV_FRAME_DATA_3D_REFERENCE_DISPLAYS
This side data contains information about the reference display width(s) and reference viewing distan...
Definition: frame.h:256
AV_PKT_DATA_3D_REFERENCE_DISPLAYS
@ AV_PKT_DATA_3D_REFERENCE_DISPLAYS
This side data contains information about the reference display width(s) and reference viewing distan...
Definition: packet.h:357
AV_PKT_DATA_EXIF
@ AV_PKT_DATA_EXIF
Extensible image file format metadata.
Definition: packet.h:369
AV_FRAME_DATA_SPHERICAL
@ AV_FRAME_DATA_SPHERICAL
The data represents the AVSphericalMapping structure defined in libavutil/spherical....
Definition: frame.h:131
AV_FRAME_DATA_ICC_PROFILE
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:144
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
AV_PKT_DATA_CONTENT_LIGHT_LEVEL
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: packet.h:232
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:743
AV_PKT_DATA_NB
@ AV_PKT_DATA_NB
The number of side data types.
Definition: packet.h:379
AV_PKT_DATA_SPHERICAL
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
Definition: packet.h:225
AV_FRAME_DATA_REPLAYGAIN
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
Definition: frame.h:77
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
@ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition: frame.h:220
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV_PKT_DATA_ICC_PROFILE
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
Definition: packet.h:271
AV_FRAME_DATA_STEREO3D
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
Definition: frame.h:64
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:760
AVALPHA_MODE_UNSPECIFIED
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
Definition: pixfmt.h:811
AV_PKT_DATA_AUDIO_SERVICE_TYPE
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
Definition: packet.h:117
AV_FRAME_DATA_EXIF
@ AV_FRAME_DATA_EXIF
Extensible image file format metadata.
Definition: frame.h:262