History

lavfi: add query_func2()

It differs from query_func() in accepting arrays of input/output format configurations to be filled as callback parameters. This allows to mark the filter context as const, ensuring it is not modified by this function, as it is not supposed to have any side effects beyond returning the supported formats.

Anton Khirnov committed 2 years ago

Commit eddffbe1 parent 01f2d956 files · +347 −36Browse files

Showing the changes to libavfilter/avfilter.h (1 of 6 files). Show all

Unified · Split

libavfilter/avfilter.h+50−35
@@ -98,6 +98,41 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx); · 97 unmodified lines
9898 */
9999 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
100100
101+/**
102+ * Lists of formats / etc. supported by an end of a link.
103+ *
104+ * This structure is directly part of AVFilterLink, in two copies:
105+ * one for the source filter, one for the destination filter.
106+
107+ * These lists are used for negotiating the format to actually be used,
108+ * which will be loaded into the format and channel_layout members of
109+ * AVFilterLink, when chosen.
110+ */
111+typedef struct AVFilterFormatsConfig {
112+
113+ /**
114+ * List of supported formats (pixel or sample).
115+ */
116+ AVFilterFormats *formats;
117+
118+ /**
119+ * Lists of supported sample rates, only for audio.
120+ */
121+ AVFilterFormats *samplerates;
122+
123+ /**
124+ * Lists of supported channel layouts, only for audio.
125+ */
126+ AVFilterChannelLayouts *channel_layouts;
127+
128+ /**
129+ * Lists of supported YUV color metadata, only for YUV video.
130+ */
131+ AVFilterFormats *color_spaces; ///< AVColorSpace
132+ AVFilterFormats *color_ranges; ///< AVColorRange
133+
134+} AVFilterFormatsConfig;
135+
101136 /**
102137 * The number of the filter inputs is not determined just by AVFilter.inputs.
103138 * The filter might add additional inputs during initialization depending on the
@@ -324,6 +359,21 @@ typedef struct AVFilter { · 220 unmodified lines
324359 * AVERROR code otherwise
325360 */
326361 int (*query_func)(AVFilterContext *);
362+
363+ /**
364+ * Same as query_func(), except this function writes the results into
365+ * provided arrays.
366+ *
367+ * @param cfg_in array of input format configurations with as many
368+ * members as the filters has inputs (NULL when there are
369+ * no inputs);
370+ * @param cfg_out array of output format configurations with as many
371+ * members as the filters has outputs (NULL when there
372+ * are no outputs);
373+ */
374+ int (*query_func2)(const AVFilterContext *,
375+ struct AVFilterFormatsConfig **cfg_in,
376+ struct AVFilterFormatsConfig **cfg_out);
327377 /**
328378 * A pointer to an array of admissible pixel formats delimited
329379 * by AV_PIX_FMT_NONE. The generic code will use this list
@@ -492,41 +542,6 @@ struct AVFilterContext { · 162 unmodified lines
492542 int extra_hw_frames;
493543 };
494544
495−/**
496− * Lists of formats / etc. supported by an end of a link.
497− *
498− * This structure is directly part of AVFilterLink, in two copies:
499− * one for the source filter, one for the destination filter.
500−
501− * These lists are used for negotiating the format to actually be used,
502− * which will be loaded into the format and channel_layout members of
503− * AVFilterLink, when chosen.
504− */
505−typedef struct AVFilterFormatsConfig {
506−
507− /**
508− * List of supported formats (pixel or sample).
509− */
510− AVFilterFormats *formats;
511−
512− /**
513− * Lists of supported sample rates, only for audio.
514− */
515− AVFilterFormats *samplerates;
516−
517− /**
518− * Lists of supported channel layouts, only for audio.
519− */
520− AVFilterChannelLayouts *channel_layouts;
521−
522− /**
523− * Lists of supported YUV color metadata, only for YUV video.
524− */
525− AVFilterFormats *color_spaces; ///< AVColorSpace
526− AVFilterFormats *color_ranges; ///< AVColorRange
527−
528−} AVFilterFormatsConfig;
529−
530545 /**
531546 * A link between two filters. This contains pointers to the source and
532547 * destination filters between which this link exists, and the indexes of

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t