FFmpeg
Data Structures | Macros | Functions
formats.h File Reference
#include "avfilter.h"
#include "version.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...
 

Macros

#define FF_COUNT2LAYOUT(c)   (0x8000000000000000ULL | (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 FF_PIX_FMT_FLAG_SW_FLAT_SUB   (1 << 24)
 

Functions

int ff_can_merge_formats (const AVFilterFormats *a, const AVFilterFormats *b, enum AVMediaType type)
 Check the formats/samplerates lists for compatibility for merging without actually merging. More...
 
int ff_can_merge_samplerates (const AVFilterFormats *a, const AVFilterFormats *b)
 
int ff_merge_channel_layouts (AVFilterChannelLayouts *a, AVFilterChannelLayouts *b)
 Merge the formats/channel layouts/samplerates 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...
 
int ff_merge_formats (AVFilterFormats *a, AVFilterFormats *b, enum AVMediaType type)
 
int ff_merge_samplerates (AVFilterFormats *a, AVFilterFormats *b)
 
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_format64_list (const int64_t *fmts)
 
AVFilterChannelLayoutsavfilter_make_format64_list (const int64_t *fmts)
 
av_warn_unused_result int ff_set_common_channel_layouts (AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
 A helper for query_formats() which sets all links to the same list of channel layouts/sample rates. More...
 
av_warn_unused_result int ff_set_common_samplerates (AVFilterContext *ctx, AVFilterFormats *samplerates)
 
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_add_channel_layout (AVFilterChannelLayouts **l, uint64_t 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 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 int ff_formats_pixdesc_filter (AVFilterFormats **rfmts, 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)
 
   Before                                 After

|formats |<------—. More...

 
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...
 

Macro Definition Documentation

#define FF_COUNT2LAYOUT (   c)    (0x8000000000000000ULL | (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 103 of file formats.h.

Referenced by aeval_query_formats(), asink_query_formats(), ff_merge_channel_layouts(), and query_formats().

#define FF_LAYOUT2COUNT (   l)
Value:
(((l) & 0x8000000000000000ULL) ? \
(int)((l) & 0x7FFFFFFF) : 0)
int

Decode a channel count encoded as a channel layout.

Return 0 if the channel layout was a real one.

Definition at line 109 of file formats.h.

Referenced by layouts_compatible(), pick_format(), query_formats(), reduce_formats_on_filter(), and swap_channel_layouts_on_filter().

#define FF_PIX_FMT_FLAG_SW_FLAT_SUB   (1 << 24)

Definition at line 240 of file formats.h.

Referenced by ff_formats_pixdesc_filter(), and query_formats().

Function Documentation

int ff_can_merge_formats ( const AVFilterFormats a,
const AVFilterFormats b,
enum AVMediaType  type 
)

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

Returns
1 if they are compatible, 0 if not.

Definition at line 135 of file formats.c.

Referenced by query_formats().

int ff_can_merge_samplerates ( const AVFilterFormats a,
const AVFilterFormats b 
)

Definition at line 158 of file formats.c.

Referenced by query_formats().

int ff_merge_channel_layouts ( AVFilterChannelLayouts a,
AVFilterChannelLayouts b 
)

Merge the formats/channel layouts/samplerates 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 169 of file formats.c.

int ff_merge_formats ( AVFilterFormats a,
AVFilterFormats b,
enum AVMediaType  type 
)

Definition at line 142 of file formats.c.

int ff_merge_samplerates ( AVFilterFormats a,
AVFilterFormats b 
)

Definition at line 163 of file formats.c.

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

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

av_warn_unused_result AVFilterFormats* ff_all_samplerates ( void  )
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 437 of file formats.c.

Referenced by aeval_query_formats(), asink_query_formats(), channelmap_query_formats(), ff_default_query_formats(), filter_frame(), gate(), process_command(), and query_formats().

av_warn_unused_result AVFilterChannelLayouts* ff_make_format64_list ( const int64_t *  fmts)

Definition at line 296 of file formats.c.

Referenced by avfilter_make_format64_list(), movie_query_formats(), and query_formats().

AVFilterChannelLayouts* avfilter_make_format64_list ( const int64_t *  fmts)

Definition at line 308 of file formats.c.

av_warn_unused_result int ff_set_common_channel_layouts ( AVFilterContext ctx,
AVFilterChannelLayouts layouts 
)

A helper for query_formats() which sets all links to the same list of channel layouts/sample rates.

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

Definition at line 569 of file formats.c.

Referenced by aeval_query_formats(), asink_query_formats(), ff_default_query_formats(), filter_frame(), filter_query_formats(), gate(), process_command(), and query_formats().

av_warn_unused_result int ff_set_common_samplerates ( AVFilterContext ctx,
AVFilterFormats samplerates 
)
av_warn_unused_result int ff_set_common_formats ( AVFilterContext ctx,
AVFilterFormats formats 
)
av_warn_unused_result int ff_add_channel_layout ( AVFilterChannelLayouts **  l,
uint64_t  channel_layout 
)
av_warn_unused_result int ff_channel_layouts_ref ( AVFilterChannelLayouts f,
AVFilterChannelLayouts **  ref 
)
void ff_channel_layouts_unref ( AVFilterChannelLayouts **  ref)

Remove a reference to a channel layouts list.

Definition at line 509 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().

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

Definition at line 527 of file formats.c.

Referenced by avfilter_insert_filter().

av_warn_unused_result int ff_default_query_formats ( AVFilterContext ctx)

Definition at line 594 of file formats.c.

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

av_warn_unused_result AVFilterFormats* ff_make_format_list ( const int fmts)
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 333 of file formats.c.

Referenced by asink_query_formats(), ff_all_formats(), ff_draw_supported_pixel_formats(), ff_planar_sample_fmts(), gate(), hwupload_query_formats(), init(), query_formats(), reduce_formats_on_filter(), and vsink_query_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 346 of file formats.c.

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

av_warn_unused_result int ff_formats_pixdesc_filter ( AVFilterFormats **  rfmts,
unsigned  want,
unsigned  rej 
)

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

Definition at line 368 of file formats.c.

Referenced by hwdownload_query_formats(), and query_formats().

av_warn_unused_result AVFilterFormats* ff_planar_sample_fmts ( void  )

Construct a formats list containing all planar sample formats.

Definition at line 409 of file formats.c.

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

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

Referenced by cudaupload_query_formats(), deint_cuda_query_formats(), ff_set_common_formats(), ff_set_common_samplerates(), ff_vaapi_vpp_query_formats(), hwdownload_query_formats(), hwmap_query_formats(), hwupload_query_formats(), movie_query_formats(), overlay_qsv_query_formats(), query_formats(), and query_formats_src().

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

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

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

   Before                                 After

|formats |<------—.

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

Definition at line 533 of file formats.c.

Referenced by avfilter_insert_filter().

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

Referenced by filter_link_check_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 692 of file formats.c.

Referenced by filter_link_check_formats().

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

Referenced by filter_link_check_formats().

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

Referenced by filter_link_check_formats().