History

lavfi: make AVFilterPad opaque after two major bumps.

It will allow adding new fields to it without ABI breaks.

Anton Khirnov committed 14 years ago

Commit 9d0bfc51 parent 84b9fbe39 files · +179 −6Browse files

Unified · Split

39 files
  1. avconv.c +8 −6
  2. libavfilter/af_anull.c +1 −0
  3. libavfilter/asink_anullsink.c +1 −0
  4. libavfilter/asrc_anullsrc.c +1 −0
  5. libavfilter/avfilter.h +7 −0
  6. libavfilter/buffersrc.c +1 −0
  7. libavfilter/internal.h +126 −0
  8. libavfilter/version.h +3 −0
  9. libavfilter/vf_aspect.c +1 −0
  10. libavfilter/vf_blackframe.c +1 −0
  11. libavfilter/vf_boxblur.c +1 −0
  12. libavfilter/vf_copy.c +1 −0
  13. libavfilter/vf_crop.c +1 −0
  14. libavfilter/vf_cropdetect.c +1 −0
  15. libavfilter/vf_delogo.c +1 −0
  16. libavfilter/vf_drawbox.c +1 −0
  17. libavfilter/vf_drawtext.c +1 −0
  18. libavfilter/vf_fade.c +1 −0
  19. libavfilter/vf_fieldorder.c +1 −0
  20. libavfilter/vf_format.c +1 −0
  21. libavfilter/vf_frei0r.c +1 −0
  22. libavfilter/vf_gradfun.c +1 −0
  23. libavfilter/vf_hflip.c +1 −0
  24. libavfilter/vf_hqdn3d.c +1 −0
  25. libavfilter/vf_null.c +1 −0
  26. libavfilter/vf_pad.c +1 −0
  27. libavfilter/vf_pixdesctest.c +1 −0
  28. libavfilter/vf_scale.c +1 −0
  29. libavfilter/vf_setpts.c +1 −0
  30. libavfilter/vf_showinfo.c +1 −0
  31. libavfilter/vf_slicify.c +1 −0
  32. libavfilter/vf_transpose.c +1 −0
  33. libavfilter/vf_unsharp.c +1 −0
  34. libavfilter/vf_vflip.c +1 −0
  35. libavfilter/vsink_nullsink.c +1 −0
  36. libavfilter/vsrc_color.c +1 −0
  37. libavfilter/vsrc_movie.c +1 −0
  38. libavfilter/vsrc_nullsrc.c +1 −0
  39. libavfilter/vsrc_testsrc.c +1 −0
avconv.c+8−6
@@ -548,7 +548,7 @@ static FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost) · 547 unmodified lines
548548 static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
549549 {
550550 InputStream *ist;
551− enum AVMediaType type = in->filter_ctx->input_pads[in->pad_idx].type;
551+ enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
552552 int i;
553553
554554 // TODO: support other filter types
@@ -789,7 +789,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, · 234 unmodified lines
789789 \
790790 avio_printf(pb, "%s", ctx->filter->name); \
791791 if (nb_pads > 1) \
792− avio_printf(pb, ":%s", pads[inout->pad_idx].name); \
792+ avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\
793793 avio_w8(pb, 0); \
794794 avio_close_dyn_buf(pb, &f->name); \
795795 }
@@ -799,7 +799,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFil · 3 unmodified lines
799799 av_freep(&ofilter->name);
800800 DESCRIBE_FILTER_LINK(ofilter, out, 0);
801801
802− switch (out->filter_ctx->output_pads[out->pad_idx].type) {
802+ switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
803803 case AVMEDIA_TYPE_VIDEO: return configure_output_video_filter(fg, ofilter, out);
804804 case AVMEDIA_TYPE_AUDIO: return configure_output_audio_filter(fg, ofilter, out);
805805 default: av_assert0(0);
@@ -913,7 +913,7 @@ static int configure_input_filter(FilterGraph *fg, InputFilter *ifilter, · 107 unmodified lines
913913 av_freep(&ifilter->name);
914914 DESCRIBE_FILTER_LINK(ifilter, in, 1);
915915
916− switch (in->filter_ctx->input_pads[in->pad_idx].type) {
916+ switch (avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx)) {
917917 case AVMEDIA_TYPE_VIDEO: return configure_input_video_filter(fg, ifilter, in);
918918 case AVMEDIA_TYPE_AUDIO: return configure_input_audio_filter(fg, ifilter, in);
919919 default: av_assert0(0);
@@ -4112,7 +4112,8 @@ static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, · 3192 unmodified lines
41124112 {
41134113 OutputStream *ost;
41144114
4115− switch (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type) {
4115+ switch (avfilter_pad_get_type(ofilter->out_tmp->filter_ctx->output_pads,
4116+ ofilter->out_tmp->pad_idx)) {
41164117 case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break;
41174118 case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break;
41184119 default:
@@ -4191,7 +4192,8 @@ static void opt_output_file(void *optctx, const char *filename) · 72 unmodified lines
41914192 if (!ofilter->out_tmp || ofilter->out_tmp->name)
41924193 continue;
41934194
4194− switch (ofilter->out_tmp->filter_ctx->output_pads[ofilter->out_tmp->pad_idx].type) {
4195+ switch (avfilter_pad_get_type(ofilter->out_tmp->filter_ctx->output_pads,
4196+ ofilter->out_tmp->pad_idx)) {
41954197 case AVMEDIA_TYPE_VIDEO: o->video_disable = 1; break;
41964198 case AVMEDIA_TYPE_AUDIO: o->audio_disable = 1; break;
41974199 case AVMEDIA_TYPE_SUBTITLE: o->subtitle_disable = 1; break;
libavfilter/af_anull.c+1−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323
2424 #include "audio.h"
2525 #include "avfilter.h"
26+#include "internal.h"
2627
2728 AVFilter avfilter_af_anull = {
2829 .name = "anull",
libavfilter/asink_anullsink.c+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 */
1818
1919 #include "avfilter.h"
20+#include "internal.h"
2021
2122 static void null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) { }
2223
libavfilter/asrc_anullsrc.c+1−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 */
2323
2424 #include "avfilter.h"
25+#include "internal.h"
2526 #include "libavutil/audioconvert.h"
2627
2728 typedef struct {
libavfilter/avfilter.h+7−0
@@ -235,8 +235,14 @@ void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats) · 234 unmodified lines
235235 */
236236 #endif
237237
238+#if FF_API_AVFILTERPAD_PUBLIC
238239 /**
239240 * A filter pad used for either input or output.
241+ *
242+ * @warning this struct will be removed from public API.
243+ * users should call avfilter_pad_get_name() and avfilter_pad_get_type()
244+ * to access the name and type fields; there should be no need to access
245+ * any other fields from outside of libavfilter.
240246 */
241247 struct AVFilterPad {
242248 /**
@@ -358,6 +364,7 @@ struct AVFilterPad { · 115 unmodified lines
358364 */
359365 int (*config_props)(AVFilterLink *link);
360366 };
367+#endif
361368
362369 /**
363370 * Get the name of an AVFilterPad.
libavfilter/buffersrc.c+1−0
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "avfilter.h"
2828 #include "buffersrc.h"
2929 #include "formats.h"
30+#include "internal.h"
3031 #include "video.h"
3132 #include "vsrc_buffer.h"
3233
libavfilter/internal.h+126−0
@@ -26,6 +26,132 @@ · 25 unmodified lines
2626
2727 #include "avfilter.h"
2828
29+#if !FF_API_AVFILTERPAD_PUBLIC
30+/**
31+ * A filter pad used for either input or output.
32+ */
33+struct AVFilterPad {
34+ /**
35+ * Pad name. The name is unique among inputs and among outputs, but an
36+ * input may have the same name as an output. This may be NULL if this
37+ * pad has no need to ever be referenced by name.
38+ */
39+ const char *name;
40+
41+ /**
42+ * AVFilterPad type.
43+ */
44+ enum AVMediaType type;
45+
46+ /**
47+ * Minimum required permissions on incoming buffers. Any buffer with
48+ * insufficient permissions will be automatically copied by the filter
49+ * system to a new buffer which provides the needed access permissions.
50+ *
51+ * Input pads only.
52+ */
53+ int min_perms;
54+
55+ /**
56+ * Permissions which are not accepted on incoming buffers. Any buffer
57+ * which has any of these permissions set will be automatically copied
58+ * by the filter system to a new buffer which does not have those
59+ * permissions. This can be used to easily disallow buffers with
60+ * AV_PERM_REUSE.
61+ *
62+ * Input pads only.
63+ */
64+ int rej_perms;
65+
66+ /**
67+ * Callback called before passing the first slice of a new frame. If
68+ * NULL, the filter layer will default to storing a reference to the
69+ * picture inside the link structure.
70+ *
71+ * Input video pads only.
72+ */
73+ void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
74+
75+ /**
76+ * Callback function to get a video buffer. If NULL, the filter system will
77+ * use avfilter_default_get_video_buffer().
78+ *
79+ * Input video pads only.
80+ */
81+ AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
82+
83+ /**
84+ * Callback function to get an audio buffer. If NULL, the filter system will
85+ * use avfilter_default_get_audio_buffer().
86+ *
87+ * Input audio pads only.
88+ */
89+ AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
90+ int nb_samples);
91+
92+ /**
93+ * Callback called after the slices of a frame are completely sent. If
94+ * NULL, the filter layer will default to releasing the reference stored
95+ * in the link structure during start_frame().
96+ *
97+ * Input video pads only.
98+ */
99+ void (*end_frame)(AVFilterLink *link);
100+
101+ /**
102+ * Slice drawing callback. This is where a filter receives video data
103+ * and should do its processing.
104+ *
105+ * Input video pads only.
106+ */
107+ void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
108+
109+ /**
110+ * Samples filtering callback. This is where a filter receives audio data
111+ * and should do its processing.
112+ *
113+ * Input audio pads only.
114+ */
115+ void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
116+
117+ /**
118+ * Frame poll callback. This returns the number of immediately available
119+ * samples. It should return a positive value if the next request_frame()
120+ * is guaranteed to return one frame (with no delay).
121+ *
122+ * Defaults to just calling the source poll_frame() method.
123+ *
124+ * Output pads only.
125+ */
126+ int (*poll_frame)(AVFilterLink *link);
127+
128+ /**
129+ * Frame request callback. A call to this should result in at least one
130+ * frame being output over the given link. This should return zero on
131+ * success, and another value on error.
132+ *
133+ * Output pads only.
134+ */
135+ int (*request_frame)(AVFilterLink *link);
136+
137+ /**
138+ * Link configuration callback.
139+ *
140+ * For output pads, this should set the link properties such as
141+ * width/height. This should NOT set the format property - that is
142+ * negotiated between filters by the filter system using the
143+ * query_formats() callback before this function is called.
144+ *
145+ * For input pads, this should check the properties of the link, and update
146+ * the filter's internal state as necessary.
147+ *
148+ * For both input and output filters, this should return zero on success,
149+ * and another value on error.
150+ */
151+ int (*config_props)(AVFilterLink *link);
152+};
153+#endif
154+
29155 /** default handler for freeing audio/video buffer when there are no references left */
30156 void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
31157
libavfilter/version.h+3−0
@@ -59,5 +59,8 @@ · 58 unmodified lines
5959 #ifndef FF_API_FILTERS_PUBLIC
6060 #define FF_API_FILTERS_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 3)
6161 #endif
62+#ifndef FF_API_AVFILTERPAD_PUBLIC
63+#define FF_API_AVFILTERPAD_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 4)
64+#endif
6265
6366 #endif // AVFILTER_VERSION_H
libavfilter/vf_aspect.c+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 #include "libavutil/mathematics.h"
2727 #include "avfilter.h"
28+#include "internal.h"
2829 #include "video.h"
2930
3031 typedef struct {
libavfilter/vf_blackframe.c+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929
3030 #include "avfilter.h"
3131 #include "formats.h"
32+#include "internal.h"
3233 #include "video.h"
3334
3435 typedef struct {
libavfilter/vf_boxblur.c+1−0
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/pixdesc.h"
3131 #include "avfilter.h"
3232 #include "formats.h"
33+#include "internal.h"
3334 #include "video.h"
3435
3536 static const char *const var_names[] = {
libavfilter/vf_copy.c+1−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 */
2323
2424 #include "avfilter.h"
25+#include "internal.h"
2526 #include "video.h"
2627
2728 AVFilter avfilter_vf_copy = {
libavfilter/vf_crop.c+1−0
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727
2828 #include "avfilter.h"
2929 #include "formats.h"
30+#include "internal.h"
3031 #include "video.h"
3132 #include "libavutil/eval.h"
3233 #include "libavutil/avstring.h"
libavfilter/vf_cropdetect.c+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/imgutils.h"
2727 #include "avfilter.h"
2828 #include "formats.h"
29+#include "internal.h"
2930 #include "video.h"
3031
3132 typedef struct {
libavfilter/vf_delogo.c+1−0
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/pixdesc.h"
3131 #include "avfilter.h"
3232 #include "formats.h"
33+#include "internal.h"
3334 #include "video.h"
3435
3536 /**
libavfilter/vf_drawbox.c+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/parseutils.h"
3030 #include "avfilter.h"
3131 #include "formats.h"
32+#include "internal.h"
3233 #include "video.h"
3334
3435 enum { Y, U, V, A };
libavfilter/vf_drawtext.c+1−0
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include "avfilter.h"
4343 #include "drawutils.h"
4444 #include "formats.h"
45+#include "internal.h"
4546 #include "video.h"
4647
4748 #undef time
libavfilter/vf_fade.c+1−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/pixdesc.h"
2929 #include "avfilter.h"
3030 #include "formats.h"
31+#include "internal.h"
3132 #include "video.h"
3233
3334 typedef struct {
libavfilter/vf_fieldorder.c+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/pixdesc.h"
3030 #include "avfilter.h"
3131 #include "formats.h"
32+#include "internal.h"
3233 #include "video.h"
3334
3435 typedef struct
libavfilter/vf_format.c+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/pixdesc.h"
2727 #include "avfilter.h"
2828 #include "formats.h"
29+#include "internal.h"
2930 #include "video.h"
3031
3132 typedef struct {
libavfilter/vf_frei0r.c+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "libavutil/parseutils.h"
3333 #include "avfilter.h"
3434 #include "formats.h"
35+#include "internal.h"
3536 #include "video.h"
3637
3738 typedef f0r_instance_t (*f0r_construct_f)(unsigned int width, unsigned int height);
libavfilter/vf_gradfun.c+1−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include "avfilter.h"
3939 #include "formats.h"
4040 #include "gradfun.h"
41+#include "internal.h"
4142 #include "video.h"
4243
4344 DECLARE_ALIGNED(16, static const uint16_t, dither)[8][8] = {
libavfilter/vf_hflip.c+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626
2727 #include "avfilter.h"
2828 #include "formats.h"
29+#include "internal.h"
2930 #include "video.h"
3031 #include "libavutil/pixdesc.h"
3132 #include "libavutil/intreadwrite.h"
libavfilter/vf_hqdn3d.c+1−0
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/pixdesc.h"
2929 #include "avfilter.h"
3030 #include "formats.h"
31+#include "internal.h"
3132 #include "video.h"
3233
3334 typedef struct {
libavfilter/vf_null.c+1−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 */
2323
2424 #include "avfilter.h"
25+#include "internal.h"
2526 #include "video.h"
2627
2728 AVFilter avfilter_vf_null = {
libavfilter/vf_pad.c+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626
2727 #include "avfilter.h"
2828 #include "formats.h"
29+#include "internal.h"
2930 #include "video.h"
3031 #include "libavutil/avstring.h"
3132 #include "libavutil/eval.h"
libavfilter/vf_pixdesctest.c+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 #include "libavutil/pixdesc.h"
2727 #include "avfilter.h"
28+#include "internal.h"
2829 #include "video.h"
2930
3031 typedef struct {
libavfilter/vf_scale.c+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 #include "avfilter.h"
2727 #include "formats.h"
28+#include "internal.h"
2829 #include "video.h"
2930 #include "libavutil/avstring.h"
3031 #include "libavutil/eval.h"
libavfilter/vf_setpts.c+1−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/eval.h"
3030 #include "libavutil/mathematics.h"
3131 #include "avfilter.h"
32+#include "internal.h"
3233 #include "video.h"
3334
3435 static const char *const var_names[] = {
libavfilter/vf_showinfo.c+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
2626 #include "libavutil/imgutils.h"
2727 #include "libavutil/pixdesc.h"
2828 #include "avfilter.h"
29+#include "internal.h"
2930 #include "video.h"
3031
3132 typedef struct {
libavfilter/vf_slicify.c+1−0
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 */
2525
2626 #include "avfilter.h"
27+#include "internal.h"
2728 #include "video.h"
2829 #include "libavutil/pixdesc.h"
2930
libavfilter/vf_transpose.c+1−0
@@ -30,6 +30,7 @@ · 29 unmodified lines
3030 #include "libavutil/imgutils.h"
3131 #include "avfilter.h"
3232 #include "formats.h"
33+#include "internal.h"
3334 #include "video.h"
3435
3536 typedef struct {
libavfilter/vf_unsharp.c+1−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838
3939 #include "avfilter.h"
4040 #include "formats.h"
41+#include "internal.h"
4142 #include "video.h"
4243 #include "libavutil/common.h"
4344 #include "libavutil/mem.h"
libavfilter/vf_vflip.c+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 #include "libavutil/pixdesc.h"
2727 #include "avfilter.h"
28+#include "internal.h"
2829 #include "video.h"
2930
3031 typedef struct {
libavfilter/vsink_nullsink.c+1−0
@@ -17,6 +17,7 @@ · 16 unmodified lines
1717 */
1818
1919 #include "avfilter.h"
20+#include "internal.h"
2021
2122 static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
2223 {
libavfilter/vsrc_color.c+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525
2626 #include "avfilter.h"
2727 #include "formats.h"
28+#include "internal.h"
2829 #include "video.h"
2930 #include "libavutil/pixdesc.h"
3031 #include "libavutil/colorspace.h"
libavfilter/vsrc_movie.c+1−0
@@ -37,6 +37,7 @@ · 36 unmodified lines
3737 #include "libavformat/avformat.h"
3838 #include "avfilter.h"
3939 #include "formats.h"
40+#include "internal.h"
4041 #include "video.h"
4142
4243 typedef struct {
libavfilter/vsrc_nullsrc.c+1−0
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/parseutils.h"
2828 #include "avfilter.h"
2929 #include "formats.h"
30+#include "internal.h"
3031
3132 static const char *const var_names[] = {
3233 "E",
libavfilter/vsrc_testsrc.c+1−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include "libavutil/parseutils.h"
3939 #include "avfilter.h"
4040 #include "formats.h"
41+#include "internal.h"
4142 #include "video.h"
4243
4344 typedef struct {

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