Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2015/02/25 18:34:32... | ... |
@@ -3718,6 +3718,24 @@ Set whether or not chroma is considered in the metric calculations. Default is |
3718 | 3718 |
@code{1}. |
3719 | 3719 |
@end table |
3720 | 3720 |
|
3721 |
+@section deflate |
|
3722 |
+ |
|
3723 |
+Apply deflate effect to the video. |
|
3724 |
+ |
|
3725 |
+This filter replaces the pixel by the local(3x3) average by taking into account |
|
3726 |
+only values lower than the pixel. |
|
3727 |
+ |
|
3728 |
+It accepts the following options: |
|
3729 |
+ |
|
3730 |
+@table @option |
|
3731 |
+@item threshold0 |
|
3732 |
+@item threshold1 |
|
3733 |
+@item threshold2 |
|
3734 |
+@item threshold3 |
|
3735 |
+Allows to limit the maximum change for each plane, default is 65535. |
|
3736 |
+If 0, plane will remain unchanged. |
|
3737 |
+@end table |
|
3738 |
+ |
|
3721 | 3739 |
@section dejudder |
3722 | 3740 |
|
3723 | 3741 |
Remove judder produced by partially interlaced telecined content. |
... | ... |
@@ -3904,6 +3922,33 @@ A number representing position of the first frame with respect to the telecine |
3904 | 3904 |
pattern. This is to be used if the stream is cut. The default value is @code{0}. |
3905 | 3905 |
@end table |
3906 | 3906 |
|
3907 |
+@section dilation |
|
3908 |
+ |
|
3909 |
+Apply dilation effect to the video. |
|
3910 |
+ |
|
3911 |
+This filter replaces the pixel by the local(3x3) maximum. |
|
3912 |
+ |
|
3913 |
+It accepts the following options: |
|
3914 |
+ |
|
3915 |
+@table @option |
|
3916 |
+@item threshold0 |
|
3917 |
+@item threshold1 |
|
3918 |
+@item threshold2 |
|
3919 |
+@item threshold3 |
|
3920 |
+Allows to limit the maximum change for each plane, default is 65535. |
|
3921 |
+If 0, plane will remain unchanged. |
|
3922 |
+ |
|
3923 |
+@item coordinates |
|
3924 |
+Flag which specifies the pixel to refer to. Default is 255 i.e. all eight |
|
3925 |
+pixels are used. |
|
3926 |
+ |
|
3927 |
+Flags to local 3x3 coordinates maps like this: |
|
3928 |
+ |
|
3929 |
+ 1 2 3 |
|
3930 |
+ 4 5 |
|
3931 |
+ 6 7 8 |
|
3932 |
+@end table |
|
3933 |
+ |
|
3907 | 3934 |
@section drawbox |
3908 | 3935 |
|
3909 | 3936 |
Draw a colored box on the input image. |
... | ... |
@@ -4759,6 +4804,33 @@ value. |
4759 | 4759 |
|
4760 | 4760 |
@end table |
4761 | 4761 |
|
4762 |
+@section erosion |
|
4763 |
+ |
|
4764 |
+Apply erosion effect to the video. |
|
4765 |
+ |
|
4766 |
+This filter replaces the pixel by the local(3x3) minimum. |
|
4767 |
+ |
|
4768 |
+It accepts the following options: |
|
4769 |
+ |
|
4770 |
+@table @option |
|
4771 |
+@item threshold0 |
|
4772 |
+@item threshold1 |
|
4773 |
+@item threshold2 |
|
4774 |
+@item threshold3 |
|
4775 |
+Allows to limit the maximum change for each plane, default is 65535. |
|
4776 |
+If 0, plane will remain unchanged. |
|
4777 |
+ |
|
4778 |
+@item coordinates |
|
4779 |
+Flag which specifies the pixel to refer to. Default is 255 i.e. all eight |
|
4780 |
+pixels are used. |
|
4781 |
+ |
|
4782 |
+Flags to local 3x3 coordinates maps like this: |
|
4783 |
+ |
|
4784 |
+ 1 2 3 |
|
4785 |
+ 4 5 |
|
4786 |
+ 6 7 8 |
|
4787 |
+@end table |
|
4788 |
+ |
|
4762 | 4789 |
@section extractplanes |
4763 | 4790 |
|
4764 | 4791 |
Extract color channel components from input video stream into |
... | ... |
@@ -6356,6 +6428,24 @@ Default value is @code{none}. |
6356 | 6356 |
Swap luma/chroma/alpha fields. Exchange even & odd lines. Default value is @code{0}. |
6357 | 6357 |
@end table |
6358 | 6358 |
|
6359 |
+@section inflate |
|
6360 |
+ |
|
6361 |
+Apply inflate effect to the video. |
|
6362 |
+ |
|
6363 |
+This filter replaces the pixel by the local(3x3) average by taking into account |
|
6364 |
+only values higher than the pixel. |
|
6365 |
+ |
|
6366 |
+It accepts the following options: |
|
6367 |
+ |
|
6368 |
+@table @option |
|
6369 |
+@item threshold0 |
|
6370 |
+@item threshold1 |
|
6371 |
+@item threshold2 |
|
6372 |
+@item threshold3 |
|
6373 |
+Allows to limit the maximum change for each plane, default is 65535. |
|
6374 |
+If 0, plane will remain unchanged. |
|
6375 |
+@end table |
|
6376 |
+ |
|
6359 | 6377 |
@section interlace |
6360 | 6378 |
|
6361 | 6379 |
Simple interlacing filter from progressive contents. This interleaves upper (or |
... | ... |
@@ -112,10 +112,12 @@ OBJS-$(CONFIG_CROPDETECT_FILTER) += vf_cropdetect.o |
112 | 112 |
OBJS-$(CONFIG_CURVES_FILTER) += vf_curves.o |
113 | 113 |
OBJS-$(CONFIG_DCTDNOIZ_FILTER) += vf_dctdnoiz.o |
114 | 114 |
OBJS-$(CONFIG_DECIMATE_FILTER) += vf_decimate.o |
115 |
+OBJS-$(CONFIG_DEFLATE_FILTER) += vf_neighbor.o |
|
115 | 116 |
OBJS-$(CONFIG_DEJUDDER_FILTER) += vf_dejudder.o |
116 | 117 |
OBJS-$(CONFIG_DELOGO_FILTER) += vf_delogo.o |
117 | 118 |
OBJS-$(CONFIG_DESHAKE_FILTER) += vf_deshake.o |
118 | 119 |
OBJS-$(CONFIG_DETELECINE_FILTER) += vf_detelecine.o |
120 |
+OBJS-$(CONFIG_DILATION_FILTER) += vf_neighbor.o |
|
119 | 121 |
OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o |
120 | 122 |
OBJS-$(CONFIG_DRAWGRAPH_FILTER) += f_drawgraph.o |
121 | 123 |
OBJS-$(CONFIG_DRAWGRID_FILTER) += vf_drawbox.o |
... | ... |
@@ -123,6 +125,7 @@ OBJS-$(CONFIG_DRAWTEXT_FILTER) += vf_drawtext.o |
123 | 123 |
OBJS-$(CONFIG_ELBG_FILTER) += vf_elbg.o |
124 | 124 |
OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o |
125 | 125 |
OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o |
126 |
+OBJS-$(CONFIG_EROSION_FILTER) += vf_neighbor.o |
|
126 | 127 |
OBJS-$(CONFIG_EXTRACTPLANES_FILTER) += vf_extractplanes.o |
127 | 128 |
OBJS-$(CONFIG_FADE_FILTER) += vf_fade.o |
128 | 129 |
OBJS-$(CONFIG_FFTFILT_FILTER) += vf_fftfilt.o |
... | ... |
@@ -147,6 +150,7 @@ OBJS-$(CONFIG_HQX_FILTER) += vf_hqx.o |
147 | 147 |
OBJS-$(CONFIG_HUE_FILTER) += vf_hue.o |
148 | 148 |
OBJS-$(CONFIG_IDET_FILTER) += vf_idet.o |
149 | 149 |
OBJS-$(CONFIG_IL_FILTER) += vf_il.o |
150 |
+OBJS-$(CONFIG_INFLATE_FILTER) += vf_neighbor.o |
|
150 | 151 |
OBJS-$(CONFIG_INTERLACE_FILTER) += vf_interlace.o |
151 | 152 |
OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o |
152 | 153 |
OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o |
... | ... |
@@ -128,10 +128,12 @@ void avfilter_register_all(void) |
128 | 128 |
REGISTER_FILTER(CURVES, curves, vf); |
129 | 129 |
REGISTER_FILTER(DCTDNOIZ, dctdnoiz, vf); |
130 | 130 |
REGISTER_FILTER(DECIMATE, decimate, vf); |
131 |
+ REGISTER_FILTER(DEFLATE, deflate, vf); |
|
131 | 132 |
REGISTER_FILTER(DEJUDDER, dejudder, vf); |
132 | 133 |
REGISTER_FILTER(DELOGO, delogo, vf); |
133 | 134 |
REGISTER_FILTER(DESHAKE, deshake, vf); |
134 | 135 |
REGISTER_FILTER(DETELECINE, detelecine, vf); |
136 |
+ REGISTER_FILTER(DILATION, dilation, vf); |
|
135 | 137 |
REGISTER_FILTER(DRAWBOX, drawbox, vf); |
136 | 138 |
REGISTER_FILTER(DRAWGRAPH, drawgraph, vf); |
137 | 139 |
REGISTER_FILTER(DRAWGRID, drawgrid, vf); |
... | ... |
@@ -139,6 +141,7 @@ void avfilter_register_all(void) |
139 | 139 |
REGISTER_FILTER(EDGEDETECT, edgedetect, vf); |
140 | 140 |
REGISTER_FILTER(ELBG, elbg, vf); |
141 | 141 |
REGISTER_FILTER(EQ, eq, vf); |
142 |
+ REGISTER_FILTER(EROSION, erosion, vf); |
|
142 | 143 |
REGISTER_FILTER(EXTRACTPLANES, extractplanes, vf); |
143 | 144 |
REGISTER_FILTER(FADE, fade, vf); |
144 | 145 |
REGISTER_FILTER(FFTFILT, fftfilt, vf); |
... | ... |
@@ -163,6 +166,7 @@ void avfilter_register_all(void) |
163 | 163 |
REGISTER_FILTER(HUE, hue, vf); |
164 | 164 |
REGISTER_FILTER(IDET, idet, vf); |
165 | 165 |
REGISTER_FILTER(IL, il, vf); |
166 |
+ REGISTER_FILTER(INFLATE, inflate, vf); |
|
166 | 167 |
REGISTER_FILTER(INTERLACE, interlace, vf); |
167 | 168 |
REGISTER_FILTER(INTERLEAVE, interleave, vf); |
168 | 169 |
REGISTER_FILTER(KERNDEINT, kerndeint, vf); |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
#include "libavutil/version.h" |
31 | 31 |
|
32 | 32 |
#define LIBAVFILTER_VERSION_MAJOR 5 |
33 |
-#define LIBAVFILTER_VERSION_MINOR 21 |
|
33 |
+#define LIBAVFILTER_VERSION_MINOR 22 |
|
34 | 34 |
#define LIBAVFILTER_VERSION_MICRO 100 |
35 | 35 |
|
36 | 36 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
37 | 37 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,324 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com) |
|
2 |
+ * Copyright (c) 2015 Paul B Mahol |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include "libavutil/imgutils.h" |
|
22 |
+#include "libavutil/pixdesc.h" |
|
23 |
+#include "libavutil/opt.h" |
|
24 |
+#include "avfilter.h" |
|
25 |
+#include "formats.h" |
|
26 |
+#include "internal.h" |
|
27 |
+#include "video.h" |
|
28 |
+ |
|
29 |
+typedef struct NContext { |
|
30 |
+ const AVClass *class; |
|
31 |
+ int planeheight[4]; |
|
32 |
+ int planewidth[4]; |
|
33 |
+ int nb_planes; |
|
34 |
+ int threshold[4]; |
|
35 |
+ int coordinates; |
|
36 |
+ uint8_t *buffer; |
|
37 |
+ |
|
38 |
+ void (*filter)(uint8_t *dst, const uint8_t *p1, int width, |
|
39 |
+ int threshold, const uint8_t *coordinates[], int coord); |
|
40 |
+} NContext; |
|
41 |
+ |
|
42 |
+static int query_formats(AVFilterContext *ctx) |
|
43 |
+{ |
|
44 |
+ static const enum AVPixelFormat pix_fmts[] = { |
|
45 |
+ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, |
|
46 |
+ AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P,AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P, |
|
47 |
+ AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, |
|
48 |
+ AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE |
|
49 |
+ }; |
|
50 |
+ |
|
51 |
+ ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); |
|
52 |
+ return 0; |
|
53 |
+} |
|
54 |
+ |
|
55 |
+static av_cold void uninit(AVFilterContext *ctx) |
|
56 |
+{ |
|
57 |
+ NContext *s = ctx->priv; |
|
58 |
+ |
|
59 |
+ av_freep(&s->buffer); |
|
60 |
+} |
|
61 |
+ |
|
62 |
+static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin) |
|
63 |
+{ |
|
64 |
+ int i; |
|
65 |
+ |
|
66 |
+ memcpy(line, srcp, width); |
|
67 |
+ |
|
68 |
+ for (i = mergin; i > 0; i--) { |
|
69 |
+ line[-i] = line[i]; |
|
70 |
+ line[width - 1 + i] = line[width - 1 - i]; |
|
71 |
+ } |
|
72 |
+} |
|
73 |
+ |
|
74 |
+static void erosion(uint8_t *dst, const uint8_t *p1, int width, |
|
75 |
+ int threshold, const uint8_t *coordinates[], int coord) |
|
76 |
+{ |
|
77 |
+ int x, i; |
|
78 |
+ |
|
79 |
+ for (x = 0; x < width; x++) { |
|
80 |
+ int min = p1[x]; |
|
81 |
+ int limit = FFMAX(min - threshold, 0); |
|
82 |
+ |
|
83 |
+ for (i = 0; i < 8; i++) { |
|
84 |
+ if (coord & (1 << i)) { |
|
85 |
+ min = FFMIN(min, *(coordinates[i] + x)); |
|
86 |
+ } |
|
87 |
+ min = FFMAX(min, limit); |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ dst[x] = min; |
|
91 |
+ } |
|
92 |
+} |
|
93 |
+ |
|
94 |
+static void dilation(uint8_t *dst, const uint8_t *p1, int width, |
|
95 |
+ int threshold, const uint8_t *coordinates[], int coord) |
|
96 |
+{ |
|
97 |
+ int x, i; |
|
98 |
+ |
|
99 |
+ for (x = 0; x < width; x++) { |
|
100 |
+ int max = p1[x]; |
|
101 |
+ int limit = FFMIN(max + threshold, 255); |
|
102 |
+ |
|
103 |
+ for (i = 0; i < 8; i++) { |
|
104 |
+ if (coord & (1 << i)) { |
|
105 |
+ max = FFMAX(max, *(coordinates[i] + x)); |
|
106 |
+ } |
|
107 |
+ max = FFMIN(max, limit); |
|
108 |
+ } |
|
109 |
+ |
|
110 |
+ dst[x] = max; |
|
111 |
+ } |
|
112 |
+} |
|
113 |
+ |
|
114 |
+static void deflate(uint8_t *dst, const uint8_t *p1, int width, |
|
115 |
+ int threshold, const uint8_t *coordinates[], int coord) |
|
116 |
+{ |
|
117 |
+ int x, i; |
|
118 |
+ |
|
119 |
+ for (x = 0; x < width; x++) { |
|
120 |
+ int sum = 0; |
|
121 |
+ int limit = FFMAX(p1[x] - threshold, 0); |
|
122 |
+ |
|
123 |
+ for (i = 0; i < 8; sum += *(coordinates[i++] + x)); |
|
124 |
+ |
|
125 |
+ dst[x] = FFMAX(FFMIN(sum / 8, p1[x]), limit); |
|
126 |
+ } |
|
127 |
+} |
|
128 |
+ |
|
129 |
+static void inflate(uint8_t *dst, const uint8_t *p1, int width, |
|
130 |
+ int threshold, const uint8_t *coordinates[], int coord) |
|
131 |
+{ |
|
132 |
+ int x, i; |
|
133 |
+ |
|
134 |
+ for (x = 0; x < width; x++) { |
|
135 |
+ int sum = 0; |
|
136 |
+ int limit = FFMIN(p1[x] + threshold, 255); |
|
137 |
+ |
|
138 |
+ for (i = 0; i < 8; sum += *(coordinates[i++] + x)); |
|
139 |
+ |
|
140 |
+ dst[x] = FFMIN(FFMAX(sum / 8, p1[x]), limit); |
|
141 |
+ } |
|
142 |
+} |
|
143 |
+ |
|
144 |
+static int config_input(AVFilterLink *inlink) |
|
145 |
+{ |
|
146 |
+ AVFilterContext *ctx = inlink->dst; |
|
147 |
+ NContext *s = ctx->priv; |
|
148 |
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); |
|
149 |
+ int ret; |
|
150 |
+ |
|
151 |
+ if ((ret = av_image_fill_linesizes(s->planewidth, inlink->format, inlink->w)) < 0) |
|
152 |
+ return ret; |
|
153 |
+ |
|
154 |
+ s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); |
|
155 |
+ s->planeheight[0] = s->planeheight[3] = inlink->h; |
|
156 |
+ |
|
157 |
+ s->nb_planes = av_pix_fmt_count_planes(inlink->format); |
|
158 |
+ s->buffer = av_malloc(3 * (s->planewidth[0] + 32)); |
|
159 |
+ if (!s->buffer) |
|
160 |
+ return AVERROR(ENOMEM); |
|
161 |
+ |
|
162 |
+ if (!strcmp(ctx->filter->name, "erosion")) |
|
163 |
+ s->filter = erosion; |
|
164 |
+ else if (!strcmp(ctx->filter->name, "dilation")) |
|
165 |
+ s->filter = dilation; |
|
166 |
+ else if (!strcmp(ctx->filter->name, "deflate")) |
|
167 |
+ s->filter = deflate; |
|
168 |
+ else if (!strcmp(ctx->filter->name, "inflate")) |
|
169 |
+ s->filter = inflate; |
|
170 |
+ |
|
171 |
+ return 0; |
|
172 |
+} |
|
173 |
+ |
|
174 |
+static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
|
175 |
+{ |
|
176 |
+ AVFilterContext *ctx = inlink->dst; |
|
177 |
+ AVFilterLink *outlink = ctx->outputs[0]; |
|
178 |
+ NContext *s = ctx->priv; |
|
179 |
+ AVFrame *out; |
|
180 |
+ int plane, y; |
|
181 |
+ |
|
182 |
+ out = ff_get_video_buffer(outlink, outlink->w, outlink->h); |
|
183 |
+ if (!out) { |
|
184 |
+ av_frame_free(&in); |
|
185 |
+ return AVERROR(ENOMEM); |
|
186 |
+ } |
|
187 |
+ av_frame_copy_props(out, in); |
|
188 |
+ |
|
189 |
+ for (plane = 0; plane < s->nb_planes; plane++) { |
|
190 |
+ const int threshold = s->threshold[plane]; |
|
191 |
+ |
|
192 |
+ if (threshold) { |
|
193 |
+ const uint8_t *src = in->data[plane]; |
|
194 |
+ uint8_t *dst = out->data[plane]; |
|
195 |
+ int stride = in->linesize[plane]; |
|
196 |
+ int height = s->planeheight[plane]; |
|
197 |
+ int width = s->planewidth[plane]; |
|
198 |
+ uint8_t *p0 = s->buffer + 16; |
|
199 |
+ uint8_t *p1 = p0 + s->planewidth[0]; |
|
200 |
+ uint8_t *p2 = p1 + s->planewidth[0]; |
|
201 |
+ uint8_t *orig = p0, *end = p2; |
|
202 |
+ |
|
203 |
+ line_copy8(p0, src + stride, width, 1); |
|
204 |
+ line_copy8(p1, src, width, 1); |
|
205 |
+ |
|
206 |
+ for (y = 0; y < height; y++) { |
|
207 |
+ const uint8_t *coordinates[] = { p0 - 1, p0, p0 + 1, |
|
208 |
+ p1 - 1, p1 + 1, |
|
209 |
+ p2 - 1, p2, p2 + 1}; |
|
210 |
+ src += stride * (y < height - 1 ? 1 : -1); |
|
211 |
+ line_copy8(p2, src, width, 1); |
|
212 |
+ |
|
213 |
+ s->filter(dst, p1, width, threshold, coordinates, s->coordinates); |
|
214 |
+ |
|
215 |
+ p0 = p1; |
|
216 |
+ p1 = p2; |
|
217 |
+ p2 = (p2 == end) ? orig: p2 + s->planewidth[0]; |
|
218 |
+ dst += out->linesize[plane]; |
|
219 |
+ } |
|
220 |
+ } else { |
|
221 |
+ av_image_copy_plane(out->data[plane], out->linesize[plane], |
|
222 |
+ in->data[plane], in->linesize[plane], |
|
223 |
+ s->planewidth[plane], s->planeheight[plane]); |
|
224 |
+ } |
|
225 |
+ } |
|
226 |
+ |
|
227 |
+ av_frame_free(&in); |
|
228 |
+ return ff_filter_frame(outlink, out); |
|
229 |
+} |
|
230 |
+ |
|
231 |
+static const AVFilterPad neighbor_inputs[] = { |
|
232 |
+ { |
|
233 |
+ .name = "default", |
|
234 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
235 |
+ .filter_frame = filter_frame, |
|
236 |
+ .config_props = config_input, |
|
237 |
+ }, |
|
238 |
+ { NULL } |
|
239 |
+}; |
|
240 |
+ |
|
241 |
+static const AVFilterPad neighbor_outputs[] = { |
|
242 |
+ { |
|
243 |
+ .name = "default", |
|
244 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
245 |
+ }, |
|
246 |
+ { NULL } |
|
247 |
+}; |
|
248 |
+ |
|
249 |
+#define OFFSET(x) offsetof(NContext, x) |
|
250 |
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
|
251 |
+ |
|
252 |
+#define DEFINE_NEIGHBOR_FILTER(name_, description_) \ |
|
253 |
+AVFILTER_DEFINE_CLASS(name_); \ |
|
254 |
+ \ |
|
255 |
+AVFilter ff_vf_##name_ = { \ |
|
256 |
+ .name = #name_, \ |
|
257 |
+ .description = NULL_IF_CONFIG_SMALL(description_), \ |
|
258 |
+ .priv_size = sizeof(NContext), \ |
|
259 |
+ .priv_class = &name_##_class, \ |
|
260 |
+ .uninit = uninit, \ |
|
261 |
+ .query_formats = query_formats, \ |
|
262 |
+ .inputs = neighbor_inputs, \ |
|
263 |
+ .outputs = neighbor_outputs, \ |
|
264 |
+ .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, \ |
|
265 |
+} |
|
266 |
+ |
|
267 |
+#if CONFIG_EROSION_FILTER |
|
268 |
+ |
|
269 |
+static const AVOption erosion_options[] = { |
|
270 |
+ { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
271 |
+ { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
272 |
+ { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
273 |
+ { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
274 |
+ { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, |
|
275 |
+ { NULL } |
|
276 |
+}; |
|
277 |
+ |
|
278 |
+DEFINE_NEIGHBOR_FILTER(erosion, "Apply erosion effect"); |
|
279 |
+ |
|
280 |
+#endif /* CONFIG_EROSION_FILTER */ |
|
281 |
+ |
|
282 |
+#if CONFIG_DILATION_FILTER |
|
283 |
+ |
|
284 |
+static const AVOption dilation_options[] = { |
|
285 |
+ { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
286 |
+ { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
287 |
+ { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
288 |
+ { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
289 |
+ { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS }, |
|
290 |
+ { NULL } |
|
291 |
+}; |
|
292 |
+ |
|
293 |
+DEFINE_NEIGHBOR_FILTER(dilation, "Apply dilation effect"); |
|
294 |
+ |
|
295 |
+#endif /* CONFIG_DILATION_FILTER */ |
|
296 |
+ |
|
297 |
+#if CONFIG_DEFLATE_FILTER |
|
298 |
+ |
|
299 |
+static const AVOption deflate_options[] = { |
|
300 |
+ { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
301 |
+ { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
302 |
+ { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
303 |
+ { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
304 |
+ { NULL } |
|
305 |
+}; |
|
306 |
+ |
|
307 |
+DEFINE_NEIGHBOR_FILTER(deflate, "Apply deflate effect"); |
|
308 |
+ |
|
309 |
+#endif /* CONFIG_DEFLATE_FILTER */ |
|
310 |
+ |
|
311 |
+#if CONFIG_INFLATE_FILTER |
|
312 |
+ |
|
313 |
+static const AVOption inflate_options[] = { |
|
314 |
+ { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
315 |
+ { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
316 |
+ { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
317 |
+ { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS }, |
|
318 |
+ { NULL } |
|
319 |
+}; |
|
320 |
+ |
|
321 |
+DEFINE_NEIGHBOR_FILTER(inflate, "Apply inflate effect"); |
|
322 |
+ |
|
323 |
+#endif /* CONFIG_INFLATE_FILTER */ |