[FFmpeg-devel] [PATCH] avfilter: add allrgb
Clément Bœsch
u at pkh.me
Sun Aug 16 01:21:53 CEST 2015
---
TODO: bump lavfi version
---
Changelog | 2 +-
doc/filters.texi | 5 ++-
libavfilter/Makefile | 1 +
libavfilter/allfilters.c | 1 +
libavfilter/vsrc_testsrc.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 91 insertions(+), 2 deletions(-)
diff --git a/Changelog b/Changelog
index 0e87c09..f85fe8e 100644
--- a/Changelog
+++ b/Changelog
@@ -27,7 +27,7 @@ version <next>:
- sidechaincompress audio filter
- bitstream filter for converting HEVC from MP4 to Annex B
- acrossfade audio filter
-- allyuv video source
+- allyuv and allrgb video sources
- atadenoise video filter
- OS X VideoToolbox support
- aphasemeter filter
diff --git a/doc/filters.texi b/doc/filters.texi
index 2dd7d22..536ff56 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11507,6 +11507,7 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c
@end example
@end itemize
+ at anchor{allrgb}
@anchor{allyuv}
@anchor{color}
@anchor{haldclutsrc}
@@ -11515,7 +11516,9 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c
@anchor{smptebars}
@anchor{smptehdbars}
@anchor{testsrc}
- at section allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
+ at section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, smptehdbars, testsrc
+
+The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index d431f99..85265ba 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -236,6 +236,7 @@ OBJS-$(CONFIG_ZMQ_FILTER) += f_zmq.o
OBJS-$(CONFIG_ZOOMPAN_FILTER) += vf_zoompan.o
OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o
+OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o
OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o
OBJS-$(CONFIG_COLOR_FILTER) += vsrc_testsrc.o
OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 2900e88..58e6538 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -250,6 +250,7 @@ void avfilter_register_all(void)
REGISTER_FILTER(ZMQ, zmq, vf);
REGISTER_FILTER(ZOOMPAN, zoompan, vf);
+ REGISTER_FILTER(ALLRGB, allrgb, vsrc);
REGISTER_FILTER(ALLYUV, allyuv, vsrc);
REGISTER_FILTER(CELLAUTO, cellauto, vsrc);
REGISTER_FILTER(COLOR, color, vsrc);
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 3493b0f..1912c99 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -1170,3 +1170,87 @@ AVFilter ff_vsrc_allyuv = {
};
#endif /* CONFIG_ALLYUV_FILTER */
+
+#if CONFIG_ALLRGB_FILTER
+
+static const AVOption allrgb_options[] = {
+ COMMON_OPTIONS_NOSIZE
+ { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(allrgb);
+
+static void allrgb_fill_picture(AVFilterContext *ctx, AVFrame *frame)
+{
+ int r, g, b;
+ uint8_t *dst = frame->data[0];
+ const int linesize = frame->linesize[0];
+
+ for (r = 0; r < 256; r++) {
+ for (g = 0; g < 256; g++) {
+ for (b = 0; b < 256; b++) {
+ const int c = r<<16 | g<<8 | b;
+ const int y = c / 4096;
+ const int x = c % 4096;
+ const int base_pos = y * linesize + x*3;
+ dst[base_pos + 0] = r;
+ dst[base_pos + 1] = g;
+ dst[base_pos + 2] = b;
+ }
+ }
+ }
+}
+
+static av_cold int allrgb_init(AVFilterContext *ctx)
+{
+ TestSourceContext *test = ctx->priv;
+
+ test->w = test->h = 4096;
+ test->draw_once = 1;
+ test->fill_picture_fn = allrgb_fill_picture;
+ return init(ctx);
+}
+
+static int allrgb_config_props(AVFilterLink *outlink)
+{
+ TestSourceContext *test = outlink->src->priv;
+
+ ff_fill_rgba_map(test->rgba_map, outlink->format);
+ return config_props(outlink);
+}
+
+static int allrgb_query_formats(AVFilterContext *ctx)
+{
+ static const enum AVPixelFormat pix_fmts[] = {
+ AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE
+ };
+
+ AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
+ if (!fmts_list)
+ return AVERROR(ENOMEM);
+ return ff_set_common_formats(ctx, fmts_list);
+}
+
+static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .request_frame = request_frame,
+ .config_props = allrgb_config_props,
+ },
+ { NULL }
+};
+
+AVFilter ff_vsrc_allrgb = {
+ .name = "allrgb",
+ .description = NULL_IF_CONFIG_SMALL("Generate all rgb colors."),
+ .priv_size = sizeof(TestSourceContext),
+ .priv_class = &allrgb_class,
+ .init = allrgb_init,
+ .uninit = uninit,
+ .query_formats = allrgb_query_formats,
+ .inputs = NULL,
+ .outputs = avfilter_vsrc_allrgb_outputs,
+};
+
+#endif /* CONFIG_ALLRGB_FILTER */
--
2.5.0
More information about the ffmpeg-devel
mailing list