History

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 committed 16 years ago

Commit d313e171 parent 91d1c745 files · +18 −84Browse files

Showing the changes to libavfilter (5 of 5 files). Show all

Unified · Split

5 files
  1. libavfilter/vf_aspect.c +4 −16
  2. libavfilter/vf_crop.c +1 −7
  3. libavfilter/vf_format.c +8 −29
  4. libavfilter/vf_null.c +3 −19
  5. libavfilter/vf_slicify.c +2 −13
libavfilter/vf_aspect.c+4−16
@@ -56,13 +56,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) · 55 unmodified lines
56 return 0;56 return 0;
57}57}
58 58
59
60static 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
66static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)59static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
67{60{
68 AspectContext *aspect = link->dst->priv;61 AspectContext *aspect = link->dst->priv;
@@ -71,11 +64,6 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref) · 2 unmodified lines
71 avfilter_start_frame(link->dst->outputs[0], picref);64 avfilter_start_frame(link->dst->outputs[0], picref);
72}65}
73 66
74static void end_frame(AVFilterLink *link)
75{
76 avfilter_end_frame(link->dst->outputs[0]);
77}
78
79#if CONFIG_ASPECT_FILTER67#if CONFIG_ASPECT_FILTER
80/* for aspect filter, convert from frame aspect ratio to pixel aspect ratio */68/* for aspect filter, convert from frame aspect ratio to pixel aspect ratio */
81static int frameaspect_config_props(AVFilterLink *inlink)69static int frameaspect_config_props(AVFilterLink *inlink)
@@ -100,9 +88,9 @@ AVFilter avfilter_vf_aspect = { · 18 unmodified lines
100 .inputs = (AVFilterPad[]) {{ .name = "default",88 .inputs = (AVFilterPad[]) {{ .name = "default",
101 .type = CODEC_TYPE_VIDEO,89 .type = CODEC_TYPE_VIDEO,
102 .config_props = frameaspect_config_props,90 .config_props = frameaspect_config_props,
103 .get_video_buffer = get_video_buffer,91 .get_video_buffer = avfilter_null_get_video_buffer,
104 .start_frame = start_frame,92 .start_frame = start_frame,
105 .end_frame = end_frame },93 .end_frame = avfilter_null_end_frame },
106 { .name = NULL}},94 { .name = NULL}},
107 95
108 .outputs = (AVFilterPad[]) {{ .name = "default",96 .outputs = (AVFilterPad[]) {{ .name = "default",
@@ -122,9 +110,9 @@ AVFilter avfilter_vf_pixelaspect = { · 13 unmodified lines
122 110
123 .inputs = (AVFilterPad[]) {{ .name = "default",111 .inputs = (AVFilterPad[]) {{ .name = "default",
124 .type = CODEC_TYPE_VIDEO,112 .type = CODEC_TYPE_VIDEO,
125 .get_video_buffer = get_video_buffer,113 .get_video_buffer = avfilter_null_get_video_buffer,
126 .start_frame = start_frame,114 .start_frame = start_frame,
127 .end_frame = end_frame },115 .end_frame = avfilter_null_end_frame },
128 { .name = NULL}},116 { .name = NULL}},
129 117
130 .outputs = (AVFilterPad[]) {{ .name = "default",118 .outputs = (AVFilterPad[]) {{ .name = "default",
libavfilter/vf_crop.c+1−7
@@ -156,12 +156,6 @@ static int config_output(AVFilterLink *link) · 155 unmodified lines
156 return 0;156 return 0;
157}157}
158 158
159static 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
165static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)159static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
166{160{
167 CropContext *crop = link->dst->priv;161 CropContext *crop = link->dst->priv;
@@ -223,7 +217,7 @@ AVFilter avfilter_vf_crop = { · 55 unmodified lines
223 .type = CODEC_TYPE_VIDEO,217 .type = CODEC_TYPE_VIDEO,
224 .start_frame = start_frame,218 .start_frame = start_frame,
225 .draw_slice = draw_slice,219 .draw_slice = draw_slice,
226 .get_video_buffer = get_video_buffer,220 .get_video_buffer = avfilter_null_get_video_buffer,
227 .config_props = config_input, },221 .config_props = config_input, },
228 { .name = NULL}},222 { .name = NULL}},
229 .outputs = (AVFilterPad[]) {{ .name = "default",223 .outputs = (AVFilterPad[]) {{ .name = "default",
libavfilter/vf_format.c+8−29
@@ -85,27 +85,6 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag) · 84 unmodified lines
85 return formats;85 return formats;
86}86}
87 87
88static 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
94static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
95{
96 avfilter_start_frame(link->dst->outputs[0], picref);
97}
98
99static void end_frame(AVFilterLink *link)
100{
101 avfilter_end_frame(link->dst->outputs[0]);
102}
103
104static 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#if CONFIG_FORMAT_FILTER88#if CONFIG_FORMAT_FILTER
110static int query_formats_format(AVFilterContext *ctx)89static int query_formats_format(AVFilterContext *ctx)
111{90{
@@ -125,10 +104,10 @@ AVFilter avfilter_vf_format = { · 13 unmodified lines
125 104
126 .inputs = (AVFilterPad[]) {{ .name = "default",105 .inputs = (AVFilterPad[]) {{ .name = "default",
127 .type = CODEC_TYPE_VIDEO,106 .type = CODEC_TYPE_VIDEO,
128 .get_video_buffer= get_video_buffer,107 .get_video_buffer= avfilter_null_get_video_buffer,
129 .start_frame = start_frame,108 .start_frame = avfilter_null_start_frame,
130 .draw_slice = draw_slice,109 .draw_slice = avfilter_null_draw_slice,
131 .end_frame = end_frame, },110 .end_frame = avfilter_null_end_frame, },
132 { .name = NULL}},111 { .name = NULL}},
133 .outputs = (AVFilterPad[]) {{ .name = "default",112 .outputs = (AVFilterPad[]) {{ .name = "default",
134 .type = CODEC_TYPE_VIDEO },113 .type = CODEC_TYPE_VIDEO },
@@ -155,10 +134,10 @@ AVFilter avfilter_vf_noformat = { · 20 unmodified lines
155 134
156 .inputs = (AVFilterPad[]) {{ .name = "default",135 .inputs = (AVFilterPad[]) {{ .name = "default",
157 .type = CODEC_TYPE_VIDEO,136 .type = CODEC_TYPE_VIDEO,
158 .get_video_buffer= get_video_buffer,137 .get_video_buffer= avfilter_null_get_video_buffer,
159 .start_frame = start_frame,138 .start_frame = avfilter_null_start_frame,
160 .draw_slice = draw_slice,139 .draw_slice = avfilter_null_draw_slice,
161 .end_frame = end_frame, },140 .end_frame = avfilter_null_end_frame, },
162 { .name = NULL}},141 { .name = NULL}},
163 .outputs = (AVFilterPad[]) {{ .name = "default",142 .outputs = (AVFilterPad[]) {{ .name = "default",
164 .type = CODEC_TYPE_VIDEO },143 .type = CODEC_TYPE_VIDEO },
libavfilter/vf_null.c+3−19
@@ -23,22 +23,6 @@ · 22 unmodified lines
23 23
24#include "avfilter.h"24#include "avfilter.h"
25 25
26static 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
32static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
33{
34 avfilter_start_frame(link->dst->outputs[0], picref);
35}
36
37static void end_frame(AVFilterLink *link)
38{
39 avfilter_end_frame(link->dst->outputs[0]);
40}
41
42AVFilter avfilter_vf_null = {26AVFilter avfilter_vf_null = {
43 .name = "null",27 .name = "null",
44 .description = NULL_IF_CONFIG_SMALL("Pass the source unchanged to the output."),28 .description = NULL_IF_CONFIG_SMALL("Pass the source unchanged to the output."),
@@ -47,9 +31,9 @@ AVFilter avfilter_vf_null = { · 2 unmodified lines
47 31
48 .inputs = (AVFilterPad[]) {{ .name = "default",32 .inputs = (AVFilterPad[]) {{ .name = "default",
49 .type = CODEC_TYPE_VIDEO,33 .type = CODEC_TYPE_VIDEO,
50 .get_video_buffer = get_video_buffer,34 .get_video_buffer = avfilter_null_get_video_buffer,
51 .start_frame = start_frame,35 .start_frame = avfilter_null_start_frame,
52 .end_frame = end_frame },36 .end_frame = avfilter_null_end_frame },
53 { .name = NULL}},37 { .name = NULL}},
54 38
55 .outputs = (AVFilterPad[]) {{ .name = "default",39 .outputs = (AVFilterPad[]) {{ .name = "default",
libavfilter/vf_slicify.c+2−13
@@ -57,12 +57,6 @@ static int config_props(AVFilterLink *link) · 56 unmodified lines
57 return 0;57 return 0;
58}58}
59 59
60static 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
66static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)60static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
67{61{
68 SliceContext *slice = link->dst->priv;62 SliceContext *slice = link->dst->priv;
@@ -81,11 +75,6 @@ static void start_frame(AVFilterLink *link, AVFilterPicRef *picref) · 12 unmodified lines
81 avfilter_start_frame(link->dst->outputs[0], picref);75 avfilter_start_frame(link->dst->outputs[0], picref);
82}76}
83 77
84static void end_frame(AVFilterLink *link)
85{
86 avfilter_end_frame(link->dst->outputs[0]);
87}
88
89static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)78static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
90{79{
91 SliceContext *slice = link->dst->priv;80 SliceContext *slice = link->dst->priv;
@@ -116,11 +105,11 @@ AVFilter avfilter_vf_slicify = { · 24 unmodified lines
116 105
117 .inputs = (AVFilterPad[]) {{ .name = "default",106 .inputs = (AVFilterPad[]) {{ .name = "default",
118 .type = CODEC_TYPE_VIDEO,107 .type = CODEC_TYPE_VIDEO,
119 .get_video_buffer = get_video_buffer,108 .get_video_buffer = avfilter_null_get_video_buffer,
120 .start_frame = start_frame,109 .start_frame = start_frame,
121 .draw_slice = draw_slice,110 .draw_slice = draw_slice,
122 .config_props = config_props,111 .config_props = config_props,
123 .end_frame = end_frame, },112 .end_frame = avfilter_null_end_frame, },
124 { .name = NULL}},113 { .name = NULL}},
125 .outputs = (AVFilterPad[]) {{ .name = "default",114 .outputs = (AVFilterPad[]) {{ .name = "default",
126 .type = CODEC_TYPE_VIDEO, },115 .type = CODEC_TYPE_VIDEO, },

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