... | ... |
@@ -3635,45 +3635,6 @@ cellauto=p='@@@@ @@ @@@@':s=100x400:full=0:rule=18 |
3635 | 3635 |
|
3636 | 3636 |
@end itemize |
3637 | 3637 |
|
3638 |
-@section color |
|
3639 |
- |
|
3640 |
-Provide an uniformly colored input. |
|
3641 |
- |
|
3642 |
-This source accepts list of options in the form of |
|
3643 |
-@var{key}=@var{value} pairs separated by ":". |
|
3644 |
- |
|
3645 |
-Follows the description of the accepted parameters. |
|
3646 |
- |
|
3647 |
-@table @option |
|
3648 |
- |
|
3649 |
-@item color, c |
|
3650 |
-Specify the color of the source. It can be the name of a color (case |
|
3651 |
-insensitive match) or a 0xRRGGBB[AA] sequence, possibly followed by an |
|
3652 |
-alpha specifier. The default value is "black". |
|
3653 |
- |
|
3654 |
-@item size, s |
|
3655 |
-Specify the size of the sourced video, it may be a string of the form |
|
3656 |
-@var{width}x@var{height}, or the name of a size abbreviation. The |
|
3657 |
-default value is "320x240". |
|
3658 |
- |
|
3659 |
-@item rate, r |
|
3660 |
-Specify the frame rate of the sourced video, as the number of frames |
|
3661 |
-generated per second. It has to be a string in the format |
|
3662 |
-@var{frame_rate_num}/@var{frame_rate_den}, an integer number, a float |
|
3663 |
-number or a valid video frame rate abbreviation. The default value is |
|
3664 |
-"25". |
|
3665 |
- |
|
3666 |
-@end table |
|
3667 |
- |
|
3668 |
-For example the following graph description will generate a red source |
|
3669 |
-with an opacity of 0.2, with size "qcif" and a frame rate of 10 |
|
3670 |
-frames per second, which will be overlayed over the source connected |
|
3671 |
-to the pad with identifier "in". |
|
3672 |
- |
|
3673 |
-@example |
|
3674 |
-"color=c=red@@0.2:s=qcif:r=10 [color]; [in][color] overlay [out]" |
|
3675 |
-@end example |
|
3676 |
- |
|
3677 | 3638 |
@section mptestsrc |
3678 | 3639 |
|
3679 | 3640 |
Generate various test patterns, as generated by the MPlayer test filter. |
... | ... |
@@ -3884,7 +3845,9 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c |
3884 | 3884 |
@end example |
3885 | 3885 |
@end itemize |
3886 | 3886 |
|
3887 |
-@section nullsrc, rgbtestsrc, testsrc |
|
3887 |
+@section color, nullsrc, rgbtestsrc, testsrc |
|
3888 |
+ |
|
3889 |
+The @code{color} source provides an uniformly colored input. |
|
3888 | 3890 |
|
3889 | 3891 |
The @code{nullsrc} source returns unprocessed video frames. It is |
3890 | 3892 |
mainly useful to be employed in analysis / debugging tools, or as the |
... | ... |
@@ -3903,6 +3866,12 @@ separated by ":". The description of the accepted options follows. |
3903 | 3903 |
|
3904 | 3904 |
@table @option |
3905 | 3905 |
|
3906 |
+@item color, c |
|
3907 |
+Specify the color of the source, only used in the @code{color} |
|
3908 |
+source. It can be the name of a color (case insensitive match) or a |
|
3909 |
+0xRRGGBB[AA] sequence, possibly followed by an alpha specifier. The |
|
3910 |
+default value is "black". |
|
3911 |
+ |
|
3906 | 3912 |
@item size, s |
3907 | 3913 |
Specify the size of the sourced video, it may be a string of the form |
3908 | 3914 |
@var{width}x@var{height}, or the name of a size abbreviation. The |
... | ... |
@@ -3946,6 +3915,13 @@ testsrc=duration=5.3:size=qcif:rate=10 |
3946 | 3946 |
will generate a video with a duration of 5.3 seconds, with size |
3947 | 3947 |
176x144 and a frame rate of 10 frames per second. |
3948 | 3948 |
|
3949 |
+The following graph description will generate a red source |
|
3950 |
+with an opacity of 0.2, with size "qcif" and a frame rate of 10 |
|
3951 |
+frames per second. |
|
3952 |
+@example |
|
3953 |
+color=c=red@@0.2:s=qcif:r=10 |
|
3954 |
+@end example |
|
3955 |
+ |
|
3949 | 3956 |
If the input content is to be ignored, @code{nullsrc} can be used. The |
3950 | 3957 |
following command generates noise in the luminance plane by employing |
3951 | 3958 |
the @code{mp=geq} filter: |
... | ... |
@@ -132,7 +132,7 @@ OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o |
132 | 132 |
OBJS-$(CONFIG_YADIF_FILTER) += vf_yadif.o |
133 | 133 |
|
134 | 134 |
OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o |
135 |
-OBJS-$(CONFIG_COLOR_FILTER) += vsrc_color.o |
|
135 |
+OBJS-$(CONFIG_COLOR_FILTER) += vsrc_testsrc.o |
|
136 | 136 |
OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o |
137 | 137 |
OBJS-$(CONFIG_LIFE_FILTER) += vsrc_life.o |
138 | 138 |
OBJS-$(CONFIG_MANDELBROT_FILTER) += vsrc_mandelbrot.o |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
|
31 | 31 |
#define LIBAVFILTER_VERSION_MAJOR 3 |
32 | 32 |
#define LIBAVFILTER_VERSION_MINOR 5 |
33 |
-#define LIBAVFILTER_VERSION_MICRO 101 |
|
33 |
+#define LIBAVFILTER_VERSION_MICRO 102 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
36 | 36 |
LIBAVFILTER_VERSION_MINOR, \ |
37 | 37 |
deleted file mode 100644 |
... | ... |
@@ -1,188 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (c) 2010 Stefano Sabatini |
|
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 |
-/** |
|
22 |
- * @file |
|
23 |
- * color source |
|
24 |
- */ |
|
25 |
- |
|
26 |
-#include "avfilter.h" |
|
27 |
-#include "formats.h" |
|
28 |
-#include "internal.h" |
|
29 |
-#include "video.h" |
|
30 |
-#include "libavutil/pixdesc.h" |
|
31 |
-#include "libavutil/colorspace.h" |
|
32 |
-#include "libavutil/imgutils.h" |
|
33 |
-#include "libavutil/mathematics.h" |
|
34 |
-#include "libavutil/opt.h" |
|
35 |
-#include "libavutil/parseutils.h" |
|
36 |
-#include "drawutils.h" |
|
37 |
- |
|
38 |
-typedef struct { |
|
39 |
- const AVClass *class; |
|
40 |
- int w, h; |
|
41 |
- char *rate_str; |
|
42 |
- char *color_str; |
|
43 |
- uint8_t color_rgba[4]; |
|
44 |
- AVRational time_base; |
|
45 |
- uint64_t pts; |
|
46 |
- FFDrawContext draw; |
|
47 |
- FFDrawColor color; |
|
48 |
- AVFilterBufferRef *picref; ///< cached reference containing the painted picture |
|
49 |
-} ColorContext; |
|
50 |
- |
|
51 |
-#define OFFSET(x) offsetof(ColorContext, x) |
|
52 |
- |
|
53 |
-static const AVOption color_options[]= { |
|
54 |
- { "size", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0 }, |
|
55 |
- { "s", "set frame size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0 }, |
|
56 |
- { "rate", "set frame rate", OFFSET(rate_str), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, |
|
57 |
- { "r", "set frame rate", OFFSET(rate_str), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, |
|
58 |
- { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX }, |
|
59 |
- { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX }, |
|
60 |
- { NULL }, |
|
61 |
-}; |
|
62 |
- |
|
63 |
-AVFILTER_DEFINE_CLASS(color); |
|
64 |
- |
|
65 |
-static av_cold int color_init(AVFilterContext *ctx, const char *args) |
|
66 |
-{ |
|
67 |
- ColorContext *color = ctx->priv; |
|
68 |
- AVRational frame_rate_q; |
|
69 |
- int ret = 0; |
|
70 |
- |
|
71 |
- color->class = &color_class; |
|
72 |
- |
|
73 |
- av_opt_set_defaults(color); |
|
74 |
- if ((ret = av_set_options_string(color, args, "=", ":")) < 0) { |
|
75 |
- av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args); |
|
76 |
- goto end; |
|
77 |
- } |
|
78 |
- if (av_parse_video_rate(&frame_rate_q, color->rate_str) < 0) { |
|
79 |
- av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", color->rate_str); |
|
80 |
- ret = AVERROR(EINVAL); |
|
81 |
- goto end; |
|
82 |
- } |
|
83 |
- if (av_parse_color(color->color_rgba, color->color_str, -1, ctx) < 0) { |
|
84 |
- ret = AVERROR(EINVAL); |
|
85 |
- goto end; |
|
86 |
- } |
|
87 |
- |
|
88 |
- color->time_base.num = frame_rate_q.den; |
|
89 |
- color->time_base.den = frame_rate_q.num; |
|
90 |
- |
|
91 |
-end: |
|
92 |
- return ret; |
|
93 |
-} |
|
94 |
- |
|
95 |
-static av_cold void color_uninit(AVFilterContext *ctx) |
|
96 |
-{ |
|
97 |
- ColorContext *color = ctx->priv; |
|
98 |
- av_opt_free(color); |
|
99 |
- avfilter_unref_bufferp(&color->picref); |
|
100 |
-} |
|
101 |
- |
|
102 |
-static int query_formats(AVFilterContext *ctx) |
|
103 |
-{ |
|
104 |
- ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
105 |
- return 0; |
|
106 |
-} |
|
107 |
- |
|
108 |
-static int color_config_props(AVFilterLink *inlink) |
|
109 |
-{ |
|
110 |
- AVFilterContext *ctx = inlink->src; |
|
111 |
- ColorContext *color = ctx->priv; |
|
112 |
- |
|
113 |
- ff_draw_init(&color->draw, inlink->format, 0); |
|
114 |
- ff_draw_color(&color->draw, &color->color, color->color_rgba); |
|
115 |
- |
|
116 |
- color->w = ff_draw_round_to_sub(&color->draw, 0, -1, color->w); |
|
117 |
- color->h = ff_draw_round_to_sub(&color->draw, 1, -1, color->h); |
|
118 |
- if (av_image_check_size(color->w, color->h, 0, ctx) < 0) |
|
119 |
- return AVERROR(EINVAL); |
|
120 |
- |
|
121 |
- av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d r:%d/%d color:0x%02x%02x%02x%02x\n", |
|
122 |
- color->w, color->h, color->time_base.den, color->time_base.num, |
|
123 |
- color->color_rgba[0], color->color_rgba[1], color->color_rgba[2], color->color_rgba[3]); |
|
124 |
- inlink->w = color->w; |
|
125 |
- inlink->h = color->h; |
|
126 |
- inlink->time_base = color->time_base; |
|
127 |
- |
|
128 |
- return 0; |
|
129 |
-} |
|
130 |
- |
|
131 |
-static int color_request_frame(AVFilterLink *link) |
|
132 |
-{ |
|
133 |
- ColorContext *color = link->src->priv; |
|
134 |
- AVFilterBufferRef *buf_out; |
|
135 |
- int ret; |
|
136 |
- |
|
137 |
- if (!color->picref) { |
|
138 |
- color->picref = |
|
139 |
- ff_get_video_buffer(link, AV_PERM_WRITE|AV_PERM_PRESERVE|AV_PERM_REUSE, |
|
140 |
- color->w, color->h); |
|
141 |
- if (!color->picref) |
|
142 |
- return AVERROR(ENOMEM); |
|
143 |
- ff_fill_rectangle(&color->draw, &color->color, |
|
144 |
- color->picref->data, color->picref->linesize, |
|
145 |
- 0, 0, color->w, color->h); |
|
146 |
- color->picref->video->sample_aspect_ratio = (AVRational) {1, 1}; |
|
147 |
- color->picref->pos = -1; |
|
148 |
- } |
|
149 |
- |
|
150 |
- color->picref->pts = color->pts++; |
|
151 |
- buf_out = avfilter_ref_buffer(color->picref, ~AV_PERM_WRITE); |
|
152 |
- if (!buf_out) { |
|
153 |
- ret = AVERROR(ENOMEM); |
|
154 |
- goto fail; |
|
155 |
- } |
|
156 |
- |
|
157 |
- ret = ff_start_frame(link, buf_out); |
|
158 |
- if (ret < 0) |
|
159 |
- goto fail; |
|
160 |
- |
|
161 |
- ret = ff_draw_slice(link, 0, color->h, 1); |
|
162 |
- if (ret < 0) |
|
163 |
- goto fail; |
|
164 |
- |
|
165 |
- ret = ff_end_frame(link); |
|
166 |
- |
|
167 |
-fail: |
|
168 |
- return ret; |
|
169 |
-} |
|
170 |
- |
|
171 |
-AVFilter avfilter_vsrc_color = { |
|
172 |
- .name = "color", |
|
173 |
- .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."), |
|
174 |
- |
|
175 |
- .priv_size = sizeof(ColorContext), |
|
176 |
- .init = color_init, |
|
177 |
- .uninit = color_uninit, |
|
178 |
- |
|
179 |
- .query_formats = query_formats, |
|
180 |
- |
|
181 |
- .inputs = (const AVFilterPad[]) {{ .name = NULL}}, |
|
182 |
- |
|
183 |
- .outputs = (const AVFilterPad[]) {{ .name = "default", |
|
184 |
- .type = AVMEDIA_TYPE_VIDEO, |
|
185 |
- .request_frame = color_request_frame, |
|
186 |
- .config_props = color_config_props }, |
|
187 |
- { .name = NULL}}, |
|
188 |
-}; |
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
#include <float.h> |
34 | 34 |
|
35 | 35 |
#include "libavutil/opt.h" |
36 |
+#include "libavutil/imgutils.h" |
|
36 | 37 |
#include "libavutil/intreadwrite.h" |
37 | 38 |
#include "libavutil/parseutils.h" |
38 | 39 |
#include "avfilter.h" |
... | ... |
@@ -56,6 +57,12 @@ typedef struct { |
56 | 56 |
|
57 | 57 |
void (* fill_picture_fn)(AVFilterContext *ctx, AVFilterBufferRef *picref); |
58 | 58 |
|
59 |
+ /* only used by color */ |
|
60 |
+ char *color_str; |
|
61 |
+ FFDrawContext draw; |
|
62 |
+ FFDrawColor color; |
|
63 |
+ uint8_t color_rgba[4]; |
|
64 |
+ |
|
59 | 65 |
/* only used by rgbtest */ |
60 | 66 |
uint8_t rgba_map[4]; |
61 | 67 |
} TestSourceContext; |
... | ... |
@@ -71,6 +78,10 @@ static const AVOption options[] = { |
71 | 71 |
{ "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, |
72 | 72 |
{ "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX }, |
73 | 73 |
|
74 |
+ /* only used by color */ |
|
75 |
+ { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX }, |
|
76 |
+ { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX }, |
|
77 |
+ |
|
74 | 78 |
/* only used by testsrc */ |
75 | 79 |
{ "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, |
76 | 80 |
{ "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, |
... | ... |
@@ -107,6 +118,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args) |
107 | 107 |
ctx->filter->name); |
108 | 108 |
} |
109 | 109 |
|
110 |
+ if (test->color_str && strcmp(ctx->filter->name, "color")) { |
|
111 |
+ av_log(ctx, AV_LOG_WARNING, |
|
112 |
+ "Option 'color' is ignored with source '%s'\n", |
|
113 |
+ ctx->filter->name); |
|
114 |
+ } |
|
115 |
+ if ((ret = av_parse_color(test->color_rgba, test->color_str, -1, ctx)) < 0) |
|
116 |
+ return ret; |
|
117 |
+ |
|
110 | 118 |
test->time_base.num = frame_rate_q.den; |
111 | 119 |
test->time_base.den = frame_rate_q.num; |
112 | 120 |
test->max_pts = duration >= 0 ? |
... | ... |
@@ -185,6 +204,83 @@ static int request_frame(AVFilterLink *outlink) |
185 | 185 |
return 0; |
186 | 186 |
} |
187 | 187 |
|
188 |
+#if CONFIG_COLOR_FILTER |
|
189 |
+ |
|
190 |
+#define color_options options |
|
191 |
+AVFILTER_DEFINE_CLASS(color); |
|
192 |
+ |
|
193 |
+static void color_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) |
|
194 |
+{ |
|
195 |
+ TestSourceContext *test = ctx->priv; |
|
196 |
+ ff_fill_rectangle(&test->draw, &test->color, |
|
197 |
+ picref->data, picref->linesize, |
|
198 |
+ 0, 0, test->w, test->h); |
|
199 |
+} |
|
200 |
+ |
|
201 |
+static av_cold int color_init(AVFilterContext *ctx, const char *args) |
|
202 |
+{ |
|
203 |
+ TestSourceContext *test = ctx->priv; |
|
204 |
+ test->class = &color_class; |
|
205 |
+ test->fill_picture_fn = color_fill_picture; |
|
206 |
+ test->draw_once = 1; |
|
207 |
+ return init(ctx, args); |
|
208 |
+} |
|
209 |
+ |
|
210 |
+static int color_query_formats(AVFilterContext *ctx) |
|
211 |
+{ |
|
212 |
+ ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); |
|
213 |
+ return 0; |
|
214 |
+} |
|
215 |
+ |
|
216 |
+static int color_config_props(AVFilterLink *inlink) |
|
217 |
+{ |
|
218 |
+ AVFilterContext *ctx = inlink->src; |
|
219 |
+ TestSourceContext *test = ctx->priv; |
|
220 |
+ int ret; |
|
221 |
+ |
|
222 |
+ ff_draw_init(&test->draw, inlink->format, 0); |
|
223 |
+ ff_draw_color(&test->draw, &test->color, test->color_rgba); |
|
224 |
+ |
|
225 |
+ test->w = ff_draw_round_to_sub(&test->draw, 0, -1, test->w); |
|
226 |
+ test->h = ff_draw_round_to_sub(&test->draw, 1, -1, test->h); |
|
227 |
+ if (av_image_check_size(test->w, test->h, 0, ctx) < 0) |
|
228 |
+ return AVERROR(EINVAL); |
|
229 |
+ |
|
230 |
+ if (ret = config_props(inlink) < 0) |
|
231 |
+ return ret; |
|
232 |
+ |
|
233 |
+ av_log(ctx, AV_LOG_VERBOSE, "color:0x%02x%02x%02x%02x\n", |
|
234 |
+ test->color_rgba[0], test->color_rgba[1], test->color_rgba[2], test->color_rgba[3]); |
|
235 |
+ return 0; |
|
236 |
+} |
|
237 |
+ |
|
238 |
+AVFilter avfilter_vsrc_color = { |
|
239 |
+ .name = "color", |
|
240 |
+ .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."), |
|
241 |
+ |
|
242 |
+ .priv_size = sizeof(TestSourceContext), |
|
243 |
+ .init = color_init, |
|
244 |
+ .uninit = uninit, |
|
245 |
+ |
|
246 |
+ .query_formats = color_query_formats, |
|
247 |
+ |
|
248 |
+ .inputs = (const AVFilterPad[]) { |
|
249 |
+ { .name = NULL } |
|
250 |
+ }, |
|
251 |
+ |
|
252 |
+ .outputs = (const AVFilterPad[]) { |
|
253 |
+ { |
|
254 |
+ .name = "default", |
|
255 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
256 |
+ .request_frame = request_frame, |
|
257 |
+ .config_props = color_config_props, |
|
258 |
+ }, |
|
259 |
+ { .name = NULL } |
|
260 |
+ }, |
|
261 |
+}; |
|
262 |
+ |
|
263 |
+#endif /* CONFIG_COLOR_FILTER */ |
|
264 |
+ |
|
188 | 265 |
#if CONFIG_NULLSRC_FILTER |
189 | 266 |
|
190 | 267 |
#define nullsrc_options options |