FFmpeg
Macros | Functions
internal.h File Reference
#include <limits.h>
#include <stdint.h>
#include <stddef.h>
#include <assert.h>
#include "config.h"
#include "attributes.h"
#include "timer.h"
#include "cpu.h"
#include "dict.h"
#include "macros.h"
#include "mem.h"
#include "pixfmt.h"
#include "version.h"
#include "libm.h"

Go to the source code of this file.

Macros

#define NDEBUG
 
#define av_export_avutil
 
#define FF_DISABLE_DEPRECATION_WARNINGS
 
#define FF_ENABLE_DEPRECATION_WARNINGS
 
#define FF_MEMORY_POISON   0x2a
 
#define MAKE_ACCESSORS(str, name, type, field)
 
#define E1(x)   x
 
#define AV_CHECK_OFFSET(s, m, o)
 
#define LOCAL_ALIGNED_A(a, t, v, s, o, ...)
 
#define LOCAL_ALIGNED_D(a, t, v, s, o, ...)
 
#define LOCAL_ALIGNED(a, t, v, ...)   LOCAL_ALIGNED_##a(t, v, __VA_ARGS__)
 
#define LOCAL_ALIGNED_4(t, v, ...)   E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,))
 
#define LOCAL_ALIGNED_8(t, v, ...)   E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,))
 
#define LOCAL_ALIGNED_16(t, v, ...)   E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,))
 
#define LOCAL_ALIGNED_32(t, v, ...)   E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
 
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
 
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
 
#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
 
#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
 
#define FF_PTR_ADD(ptr, off)   ((off) ? (ptr) + (off) : (ptr))
 
#define NULL_IF_CONFIG_SMALL(x)   x
 Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. More...
 
#define ONLY_IF_THREADS_ENABLED(x)   NULL
 Define a function with only the non-default version specified. More...
 
#define PTRDIFF_SPECIFIER   "td"
 
#define SIZE_SPECIFIER   "zu"
 
#define ff_dlog(ctx, ...)   do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
 
#define SUINT   unsigned
 
#define SUINT32   uint32_t
 
#define FF_PSEUDOPAL   AV_PIX_FMT_FLAG_PSEUDOPAL
 

Functions

void avpriv_report_missing_feature (void *avc, const char *msg,...) av_printf_format(2
 Log a generic warning message about a missing feature. More...
 
void void avpriv_request_sample (void *avc, const char *msg,...) av_printf_format(2
 Log a generic warning message about a missing feature. More...
 
static av_always_inline av_const int64_t ff_rint64_clip (double a, int64_t amin, int64_t amax)
 Clip and convert a double value into the long long amin-amax range. More...
 
av_warn_unused_result int avpriv_open (const char *filename, int flags,...)
 A wrapper for open() setting O_CLOEXEC. More...
 
int avpriv_tempfile (const char *prefix, char **filename, int log_offset, void *log_ctx)
 Wrapper to work around the lack of mkstemp() on mingw. More...
 
int avpriv_set_systematic_pal2 (uint32_t pal[256], enum AVPixelFormat pix_fmt)
 
static av_always_inline av_const int avpriv_mirror (int x, int w)
 
void ff_check_pixfmt_descriptors (void)
 
int avpriv_dict_set_timestamp (AVDictionary **dict, const char *key, int64_t timestamp)
 Set a dictionary value to an ISO-8601 compliant timestamp string. More...
 

Detailed Description

common internal API header

Definition in file internal.h.

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 30 of file internal.h.

◆ av_export_avutil

#define av_export_avutil

Definition at line 69 of file internal.h.

◆ FF_DISABLE_DEPRECATION_WARNINGS

#define FF_DISABLE_DEPRECATION_WARNINGS

Definition at line 84 of file internal.h.

◆ FF_ENABLE_DEPRECATION_WARNINGS

#define FF_ENABLE_DEPRECATION_WARNINGS

Definition at line 85 of file internal.h.

◆ FF_MEMORY_POISON

#define FF_MEMORY_POISON   0x2a

Definition at line 89 of file internal.h.

◆ MAKE_ACCESSORS

#define MAKE_ACCESSORS (   str,
  name,
  type,
  field 
)
Value:
type av_##name##_get_##field(const str *s) { return s->field; } \
void av_##name##_set_##field(str *s, type v) { s->field = v; }

Definition at line 91 of file internal.h.

◆ E1

#define E1 (   x)    x

Definition at line 97 of file internal.h.

◆ AV_CHECK_OFFSET

#define AV_CHECK_OFFSET (   s,
  m,
 
)
Value:
struct check_##o { \
int x_##o[offsetof(s, m) == o? 1: -1]; \
}

Definition at line 102 of file internal.h.

◆ LOCAL_ALIGNED_A

#define LOCAL_ALIGNED_A (   a,
  t,
  v,
  s,
  o,
  ... 
)
Value:
uint8_t la_##v[sizeof(t s o) + (a)]; \
t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)

Definition at line 106 of file internal.h.

◆ LOCAL_ALIGNED_D

#define LOCAL_ALIGNED_D (   a,
  t,
  v,
  s,
  o,
  ... 
)
Value:
DECLARE_ALIGNED(a, t, la_##v) s o; \
t (*v) o = la_##v

Definition at line 110 of file internal.h.

◆ LOCAL_ALIGNED

#define LOCAL_ALIGNED (   a,
  t,
  v,
  ... 
)    LOCAL_ALIGNED_##a(t, v, __VA_ARGS__)

Definition at line 114 of file internal.h.

◆ LOCAL_ALIGNED_4

#define LOCAL_ALIGNED_4 (   t,
  v,
  ... 
)    E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,))

Definition at line 119 of file internal.h.

◆ LOCAL_ALIGNED_8

#define LOCAL_ALIGNED_8 (   t,
  v,
  ... 
)    E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,))

Definition at line 125 of file internal.h.

◆ LOCAL_ALIGNED_16

#define LOCAL_ALIGNED_16 (   t,
  v,
  ... 
)    E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,))

Definition at line 131 of file internal.h.

◆ LOCAL_ALIGNED_32

#define LOCAL_ALIGNED_32 (   t,
  v,
  ... 
)    E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))

Definition at line 137 of file internal.h.

◆ FF_ALLOC_OR_GOTO

#define FF_ALLOC_OR_GOTO (   ctx,
  p,
  size,
  label 
)
Value:
{\
p = av_malloc(size);\
if (!(p) && (size) != 0) {\
av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
goto label;\
}\
}

Definition at line 140 of file internal.h.

◆ FF_ALLOCZ_OR_GOTO

#define FF_ALLOCZ_OR_GOTO (   ctx,
  p,
  size,
  label 
)
Value:
{\
if (!(p) && (size) != 0) {\
av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
goto label;\
}\
}

Definition at line 149 of file internal.h.

◆ FF_ALLOC_ARRAY_OR_GOTO

#define FF_ALLOC_ARRAY_OR_GOTO (   ctx,
  p,
  nelem,
  elsize,
  label 
)
Value:
{\
p = av_malloc_array(nelem, elsize);\
if (!p) {\
av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
goto label;\
}\
}

Definition at line 158 of file internal.h.

◆ FF_ALLOCZ_ARRAY_OR_GOTO

#define FF_ALLOCZ_ARRAY_OR_GOTO (   ctx,
  p,
  nelem,
  elsize,
  label 
)
Value:
{\
p = av_mallocz_array(nelem, elsize);\
if (!p) {\
av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
goto label;\
}\
}

Definition at line 167 of file internal.h.

◆ FF_PTR_ADD

#define FF_PTR_ADD (   ptr,
  off 
)    ((off) ? (ptr) + (off) : (ptr))

Definition at line 176 of file internal.h.

◆ NULL_IF_CONFIG_SMALL

#define NULL_IF_CONFIG_SMALL (   x)    x

Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.

Used to disable the definition of strings (for example AVCodec long_names).

Definition at line 188 of file internal.h.

◆ ONLY_IF_THREADS_ENABLED

#define ONLY_IF_THREADS_ENABLED (   x)    NULL

Define a function with only the non-default version specified.

On systems with ELF shared libraries, all symbols exported from FFmpeg libraries are tagged with the name and major version of the library to which they belong. If a function is moved from one library to another, a wrapper must be retained in the original location to preserve binary compatibility.

Functions defined with this macro will never be used to resolve symbols by the build-time linker.

Parameters
typereturn type of function
namename of function
argsargument list of function
verversion tag to assign function Return NULL if a threading library has not been enabled. Used to disable threading functions in AVCodec definitions when not needed.

Definition at line 227 of file internal.h.

◆ PTRDIFF_SPECIFIER

#define PTRDIFF_SPECIFIER   "td"

Definition at line 263 of file internal.h.

◆ SIZE_SPECIFIER

#define SIZE_SPECIFIER   "zu"

Definition at line 264 of file internal.h.

◆ ff_dlog

#define ff_dlog (   ctx,
  ... 
)    do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)

Definition at line 270 of file internal.h.

◆ SUINT

#define SUINT   unsigned

Definition at line 279 of file internal.h.

◆ SUINT32

#define SUINT32   uint32_t

Definition at line 280 of file internal.h.

◆ FF_PSEUDOPAL

#define FF_PSEUDOPAL   AV_PIX_FMT_FLAG_PSEUDOPAL

Definition at line 369 of file internal.h.

Function Documentation

◆ avpriv_report_missing_feature()

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

Log a generic warning message about a missing feature.

Parameters
[in]avca pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct
[in]msgstring containing the name of the missing feature

Referenced by aac_adtstoasc_filter(), alac_decode_frame(), alac_decode_init(), amrnb_decode_frame(), amrnb_decode_init(), amrwb_decode_init(), atrac3p_decode_frame(), avi_write_header(), bmp_decode_frame(), cfhd_decode(), codec2_read_header(), cpia_decode_frame(), decode_audio_specific_config_gb(), decode_block(), decode_eld_specific_config(), decode_element(), decode_extension_payload(), decode_frame(), decode_ga_specific_config(), decode_gop_header(), decode_group3_2d_line(), decode_header(), decode_ics(), decode_idat_chunk(), decode_seq_header(), decode_subframe(), decode_tones_info(), ff_get_wav_header(), ff_h264_decode_picture_parameter_set(), ff_hevc_encode_nal_vps(), ff_ivi_decode_frame(), ff_jpegls_decode_picture(), ff_mjpeg_decode_sof(), ff_mjpeg_decode_sos(), ff_rtp_send_vc2hq(), ff_rv10_encode_picture_header(), ff_spdif_read_packet(), ff_vc1_parse_frame_header_adv(), g2m_decode_frame(), g2m_load_cursor(), g723_1_encode_init(), get_packet_header(), h264_handle_packet(), handle_id3(), hevc_handle_packet(), jpeg_parse_packet(), libopenjpeg_decode_frame(), mpc8_read_header(), mpegaudio_parse(), ogg_replace_stream(), old_codec37(), old_codec47(), parse_adts_frame_header(), parse_bit_alloc(), parse_channel(), parse_decoder_init(), parse_fmtp_config(), parse_MP4SLDescrTag(), parse_packed_headers(), pixfmt_from_pixmap_format(), read_frame_header(), read_header(), rpl_read_header(), rso_read_header(), rso_write_header(), s337m_get_offset_and_codec(), set_option(), shorten_decode_frame(), spdif_write_header(), svq3_decode_slice_header(), tak_decode_frame(), tiff_decode_tag(), txd_decode_frame(), v4l2_check_b_frame_support(), vfw_read_header(), vp5_parse_header(), vp6_parse_header(), vp9_handle_packet(), vqa_decode_init(), wv_read_block_header(), xcbgrab_read_header(), xiph_handle_packet(), and xwd_decode_frame().

◆ avpriv_request_sample()

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

Log a generic warning message about a missing feature.

Additionally request that a sample showcasing the feature be uploaded.

Parameters
[in]avca pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct
[in]msgstring containing the name of the missing feature

◆ ff_rint64_clip()

static av_always_inline av_const int64_t ff_rint64_clip ( double  a,
int64_t  amin,
int64_t  amax 
)
static

Clip and convert a double value into the long long amin-amax range.

This function is needed because conversion of floating point to integers when it does not fit in the integer's representation does not necessarily saturate correctly (usually converted to a cvttsd2si on x86) which saturates numbers

INT64_MAX to INT64_MIN. The standard marks such conversions as undefined

behavior, allowing this sort of mathematically bogus conversions. This provides a safe alternative that is slower obviously but assures safety and better mathematical behavior.

Parameters
avalue to clip
aminminimum value of the clip range
amaxmaximum value of the clip range
Returns
clipped value

Definition at line 297 of file internal.h.

◆ avpriv_open()

av_warn_unused_result int avpriv_open ( const char *  filename,
int  flags,
  ... 
)

A wrapper for open() setting O_CLOEXEC.

Definition at line 66 of file file_open.c.

Referenced by av_file_map(), av_fopen_utf8(), bktr_init(), fbdev_read_header(), fbdev_write_header(), ff_fbdev_get_device_list(), ff_oss_audio_open(), and read_random().

◆ avpriv_tempfile()

int avpriv_tempfile ( const char *  prefix,
char **  filename,
int  log_offset,
void *  log_ctx 
)

Wrapper to work around the lack of mkstemp() on mingw.

Also, tries to create file in /tmp first, if possible. *prefix can be a character constant; *filename will be allocated internally.

Returns
file descriptor of opened file (or negative value corresponding to an AVERROR code on error) and opened file name in **filename.
Note
On very old libcs it is necessary to set a secure umask before calling this, av_tempfile() can't call umask itself as it is used in libraries and could interfere with the calling application.

Definition at line 110 of file file_open.c.

Referenced by av_tempfile(), cache_open(), and xvid_encode_init().

◆ avpriv_set_systematic_pal2()

int avpriv_set_systematic_pal2 ( uint32_t  pal[256],
enum AVPixelFormat  pix_fmt 
)

◆ avpriv_mirror()

static av_always_inline av_const int avpriv_mirror ( int  x,
int  w 
)
static

◆ ff_check_pixfmt_descriptors()

void ff_check_pixfmt_descriptors ( void  )

Definition at line 2604 of file pixdesc.c.

Referenced by main().

◆ avpriv_dict_set_timestamp()

int avpriv_dict_set_timestamp ( AVDictionary **  dict,
const char *  key,
int64_t  timestamp 
)

Set a dictionary value to an ISO-8601 compliant timestamp string.

Parameters
sAVFormatContext
keymetadata key
timestampunix timestamp in microseconds
Returns
<0 on error

Definition at line 258 of file dict.c.

Referenced by ff_standardize_creation_time(), matroska_parse_flac(), mov_metadata_creation_time(), and parse_header().

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
av_mallocz_array
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:190
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
s
#define s(width, name)
Definition: cbs_vp9.c:257
ctx
AVFormatContext * ctx
Definition: movenc.c:48
field
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
Definition: writing_filters.txt:78
size
int size
Definition: twinvq_data.h:11134
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:112
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
uint8_t
uint8_t
Definition: audio_convert.c:194
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:48
convert_header.str
string str
Definition: convert_header.py:20