summaryrefslogtreecommitdiff
path: root/libavfilter/formats.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-06-05 22:43:44 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-06-06 01:08:33 +0200
commitad60b3b1811f6fce23baf8cf081f469244004aae (patch)
tree940b8fe92e81801860c5d010d3031e51cd02511a /libavfilter/formats.h
parent647e2e070f0dbb7055c3a1443de0f5ed3292e0cc (diff)
parentecf79c4d3e8baaf2f303278ef81db6f8407656bc (diff)
downloadffmpeg-ad60b3b1811f6fce23baf8cf081f469244004aae.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: vorbis: Validate that the floor 1 X values contain no duplicates. avprobe: Identify codec probe failures rather than calling them unsupported codecs. avformat: Probe codecs at score 0 on buffer exhaustion conditions. avformat: Factorize codec probing. Indeo Audio decoder imc: make IMDCT support stereo output imc: move channel-specific data into separate context lavfi: remove request/poll and drawing functions from public API on next bump lavfi: make avfilter_insert_pad and pals private on next bump. lavfi: make formats API private on next bump. avplay: use buffersrc instead of custom input filter. avtools: move buffer management code from avconv to cmdutils. avconv: don't use InputStream in the buffer management code. avconv: fix exiting when max frames is reached. mpc8: fix maximum bands handling aacdec: Turn PS off when switching to stereo and turn it to implicit when switching to mono. Conflicts: Changelog cmdutils.h ffmpeg.c ffplay.c ffprobe.c libavcodec/avcodec.h libavcodec/mpc8.c libavcodec/v210dec.h libavcodec/version.h libavcodec/vorbisdec.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/buffersrc.c libavfilter/formats.c libavfilter/src_movie.c libavfilter/vf_aspect.c libavfilter/vf_blackframe.c libavfilter/vf_boxblur.c libavfilter/vf_crop.c libavfilter/vf_cropdetect.c libavfilter/vf_delogo.c libavfilter/vf_drawbox.c libavfilter/vf_drawtext.c libavfilter/vf_fade.c libavfilter/vf_fifo.c libavfilter/vf_format.c libavfilter/vf_frei0r.c libavfilter/vf_gradfun.c libavfilter/vf_hflip.c libavfilter/vf_hqdn3d.c libavfilter/vf_libopencv.c libavfilter/vf_lut.c libavfilter/vf_overlay.c libavfilter/vf_pad.c libavfilter/vf_scale.c libavfilter/vf_select.c libavfilter/vf_showinfo.c libavfilter/vf_transpose.c libavfilter/vf_unsharp.c libavfilter/vf_yadif.c libavfilter/vsrc_color.c libavfilter/vsrc_testsrc.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/formats.h')
-rw-r--r--libavfilter/formats.h138
1 files changed, 138 insertions, 0 deletions
diff --git a/libavfilter/formats.h b/libavfilter/formats.h
index c7503d649a..7e16733b74 100644
--- a/libavfilter/formats.h
+++ b/libavfilter/formats.h
@@ -21,6 +21,56 @@
#include "avfilter.h"
+/**
+ * A list of supported formats for one end of a filter link. This is used
+ * during the format negotiation process to try to pick the best format to
+ * use to minimize the number of necessary conversions. Each filter gives a
+ * list of the formats supported by each input and output pad. The list
+ * given for each pad need not be distinct - they may be references to the
+ * same list of formats, as is often the case when a filter supports multiple
+ * formats, but will always output the same format as it is given in input.
+ *
+ * In this way, a list of possible input formats and a list of possible
+ * output formats are associated with each link. When a set of formats is
+ * negotiated over a link, the input and output lists are merged to form a
+ * new list containing only the common elements of each list. In the case
+ * that there were no common elements, a format conversion is necessary.
+ * Otherwise, the lists are merged, and all other links which reference
+ * either of the format lists involved in the merge are also affected.
+ *
+ * For example, consider the filter chain:
+ * filter (a) --> (b) filter (b) --> (c) filter
+ *
+ * where the letters in parenthesis indicate a list of formats supported on
+ * the input or output of the link. Suppose the lists are as follows:
+ * (a) = {A, B}
+ * (b) = {A, B, C}
+ * (c) = {B, C}
+ *
+ * First, the first link's lists are merged, yielding:
+ * filter (a) --> (a) filter (a) --> (c) filter
+ *
+ * Notice that format list (b) now refers to the same list as filter list (a).
+ * Next, the lists for the second link are merged, yielding:
+ * filter (a) --> (a) filter (a) --> (a) filter
+ *
+ * where (a) = {B}.
+ *
+ * Unfortunately, when the format lists at the two ends of a link are merged,
+ * we must ensure that all links which reference either pre-merge format list
+ * get updated as well. Therefore, we have the format list structure store a
+ * pointer to each of the pointers to itself.
+ */
+#if !FF_API_FILTERS_PUBLIC
+struct AVFilterFormats {
+ unsigned format_count; ///< number of formats
+ int *formats; ///< list of media formats
+
+ unsigned refcount; ///< number of references to this list
+ struct AVFilterFormats ***refs; ///< references to this list
+};
+#endif
+
typedef struct AVFilterChannelLayouts {
uint64_t *channel_layouts; ///< list of channel layouts
int nb_channel_layouts; ///< number of channel layouts
@@ -62,6 +112,13 @@ void ff_set_common_channel_layouts(AVFilterContext *ctx,
void ff_set_common_samplerates(AVFilterContext *ctx,
AVFilterFormats *samplerates);
+/**
+ * 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.
+ */
+void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
+
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout);
/**
@@ -80,4 +137,85 @@ void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref,
int ff_default_query_formats(AVFilterContext *ctx);
+
+/**
+ * Create a list of supported formats. This is intended for use in
+ * AVFilter->query_formats().
+ *
+ * @param fmts list of media formats, terminated by -1
+ * @return the format list, with no existing references
+ */
+AVFilterFormats *ff_make_format_list(const int *fmts);
+
+/**
+ * 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.
+ *
+ * @return a non negative value in case of success, or a negative
+ * value corresponding to an AVERROR code in case of error
+ */
+int ff_add_format(AVFilterFormats **avff, int64_t fmt);
+
+/**
+ * Return a list of all formats supported by Libav for the given media type.
+ */
+AVFilterFormats *ff_all_formats(enum AVMediaType type);
+
+/**
+ * Return a format list which contains the intersection of the formats of
+ * a and b. Also, all the references of a, all the references of b, and
+ * a and b themselves will be deallocated.
+ *
+ * If a and b do not share any common formats, neither is modified, and NULL
+ * is returned.
+ */
+AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
+
+/**
+ * Add *ref as a new reference to formats.
+ * That is the pointers will point like in the ascii art below:
+ * ________
+ * |formats |<--------.
+ * | ____ | ____|___________________
+ * | |refs| | | __|_
+ * | |* * | | | | | | AVFilterLink
+ * | |* *--------->|*ref|
+ * | |____| | | |____|
+ * |________| |________________________
+ */
+void ff_formats_ref(AVFilterFormats *formats, 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|
+ * | |____| | | |____| | |____| | | |____|
+ * |________| |_____________________ |________| |_____________________
+ */
+void ff_formats_unref(AVFilterFormats **ref);
+
+/**
+ *
+ * Before After
+ * ________ ________
+ * |formats |<---------. |formats |<---------.
+ * | ____ | ___|___ | ____ | ___|___
+ * | |refs| | | | | | |refs| | | | | NULL
+ * | |* *--------->|*oldref| | |* *--------->|*newref| ^
+ * | |* * | | |_______| | |* * | | |_______| ___|___
+ * | |____| | | |____| | | | |
+ * |________| |________| |*oldref|
+ * |_______|
+ */
+void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref);
+
#endif // AVFILTER_FORMATS_H