lavfi: make AVFilterPad opaque after two major bumps.
authorAnton Khirnov <anton@khirnov.net>
Tue, 12 Jun 2012 18:12:42 +0000 (20:12 +0200)
committerAnton Khirnov <anton@khirnov.net>
Wed, 13 Jun 2012 09:11:33 +0000 (11:11 +0200)
It will allow adding new fields to it without ABI breaks.

39 files changed:
avconv.c
libavfilter/af_anull.c
libavfilter/asink_anullsink.c
libavfilter/asrc_anullsrc.c
libavfilter/avfilter.h
libavfilter/buffersrc.c
libavfilter/internal.h
libavfilter/version.h
libavfilter/vf_aspect.c
libavfilter/vf_blackframe.c
libavfilter/vf_boxblur.c
libavfilter/vf_copy.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_fieldorder.c
libavfilter/vf_format.c
libavfilter/vf_frei0r.c
libavfilter/vf_gradfun.c
libavfilter/vf_hflip.c
libavfilter/vf_hqdn3d.c
libavfilter/vf_null.c
libavfilter/vf_pad.c
libavfilter/vf_pixdesctest.c
libavfilter/vf_scale.c
libavfilter/vf_setpts.c
libavfilter/vf_showinfo.c
libavfilter/vf_slicify.c
libavfilter/vf_transpose.c
libavfilter/vf_unsharp.c
libavfilter/vf_vflip.c
libavfilter/vsink_nullsink.c
libavfilter/vsrc_color.c
libavfilter/vsrc_movie.c
libavfilter/vsrc_nullsrc.c
libavfilter/vsrc_testsrc.c

index 293f839ee5b8d97954f160e5db10acd2483d8309..2ed590d086d4b93dc24a652a53d0ecf65e3d8045 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -548,7 +548,7 @@ static FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost)
 static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
 {
     InputStream *ist;
-    enum AVMediaType type = in->filter_ctx->input_pads[in->pad_idx].type;
+    enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
     int i;
 
     // TODO: support other filter types
@@ -789,7 +789,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
                                                                    \
     avio_printf(pb, "%s", ctx->filter->name);                      \
     if (nb_pads > 1)                                               \
-        avio_printf(pb, ":%s", pads[inout->pad_idx].name);         \
+        avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\
     avio_w8(pb, 0);                                                \
     avio_close_dyn_buf(pb, &f->name);                              \
 }
@@ -799,7 +799,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFil
     av_freep(&ofilter->name);
     DESCRIBE_FILTER_LINK(ofilter, out, 0);
 
-    switch (out->filter_ctx->output_pads[out->pad_idx].type) {
+    switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
     case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out);
     case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out);
     default: av_assert0(0);
@@ -913,7 +913,7 @@ static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter,
     av_freep(&ifilter->name);
     DESCRIBE_FILTER_LINK(ifilter, in, 1);
 
-    switch (in->filter_ctx->input_pads[in->pad_idx].type) {
+    switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) {
     case AVMEDIA_TYPE_VIDEO: return configure_input_video_filter(fg, ifilter, in);
     case AVMEDIA_TYPE_AUDIO: return configure_input_audio_filter(fg, ifilter, in);
     default: av_assert0(0);
@@ -4112,7 +4112,8 @@ static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
 {
     OutputStream *ost;
 
-    switch (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type) {
+    switch (avfilter_pad_get_type(ofilter->out_tmp->filter_ctx->output_pads,
+                                  ofilter->out_tmp->pad_idx)) {
     case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break;
     case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break;
     default:
@@ -4191,7 +4192,8 @@ static void opt_output_file(void *optctx, const char *filename)
             if (!ofilter->out_tmp || ofilter->out_tmp->name)
                 continue;
 
-            switch (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type) {
+            switch (avfilter_pad_get_type(ofilter->out_tmp->filter_ctx->output_pads,
+                                          ofilter->out_tmp->pad_idx)) {
             case AVMEDIA_TYPE_VIDEO:    o->video_disable    = 1; break;
             case AVMEDIA_TYPE_AUDIO:    o->audio_disable    = 1; break;
             case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
index 59b275c7670cdc7153c6bc2398a702ba6746986f..294586e1f3d3d01d762a623670e205f6a739e6a6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "audio.h"
 #include "avfilter.h"
+#include "internal.h"
 
 AVFilter avfilter_af_anull = {
     .name      = "anull",
index 3a505e79f21f1af0da028b4f67b5ec205a9ea6c9..b527850d4a2139df19f849f2ae84c36102598aa1 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "avfilter.h"
+#include "internal.h"
 
 static void null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) { }
 
index 8e99012faf6dac724ff26f632f877f30650fff06..6f1c1e78a4b3f28558c0a58b32c7d1689e8dfef7 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "avfilter.h"
+#include "internal.h"
 #include "libavutil/audioconvert.h"
 
 typedef struct {
index 7ee18fbce6938065264643d649fff0dd6d54a3a2..157e72fe2afe6e122ee82cccc271cfbd799ab4be 100644 (file)
@@ -235,8 +235,14 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
  */
 #endif
 
+#if FF_API_AVFILTERPAD_PUBLIC
 /**
  * A filter pad used for either input or output.
+ *
+ * @warning this struct will be removed from public API.
+ * users should call avfilter_pad_get_name() and avfilter_pad_get_type()
+ * to access the name and type fields; there should be no need to access
+ * any other fields from outside of libavfilter.
  */
 struct AVFilterPad {
     /**
@@ -358,6 +364,7 @@ struct AVFilterPad {
      */
     int (*config_props)(AVFilterLink *link);
 };
+#endif
 
 /**
  * Get the name of an AVFilterPad.
index 3ffab6039837cfb50aefacaa9c573c9e45d39326..ad9f45bd5d0cbf8fdac9d56719b9ebdf427c595b 100644 (file)
@@ -27,6 +27,7 @@
 #include "avfilter.h"
 #include "buffersrc.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "vsrc_buffer.h"
 
index 4b53831063dfc26b5992bf00299f10516f114ca9..f6dc74b082401ffc5b3261a76ea64ff5d7ef8126 100644 (file)
 
 #include "avfilter.h"
 
+#if !FF_API_AVFILTERPAD_PUBLIC
+/**
+ * A filter pad used for either input or output.
+ */
+struct AVFilterPad {
+    /**
+     * Pad name. The name is unique among inputs and among outputs, but an
+     * input may have the same name as an output. This may be NULL if this
+     * pad has no need to ever be referenced by name.
+     */
+    const char *name;
+
+    /**
+     * AVFilterPad type.
+     */
+    enum AVMediaType type;
+
+    /**
+     * Minimum required permissions on incoming buffers. Any buffer with
+     * insufficient permissions will be automatically copied by the filter
+     * system to a new buffer which provides the needed access permissions.
+     *
+     * Input pads only.
+     */
+    int min_perms;
+
+    /**
+     * Permissions which are not accepted on incoming buffers. Any buffer
+     * which has any of these permissions set will be automatically copied
+     * by the filter system to a new buffer which does not have those
+     * permissions. This can be used to easily disallow buffers with
+     * AV_PERM_REUSE.
+     *
+     * Input pads only.
+     */
+    int rej_perms;
+
+    /**
+     * Callback called before passing the first slice of a new frame. If
+     * NULL, the filter layer will default to storing a reference to the
+     * picture inside the link structure.
+     *
+     * Input video pads only.
+     */
+    void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
+
+    /**
+     * Callback function to get a video buffer. If NULL, the filter system will
+     * use avfilter_default_get_video_buffer().
+     *
+     * Input video pads only.
+     */
+    AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
+
+    /**
+     * Callback function to get an audio buffer. If NULL, the filter system will
+     * use avfilter_default_get_audio_buffer().
+     *
+     * Input audio pads only.
+     */
+    AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
+                                           int nb_samples);
+
+    /**
+     * Callback called after the slices of a frame are completely sent. If
+     * NULL, the filter layer will default to releasing the reference stored
+     * in the link structure during start_frame().
+     *
+     * Input video pads only.
+     */
+    void (*end_frame)(AVFilterLink *link);
+
+    /**
+     * Slice drawing callback. This is where a filter receives video data
+     * and should do its processing.
+     *
+     * Input video pads only.
+     */
+    void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
+
+    /**
+     * Samples filtering callback. This is where a filter receives audio data
+     * and should do its processing.
+     *
+     * Input audio pads only.
+     */
+    void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
+
+    /**
+     * Frame poll callback. This returns the number of immediately available
+     * samples. It should return a positive value if the next request_frame()
+     * is guaranteed to return one frame (with no delay).
+     *
+     * Defaults to just calling the source poll_frame() method.
+     *
+     * Output pads only.
+     */
+    int (*poll_frame)(AVFilterLink *link);
+
+    /**
+     * Frame request callback. A call to this should result in at least one
+     * frame being output over the given link. This should return zero on
+     * success, and another value on error.
+     *
+     * Output pads only.
+     */
+    int (*request_frame)(AVFilterLink *link);
+
+    /**
+     * Link configuration callback.
+     *
+     * For output pads, this should set the link properties such as
+     * width/height. This should NOT set the format property - that is
+     * negotiated between filters by the filter system using the
+     * query_formats() callback before this function is called.
+     *
+     * For input pads, this should check the properties of the link, and update
+     * the filter's internal state as necessary.
+     *
+     * For both input and output filters, this should return zero on success,
+     * and another value on error.
+     */
+    int (*config_props)(AVFilterLink *link);
+};
+#endif
+
 /** default handler for freeing audio/video buffer when there are no references left */
 void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
 
index d8baf0eaa995a2f0b15cd74dbce4b51c28ccb0cf..76fe1664a7be02d44d42e7542d6140cebbb1cd7d 100644 (file)
@@ -59,5 +59,8 @@
 #ifndef FF_API_FILTERS_PUBLIC
 #define FF_API_FILTERS_PUBLIC               (LIBAVFILTER_VERSION_MAJOR < 3)
 #endif
+#ifndef FF_API_AVFILTERPAD_PUBLIC
+#define FF_API_AVFILTERPAD_PUBLIC           (LIBAVFILTER_VERSION_MAJOR < 4)
+#endif
 
 #endif // AVFILTER_VERSION_H
index 0555afe4c0ac1eca76d81ef7115566d861810af1..44bef91fbc267c7ef6a0f42269567ee2a37e9da7 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "libavutil/mathematics.h"
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 1d9a75d502cf4f12a1be06d463840b403bd17b0a..a1f97328d005913a91a4356fb935274139553a01 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 21a0173ccb9a5eeb868f1dd8b6d691dfc8e073bc..06917ecf07828b7321a200d7e356811828a0f2c4 100644 (file)
@@ -30,6 +30,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 static const char *const var_names[] = {
index 271a729211f320114865baa0ab07ca1b6b948b3f..9ceb2f8a42ec1768d553888f4ac14e97df80c292 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 AVFilter avfilter_vf_copy = {
index f25278e79e7a41013daada8311308139fa5fd7ea..c884ce1f2ae5a6f7b37424fdacb083b88c368900 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/eval.h"
 #include "libavutil/avstring.h"
index 38fd5c13558db7c28f79c73d9d70f4674f7d46c3..c890dab5b9895754d11b7403d7e9ab3efe8e9f72 100644 (file)
@@ -26,6 +26,7 @@
 #include "libavutil/imgutils.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 70aa12a5d15c2e35d2709b998637dd323a35ba39..77382c99b5d241c93d6d9f0e0370f21711682684 100644 (file)
@@ -30,6 +30,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 /**
index 47db0490a7e2cf0d0f6ac5b8ef0b8559146f69db..eb129a23d84fac8af61a1e6deca357ceb60a4a13 100644 (file)
@@ -29,6 +29,7 @@
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 enum { Y, U, V, A };
index 411bcbc78112b80eb3752de80371d10a89750b8e..db66ad618d3448f2f7826642042936939ae36f02 100644 (file)
@@ -42,6 +42,7 @@
 #include "avfilter.h"
 #include "drawutils.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 #undef time
index 6b9cb66fe64c55d1d5f043001427490726b776d2..00501dd53c314c1ea82e74be03e3c91ee360bf19 100644 (file)
@@ -28,6 +28,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 67a69587bf3a07cabde5c087ebb324276704c3fb..89218560c6216270bd5ef1292c7ccb4b59b91b58 100644 (file)
@@ -29,6 +29,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct
index fff616b06ac51a982bd2456b2af420dfcf2b0898..1a5011851957124c4896323a82a9880c3b756b83 100644 (file)
@@ -26,6 +26,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 2a72fcc6a0d4f3a95909735bea0a061cdf23335d..54881571af16bf50f49faf48058b188e54226a73 100644 (file)
@@ -32,6 +32,7 @@
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
index 88872b3e25abc6069b8cdb9fd525de574e7da2a5..303e54c7f9d4db5fed454a33b019c188749e6c3b 100644 (file)
@@ -38,6 +38,7 @@
 #include "avfilter.h"
 #include "formats.h"
 #include "gradfun.h"
+#include "internal.h"
 #include "video.h"
 
 DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = {
index aff0f8c5d33fe88f013d9e50c3b48a3a47207b09..af167e142d167f6c0e36af05f99ab7a805e669ea 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/intreadwrite.h"
index 0a26dd001747beb97e06f0519694e84cc25479aa..f9b864e9eaabcfb8a6289754f214f05a8a466617 100644 (file)
@@ -28,6 +28,7 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 470c3d28a50ac098c83ae8f8e8624c43633ade19..26545dc8439179cdfcdf8ccf381afaafef0a23b8 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 AVFilter avfilter_vf_null = {
index 11c59b9f693269a51debe21e544ed253abe1a5db..098fc806c8d2b6c07c428ace071617922c95979e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/avstring.h"
 #include "libavutil/eval.h"
index 353c57b8a6c8747fdc2c1a775d6fd1dbc8741601..37dbe2d08a317d710720e003f9a975756a797226 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index 68ff84532db8d8058b38c0ddd73a6502af48c987..58daf38376aae19c9d1eec30cbe87dda6399a0b8 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/avstring.h"
 #include "libavutil/eval.h"
index d30385168684aa8070c2bb580f72d4a3f6f9e14a..77eef606791a7c1c9efa87b08edeb84e4fcb8364 100644 (file)
@@ -29,6 +29,7 @@
 #include "libavutil/eval.h"
 #include "libavutil/mathematics.h"
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 static const char *const var_names[] = {
index 1a8f16e2c308e8752c7f0350ebf672c05df41406..dbb67e91a2f62a904ae70290882f6ddda29f3a0f 100644 (file)
@@ -26,6 +26,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index fdc10bea9d2c09f2433ec7a23b3d431868926f82..636912dbdc5b0c6572d0e4eae8a274cb6ea72b47 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/pixdesc.h"
 
index aa5c0156a3969cef770332871ff102d01b16163b..5bcee9d32e062c258764425b89b41d5f1fe8aeb6 100644 (file)
@@ -30,6 +30,7 @@
 #include "libavutil/imgutils.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index a5d301cd722cfd21f8fe722d065a83442adfbeaa..8010f2dc177c196b686c39e2ba0db564ca17e8be 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/common.h"
 #include "libavutil/mem.h"
index bece2b26acc5077deae8992c882b326dbc6f00f3..0f528f137ada774d3841ad78859c1c66e6ec2cd5 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index bdfcb8a2e42dc003d239cb4f5cf06c33f8d1627d..6f11158c3a5439f00ae07981373b432c58f0a207 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "avfilter.h"
+#include "internal.h"
 
 static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
 {
index bfd8493761c0e76aa4050e7572c439772997783d..de1f340b013ef0c9903ba4099f1c9ebfa3f03f04 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/colorspace.h"
index f887e95c864ae1427a330be65714994b6ebc4b3f..64f6e18301881afa0937a68312e23d4a30317bea 100644 (file)
@@ -37,6 +37,7 @@
 #include "libavformat/avformat.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {
index d145b0b277f3d5a78cc398ba6813e31bf8f36073..71094dc95b33b7bb5e05f09f3086170358fb64fb 100644 (file)
@@ -27,6 +27,7 @@
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 
 static const char *const var_names[] = {
     "E",
index a6159ef6e169ab3d58ae2e4a6302ee8fae539bad..36f18b621347f2103f50f6ac46729fc07f639e8b 100644 (file)
@@ -38,6 +38,7 @@
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "internal.h"
 #include "video.h"
 
 typedef struct {