History

Move default entry point implementations to their own file. Make them externally visible because they may be useful for filters to use.

Commited in SoC by Bobby Bingham on 2007-08-02 15:14:05 Originally committed as revision 11997 to svn://svn.ffmpeg.org/ffmpeg/trunk

Vitor Sessak committed 18 years ago

Commit 78b0c0b1 parent d4169dd1 file · +2 −97Browse files

Unified · Split

libavfilter/avfilter.c+2−97
@@ -31,70 +31,6 @@ · 30 unmodified lines
31static int filter_count = 0;31static int filter_count = 0;
32static AVFilter **filters = NULL;32static AVFilter **filters = NULL;
33 33
34/* TODO: buffer pool. see comment for avfilter_default_get_video_buffer() */
35void avfilter_default_free_video_buffer(AVFilterPic *pic)
36{
37 avpicture_free((AVPicture *) pic);
38 av_free(pic);
39}
40
41/* TODO: set the buffer's priv member to a context structure for the whole
42 * filter chain. This will allow for a buffer pool instead of the constant
43 * alloc & free cycle currently implemented. */
44AVFilterPicRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms)
45{
46 AVFilterPic *pic = av_mallocz(sizeof(AVFilterPic));
47 AVFilterPicRef *ref = av_mallocz(sizeof(AVFilterPicRef));
48
49 ref->pic = pic;
50 ref->w = link->w;
51 ref->h = link->h;
52 ref->perms = perms;
53
54 pic->refcount = 1;
55 pic->format = link->format;
56 pic->free = avfilter_default_free_video_buffer;
57 avpicture_alloc((AVPicture *)pic, pic->format, ref->w, ref->h);
58
59 memcpy(ref->data, pic->data, sizeof(pic->data));
60 memcpy(ref->linesize, pic->linesize, sizeof(pic->linesize));
61
62 return ref;
63}
64
65void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
66{
67 AVFilterLink *out = NULL;
68
69 if(link->dst->output_count)
70 out = link->dst->outputs[0];
71
72 link->cur_pic = picref;
73
74 if(out) {
75 out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE);
76 out->outpic->pts = picref->pts;
77 avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));
78 }
79}
80
81void avfilter_default_end_frame(AVFilterLink *link)
82{
83 AVFilterLink *out = NULL;
84
85 if(link->dst->output_count)
86 out = link->dst->outputs[0];
87
88 avfilter_unref_pic(link->cur_pic);
89 link->cur_pic = NULL;
90
91 if(out) {
92 avfilter_unref_pic(out->outpic);
93 out->outpic = NULL;
94 avfilter_end_frame(out);
95 }
96}
97
98AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask)34AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask)
99{35{
100 AVFilterPicRef *ret = av_malloc(sizeof(AVFilterPicRef));36 AVFilterPicRef *ret = av_malloc(sizeof(AVFilterPicRef));
@@ -111,37 +47,6 @@ void avfilter_unref_pic(AVFilterPicRef *ref) · 10 unmodified lines
111 av_free(ref);47 av_free(ref);
112}48}
113 49
114/**
115 * default config_link() implementation for output video links to simplify
116 * the implementation of one input one output video filters */
117static int default_config_output_link(AVFilterLink *link)
118{
119 if(link->src->input_count && link->src->inputs[0]) {
120 link->w = link->src->inputs[0]->w;
121 link->h = link->src->inputs[0]->h;
122 } else {
123 /* XXX: any non-simple filter which would cause this branch to be taken
124 * really should implement its own config_props() for this link. */
125 link->w =
126 link->h = 0;
127 }
128
129 return 0;
130}
131
132/**
133 * default query_formats() implementation for output video links to simplify
134 * the implementation of one input one output video filters */
135static int *default_query_output_formats(AVFilterLink *link)
136{
137 if(link->src->input_count && link->src->inputs[0])
138 return avfilter_make_format_list(1, link->src->inputs[0]->format);
139 else
140 /* XXX: any non-simple filter which would cause this branch to be taken
141 * really should implement its own query_formats() for this link */
142 return avfilter_make_format_list(0);
143}
144
145int avfilter_link(AVFilterContext *src, unsigned srcpad,50int avfilter_link(AVFilterContext *src, unsigned srcpad,
146 AVFilterContext *dst, unsigned dstpad)51 AVFilterContext *dst, unsigned dstpad)
147{52{
@@ -166,7 +71,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, · 18 unmodified lines
166 if(src->output_pads[srcpad].query_formats)71 if(src->output_pads[srcpad].query_formats)
167 fmts[0] = src->output_pads[srcpad].query_formats(link);72 fmts[0] = src->output_pads[srcpad].query_formats(link);
168 else73 else
169 fmts[0] = default_query_output_formats(link);74 fmts[0] = avfilter_default_query_output_formats(link);
170 fmts[1] = dst->input_pads[dstpad].query_formats(link);75 fmts[1] = dst->input_pads[dstpad].query_formats(link);
171 for(i = 0; fmts[0][i] != -1; i ++)76 for(i = 0; fmts[0][i] != -1; i ++)
172 for(j = 0; fmts[1][j] != -1; j ++)77 for(j = 0; fmts[1][j] != -1; j ++)
@@ -189,7 +94,7 @@ format_done: · 16 unmodified lines
189 if (src->output_pads[srcpad].config_props)94 if (src->output_pads[srcpad].config_props)
190 src->output_pads[srcpad].config_props(link);95 src->output_pads[srcpad].config_props(link);
191 else96 else
192 default_config_output_link(link);97 avfilter_default_config_output_link(link);
193 98
194 if (dst->input_pads[dstpad].config_props)99 if (dst->input_pads[dstpad].config_props)
195 dst->input_pads[dstpad].config_props(link);100 dst->input_pads[dstpad].config_props(link);

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