Unified · Split
| @@ -30,6 +30,7 @@ version <next>: · 29 unmodified lines | |||
| 30 | - xcorrelate video filter | 30 | - xcorrelate video filter |
| 31 | - varblur video filter | 31 | - varblur video filter |
| 32 | - huesaturation video filter | 32 | - huesaturation video filter |
| 33 | - colorspectrum source video filter | ||
| 33 | 34 | ||
| 34 | 35 | ||
| 35 | version 4.4: | 36 | version 4.4: |
| @@ -25257,6 +25257,7 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c · 25256 unmodified lines | |||
| 25257 | @anchor{allrgb} | 25257 | @anchor{allrgb} |
| 25258 | @anchor{allyuv} | 25258 | @anchor{allyuv} |
| 25259 | @anchor{color} | 25259 | @anchor{color} |
| 25260 | @anchor{colorspectrum} | ||
| 25260 | @anchor{haldclutsrc} | 25261 | @anchor{haldclutsrc} |
| 25261 | @anchor{nullsrc} | 25262 | @anchor{nullsrc} |
| 25262 | @anchor{pal75bars} | 25263 | @anchor{pal75bars} |
| @@ -25267,7 +25268,7 @@ ffplay -f lavfi life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c · 4 unmodified lines | |||
| 25267 | @anchor{testsrc} | 25268 | @anchor{testsrc} |
| 25268 | @anchor{testsrc2} | 25269 | @anchor{testsrc2} |
| 25269 | @anchor{yuvtestsrc} | 25270 | @anchor{yuvtestsrc} |
| 25270 | @section allrgb, allyuv, color, haldclutsrc, nullsrc, pal75bars, pal100bars, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc | 25271 | @section allrgb, allyuv, color, colorspectrum, haldclutsrc, nullsrc, pal75bars, pal100bars, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc |
| 25271 | 25272 | ||
| 25272 | The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors. | 25273 | The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors. |
| 25273 | 25274 | ||
| @@ -25275,6 +25276,8 @@ The @code{allyuv} source returns frames of size 4096x4096 of all yuv colors. · 1 unmodified line | |||
| 25275 | 25276 | ||
| 25276 | The @code{color} source provides an uniformly colored input. | 25277 | The @code{color} source provides an uniformly colored input. |
| 25277 | 25278 | ||
| 25279 | The @code{colorspectrum} source provides a color spectrum input. | ||
| 25280 | |||
| 25278 | The @code{haldclutsrc} source provides an identity Hald CLUT. See also | 25281 | The @code{haldclutsrc} source provides an identity Hald CLUT. See also |
| 25279 | @ref{haldclut} filter. | 25282 | @ref{haldclut} filter. |
| 25280 | 25283 | ||
| @@ -25366,6 +25369,16 @@ Set the number of decimals to show in the timestamp, only available in the · 85 unmodified lines | |||
| 25366 | The displayed timestamp value will correspond to the original | 25369 | The displayed timestamp value will correspond to the original |
| 25367 | timestamp value multiplied by the power of 10 of the specified | 25370 | timestamp value multiplied by the power of 10 of the specified |
| 25368 | value. Default value is 0. | 25371 | value. Default value is 0. |
| 25372 | |||
| 25373 | @item type | ||
| 25374 | Set the type of the color spectrum, only available in the | ||
| 25375 | @code{colorspectrum} source. Can be one of the following: | ||
| 25376 | |||
| 25377 | @table @samp | ||
| 25378 | @item black | ||
| 25379 | @item white | ||
| 25380 | @item all | ||
| 25381 | @end table | ||
| 25369 | @end table | 25382 | @end table |
| 25370 | 25383 | ||
| 25371 | @subsection Examples | 25384 | @subsection Examples |
| @@ -522,6 +522,7 @@ OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o · 521 unmodified lines | |||
| 522 | OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o | 522 | OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o |
| 523 | OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o | 523 | OBJS-$(CONFIG_CELLAUTO_FILTER) += vsrc_cellauto.o |
| 524 | OBJS-$(CONFIG_COLOR_FILTER) += vsrc_testsrc.o | 524 | OBJS-$(CONFIG_COLOR_FILTER) += vsrc_testsrc.o |
| 525 | OBJS-$(CONFIG_COLORSPECTRUM_FILTER) += vsrc_testsrc.o | ||
| 525 | OBJS-$(CONFIG_COREIMAGESRC_FILTER) += vf_coreimage.o | 526 | OBJS-$(CONFIG_COREIMAGESRC_FILTER) += vf_coreimage.o |
| 526 | OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o | 527 | OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o |
| 527 | OBJS-$(CONFIG_GRADIENTS_FILTER) += vsrc_gradients.o | 528 | OBJS-$(CONFIG_GRADIENTS_FILTER) += vsrc_gradients.o |
| @@ -498,6 +498,7 @@ extern const AVFilter ff_vsrc_allrgb; · 497 unmodified lines | |||
| 498 | extern const AVFilter ff_vsrc_allyuv; | 498 | extern const AVFilter ff_vsrc_allyuv; |
| 499 | extern const AVFilter ff_vsrc_cellauto; | 499 | extern const AVFilter ff_vsrc_cellauto; |
| 500 | extern const AVFilter ff_vsrc_color; | 500 | extern const AVFilter ff_vsrc_color; |
| 501 | extern const AVFilter ff_vsrc_colorspectrum; | ||
| 501 | extern const AVFilter ff_vsrc_coreimagesrc; | 502 | extern const AVFilter ff_vsrc_coreimagesrc; |
| 502 | extern const AVFilter ff_vsrc_frei0r_src; | 503 | extern const AVFilter ff_vsrc_frei0r_src; |
| 503 | extern const AVFilter ff_vsrc_gradients; | 504 | extern const AVFilter ff_vsrc_gradients; |
| @@ -30,8 +30,8 @@ · 29 unmodified lines | |||
| 30 | #include "libavutil/version.h" | 30 | #include "libavutil/version.h" |
| 31 | 31 | ||
| 32 | #define LIBAVFILTER_VERSION_MAJOR 8 | 32 | #define LIBAVFILTER_VERSION_MAJOR 8 |
| 33 | #define LIBAVFILTER_VERSION_MINOR 16 | 33 | #define LIBAVFILTER_VERSION_MINOR 17 |
| 34 | #define LIBAVFILTER_VERSION_MICRO 102 | 34 | #define LIBAVFILTER_VERSION_MICRO 100 |
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ | 37 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
| @@ -70,6 +70,9 @@ typedef struct TestSourceContext { · 69 unmodified lines | |||
| 70 | /* only used by testsrc2 */ | 70 | /* only used by testsrc2 */ |
| 71 | int alpha; | 71 | int alpha; |
| 72 | 72 | ||
| 73 | /* only used by colorspectrum */ | ||
| 74 | int type; | ||
| 75 | |||
| 73 | /* only used by color */ | 76 | /* only used by color */ |
| 74 | FFDrawContext draw; | 77 | FFDrawContext draw; |
| 75 | FFDrawColor color; | 78 | FFDrawColor color; |
| @@ -1791,3 +1794,92 @@ const AVFilter ff_vsrc_allrgb = { · 1715 unmodified lines | |||
| 1791 | }; | 1794 | }; |
| 1792 | 1795 | ||
| 1793 | #endif /* CONFIG_ALLRGB_FILTER */ | 1796 | #endif /* CONFIG_ALLRGB_FILTER */ |
| 1797 | |||
| 1798 | #if CONFIG_COLORSPECTRUM_FILTER | ||
| 1799 | |||
| 1800 | static const AVOption colorspectrum_options[] = { | ||
| 1801 | COMMON_OPTIONS | ||
| 1802 | { "type", "set the color spectrum type", OFFSET(type), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "type" }, | ||
| 1803 | { "black","fade to black", 0, AV_OPT_TYPE_CONST,{.i64=0},0, 0, FLAGS, "type" }, | ||
| 1804 | { "white","fade to white", 0, AV_OPT_TYPE_CONST,{.i64=1},0, 0, FLAGS, "type" }, | ||
| 1805 | { "all", "white to black", 0, AV_OPT_TYPE_CONST,{.i64=2},0, 0, FLAGS, "type" }, | ||
| 1806 | { NULL } | ||
| 1807 | }; | ||
| 1808 | |||
| 1809 | AVFILTER_DEFINE_CLASS(colorspectrum); | ||
| 1810 | |||
| 1811 | static inline float mix(float a, float b, float mix) | ||
| 1812 | { | ||
| 1813 | return a * mix + b * (1.f - mix); | ||
| 1814 | } | ||
| 1815 | |||
| 1816 | static void hsb2rgb(const float *c, float *rgb) | ||
| 1817 | { | ||
| 1818 | rgb[0] = av_clipf(fabsf(fmodf(c[0] * 6.f + 0.f, 6.f) - 3.f) - 1.f, 0.f, 1.f); | ||
| 1819 | rgb[1] = av_clipf(fabsf(fmodf(c[0] * 6.f + 4.f, 6.f) - 3.f) - 1.f, 0.f, 1.f); | ||
| 1820 | rgb[2] = av_clipf(fabsf(fmodf(c[0] * 6.f + 2.f, 6.f) - 3.f) - 1.f, 0.f, 1.f); | ||
| 1821 | rgb[0] = mix(c[3], (rgb[0] * rgb[0] * (3.f - 2.f * rgb[0])), c[1]) * c[2]; | ||
| 1822 | rgb[1] = mix(c[3], (rgb[1] * rgb[1] * (3.f - 2.f * rgb[1])), c[1]) * c[2]; | ||
| 1823 | rgb[2] = mix(c[3], (rgb[2] * rgb[2] * (3.f - 2.f * rgb[2])), c[1]) * c[2]; | ||
| 1824 | } | ||
| 1825 | |||
| 1826 | static void colorspectrum_fill_picture(AVFilterContext *ctx, AVFrame *frame) | ||
| 1827 | { | ||
| 1828 | TestSourceContext *test = ctx->priv; | ||
| 1829 | const float w = frame->width - 1.f; | ||
| 1830 | const float h = frame->height - 1.f; | ||
| 1831 | float c[4]; | ||
| 1832 | |||
| 1833 | for (int y = 0; y < frame->height; y++) { | ||
| 1834 | float *r = (float *)(frame->data[2] + y * frame->linesize[2]); | ||
| 1835 | float *g = (float *)(frame->data[0] + y * frame->linesize[0]); | ||
| 1836 | float *b = (float *)(frame->data[1] + y * frame->linesize[1]); | ||
| 1837 | const float yh = y / h; | ||
| 1838 | |||
| 1839 | c[1] = test->type == 2 ? yh > 0.5f ? 2.f * (yh - 0.5f) : 1.f - 2.f * yh : test->type == 1 ? 1.f - yh : yh; | ||
| 1840 | c[2] = 1.f; | ||
| 1841 | c[3] = test->type == 1 ? 1.f : test->type == 2 ? (yh > 0.5f ? 0.f : 1.f): 0.f; | ||
| 1842 | for (int x = 0; x < frame->width; x++) { | ||
| 1843 | float rgb[3]; | ||
| 1844 | |||
| 1845 | c[0] = x / w; | ||
| 1846 | hsb2rgb(c, rgb); | ||
| 1847 | |||
| 1848 | r[x] = rgb[0]; | ||
| 1849 | g[x] = rgb[1]; | ||
| 1850 | b[x] = rgb[2]; | ||
| 1851 | } | ||
| 1852 | } | ||
| 1853 | } | ||
| 1854 | |||
| 1855 | static av_cold int colorspectrum_init(AVFilterContext *ctx) | ||
| 1856 | { | ||
| 1857 | TestSourceContext *test = ctx->priv; | ||
| 1858 | |||
| 1859 | test->draw_once = 1; | ||
| 1860 | test->fill_picture_fn = colorspectrum_fill_picture; | ||
| 1861 | return init(ctx); | ||
| 1862 | } | ||
| 1863 | |||
| 1864 | static const AVFilterPad avfilter_vsrc_colorspectrum_outputs[] = { | ||
| 1865 | { | ||
| 1866 | .name = "default", | ||
| 1867 | .type = AVMEDIA_TYPE_VIDEO, | ||
| 1868 | .config_props = config_props, | ||
| 1869 | }, | ||
| 1870 | }; | ||
| 1871 | |||
| 1872 | const AVFilter ff_vsrc_colorspectrum = { | ||
| 1873 | .name = "colorspectrum", | ||
| 1874 | .description = NULL_IF_CONFIG_SMALL("Generate colors spectrum."), | ||
| 1875 | .priv_size = sizeof(TestSourceContext), | ||
| 1876 | .priv_class = &colorspectrum_class, | ||
| 1877 | .init = colorspectrum_init, | ||
| 1878 | .uninit = uninit, | ||
| 1879 | .activate = activate, | ||
| 1880 | .inputs = NULL, | ||
| 1881 | FILTER_OUTPUTS(avfilter_vsrc_colorspectrum_outputs), | ||
| 1882 | FILTER_SINGLE_PIXFMT(AV_PIX_FMT_GBRPF32), | ||
| 1883 | }; | ||
| 1884 | |||
| 1885 | #endif /* CONFIG_COLORSPECTRUM_FILTER */ | ||