Go to the documentation of this file.
31 #define KNOWN(l) (!FF_LAYOUT2COUNT(l))
36 #define MERGE_REF(ret, a, fmts, type, fail_statement) \
41 if (!(tmp = av_realloc_array(ret->refs, ret->refcount + a->refcount, \
46 for (i = 0; i < a->refcount; i ++) { \
47 ret->refs[ret->refcount] = a->refs[i]; \
48 *ret->refs[ret->refcount++] = ret; \
63 #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed) \
65 int i, j, k = 0, skip = 0; \
67 if (empty_allowed) { \
68 if (!a->nb || !b->nb) { \
72 FFSWAP(type *, a, b); \
77 for (i = 0; i < a->nb; i++) \
78 for (j = 0; j < b->nb; j++) \
79 if (a->fmts[i] == b->fmts[j]) { \
82 a->fmts[k++] = a->fmts[i]; \
93 MERGE_REF(a, b, fmts, type, return AVERROR(ENOMEM);); \
100 int alpha1=0, alpha2=0;
101 int chroma1=0, chroma2=0;
114 for (
i = 0;
i <
a->nb_formats;
i++)
115 for (j = 0; j <
b->nb_formats; j++) {
120 if (
a->formats[
i] ==
b->formats[j]) {
127 if (alpha2 > alpha1 || chroma2 > chroma1)
152 if (
a ==
b)
return 1;
173 unsigned a_all =
a->all_layouts +
a->all_counts;
174 unsigned b_all =
b->all_layouts +
b->all_counts;
175 int ret_max, ret_nb = 0,
i, j,
round;
179 if (
a ==
b)
return 1;
184 FFSWAP(
unsigned, a_all, b_all);
187 if (a_all == 1 && !b_all) {
189 for (
i = j = 0;
i <
b->nb_channel_layouts;
i++)
190 if (
KNOWN(
b->channel_layouts[
i]))
191 b->channel_layouts[j++] =
b->channel_layouts[
i];
196 b->nb_channel_layouts = j;
202 ret_max =
a->nb_channel_layouts +
b->nb_channel_layouts;
207 for (
i = 0;
i <
a->nb_channel_layouts;
i++) {
208 if (!
KNOWN(
a->channel_layouts[
i]))
210 for (j = 0; j <
b->nb_channel_layouts; j++) {
211 if (
a->channel_layouts[
i] ==
b->channel_layouts[j]) {
213 a->channel_layouts[
i] =
b->channel_layouts[j] = 0;
221 for (
i = 0;
i <
a->nb_channel_layouts;
i++) {
222 uint64_t fmt =
a->channel_layouts[
i], bfmt;
223 if (!fmt || !
KNOWN(fmt))
226 for (j = 0; j <
b->nb_channel_layouts; j++)
227 if (
b->channel_layouts[j] == bfmt)
234 for (
i = 0;
i <
a->nb_channel_layouts;
i++) {
235 if (
KNOWN(
a->channel_layouts[
i]))
237 for (j = 0; j <
b->nb_channel_layouts; j++)
238 if (
a->channel_layouts[
i] ==
b->channel_layouts[j])
247 if (
a->refcount >
b->refcount)
254 b->nb_channel_layouts = ret_nb;
262 for (p = fmts; *p != -1; p++) {
269 #define MAKE_FORMAT_LIST(type, field, count_field) \
273 for (count = 0; fmts[count] != -1; count++) \
275 formats = av_mallocz(sizeof(*formats)); \
278 formats->count_field = count; \
280 formats->field = av_malloc_array(count, sizeof(*formats->field)); \
281 if (!formats->field) { \
282 av_freep(&formats); \
291 formats->formats[count] = fmts[count];
301 memcpy(
formats->channel_layouts, fmts,
302 sizeof(*
formats->channel_layouts) * count);
307 #if LIBAVFILTER_VERSION_MAJOR < 8
314 #define ADD_FORMAT(f, fmt, unref_fn, type, list, nb) \
318 if (!(*f) && !(*f = av_mallocz(sizeof(**f)))) { \
319 return AVERROR(ENOMEM); \
322 fmts = av_realloc_array((*f)->list, (*f)->nb + 1, \
323 sizeof(*(*f)->list)); \
326 return AVERROR(ENOMEM); \
330 (*f)->list[(*f)->nb++] = fmt; \
370 unsigned nb_formats, fmt,
flags;
375 for (fmt = 0;; fmt++) {
382 (
desc->log2_chroma_w ||
desc->log2_chroma_h))
384 if ((
flags & (want | rej)) != want)
387 formats->formats[nb_formats] = fmt;
398 formats->nb_formats = nb_formats;
433 ret->all_layouts = 1;
442 ret->all_layouts =
ret->all_counts = 1;
446 #define FORMATS_REF(f, ref, unref_fn) \
450 return AVERROR(ENOMEM); \
452 tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \
455 return AVERROR(ENOMEM); \
458 f->refs[f->refcount++] = ref; \
472 #define FIND_REF_INDEX(ref, idx) \
475 for (i = 0; i < (*ref)->refcount; i ++) \
476 if((*ref)->refs[i] == ref) { \
482 #define FORMATS_UNREF(ref, list) \
489 FIND_REF_INDEX(ref, idx); \
492 memmove((*ref)->refs + idx, (*ref)->refs + idx + 1, \
493 sizeof(*(*ref)->refs) * ((*ref)->refcount - idx - 1)); \
494 --(*ref)->refcount; \
496 if (!(*ref)->refcount) { \
497 av_free((*ref)->list); \
498 av_free((*ref)->refs); \
514 #define FORMATS_CHANGEREF(oldref, newref) \
518 FIND_REF_INDEX(oldref, idx); \
521 (*oldref)->refs[idx] = newref; \
538 #define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn) \
542 return AVERROR(ENOMEM); \
544 for (i = 0; i < ctx->nb_inputs; i++) { \
545 if (ctx->inputs[i] && !ctx->inputs[i]->outcfg.fmts) { \
546 int ret = ref_fn(fmts, &ctx->inputs[i]->outcfg.fmts); \
553 for (i = 0; i < ctx->nb_outputs; i++) { \
554 if (ctx->outputs[i] && !ctx->outputs[i]->incfg.fmts) { \
555 int ret = ref_fn(fmts, &ctx->outputs[i]->incfg.fmts); \
598 ctx->nb_outputs ?
ctx->outputs[0]->type :
637 if (*tail || srate < 1 || (
int)srate != srate || srate > INT_MAX) {
655 if (!chlayout && !nret) {
694 return check_list(log,
"sample format", fmts);
A list of supported channel layouts.
AVPixelFormat
Pixel format.
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
#define FFSWAP(type, a, b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
Iterate over all pixel format descriptors known to libavutil.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
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
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define check(x, y, S, v)
uint64_t * channel_layouts
list of channel layouts
#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.
static enum AVPixelFormat pix_fmt
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.
uint8_t nb_components
The number of components each pixel has, (1-4)
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
char all_layouts
accept any known channel layout
char all_counts
accept any channel layout or count
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
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
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.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
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_get_extended_channel_layout(const char *name, uint64_t *channel_layout, int *nb_channels)
Return a channel layout and the number of channels based on the specified name.
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]
#define flags(name, subs,...)