FFmpeg
Loading...
Searching...
No Matches
codec_internal.h File Reference
#include <stdint.h>
#include "libavutil/attributes.h"
#include "avcodec.h"
#include "codec.h"
#include "config.h"

Go to the source code of this file.

Data Structures

struct  FFCodecDefault
 
struct  FFCodec
 

Macros

#define FF_CODEC_CAP_NOT_INIT_THREADSAFE   (1 << 0)
 The codec is not known to be init-threadsafe (i.e.
 
#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.
 
#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.
 
#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.
 
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF   (1 << 5)
 Codec initializes slice-based threading with a main function.
 
#define FF_CODEC_CAP_USES_PROGRESSFRAMES   (1 << 6)
 The decoder might make use of the ProgressFrame API.
 
#define FF_CODEC_CAP_AUTO_THREADS   (1 << 7)
 Codec handles avctx->thread_count == 0 (auto) internally.
 
#define FF_CODEC_CAP_SETS_FRAME_PROPS   (1 << 8)
 Codec handles output frame properties internally instead of letting the internal logic derive them from AVCodecInternal.last_pkt_props.
 
#define FF_CODEC_CAP_ICC_PROFILES   (1 << 9)
 Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).
 
#define FF_CODEC_CAP_EOF_FLUSH   (1 << 10)
 The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it only wants to be flushed at the end to update some context variables (e.g.
 
#define FF_CODEC_TAGS_END   -1
 FFCodec.codec_tags termination value.
 
#define CODEC_LONG_NAME(str)
 
#define UPDATE_THREAD_CONTEXT(func)
 
#define UPDATE_THREAD_CONTEXT_FOR_USER(func)
 
#define FF_CODEC_DECODE_CB(func)
 
#define FF_CODEC_DECODE_SUB_CB(func)
 
#define FF_CODEC_RECEIVE_FRAME_CB(func)
 
#define FF_CODEC_ENCODE_CB(func)
 
#define FF_CODEC_ENCODE_SUB_CB(func)
 
#define FF_CODEC_RECEIVE_PACKET_CB(func)
 
#define CODEC_CH_LAYOUTS(...)
 
#define CODEC_CH_LAYOUTS_ARRAY(array)
 
#define CODEC_SAMPLERATES(...)
 
#define CODEC_SAMPLERATES_ARRAY(array)
 
#define CODEC_SAMPLEFMTS(...)
 
#define CODEC_SAMPLEFMTS_ARRAY(array)
 
#define CODEC_FRAMERATES(...)
 
#define CODEC_FRAMERATES_ARRAY(array)
 
#define CODEC_PIXFMTS(...)
 
#define CODEC_PIXFMTS_ARRAY(array)
 
#define CODEC_ARRAY(field, array)
 

Enumerations

enum  FFCodecType {
  FF_CODEC_CB_TYPE_DECODE , FF_CODEC_CB_TYPE_DECODE_SUB , FF_CODEC_CB_TYPE_RECEIVE_FRAME , FF_CODEC_CB_TYPE_ENCODE ,
  FF_CODEC_CB_TYPE_ENCODE_SUB , FF_CODEC_CB_TYPE_RECEIVE_PACKET
}
 

Functions

static av_always_inline const FFCodecffcodec (const AVCodec *codec)
 
static int ff_codec_is_encoder (const AVCodec *avcodec)
 Internal version of av_codec_is_encoder().
 
static int ff_codec_is_decoder (const AVCodec *avcodec)
 Internal version of av_codec_is_decoder().
 
int ff_default_get_supported_config (const struct AVCodecContext *avctx, const AVCodec *codec, enum AVCodecConfig config, unsigned flags, const void **out_configs, int *out_num_configs)
 Default implementation for avcodec_get_supported_config().
 

Macro Definition Documentation

◆ FF_CODEC_CAP_NOT_INIT_THREADSAFE

#define FF_CODEC_CAP_NOT_INIT_THREADSAFE   (1 << 0)

The codec is not known to be init-threadsafe (i.e.

it might be unsafe to initialize this codec and another codec concurrently, typically because the codec calls external APIs that are not known to be thread-safe). Therefore calling the codec's init function needs to be guarded with a lock.

Definition at line 35 of file codec_internal.h.

Referenced by lock_avcodec(), and unlock_avcodec().

◆ 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 43 of file codec_internal.h.

Referenced by avcodec_open2(), and init_thread().

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

Definition at line 50 of file codec_internal.h.

Referenced by decode_simple_internal(), and main().

◆ FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM

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

Definition at line 55 of file codec_internal.h.

Referenced by avpriv_codec_get_cap_skip_frame_fill_param(), and main().

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

Definition at line 61 of file codec_internal.h.

Referenced by ff_get_buffer(), and main().

◆ FF_CODEC_CAP_SLICE_THREAD_HAS_MF

#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF   (1 << 5)

Codec initializes slice-based threading with a main function.

Definition at line 65 of file codec_internal.h.

Referenced by ff_slice_thread_init(), and main().

◆ FF_CODEC_CAP_USES_PROGRESSFRAMES

#define FF_CODEC_CAP_USES_PROGRESSFRAMES   (1 << 6)

The decoder might make use of the ProgressFrame API.

Definition at line 69 of file codec_internal.h.

Referenced by ff_decode_preinit(), and main().

◆ FF_CODEC_CAP_AUTO_THREADS

#define FF_CODEC_CAP_AUTO_THREADS   (1 << 7)

Codec handles avctx->thread_count == 0 (auto) internally.

Definition at line 73 of file codec_internal.h.

Referenced by avcodec_open2(), main(), and validate_thread_parameters().

◆ FF_CODEC_CAP_SETS_FRAME_PROPS

#define FF_CODEC_CAP_SETS_FRAME_PROPS   (1 << 8)

Codec handles output frame properties internally instead of letting the internal logic derive them from AVCodecInternal.last_pkt_props.

Definition at line 78 of file codec_internal.h.

Referenced by decode_get_packet(), decode_simple_internal(), ff_decode_frame_props(), and main().

◆ FF_CODEC_CAP_ICC_PROFILES

#define FF_CODEC_CAP_ICC_PROFILES   (1 << 9)

Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE).

Definition at line 82 of file codec_internal.h.

◆ FF_CODEC_CAP_EOF_FLUSH

#define FF_CODEC_CAP_EOF_FLUSH   (1 << 10)

The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it only wants to be flushed at the end to update some context variables (e.g.

2pass stats) or produce a trailing packet. Besides that it immediately produces exactly one output packet per each input frame, just as no-delay encoders do.

Definition at line 90 of file codec_internal.h.

Referenced by ff_encode_encode_cb(), and main().

◆ FF_CODEC_TAGS_END

#define FF_CODEC_TAGS_END   -1

FFCodec.codec_tags termination value.

Definition at line 95 of file codec_internal.h.

Referenced by LLVMFuzzerTestOneInput().

◆ CODEC_LONG_NAME

#define CODEC_LONG_NAME ( str)
Value:
.p.long_name = str

Definition at line 359 of file codec_internal.h.

◆ UPDATE_THREAD_CONTEXT

#define UPDATE_THREAD_CONTEXT ( func)
Value:
.update_thread_context = NULL
#define NULL
Definition coverity.c:32

Definition at line 368 of file codec_internal.h.

◆ UPDATE_THREAD_CONTEXT_FOR_USER

#define UPDATE_THREAD_CONTEXT_FOR_USER ( func)
Value:
.update_thread_context_for_user = NULL

Definition at line 370 of file codec_internal.h.

◆ FF_CODEC_DECODE_CB

#define FF_CODEC_DECODE_CB ( func)
Value:
.is_decoder = 1, \
.cb.decode = (func)
@ FF_CODEC_CB_TYPE_DECODE
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition jacosubdec.c:66

Definition at line 374 of file codec_internal.h.

◆ FF_CODEC_DECODE_SUB_CB

#define FF_CODEC_DECODE_SUB_CB ( func)
Value:
.is_decoder = 1, \
.cb.decode_sub = (func)
@ FF_CODEC_CB_TYPE_DECODE_SUB

Definition at line 378 of file codec_internal.h.

◆ FF_CODEC_RECEIVE_FRAME_CB

#define FF_CODEC_RECEIVE_FRAME_CB ( func)
Value:
.is_decoder = 1, \
.cb.receive_frame = (func)
@ FF_CODEC_CB_TYPE_RECEIVE_FRAME

Definition at line 382 of file codec_internal.h.

◆ FF_CODEC_ENCODE_CB

#define FF_CODEC_ENCODE_CB ( func)
Value:
.is_decoder = 0, \
.cb.encode = (func)
@ FF_CODEC_CB_TYPE_ENCODE

Definition at line 386 of file codec_internal.h.

◆ FF_CODEC_ENCODE_SUB_CB

#define FF_CODEC_ENCODE_SUB_CB ( func)
Value:
.is_decoder = 0, \
.cb.encode_sub = (func)
@ FF_CODEC_CB_TYPE_ENCODE_SUB

Definition at line 390 of file codec_internal.h.

◆ FF_CODEC_RECEIVE_PACKET_CB

#define FF_CODEC_RECEIVE_PACKET_CB ( func)
Value:
.is_decoder = 0, \
.cb.receive_packet = (func)
@ FF_CODEC_CB_TYPE_RECEIVE_PACKET

Definition at line 394 of file codec_internal.h.

◆ CODEC_CH_LAYOUTS

#define CODEC_CH_LAYOUTS ( ...)
Value:
CODEC_CH_LAYOUTS_ARRAY(((const AVChannelLayout[]) { __VA_ARGS__, { 0 } }))
#define CODEC_CH_LAYOUTS_ARRAY(array)
An AVChannelLayout holds information about the channel layout of audio data.

Definition at line 399 of file codec_internal.h.

◆ CODEC_CH_LAYOUTS_ARRAY

#define CODEC_CH_LAYOUTS_ARRAY ( array)
Value:
CODEC_ARRAY(ch_layouts, (array))
#define CODEC_ARRAY(field, array)
static int array[MAX_W *MAX_W]

Definition at line 400 of file codec_internal.h.

◆ CODEC_SAMPLERATES

#define CODEC_SAMPLERATES ( ...)
Value:
CODEC_SAMPLERATES_ARRAY(((const int[]) { __VA_ARGS__, 0 }))
#define CODEC_SAMPLERATES_ARRAY(array)

Definition at line 402 of file codec_internal.h.

◆ CODEC_SAMPLERATES_ARRAY

#define CODEC_SAMPLERATES_ARRAY ( array)
Value:
CODEC_ARRAY(supported_samplerates, (array))

Definition at line 403 of file codec_internal.h.

◆ CODEC_SAMPLEFMTS

#define CODEC_SAMPLEFMTS ( ...)
Value:
CODEC_SAMPLEFMTS_ARRAY(((const enum AVSampleFormat[]) { __VA_ARGS__, AV_SAMPLE_FMT_NONE }))
#define CODEC_SAMPLEFMTS_ARRAY(array)
AVSampleFormat
Audio sample formats.
Definition samplefmt.h:55
@ AV_SAMPLE_FMT_NONE
Definition samplefmt.h:56

Definition at line 405 of file codec_internal.h.

◆ CODEC_SAMPLEFMTS_ARRAY

#define CODEC_SAMPLEFMTS_ARRAY ( array)
Value:
static enum AVSampleFormat sample_fmts[]
Definition adpcmenc.c:933

Definition at line 406 of file codec_internal.h.

◆ CODEC_FRAMERATES

#define CODEC_FRAMERATES ( ...)
Value:
CODEC_FRAMERATES_ARRAY(((const AVRational[]) { __VA_ARGS__, { 0, 0 } }))
#define CODEC_FRAMERATES_ARRAY(array)
Rational number (pair of numerator and denominator).
Definition rational.h:58

Definition at line 408 of file codec_internal.h.

◆ CODEC_FRAMERATES_ARRAY

#define CODEC_FRAMERATES_ARRAY ( array)
Value:
CODEC_ARRAY(supported_framerates, (array))

Definition at line 409 of file codec_internal.h.

◆ CODEC_PIXFMTS

#define CODEC_PIXFMTS ( ...)
Value:
CODEC_PIXFMTS_ARRAY(((const enum AVPixelFormat[]) { __VA_ARGS__, AV_PIX_FMT_NONE }))
#define CODEC_PIXFMTS_ARRAY(array)
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72

Definition at line 411 of file codec_internal.h.

◆ CODEC_PIXFMTS_ARRAY

#define CODEC_PIXFMTS_ARRAY ( array)
Value:
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296

Definition at line 412 of file codec_internal.h.

◆ CODEC_ARRAY

#define CODEC_ARRAY ( field,
array )
Value:
.field = (array) \

Definition at line 414 of file codec_internal.h.

Enumeration Type Documentation

◆ FFCodecType

Enumerator
FF_CODEC_CB_TYPE_DECODE 
FF_CODEC_CB_TYPE_DECODE_SUB 
FF_CODEC_CB_TYPE_RECEIVE_FRAME 
FF_CODEC_CB_TYPE_ENCODE 
FF_CODEC_CB_TYPE_ENCODE_SUB 
FF_CODEC_CB_TYPE_RECEIVE_PACKET 

Definition at line 108 of file codec_internal.h.

Function Documentation

◆ ffcodec()

◆ ff_codec_is_encoder()

static int ff_codec_is_encoder ( const AVCodec * avcodec)
inlinestatic

Internal version of av_codec_is_encoder().

Must not be called with a NULL AVCodec*.

Definition at line 326 of file codec_internal.h.

Referenced by avcodec_find_encoder(), avcodec_find_encoder_by_name(), and avcodec_open2().

◆ ff_codec_is_decoder()

static int ff_codec_is_decoder ( const AVCodec * avcodec)
inlinestatic

Internal version of av_codec_is_decoder().

Must not be called with a NULL AVCodec*.

Definition at line 336 of file codec_internal.h.

Referenced by avcodec_find_decoder(), avcodec_find_decoder_by_name(), avcodec_open2(), avcodec_receive_frame_flags(), ff_get_buffer(), and get_category().

◆ ff_default_get_supported_config()

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

Default implementation for avcodec_get_supported_config().

Will return the relevant fields from AVCodec if present, or NULL otherwise.

For AVCODEC_CONFIG_COLOR_RANGE, the output will depend on the bitmask in FFCodec.color_ranges, with a value of 0 returning NULL.