Browse code

Use the new null callbacks to simplify filters and reduce duplicated code.

Originally committed as revision 22595 to svn://svn.ffmpeg.org/ffmpeg/trunk

Bobby Bingham authored on 2010/03/19 08:13:02
Showing 5 changed files
... ...
@@ -56,13 +56,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
56 56
     return 0;
57 57
 }
58 58
 
59
-
60
-static AVFilterPicRef *get_video_buffer(AVFilterLink *link, int perms,
61
-                                        int w, int h)
62
-{
63
-    return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
64
-}
65
-
66 59
 static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
67 60
 {
68 61
     AspectContext *aspect = link->dst->priv;
... ...
@@ -71,11 +64,6 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
71 71
     avfilter_start_frame(link->dst->outputs[0], picref);
72 72
 }
73 73
 
74
-static void end_frame(AVFilterLink *link)
75
-{
76
-    avfilter_end_frame(link->dst->outputs[0]);
77
-}
78
-
79 74
 #if CONFIG_ASPECT_FILTER
80 75
 /* for aspect filter, convert from frame aspect ratio to pixel aspect ratio */
81 76
 static int frameaspect_config_props(AVFilterLink *inlink)
... ...
@@ -100,9 +88,9 @@ AVFilter avfilter_vf_aspect = {
100 100
     .inputs    = (AVFilterPad[]) {{ .name             = "default",
101 101
                                     .type             = CODEC_TYPE_VIDEO,
102 102
                                     .config_props     = frameaspect_config_props,
103
-                                    .get_video_buffer = get_video_buffer,
103
+                                    .get_video_buffer = avfilter_null_get_video_buffer,
104 104
                                     .start_frame      = start_frame,
105
-                                    .end_frame        = end_frame },
105
+                                    .end_frame        = avfilter_null_end_frame },
106 106
                                   { .name = NULL}},
107 107
 
108 108
     .outputs   = (AVFilterPad[]) {{ .name             = "default",
... ...
@@ -122,9 +110,9 @@ AVFilter avfilter_vf_pixelaspect = {
122 122
 
123 123
     .inputs    = (AVFilterPad[]) {{ .name             = "default",
124 124
                                     .type             = CODEC_TYPE_VIDEO,
125
-                                    .get_video_buffer = get_video_buffer,
125
+                                    .get_video_buffer = avfilter_null_get_video_buffer,
126 126
                                     .start_frame      = start_frame,
127
-                                    .end_frame        = end_frame },
127
+                                    .end_frame        = avfilter_null_end_frame },
128 128
                                   { .name = NULL}},
129 129
 
130 130
     .outputs   = (AVFilterPad[]) {{ .name             = "default",
... ...
@@ -156,12 +156,6 @@ static int config_output(AVFilterLink *link)
156 156
     return 0;
157 157
 }
158 158
 
159
-static AVFilterPicRef *get_video_buffer(AVFilterLink *link, int perms,
160
-                                        int w, int h)
161
-{
162
-    return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
163
-}
164
-
165 159
 static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
166 160
 {
167 161
     CropContext *crop = link->dst->priv;
... ...
@@ -223,7 +217,7 @@ AVFilter avfilter_vf_crop = {
223 223
                                     .type             = CODEC_TYPE_VIDEO,
224 224
                                     .start_frame      = start_frame,
225 225
                                     .draw_slice       = draw_slice,
226
-                                    .get_video_buffer = get_video_buffer,
226
+                                    .get_video_buffer = avfilter_null_get_video_buffer,
227 227
                                     .config_props     = config_input, },
228 228
                                   { .name = NULL}},
229 229
     .outputs   = (AVFilterPad[]) {{ .name             = "default",
... ...
@@ -85,27 +85,6 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag)
85 85
     return formats;
86 86
 }
87 87
 
88
-static AVFilterPicRef *get_video_buffer(AVFilterLink *link, int perms,
89
-                                        int w, int h)
90
-{
91
-    return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
92
-}
93
-
94
-static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
95
-{
96
-    avfilter_start_frame(link->dst->outputs[0], picref);
97
-}
98
-
99
-static void end_frame(AVFilterLink *link)
100
-{
101
-    avfilter_end_frame(link->dst->outputs[0]);
102
-}
103
-
104
-static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
105
-{
106
-    avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir);
107
-}
108
-
109 88
 #if CONFIG_FORMAT_FILTER
110 89
 static int query_formats_format(AVFilterContext *ctx)
111 90
 {
... ...
@@ -125,10 +104,10 @@ AVFilter avfilter_vf_format = {
125 125
 
126 126
     .inputs    = (AVFilterPad[]) {{ .name            = "default",
127 127
                                     .type            = CODEC_TYPE_VIDEO,
128
-                                    .get_video_buffer= get_video_buffer,
129
-                                    .start_frame     = start_frame,
130
-                                    .draw_slice      = draw_slice,
131
-                                    .end_frame       = end_frame, },
128
+                                    .get_video_buffer= avfilter_null_get_video_buffer,
129
+                                    .start_frame     = avfilter_null_start_frame,
130
+                                    .draw_slice      = avfilter_null_draw_slice,
131
+                                    .end_frame       = avfilter_null_end_frame, },
132 132
                                   { .name = NULL}},
133 133
     .outputs   = (AVFilterPad[]) {{ .name            = "default",
134 134
                                     .type            = CODEC_TYPE_VIDEO },
... ...
@@ -155,10 +134,10 @@ AVFilter avfilter_vf_noformat = {
155 155
 
156 156
     .inputs    = (AVFilterPad[]) {{ .name            = "default",
157 157
                                     .type            = CODEC_TYPE_VIDEO,
158
-                                    .get_video_buffer= get_video_buffer,
159
-                                    .start_frame     = start_frame,
160
-                                    .draw_slice      = draw_slice,
161
-                                    .end_frame       = end_frame, },
158
+                                    .get_video_buffer= avfilter_null_get_video_buffer,
159
+                                    .start_frame     = avfilter_null_start_frame,
160
+                                    .draw_slice      = avfilter_null_draw_slice,
161
+                                    .end_frame       = avfilter_null_end_frame, },
162 162
                                   { .name = NULL}},
163 163
     .outputs   = (AVFilterPad[]) {{ .name            = "default",
164 164
                                     .type            = CODEC_TYPE_VIDEO },
... ...
@@ -23,22 +23,6 @@
23 23
 
24 24
 #include "avfilter.h"
25 25
 
26
-static AVFilterPicRef *get_video_buffer(AVFilterLink *link, int perms,
27
-                                        int w, int h)
28
-{
29
-    return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
30
-}
31
-
32
-static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
33
-{
34
-    avfilter_start_frame(link->dst->outputs[0], picref);
35
-}
36
-
37
-static void end_frame(AVFilterLink *link)
38
-{
39
-    avfilter_end_frame(link->dst->outputs[0]);
40
-}
41
-
42 26
 AVFilter avfilter_vf_null = {
43 27
     .name      = "null",
44 28
     .description = NULL_IF_CONFIG_SMALL("Pass the source unchanged to the output."),
... ...
@@ -47,9 +31,9 @@ AVFilter avfilter_vf_null = {
47 47
 
48 48
     .inputs    = (AVFilterPad[]) {{ .name             = "default",
49 49
                                     .type             = CODEC_TYPE_VIDEO,
50
-                                    .get_video_buffer = get_video_buffer,
51
-                                    .start_frame      = start_frame,
52
-                                    .end_frame        = end_frame },
50
+                                    .get_video_buffer = avfilter_null_get_video_buffer,
51
+                                    .start_frame      = avfilter_null_start_frame,
52
+                                    .end_frame        = avfilter_null_end_frame },
53 53
                                   { .name = NULL}},
54 54
 
55 55
     .outputs   = (AVFilterPad[]) {{ .name             = "default",
... ...
@@ -57,12 +57,6 @@ static int config_props(AVFilterLink *link)
57 57
     return 0;
58 58
 }
59 59
 
60
-static AVFilterPicRef *get_video_buffer(AVFilterLink *link, int perms,
61
-                                        int w, int h)
62
-{
63
-    return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h);
64
-}
65
-
66 60
 static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
67 61
 {
68 62
     SliceContext *slice = link->dst->priv;
... ...
@@ -81,11 +75,6 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
81 81
     avfilter_start_frame(link->dst->outputs[0], picref);
82 82
 }
83 83
 
84
-static void end_frame(AVFilterLink *link)
85
-{
86
-    avfilter_end_frame(link->dst->outputs[0]);
87
-}
88
-
89 84
 static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
90 85
 {
91 86
     SliceContext *slice = link->dst->priv;
... ...
@@ -116,11 +105,11 @@ AVFilter avfilter_vf_slicify = {
116 116
 
117 117
     .inputs    = (AVFilterPad[]) {{ .name             = "default",
118 118
                                     .type             = CODEC_TYPE_VIDEO,
119
-                                    .get_video_buffer = get_video_buffer,
119
+                                    .get_video_buffer = avfilter_null_get_video_buffer,
120 120
                                     .start_frame      = start_frame,
121 121
                                     .draw_slice       = draw_slice,
122 122
                                     .config_props     = config_props,
123
-                                    .end_frame        = end_frame, },
123
+                                    .end_frame        = avfilter_null_end_frame, },
124 124
                                   { .name = NULL}},
125 125
     .outputs   = (AVFilterPad[]) {{ .name            = "default",
126 126
                                     .type            = CODEC_TYPE_VIDEO, },