FFmpeg
Data Structures | Macros | Functions
formats.h File Reference
#include "avfilter.h"

Go to the source code of this file.

Data Structures

struct  AVFilterFormats
 A list of supported formats for one end of a filter link. More...
 
struct  AVFilterChannelLayouts
 A list of supported channel layouts. More...
 
struct  AVFilterFormatMerger
 
struct  AVFilterNegotiation
 Callbacks and properties to describe the steps of a format negotiation. More...
 

Macros

#define FF_COUNT2LAYOUT(c)   ((AVChannelLayout) { .order = AV_CHANNEL_ORDER_UNSPEC, .nb_channels = c })
 Encode a channel count as a channel layout. More...
 
#define FF_LAYOUT2COUNT(l)
 Decode a channel count encoded as a channel layout. More...
 
#define KNOWN(l)   (!FF_LAYOUT2COUNT(l)) /* for readability */
 
#define FF_PIX_FMT_FLAG_SW_FLAT_SUB   (1 << 24)
 

Functions

av_warn_unused_result AVFilterChannelLayoutsff_all_channel_layouts (void)
 Construct an empty AVFilterChannelLayouts/AVFilterFormats struct – representing any channel layout (with known disposition)/sample rate. More...
 
av_warn_unused_result AVFilterFormatsff_all_samplerates (void)
 
av_warn_unused_result AVFilterChannelLayoutsff_all_channel_counts (void)
 Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition. More...
 
av_warn_unused_result AVFilterChannelLayoutsff_make_channel_layout_list (const AVChannelLayout *fmts)
 
av_warn_unused_result 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. More...
 
av_warn_unused_result 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...
 
av_warn_unused_result int ff_set_common_all_channel_counts (AVFilterContext *ctx)
 Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts()) More...
 
av_warn_unused_result int ff_set_common_samplerates (AVFilterContext *ctx, AVFilterFormats *samplerates)
 
av_warn_unused_result 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...
 
av_warn_unused_result int ff_set_common_all_samplerates (AVFilterContext *ctx)
 Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates()) More...
 
av_warn_unused_result 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...
 
av_warn_unused_result 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...
 
av_warn_unused_result int ff_add_channel_layout (AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout)
 
av_warn_unused_result int ff_channel_layouts_ref (AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
 Add *ref as a new reference to f. 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)
 
av_warn_unused_result int ff_default_query_formats (AVFilterContext *ctx)
 
av_warn_unused_result AVFilterFormatsff_make_format_list (const int *fmts)
 Create a list of supported formats. More...
 
av_warn_unused_result AVFilterFormatsff_make_formats_list_singleton (int fmt)
 Equivalent to ff_make_format_list({const int[]}{ fmt, -1 }) More...
 
av_warn_unused_result int ff_add_format (AVFilterFormats **avff, int64_t fmt)
 Add fmt to the list of media formats contained in *avff. More...
 
av_warn_unused_result AVFilterFormatsff_all_formats (enum AVMediaType type)
 Return a list of all formats supported by FFmpeg for the given media type. More...
 
av_warn_unused_result AVFilterFormatsff_formats_pixdesc_filter (unsigned want, unsigned rej)
 Construct a formats list containing all pixel formats with certain properties. More...
 
av_warn_unused_result AVFilterFormatsff_planar_sample_fmts (void)
 Construct a formats list containing all planar sample formats. More...
 
av_warn_unused_result int ff_formats_ref (AVFilterFormats *formats, 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_formats_changeref (AVFilterFormats **oldref, AVFilterFormats **newref)
 
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_channel_layouts (void *log, const AVFilterChannelLayouts *fmts)
 Check that fmts is a valid channel layouts list. More...
 
const AVFilterNegotiationff_filter_get_negotiation (AVFilterLink *link)
 

Macro Definition Documentation

◆ FF_COUNT2LAYOUT

#define FF_COUNT2LAYOUT (   c)    ((AVChannelLayout) { .order = AV_CHANNEL_ORDER_UNSPEC, .nb_channels = c })

Encode a channel count as a channel layout.

FF_COUNT2LAYOUT(c) means any channel layout with c channels, with a known or unknown disposition. The result is only valid inside AVFilterChannelLayouts and immediately related functions.

Definition at line 102 of file formats.h.

◆ FF_LAYOUT2COUNT

#define FF_LAYOUT2COUNT (   l)
Value:
(((l)->order == AV_CHANNEL_ORDER_UNSPEC) ? \
(l)->nb_channels : 0)

Decode a channel count encoded as a channel layout.

Return 0 if the channel layout was a real one.

Definition at line 108 of file formats.h.

◆ KNOWN

#define KNOWN (   l)    (!FF_LAYOUT2COUNT(l)) /* for readability */

Definition at line 111 of file formats.h.

◆ FF_PIX_FMT_FLAG_SW_FLAT_SUB

#define FF_PIX_FMT_FLAG_SW_FLAT_SUB   (1 << 24)

Definition at line 245 of file formats.h.

Function Documentation

◆ ff_all_channel_layouts()

av_warn_unused_result AVFilterChannelLayouts* ff_all_channel_layouts ( void  )

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

Definition at line 557 of file formats.c.

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

◆ ff_all_samplerates()

av_warn_unused_result AVFilterFormats* ff_all_samplerates ( void  )

Definition at line 551 of file formats.c.

Referenced by ff_set_common_all_samplerates(), and query_formats().

◆ ff_all_channel_counts()

av_warn_unused_result AVFilterChannelLayouts* ff_all_channel_counts ( void  )

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

Definition at line 566 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_make_channel_layout_list()

av_warn_unused_result AVFilterChannelLayouts* ff_make_channel_layout_list ( const AVChannelLayout fmts)

◆ ff_set_common_channel_layouts()

av_warn_unused_result 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 708 of file formats.c.

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

◆ ff_set_common_channel_layouts_from_list()

av_warn_unused_result 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 715 of file formats.c.

Referenced by query_formats().

◆ ff_set_common_all_channel_counts()

av_warn_unused_result int ff_set_common_all_channel_counts ( AVFilterContext ctx)

Equivalent to ff_set_common_channel_layouts(ctx, ff_all_channel_counts())

Definition at line 721 of file formats.c.

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

◆ ff_set_common_samplerates()

av_warn_unused_result int ff_set_common_samplerates ( AVFilterContext ctx,
AVFilterFormats samplerates 
)

◆ ff_set_common_samplerates_from_list()

av_warn_unused_result 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 733 of file formats.c.

Referenced by query_formats().

◆ ff_set_common_all_samplerates()

av_warn_unused_result int ff_set_common_all_samplerates ( AVFilterContext ctx)

Equivalent to ff_set_common_samplerates(ctx, ff_all_samplerates())

Definition at line 739 of file formats.c.

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

◆ ff_set_common_formats()

av_warn_unused_result 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 749 of file formats.c.

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

◆ ff_set_common_formats_from_list()

av_warn_unused_result 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 755 of file formats.c.

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

◆ ff_add_channel_layout()

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

◆ ff_channel_layouts_ref()

av_warn_unused_result int ff_channel_layouts_ref ( AVFilterChannelLayouts f,
AVFilterChannelLayouts **  ref 
)

◆ ff_channel_layouts_unref()

void ff_channel_layouts_unref ( AVFilterChannelLayouts **  ref)

Remove a reference to a channel layouts list.

Definition at line 647 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 665 of file formats.c.

Referenced by avfilter_insert_filter().

◆ ff_default_query_formats()

av_warn_unused_result int ff_default_query_formats ( AVFilterContext ctx)

Definition at line 760 of file formats.c.

Referenced by main(), query_formats(), and vsink_query_formats().

◆ ff_make_format_list()

av_warn_unused_result 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 380 of file formats.c.

Referenced by cudaupload_query_formats(), ff_default_query_formats(), ff_make_formats_list_singleton(), 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_formats_list_singleton()

av_warn_unused_result AVFilterFormats* ff_make_formats_list_singleton ( int  fmt)

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

Definition at line 474 of file formats.c.

Referenced by ff_default_query_formats().

◆ ff_add_format()

av_warn_unused_result 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 449 of file formats.c.

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

◆ ff_all_formats()

av_warn_unused_result AVFilterFormats* ff_all_formats ( enum AVMediaType  type)

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

Definition at line 480 of file formats.c.

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

◆ ff_formats_pixdesc_filter()

av_warn_unused_result AVFilterFormats* ff_formats_pixdesc_filter ( unsigned  want,
unsigned  rej 
)

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

Definition at line 498 of file formats.c.

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

◆ ff_planar_sample_fmts()

av_warn_unused_result AVFilterFormats* ff_planar_sample_fmts ( void  )

Construct a formats list containing all planar sample formats.

Definition at line 538 of file formats.c.

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

◆ ff_formats_ref()

av_warn_unused_result 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 596 of file formats.c.

Referenced by cudaupload_query_formats(), ff_set_common_formats(), ff_set_common_samplerates(), ff_vaapi_vpp_query_formats(), hwdownload_query_formats(), hwmap_query_formats(), hwupload_query_formats(), 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 635 of file formats.c.

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

◆ ff_formats_changeref()

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

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

Definition at line 671 of file formats.c.

Referenced by avfilter_insert_filter().

◆ 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 899 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 904 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 909 of file formats.c.

Referenced by filter_link_check_formats().

◆ 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 923 of file formats.c.

Referenced by filter_link_check_formats().

◆ ff_filter_get_negotiation()

const AVFilterNegotiation* ff_filter_get_negotiation ( AVFilterLink link)

Definition at line 342 of file formats.c.

Referenced by query_formats().

AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112