FFmpeg
Macros | Functions | Variables
formats.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.h"
#include "formats.h"

Go to the source code of this file.

Macros

#define MERGE_REF(ret, a, fmts, type, fail_statement)
 Add all refs from a to ret and destroy a. More...
 
#define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed)
 Add all formats common to a and b to a, add b's refs to a and destroy b. More...
 
#define MAKE_FORMAT_LIST(type, field, count_field)
 
#define ADD_FORMAT(f, fmt, unref_fn, type, list, nb)
 
#define ASSIGN_FMT(f, fmt, list, nb)
 
#define ASSIGN_FMT(f, fmt, list, nb)
 
#define FORMATS_REF(f, ref, unref_fn)
 
#define FIND_REF_INDEX(ref, idx)
 
#define FORMATS_UNREF(ref, list)
 
#define FREE_LIST(ref, list)   do { } while(0)
 
#define FREE_LIST(ref, list)
 
#define FORMATS_CHANGEREF(oldref, newref)
 
#define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn)
 

Functions

static int merge_formats_internal (AVFilterFormats *a, AVFilterFormats *b, enum AVMediaType type, int check)
 
static int can_merge_pix_fmts (const void *a, const void *b)
 Check the formats lists for compatibility for merging without actually merging. More...
 
static int merge_pix_fmts (void *a, void *b)
 Merge the formats lists if they are compatible and update all the references of a and b to point to the combined list and free the old lists as needed. More...
 
static int can_merge_sample_fmts (const void *a, const void *b)
 See can_merge_pix_fmts(). More...
 
static int merge_sample_fmts (void *a, void *b)
 See merge_pix_fmts(). More...
 
static int merge_samplerates_internal (AVFilterFormats *a, AVFilterFormats *b, int check)
 
static int can_merge_samplerates (const void *a, const void *b)
 See can_merge_pix_fmts(). More...
 
static int merge_samplerates (void *a, void *b)
 See merge_pix_fmts(). More...
 
static int merge_channel_layouts_internal (AVFilterChannelLayouts *a, AVFilterChannelLayouts *b, int check)
 See merge_pix_fmts(). More...
 
static int can_merge_channel_layouts (const void *a, const void *b)
 
static int merge_channel_layouts (void *a, void *b)
 
static int merge_generic_internal (AVFilterFormats *a, AVFilterFormats *b, int check)
 
static int can_merge_generic (const void *a, const void *b)
 
static int merge_generic (void *a, void *b)
 
const AVFilterNegotiationff_filter_get_negotiation (AVFilterLink *link)
 
int ff_fmt_is_in (int fmt, const int *fmts)
 Tell if an integer is contained in the provided -1-terminated list of integers. More...
 
AVFilterFormatsff_make_format_list (const int *fmts)
 Create a list of supported formats. More...
 
AVFilterChannelLayoutsff_make_channel_layout_list (const AVChannelLayout *fmts)
 
int ff_add_format (AVFilterFormats **avff, int64_t fmt)
 Add fmt to the list of media formats contained in *avff. More...
 
int ff_add_channel_layout (AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
 
AVFilterFormatsff_make_formats_list_singleton (int fmt)
 Equivalent to ff_make_format_list({const int[]}{ fmt, -1 }) More...
 
AVFilterFormatsff_all_formats (enum AVMediaType type)
 Return a list of all formats supported by FFmpeg for the given media type. More...
 
AVFilterFormatsff_formats_pixdesc_filter (unsigned want, unsigned rej)
 Construct a formats list containing all pixel formats with certain properties. More...
 
AVFilterFormatsff_planar_sample_fmts (void)
 Construct a formats list containing all planar sample formats. More...
 
AVFilterFormatsff_all_samplerates (void)
 
AVFilterChannelLayoutsff_all_channel_layouts (void)
 Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (with known disposition)/sample rate. More...
 
AVFilterChannelLayoutsff_all_channel_counts (void)
 Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition. More...
 
AVFilterFormatsff_all_color_spaces (void)
 Construct an AVFilterFormats representing all possible color spaces. More...
 
AVFilterFormatsff_all_color_ranges (void)
 Construct an AVFilterFormats representing all possible color ranges. More...
 
int ff_channel_layouts_ref (AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
 Add *ref as a new reference to f. More...
 
int ff_formats_ref (AVFilterFormats *f, AVFilterFormats **ref)
 Add *ref as a new reference to formats. More...
 
void ff_formats_unref (AVFilterFormats **ref)
 If *ref is non-NULL, remove *ref as a reference to the format list it currently points to, deallocates that list if this was the last reference, and sets *ref to NULL. More...
 
void ff_channel_layouts_unref (AVFilterChannelLayouts **ref)
 Remove a reference to a channel layouts list. More...
 
void ff_channel_layouts_changeref (AVFilterChannelLayouts **oldref, AVFilterChannelLayouts **newref)
 
void ff_formats_changeref (AVFilterFormats **oldref, AVFilterFormats **newref)
 
int ff_set_common_channel_layouts (AVFilterContext *ctx, AVFilterChannelLayouts *channel_layouts)
 Helpers for query_formats() which set all free audio links to the same list of channel layouts/sample rates. More...
 
int ff_set_common_channel_layouts_from_list (AVFilterContext *ctx, const AVChannelLayout *fmts)
 Equivalent to ff_set_common_channel_layouts(ctx, ff_make_channel_layout_list(fmts)) More...
 
int ff_set_common_all_channel_counts (AVFilterContext *ctx)
 Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts()) More...
 
int ff_set_common_samplerates (AVFilterContext *ctx, AVFilterFormats *samplerates)
 
int ff_set_common_samplerates_from_list (AVFilterContext *ctx, const int *samplerates)
 Equivalent to ff_set_common_samplerates(ctx, ff_make_format_list(samplerates)) More...
 
int ff_set_common_all_samplerates (AVFilterContext *ctx)
 Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates()) More...
 
int ff_set_common_color_spaces (AVFilterContext *ctx, AVFilterFormats *color_spaces)
 
int ff_set_common_color_spaces_from_list (AVFilterContext *ctx, const int *color_ranges)
 Equivalent to ff_set_common_color_spaces(ctx, ff_make_format_list(color_spaces)) More...
 
int ff_set_common_all_color_spaces (AVFilterContext *ctx)
 Equivalent to ff_set_common_color_spaces(ctx, ff_all_color_spaces()) More...
 
int ff_set_common_color_ranges (AVFilterContext *ctx, AVFilterFormats *color_ranges)
 
int ff_set_common_color_ranges_from_list (AVFilterContext *ctx, const int *color_ranges)
 Equivalent to ff_set_common_color_ranges(ctx, ff_make_format_list(color_ranges)) More...
 
int ff_set_common_all_color_ranges (AVFilterContext *ctx)
 Equivalent to ff_set_common_color_ranges(ctx, ff_all_color_ranges()) More...
 
int ff_set_common_formats (AVFilterContext *ctx, AVFilterFormats *formats)
 A helper for query_formats() which sets all links to the same list of formats. More...
 
int ff_set_common_formats_from_list (AVFilterContext *ctx, const int *fmts)
 Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts)) More...
 
int ff_default_query_formats (AVFilterContext *ctx)
 Sets all remaining unset filter lists for all inputs/outputs to their corresponding ff_all_*() lists. More...
 
int ff_parse_pixel_format (enum AVPixelFormat *ret, const char *arg, void *log_ctx)
 Parse a pixel format. More...
 
int ff_parse_sample_rate (int *ret, const char *arg, void *log_ctx)
 Parse a sample rate. More...
 
int ff_parse_channel_layout (AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
 Parse a channel layout or a corresponding integer representation. More...
 
static int check_list (void *log, const char *name, const AVFilterFormats *fmts)
 
int ff_formats_check_pixel_formats (void *log, const AVFilterFormats *fmts)
 Check that fmts is a valid pixel formats list. More...
 
int ff_formats_check_sample_formats (void *log, const AVFilterFormats *fmts)
 Check that fmts is a valid sample formats list. More...
 
int ff_formats_check_sample_rates (void *log, const AVFilterFormats *fmts)
 Check that fmts is a valid sample rates list. More...
 
int ff_formats_check_color_spaces (void *log, const AVFilterFormats *fmts)
 Check that fmts is a valid formats list for YUV colorspace metadata. More...
 
int ff_formats_check_color_ranges (void *log, const AVFilterFormats *fmts)
 
static int layouts_compatible (const AVChannelLayout *a, const AVChannelLayout *b)
 
int ff_formats_check_channel_layouts (void *log, const AVFilterChannelLayouts *fmts)
 Check that fmts is a valid channel layouts list. More...
 

Variables

static const AVFilterFormatsMerger mergers_video []
 
static const AVFilterFormatsMerger mergers_audio []
 
static const AVFilterNegotiation negotiate_video
 
static const AVFilterNegotiation negotiate_audio
 

Macro Definition Documentation

◆ MERGE_REF

#define MERGE_REF (   ret,
  a,
  fmts,
  type,
  fail_statement 
)
Value:
do { \
type ***tmp; \
int i; \
if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \
sizeof(*tmp)))) \
{ fail_statement } \
ret->refs = tmp; \
for (i = 0; i < a->refcount; i ++) { \
ret->refs[ret->refcount] = a->refs[i]; \
*ret->refs[ret->refcount++] = ret; \
} \
av_freep(&a->refs); \
av_freep(&a->fmts); \
av_freep(&a); \
} while (0)

Add all refs from a to ret and destroy a.

Definition at line 34 of file formats.c.

◆ MERGE_FORMATS

#define MERGE_FORMATS (   a,
  b,
  fmts,
  nb,
  type,
  check,
  empty_allowed 
)

Add all formats common to a and b to a, add b's refs to a and destroy b.

If check is set, nothing is modified and it is only checked whether the formats are compatible. If empty_allowed is set and one of a,b->nb is zero, the lists are merged; otherwise, 0 (for nonmergeability) is returned.

Definition at line 61 of file formats.c.

◆ MAKE_FORMAT_LIST

#define MAKE_FORMAT_LIST (   type,
  field,
  count_field 
)
Value:
int count = 0; \
if (fmts) \
for (count = 0; fmts[count] != -1; count++) \
; \
formats = av_mallocz(sizeof(*formats)); \
if (!formats) \
return NULL; \
formats->count_field = count; \
if (count) { \
formats->field = av_malloc_array(count, sizeof(*formats->field)); \
if (!formats->field) { \
av_freep(&formats); \
return NULL; \
} \
}

Definition at line 417 of file formats.c.

◆ ADD_FORMAT

#define ADD_FORMAT (   f,
  fmt,
  unref_fn,
  type,
  list,
  nb 
)
Value:
do { \
type *fmts; \
if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \
return AVERROR(ENOMEM); \
} \
\
fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \
sizeof(*(*f)->list)); \
if (!fmts) { \
unref_fn(f); \
return AVERROR(ENOMEM); \
} \
\
(*f)->list = fmts; \
ASSIGN_FMT(f, fmt, list, nb); \
} while (0)

Definition at line 480 of file formats.c.

◆ ASSIGN_FMT [1/2]

#define ASSIGN_FMT (   f,
  fmt,
  list,
  nb 
)
Value:
do { \
(*f)->list[(*f)->nb++] = fmt; \
} while (0)

Definition at line 511 of file formats.c.

◆ ASSIGN_FMT [2/2]

#define ASSIGN_FMT (   f,
  fmt,
  list,
  nb 
)
Value:
do { \
int ret; \
memset((*f)->list + (*f)->nb, 0, sizeof(*(*f)->list)); \
ret = av_channel_layout_copy(&(*f)->list[(*f)->nb], fmt); \
if (ret < 0) \
return ret; \
(*f)->nb++; \
} while (0)

Definition at line 511 of file formats.c.

◆ FORMATS_REF

#define FORMATS_REF (   f,
  ref,
  unref_fn 
)
Value:
void *tmp; \
if (!f) \
return AVERROR(ENOMEM); \
\
tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
if (!tmp) { \
unref_fn(&f); \
return AVERROR(ENOMEM); \
} \
f->refs = tmp; \
f->refs[f->refcount++] = ref; \
*ref = f; \
return 0

Definition at line 657 of file formats.c.

◆ FIND_REF_INDEX

#define FIND_REF_INDEX (   ref,
  idx 
)
Value:
do { \
int i; \
for (i = 0; i < (*ref)->refcount; i ++) \
if((*ref)->refs[i] == ref) { \
idx = i; \
break; \
} \
} while (0)

Definition at line 683 of file formats.c.

◆ FORMATS_UNREF

#define FORMATS_UNREF (   ref,
  list 
)
Value:
do { \
int idx = -1; \
if (!*ref) \
return; \
if (idx >= 0) { \
memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \
sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \
--(*ref)->refcount; \
} \
if (!(*ref)->refcount) { \
FREE_LIST(ref, list); \
av_free((*ref)->list); \
av_free((*ref)->refs); \
av_free(*ref); \
} \
*ref = NULL; \
} while (0)

Definition at line 693 of file formats.c.

◆ FREE_LIST [1/2]

#define FREE_LIST (   ref,
  list 
)    do { } while(0)

Definition at line 723 of file formats.c.

◆ FREE_LIST [2/2]

#define FREE_LIST (   ref,
  list 
)
Value:
do { \
for (int i = 0; i < (*ref)->nb_channel_layouts; i++) \
av_channel_layout_uninit(&(*ref)->list[i]); \
} while(0)

Definition at line 723 of file formats.c.

◆ FORMATS_CHANGEREF

#define FORMATS_CHANGEREF (   oldref,
  newref 
)
Value:
do { \
int idx = -1; \
FIND_REF_INDEX(oldref, idx); \
if (idx >= 0) { \
(*oldref)->refs[idx] = newref; \
*newref = *oldref; \
*oldref = NULL; \
} \
} while (0)

Definition at line 734 of file formats.c.

◆ SET_COMMON_FORMATS

#define SET_COMMON_FORMATS (   ctx,
  fmts,
  media_type,
  ref_fn,
  unref_fn 
)
Value:
int i; \
if (!fmts) \
return AVERROR(ENOMEM); \
for (i = 0; i < ctx->nb_inputs; i++) { \
AVFilterLink *const link = ctx->inputs[i]; \
if (link && !link->outcfg.fmts && \
(media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \
if (ret < 0) { \
return ret; \
} \
} \
} \
for (i = 0; i < ctx->nb_outputs; i++) { \
AVFilterLink *const link = ctx->outputs[i]; \
if (link && !link->incfg.fmts && \
(media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \
if (ret < 0) { \
return ret; \
} \
} \
} \
if (!fmts->refcount) \
unref_fn(&fmts); \
\
return 0;

Definition at line 758 of file formats.c.

Function Documentation

◆ merge_formats_internal()

static int merge_formats_internal ( AVFilterFormats a,
AVFilterFormats b,
enum AVMediaType  type,
int  check 
)
static

◆ can_merge_pix_fmts()

static int can_merge_pix_fmts ( const void *  a,
const void *  b 
)
static

Check the formats lists for compatibility for merging without actually merging.

Returns
1 if they are compatible, 0 if not.

Definition at line 142 of file formats.c.

◆ merge_pix_fmts()

static int merge_pix_fmts ( void *  a,
void *  b 
)
static

Merge the formats lists if they are compatible and update all the references of a and b to point to the combined list and free the old lists as needed.

The combined list usually contains the intersection of the lists of a and b.

Both a and b must have owners (i.e. refcount > 0) for these functions.

Returns
1 if merging succeeded, 0 if a and b are incompatible and negative AVERROR code on failure. a and b are unmodified if 0 is returned.

Definition at line 160 of file formats.c.

◆ can_merge_sample_fmts()

static int can_merge_sample_fmts ( const void *  a,
const void *  b 
)
static

See can_merge_pix_fmts().

Definition at line 168 of file formats.c.

◆ merge_sample_fmts()

static int merge_sample_fmts ( void *  a,
void *  b 
)
static

See merge_pix_fmts().

Definition at line 177 of file formats.c.

◆ merge_samplerates_internal()

static int merge_samplerates_internal ( AVFilterFormats a,
AVFilterFormats b,
int  check 
)
static

Definition at line 182 of file formats.c.

Referenced by can_merge_samplerates(), and merge_samplerates().

◆ can_merge_samplerates()

static int can_merge_samplerates ( const void *  a,
const void *  b 
)
static

See can_merge_pix_fmts().

Definition at line 195 of file formats.c.

◆ merge_samplerates()

static int merge_samplerates ( void *  a,
void *  b 
)
static

See merge_pix_fmts().

Definition at line 203 of file formats.c.

◆ merge_channel_layouts_internal()

static int merge_channel_layouts_internal ( AVFilterChannelLayouts a,
AVFilterChannelLayouts b,
int  check 
)
static

See merge_pix_fmts().

Definition at line 211 of file formats.c.

Referenced by can_merge_channel_layouts(), and merge_channel_layouts().

◆ can_merge_channel_layouts()

static int can_merge_channel_layouts ( const void *  a,
const void *  b 
)
static

Definition at line 312 of file formats.c.

◆ merge_channel_layouts()

static int merge_channel_layouts ( void *  a,
void *  b 
)
static

Definition at line 318 of file formats.c.

◆ merge_generic_internal()

static int merge_generic_internal ( AVFilterFormats a,
AVFilterFormats b,
int  check 
)
static

Definition at line 323 of file formats.c.

Referenced by can_merge_generic(), and merge_generic().

◆ can_merge_generic()

static int can_merge_generic ( const void *  a,
const void *  b 
)
static

Definition at line 336 of file formats.c.

◆ merge_generic()

static int merge_generic ( void *  a,
void *  b 
)
static

Definition at line 342 of file formats.c.

◆ ff_filter_get_negotiation()

const AVFilterNegotiation* ff_filter_get_negotiation ( AVFilterLink link)

Definition at line 397 of file formats.c.

Referenced by query_formats().

◆ ff_fmt_is_in()

int ff_fmt_is_in ( int  fmt,
const int fmts 
)

Tell if an integer is contained in the provided -1-terminated list of integers.

This is useful for determining (for instance) if an AVPixelFormat is in an array of supported formats.

Parameters
fmtprovided format
fmts-1-terminated list of formats
Returns
1 if present, 0 if absent

Definition at line 406 of file formats.c.

Referenced by config_input(), config_input_main(), config_input_overlay(), config_out_props(), config_props(), filter_frame(), and init().

◆ ff_make_format_list()

AVFilterFormats* ff_make_format_list ( const int fmts)

Create a list of supported formats.

This is intended for use in AVFilter->query_formats().

Parameters
fmtslist of media formats, terminated by -1
Returns
the format list, with no existing references

Definition at line 435 of file formats.c.

Referenced by cudaupload_query_formats(), ff_default_query_formats(), ff_make_formats_list_singleton(), ff_set_common_color_ranges_from_list(), ff_set_common_color_spaces_from_list(), ff_set_common_formats_from_list(), ff_set_common_samplerates_from_list(), ff_vaapi_vpp_query_formats(), hwupload_query_formats(), movie_query_formats(), overlay_qsv_query_formats(), and query_formats().

◆ ff_make_channel_layout_list()

AVFilterChannelLayouts* ff_make_channel_layout_list ( const AVChannelLayout fmts)

◆ ff_add_format()

int ff_add_format ( AVFilterFormats **  avff,
int64_t  fmt 
)

Add fmt to the list of media formats contained in *avff.

If *avff is NULL the function allocates the filter formats struct and puts its pointer in *avff.

Returns
a non negative value in case of success, or a negative value corresponding to an AVERROR code in case of error

Definition at line 504 of file formats.c.

Referenced by asink_query_formats(), ff_all_color_ranges(), ff_all_color_spaces(), ff_all_formats(), ff_draw_supported_pixel_formats(), ff_planar_sample_fmts(), hwupload_query_formats(), init(), libplacebo_query_format(), qrencodesrc_query_formats(), query_formats(), reduce_formats_on_filter(), and vsink_query_formats().

◆ ff_add_channel_layout()

int ff_add_channel_layout ( AVFilterChannelLayouts **  l,
const AVChannelLayout channel_layout 
)

◆ ff_make_formats_list_singleton()

AVFilterFormats* ff_make_formats_list_singleton ( int  fmt)

Equivalent to ff_make_format_list({const int[]}{ fmt, -1 })

Definition at line 529 of file formats.c.

Referenced by ff_default_query_formats(), libplacebo_query_format(), and query_formats().

◆ ff_all_formats()

AVFilterFormats* ff_all_formats ( enum AVMediaType  type)

Return a list of all formats supported by FFmpeg for the given media type.

Definition at line 535 of file formats.c.

Referenced by ff_default_query_formats(), hwmap_query_formats(), init(), and query_formats().

◆ ff_formats_pixdesc_filter()

AVFilterFormats* ff_formats_pixdesc_filter ( unsigned  want,
unsigned  rej 
)

Construct a formats list containing all pixel formats with certain properties.

Definition at line 553 of file formats.c.

Referenced by ff_all_formats(), hwdownload_query_formats(), and query_formats().

◆ ff_planar_sample_fmts()

AVFilterFormats* ff_planar_sample_fmts ( void  )

Construct a formats list containing all planar sample formats.

Definition at line 593 of file formats.c.

Referenced by channelmap_query_formats(), join_query_formats(), and query_formats().

◆ ff_all_samplerates()

AVFilterFormats* ff_all_samplerates ( void  )

Definition at line 606 of file formats.c.

Referenced by ff_set_common_all_samplerates(), and query_formats().

◆ ff_all_channel_layouts()

AVFilterChannelLayouts* ff_all_channel_layouts ( void  )

Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (with known disposition)/sample rate.

Definition at line 612 of file formats.c.

Referenced by join_query_formats(), and query_formats().

◆ ff_all_channel_counts()

AVFilterChannelLayouts* ff_all_channel_counts ( void  )

Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.

Definition at line 621 of file formats.c.

Referenced by aeval_query_formats(), asink_query_formats(), channelmap_query_formats(), ff_set_common_all_channel_counts(), and query_formats().

◆ ff_all_color_spaces()

AVFilterFormats* ff_all_color_spaces ( void  )

Construct an AVFilterFormats representing all possible color spaces.

Note: This list does not include AVCOL_SPC_RESERVED.

Definition at line 630 of file formats.c.

Referenced by ff_set_common_all_color_spaces(), init(), libplacebo_query_format(), and query_formats().

◆ ff_all_color_ranges()

AVFilterFormats* ff_all_color_ranges ( void  )

Construct an AVFilterFormats representing all possible color ranges.

Definition at line 646 of file formats.c.

Referenced by ff_set_common_all_color_ranges(), init(), libplacebo_query_format(), and query_formats().

◆ ff_channel_layouts_ref()

int ff_channel_layouts_ref ( AVFilterChannelLayouts f,
AVFilterChannelLayouts **  ref 
)

◆ ff_formats_ref()

int ff_formats_ref ( AVFilterFormats formats,
AVFilterFormats **  ref 
)

Add *ref as a new reference to formats.

That is the pointers will point like in the ascii art below:


|formats |<-----—. | ____ | ____|___________________ | |refs| | | __|_ | |* * | | | | | | AVFilterLink | |* *------—>|*ref| | |____| | | |____| |________| |________________________

Definition at line 678 of file formats.c.

Referenced by cudaupload_query_formats(), ff_set_common_color_ranges(), ff_set_common_color_spaces(), ff_set_common_formats(), ff_set_common_samplerates(), ff_vaapi_vpp_query_formats(), hwdownload_query_formats(), hwmap_query_formats(), hwupload_query_formats(), init(), libplacebo_query_format(), movie_query_formats(), overlay_qsv_query_formats(), and query_formats().

◆ ff_formats_unref()

void ff_formats_unref ( AVFilterFormats **  ref)

If *ref is non-NULL, remove *ref as a reference to the format list it currently points to, deallocates that list if this was the last reference, and sets *ref to NULL.

    Before                                 After

________ ________ NULL |formats |<-----—. |formats | ^ | ____ | ____|________________ | ____ | ____|________________ | |refs| | | __|_ | |refs| | | __|_ | |* * | | | | | | AVFilterLink | |* * | | | | | | AVFilterLink | |* ------—>|*ref| | | | | | |*ref| | |____| | | |____| | |____| | | |____| |________| |_____________________ |________| |_____________________

Definition at line 717 of file formats.c.

Referenced by ff_add_format(), ff_formats_ref(), ff_set_common_color_ranges(), ff_set_common_color_spaces(), ff_set_common_formats(), ff_set_common_samplerates(), free_link(), invert_formats(), libplacebo_query_format(), pick_format(), and uninit().

◆ ff_channel_layouts_unref()

void ff_channel_layouts_unref ( AVFilterChannelLayouts **  ref)

Remove a reference to a channel layouts list.

Definition at line 729 of file formats.c.

Referenced by ff_add_channel_layout(), ff_channel_layouts_ref(), ff_set_common_channel_layouts(), free_link(), pick_format(), and uninit().

◆ ff_channel_layouts_changeref()

void ff_channel_layouts_changeref ( AVFilterChannelLayouts **  oldref,
AVFilterChannelLayouts **  newref 
)

Definition at line 747 of file formats.c.

Referenced by avfilter_insert_filter().

◆ ff_formats_changeref()

void ff_formats_changeref ( AVFilterFormats **  oldref,
AVFilterFormats **  newref 
)
   Before                                 After

|formats |<------—. |formats |<------—. | ____ | ___|___ | ____ | ___|___ | |refs| | | | | | |refs| | | | | NULL | |* ------—>|*oldref| | | ------—>|*newref| ^ | | * | | |_______| | |* * | | |_______| ___|___ | |____| | | |____| | | | | |________| |________| |*oldref| |_______|

Definition at line 753 of file formats.c.

Referenced by avfilter_insert_filter().

◆ ff_set_common_channel_layouts()

int ff_set_common_channel_layouts ( AVFilterContext ctx,
AVFilterChannelLayouts layouts 
)

Helpers for query_formats() which set all free audio links to the same list of channel layouts/sample rates.

If there are no links hooked to this list, the list is freed.

Definition at line 790 of file formats.c.

Referenced by asink_query_formats(), ff_set_common_all_channel_counts(), ff_set_common_channel_layouts_from_list(), and query_formats().

◆ ff_set_common_channel_layouts_from_list()

int ff_set_common_channel_layouts_from_list ( AVFilterContext ctx,
const AVChannelLayout fmts 
)

Equivalent to ff_set_common_channel_layouts(ctx, ff_make_channel_layout_list(fmts))

Definition at line 797 of file formats.c.

Referenced by query_formats().

◆ ff_set_common_all_channel_counts()

int ff_set_common_all_channel_counts ( AVFilterContext ctx)

Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())

Definition at line 803 of file formats.c.

Referenced by aeval_query_formats(), ff_default_query_formats(), and query_formats().

◆ ff_set_common_samplerates()

int ff_set_common_samplerates ( AVFilterContext ctx,
AVFilterFormats samplerates 
)

◆ ff_set_common_samplerates_from_list()

int ff_set_common_samplerates_from_list ( AVFilterContext ctx,
const int samplerates 
)

Equivalent to ff_set_common_samplerates(ctx, ff_make_format_list(samplerates))

Definition at line 815 of file formats.c.

Referenced by query_formats().

◆ ff_set_common_all_samplerates()

int ff_set_common_all_samplerates ( AVFilterContext ctx)

Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())

Definition at line 821 of file formats.c.

Referenced by aeval_query_formats(), channelmap_query_formats(), ff_default_query_formats(), join_query_formats(), and query_formats().

◆ ff_set_common_color_spaces()

int ff_set_common_color_spaces ( AVFilterContext ctx,
AVFilterFormats color_spaces 
)

◆ ff_set_common_color_spaces_from_list()

int ff_set_common_color_spaces_from_list ( AVFilterContext ctx,
const int color_ranges 
)

Equivalent to ff_set_common_color_spaces(ctx, ff_make_format_list(color_spaces))

Definition at line 833 of file formats.c.

◆ ff_set_common_all_color_spaces()

int ff_set_common_all_color_spaces ( AVFilterContext ctx)

Equivalent to ff_set_common_color_spaces(ctx, ff_all_color_spaces())

Definition at line 839 of file formats.c.

Referenced by ff_default_query_formats(), and ff_vaapi_vpp_query_formats().

◆ ff_set_common_color_ranges()

int ff_set_common_color_ranges ( AVFilterContext ctx,
AVFilterFormats color_ranges 
)

◆ ff_set_common_color_ranges_from_list()

int ff_set_common_color_ranges_from_list ( AVFilterContext ctx,
const int color_ranges 
)

Equivalent to ff_set_common_color_ranges(ctx, ff_make_format_list(color_ranges))

Definition at line 851 of file formats.c.

◆ ff_set_common_all_color_ranges()

int ff_set_common_all_color_ranges ( AVFilterContext ctx)

Equivalent to ff_set_common_color_ranges(ctx, ff_all_color_ranges())

Definition at line 857 of file formats.c.

Referenced by ff_default_query_formats(), and ff_vaapi_vpp_query_formats().

◆ ff_set_common_formats()

int ff_set_common_formats ( AVFilterContext ctx,
AVFilterFormats formats 
)

A helper for query_formats() which sets all links to the same list of formats.

If there are no links hooked to this filter, the list of formats is freed.

Definition at line 867 of file formats.c.

Referenced by asink_query_formats(), channelmap_query_formats(), ff_default_query_formats(), ff_set_common_formats_from_list(), join_query_formats(), qrencode_query_formats(), qrencodesrc_query_formats(), query_formats(), and vsink_query_formats().

◆ ff_set_common_formats_from_list()

int ff_set_common_formats_from_list ( AVFilterContext ctx,
const int fmts 
)

Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))

Definition at line 873 of file formats.c.

Referenced by aeval_query_formats(), geq_query_formats(), qsv_stack_query_formats(), query_formats(), and vaapi_stack_query_formats().

◆ ff_default_query_formats()

int ff_default_query_formats ( AVFilterContext ctx)

Sets all remaining unset filter lists for all inputs/outputs to their corresponding ff_all_*() lists.

Definition at line 878 of file formats.c.

Referenced by filter_query_formats(), and main().

◆ ff_parse_pixel_format()

int ff_parse_pixel_format ( enum AVPixelFormat ret,
const char *  arg,
void *  log_ctx 
)

Parse a pixel format.

Parameters
retpixel format pointer to where the value should be written
argstring to parse
log_ctxlog context
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 939 of file formats.c.

Referenced by init().

◆ ff_parse_sample_rate()

int ff_parse_sample_rate ( int ret,
const char *  arg,
void *  log_ctx 
)

Parse a sample rate.

Parameters
retunsigned integer pointer to where the value should be written
argstring to parse
log_ctxlog context
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 954 of file formats.c.

Referenced by init().

◆ ff_parse_channel_layout()

int ff_parse_channel_layout ( AVChannelLayout ret,
int nret,
const char *  arg,
void *  log_ctx 
)

Parse a channel layout or a corresponding integer representation.

Parameters
ret64bit integer pointer to where the value should be written.
nretinteger pointer to the number of channels; if not NULL, then unknown channel layouts are accepted
argstring to parse
log_ctxlog context
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 966 of file formats.c.

Referenced by init(), and main().

◆ check_list()

static int check_list ( void *  log,
const char *  name,
const AVFilterFormats fmts 
)
static

◆ ff_formats_check_pixel_formats()

int ff_formats_check_pixel_formats ( void *  log,
const AVFilterFormats fmts 
)

Check that fmts is a valid pixel formats list.

In particular, check for duplicates.

Definition at line 1010 of file formats.c.

Referenced by filter_link_check_formats().

◆ ff_formats_check_sample_formats()

int ff_formats_check_sample_formats ( void *  log,
const AVFilterFormats fmts 
)

Check that fmts is a valid sample formats list.

In particular, check for duplicates.

Definition at line 1015 of file formats.c.

Referenced by filter_link_check_formats().

◆ ff_formats_check_sample_rates()

int ff_formats_check_sample_rates ( void *  log,
const AVFilterFormats fmts 
)

Check that fmts is a valid sample rates list.

In particular, check for duplicates.

Definition at line 1020 of file formats.c.

Referenced by filter_link_check_formats().

◆ ff_formats_check_color_spaces()

int ff_formats_check_color_spaces ( void *  log,
const AVFilterFormats fmts 
)

Check that fmts is a valid formats list for YUV colorspace metadata.

In particular, check for duplicates.

Definition at line 1027 of file formats.c.

Referenced by filter_link_check_formats().

◆ ff_formats_check_color_ranges()

int ff_formats_check_color_ranges ( void *  log,
const AVFilterFormats fmts 
)

Definition at line 1038 of file formats.c.

Referenced by filter_link_check_formats().

◆ layouts_compatible()

static int layouts_compatible ( const AVChannelLayout a,
const AVChannelLayout b 
)
static

Definition at line 1043 of file formats.c.

Referenced by ff_formats_check_channel_layouts().

◆ ff_formats_check_channel_layouts()

int ff_formats_check_channel_layouts ( void *  log,
const AVFilterChannelLayouts fmts 
)

Check that fmts is a valid channel layouts list.

In particular, check for duplicates.

Definition at line 1050 of file formats.c.

Referenced by filter_link_check_formats().

Variable Documentation

◆ mergers_video

const AVFilterFormatsMerger mergers_video[]
static
Initial value:
= {
{
.offset = 0x42,
.merge = merge_pix_fmts,
.can_merge = can_merge_pix_fmts,
},
{
.offset = 0x42,
.merge = merge_generic,
.can_merge = can_merge_generic,
},
{
.offset = 0x42,
.merge = merge_generic,
.can_merge = can_merge_generic,
},
}

Definition at line 347 of file formats.c.

◆ mergers_audio

const AVFilterFormatsMerger mergers_audio[]
static
Initial value:
= {
{
.offset = 0x42,
},
{
.offset = 0x42,
.can_merge = can_merge_samplerates,
},
{
.offset = 0x42,
.can_merge = can_merge_sample_fmts,
},
}

Definition at line 365 of file formats.c.

◆ negotiate_video

const AVFilterNegotiation negotiate_video
static
Initial value:
= {
.nb_mergers = FF_ARRAY_ELEMS(mergers_video),
.mergers = mergers_video,
.conversion_filter = "scale",
.conversion_opts_offset = 0x42,
}

Definition at line 383 of file formats.c.

Referenced by ff_filter_get_negotiation().

◆ negotiate_audio

const AVFilterNegotiation negotiate_audio
static
Initial value:
= {
.nb_mergers = FF_ARRAY_ELEMS(mergers_audio),
.mergers = mergers_audio,
.conversion_filter = "aresample",
.conversion_opts_offset = 0x42,
}

Definition at line 390 of file formats.c.

Referenced by ff_filter_get_negotiation().

can_merge_generic
static int can_merge_generic(const void *a, const void *b)
Definition: formats.c:336
formats
formats
Definition: signature.h:48
FIND_REF_INDEX
#define FIND_REF_INDEX(ref, idx)
Definition: formats.c:683
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
can_merge_sample_fmts
static int can_merge_sample_fmts(const void *a, const void *b)
See can_merge_pix_fmts().
Definition: formats.c:168
can_merge_pix_fmts
static int can_merge_pix_fmts(const void *a, const void *b)
Check the formats lists for compatibility for merging without actually merging.
Definition: formats.c:142
merge_generic
static int merge_generic(void *a, void *b)
Definition: formats.c:342
can_merge_channel_layouts
static int can_merge_channel_layouts(const void *a, const void *b)
Definition: formats.c:312
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
mergers_video
static const AVFilterFormatsMerger mergers_video[]
Definition: formats.c:347
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
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:215
ctx
AVFormatContext * ctx
Definition: movenc.c:48
link
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 link
Definition: filter_design.txt:23
if
if(ret)
Definition: filter_design.txt:179
NULL
#define NULL
Definition: coverity.c:32
merge_pix_fmts
static int merge_pix_fmts(void *a, void *b)
Merge the formats lists if they are compatible and update all the references of a and b to point to t...
Definition: formats.c:160
list
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 list
Definition: filter_design.txt:25
merge_samplerates
static int merge_samplerates(void *a, void *b)
See merge_pix_fmts().
Definition: formats.c:203
f
f
Definition: af_crystalizer.c:121
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
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
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:31
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:254
mergers_audio
static const AVFilterFormatsMerger mergers_audio[]
Definition: formats.c:365
merge_channel_layouts
static int merge_channel_layouts(void *a, void *b)
Definition: formats.c:318
ret
ret
Definition: filter_design.txt:187
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:432
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
can_merge_samplerates
static int can_merge_samplerates(const void *a, const void *b)
See can_merge_pix_fmts().
Definition: formats.c:195
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:439
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
merge_sample_fmts
static int merge_sample_fmts(void *a, void *b)
See merge_pix_fmts().
Definition: formats.c:177