Go to the documentation of this file.
34 #define MERGE_REF(ret, a, fmts, type, fail_statement) \
39 if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \
44 for (i = 0; i < a->refcount; i ++) { \
45 ret->refs[ret->refcount] = a->refs[i]; \
46 *ret->refs[ret->refcount++] = ret; \
61 #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed) \
63 int i, j, k = 0, skip = 0; \
65 if (empty_allowed) { \
66 if (!a->nb || !b->nb) { \
70 FFSWAP(type *, a, b); \
75 for (i = 0; i < a->nb; i++) \
76 for (j = 0; j < b->nb; j++) \
77 if (a->fmts[i] == b->fmts[j]) { \
80 a->fmts[k++] = a->fmts[i]; \
91 MERGE_REF(a, b, fmts, type, return AVERROR(ENOMEM);); \
98 int alpha1=0, alpha2=0;
99 int chroma1=0, chroma2=0;
114 for (
i = 0;
i <
a->nb_formats;
i++) {
116 for (j = 0; j <
b->nb_formats; j++) {
120 if (
a->formats[
i] ==
b->formats[j]) {
128 if (alpha2 > alpha1 || chroma2 > chroma1)
187 if (
a ==
b)
return 1;
216 unsigned a_all =
a->all_layouts +
a->all_counts;
217 unsigned b_all =
b->all_layouts +
b->all_counts;
218 int ret_max, ret_nb = 0,
i, j,
round;
222 if (
a ==
b)
return 1;
227 FFSWAP(
unsigned, a_all, b_all);
230 if (a_all == 1 && !b_all) {
232 for (
i = j = 0;
i <
b->nb_channel_layouts;
i++)
233 if (
KNOWN(&
b->channel_layouts[
i]) &&
i != j++) {
242 b->nb_channel_layouts = j;
248 ret_max =
a->nb_channel_layouts +
b->nb_channel_layouts;
253 for (
i = 0;
i <
a->nb_channel_layouts;
i++) {
254 if (!
KNOWN(&
a->channel_layouts[
i]))
256 for (j = 0; j <
b->nb_channel_layouts; j++) {
270 for (
i = 0;
i <
a->nb_channel_layouts;
i++) {
275 for (j = 0; j <
b->nb_channel_layouts; j++)
286 for (
i = 0;
i <
a->nb_channel_layouts;
i++) {
287 if (
KNOWN(&
a->channel_layouts[
i]))
289 for (j = 0; j <
b->nb_channel_layouts; j++)
302 if (
a->refcount >
b->refcount)
309 b->nb_channel_layouts = ret_nb;
387 .conversion_filter =
"scale",
394 .conversion_filter =
"aresample",
400 switch (
link->type) {
403 default:
return NULL;
411 for (p = fmts; *p != -1; p++) {
418 #define MAKE_FORMAT_LIST(type, field, count_field) \
422 for (count = 0; fmts[count] != -1; count++) \
424 formats = av_mallocz(sizeof(*formats)); \
427 formats->count_field = count; \
429 formats->field = av_malloc_array(count, sizeof(*formats->field)); \
430 if (!formats->field) { \
431 av_freep(&formats); \
440 formats->formats[count] = fmts[count];
463 for (
int i = 0;
i < count;
i++) {
473 for (
int i = 0;
i < count;
i++)
481 #define ADD_FORMAT(f, fmt, unref_fn, type, list, nb) \
485 if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \
486 return AVERROR(ENOMEM); \
489 fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \
490 sizeof(*(*f)->list)); \
493 return AVERROR(ENOMEM); \
497 ASSIGN_FMT(f, fmt, list, nb); \
500 #define ASSIGN_FMT(f, fmt, list, nb) \
502 (*f)->list[(*f)->nb++] = fmt; \
512 #define ASSIGN_FMT(f, fmt, list, nb) \
515 memset((*f)->list + (*f)->nb, 0, sizeof(*(*f)->list)); \
516 ret = av_channel_layout_copy(&(*f)->list[(*f)->nb], fmt); \
532 int fmts[2] = { fmt, -1 };
556 unsigned nb_formats, fmt,
flags;
561 for (fmt = 0;; fmt++) {
568 (
desc->log2_chroma_w ||
desc->log2_chroma_h))
570 if ((
flags & (want | rej)) != want)
573 formats->formats[nb_formats] = fmt;
583 formats->nb_formats = nb_formats;
618 ret->all_layouts = 1;
627 ret->all_layouts =
ret->all_counts = 1;
658 #define FORMATS_REF(f, ref, unref_fn) \
662 return AVERROR(ENOMEM); \
664 tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
667 return AVERROR(ENOMEM); \
670 f->refs[f->refcount++] = ref; \
684 #define FIND_REF_INDEX(ref, idx) \
687 for (i = 0; i < (*ref)->refcount; i ++) \
688 if((*ref)->refs[i] == ref) { \
694 #define FORMATS_UNREF(ref, list) \
701 FIND_REF_INDEX(ref, idx); \
704 memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \
705 sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \
706 --(*ref)->refcount; \
708 if (!(*ref)->refcount) { \
709 FREE_LIST(ref, list); \
710 av_free((*ref)->list); \
711 av_free((*ref)->refs); \
717 #define FREE_LIST(ref, list) do { } while(0)
724 #define FREE_LIST(ref, list) \
726 for (int i = 0; i < (*ref)->nb_channel_layouts; i++) \
727 av_channel_layout_uninit(&(*ref)->list[i]); \
735 #define FORMATS_CHANGEREF(oldref, newref) \
739 FIND_REF_INDEX(oldref, idx); \
742 (*oldref)->refs[idx] = newref; \
759 #define SET_COMMON_FORMATS(ctx, fmts, media_type, ref_fn, unref_fn) \
763 return AVERROR(ENOMEM); \
765 for (i = 0; i < ctx->nb_inputs; i++) { \
766 AVFilterLink *const link = ctx->inputs[i]; \
767 if (link && !link->outcfg.fmts && \
768 (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
769 int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \
775 for (i = 0; i < ctx->nb_outputs; i++) { \
776 AVFilterLink *const link = ctx->outputs[i]; \
777 if (link && !link->incfg.fmts && \
778 (media_type == AVMEDIA_TYPE_UNKNOWN || link->type == media_type)) { \
779 int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \
786 if (!fmts->refcount) \
817 const int *samplerates)
835 const int *color_ranges)
853 const int *color_ranges)
879 #define SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, fmts, media_type, \
882 return AVERROR(ENOMEM); \
884 for (unsigned i = 0; i < ctx->nb_inputs; i++) { \
885 const AVFilterLink *const link = ctx->inputs[i]; \
886 if (!cfg_in[i]->fmts && \
887 (media_type == AVMEDIA_TYPE_UNKNOWN || \
888 link->type == media_type)) { \
889 int ret = ref_fn(fmts, &cfg_in[i]->fmts); \
895 for (unsigned i = 0; i < ctx->nb_outputs; i++) { \
896 const AVFilterLink *const link = ctx->outputs[i]; \
897 if (!cfg_out[i]->fmts && \
898 (media_type == AVMEDIA_TYPE_UNKNOWN || \
899 link->type == media_type)) { \
900 int ret = ref_fn(fmts, &cfg_out[i]->fmts); \
907 if (!fmts->refcount) \
948 const int *samplerates)
972 const int *color_ranges)
996 const int *color_ranges)
1033 switch (
f->formats_state) {
1058 ctx->nb_outputs ?
ctx->outputs[0]->type :
A list of supported channel layouts.
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
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
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AVCOL_SPC_NB
Not part of ABI.
@ FF_FILTER_FORMATS_SINGLE_PIXFMT
formats.pix_fmt active
int nb_channels
Number of channels in this layout.
A link between two filters.
@ AVCOL_SPC_RESERVED
reserved for future use by ITU-T and ISO/IEC just like 15-255 are
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
@ AVCOL_RANGE_NB
Not part of ABI.
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
Callbacks and properties to describe the steps of a format negotiation.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
#define check(x, y, S, v)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
char * aresample_swr_opts
swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
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
uint8_t nb_components
The number of components each pixel has, (1-4)
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
@ FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
formats.sample_fmt active.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
An AVChannelLayout holds information about the channel layout of audio data.
AVChannelLayout * channel_layouts
list of channel layouts
char all_layouts
accept any known channel layout
char all_counts
accept any channel layout or count
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
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
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
@ FF_FILTER_FORMATS_PASSTHROUGH
The default value meaning that this filter supports all formats and (for audio) sample rates and chan...
#define i(width, name, range_min, range_max)
static av_always_inline av_const double round(double x)
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
#define av_malloc_array(a, b)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
AVSampleFormat
Audio sample formats.
static const AVChannelLayout ch_layouts[]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * av_calloc(size_t nmemb, size_t size)
#define FFSWAP(type, a, b)
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
@ FF_FILTER_FORMATS_QUERY_FUNC2
formats.query_func2 active.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
static int ref[MAX_W *MAX_W]
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
int nb_channel_layouts
number of channel layouts
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const uint16_t channel_layouts[7]
@ FF_FILTER_FORMATS_SAMPLEFMTS_LIST
formats.samples_list active.
#define flags(name, subs,...)
@ FF_FILTER_FORMATS_PIXFMT_LIST
formats.pixels_list active.