X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvsrc_testsrc.c;h=cf9fa4b2b2e101eafccc66a4a905b304782b4c35;hb=38e71d8b6c55f56ef58f1acb1c8d9e12a65e0a1d;hp=f06714807ffda7e8d8749c9f60ae059a2153f90c;hpb=185aa5e896e15ae96145609944bfc6bbb239bc64;p=ffmpeg diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index f06714807ff..cf9fa4b2b2e 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -45,6 +45,7 @@ #include "libavutil/xga_font_data.h" #include "avfilter.h" #include "drawutils.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -83,6 +84,7 @@ typedef struct TestSourceContext { #define OFFSET(x) offsetof(TestSourceContext, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM +#define FLAGSR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM #define SIZE_OPTIONS \ { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\ @@ -137,14 +139,19 @@ static int config_props(AVFilterLink *outlink) return 0; } -static int request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { - TestSourceContext *test = outlink->src->priv; + AVFilterLink *outlink = ctx->outputs[0]; + TestSourceContext *test = ctx->priv; AVFrame *frame; + if (!ff_outlink_frame_wanted(outlink)) + return FFERROR_NOT_READY; if (test->duration >= 0 && - av_rescale_q(test->pts, test->time_base, AV_TIME_BASE_Q) >= test->duration) - return AVERROR_EOF; + av_rescale_q(test->pts, test->time_base, AV_TIME_BASE_Q) >= test->duration) { + ff_outlink_set_status(outlink, AVERROR_EOF, test->pts); + return 0; + } if (test->draw_once) { if (test->draw_once_reset) { @@ -181,8 +188,8 @@ static int request_frame(AVFilterLink *outlink) #if CONFIG_COLOR_FILTER static const AVOption color_options[] = { - { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS }, + { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGSR }, + { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGSR }, COMMON_OPTIONS { NULL } }; @@ -236,27 +243,19 @@ static int color_process_command(AVFilterContext *ctx, const char *cmd, const ch TestSourceContext *test = ctx->priv; int ret; - if (!strcmp(cmd, "color") || !strcmp(cmd, "c")) { - uint8_t color_rgba[4]; - - ret = av_parse_color(color_rgba, args, -1, ctx); - if (ret < 0) - return ret; - - memcpy(test->color_rgba, color_rgba, sizeof(color_rgba)); - ff_draw_color(&test->draw, &test->color, test->color_rgba); - test->draw_once_reset = 1; - return 0; - } + ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags); + if (ret < 0) + return ret; - return AVERROR(ENOSYS); + ff_draw_color(&test->draw, &test->color, test->color_rgba); + test->draw_once_reset = 1; + return 0; } static const AVFilterPad color_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = color_config_props, }, { NULL } @@ -269,6 +268,7 @@ AVFilter ff_vsrc_color = { .priv_size = sizeof(TestSourceContext), .init = color_init, .uninit = uninit, + .activate = activate, .query_formats = color_query_formats, .inputs = NULL, .outputs = color_outputs, @@ -280,7 +280,7 @@ AVFilter ff_vsrc_color = { #if CONFIG_HALDCLUTSRC_FILTER static const AVOption haldclutsrc_options[] = { - { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 8, FLAGS }, + { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 16, FLAGS }, COMMON_OPTIONS_NOSIZE { NULL } }; @@ -390,7 +390,6 @@ static const AVFilterPad haldclutsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = haldclutsrc_config_props, }, { NULL } @@ -404,6 +403,7 @@ AVFilter ff_vsrc_haldclutsrc = { .init = haldclutsrc_init, .uninit = uninit, .query_formats = haldclutsrc_query_formats, + .activate = activate, .inputs = NULL, .outputs = haldclutsrc_outputs, }; @@ -428,7 +428,6 @@ static const AVFilterPad nullsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_props, }, { NULL }, @@ -439,6 +438,7 @@ AVFilter ff_vsrc_nullsrc = { .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."), .init = nullsrc_init, .uninit = uninit, + .activate = activate, .priv_size = sizeof(TestSourceContext), .priv_class = &nullsrc_class, .inputs = NULL, @@ -664,7 +664,6 @@ static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_props, }, { NULL } @@ -678,6 +677,7 @@ AVFilter ff_vsrc_testsrc = { .init = test_init, .uninit = uninit, .query_formats = test_query_formats, + .activate = activate, .inputs = NULL, .outputs = avfilter_vsrc_testsrc_outputs, }; @@ -937,7 +937,6 @@ static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = test2_config_props, }, { NULL } @@ -951,6 +950,7 @@ AVFilter ff_vsrc_testsrc2 = { .init = test2_init, .uninit = uninit, .query_formats = test2_query_formats, + .activate = activate, .inputs = NULL, .outputs = avfilter_vsrc_testsrc2_outputs, }; @@ -968,10 +968,10 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc); #define A 3 static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize, - int x, int y, int r, int g, int b, enum AVPixelFormat fmt, + int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt, uint8_t rgba_map[4]) { - int32_t v; + uint32_t v; uint8_t *p; switch (fmt) { @@ -991,7 +991,7 @@ static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize, case AV_PIX_FMT_BGRA: case AV_PIX_FMT_ARGB: case AV_PIX_FMT_ABGR: - v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255 << (rgba_map[A]*8)); + v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255U << (rgba_map[A]*8)); p = dst + 4*x + y*dst_linesize; AV_WL32(p, v); break; @@ -1056,7 +1056,6 @@ static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = rgbtest_config_props, }, { NULL } @@ -1070,6 +1069,7 @@ AVFilter ff_vsrc_rgbtestsrc = { .init = rgbtest_init, .uninit = uninit, .query_formats = rgbtest_query_formats, + .activate = activate, .inputs = NULL, .outputs = avfilter_vsrc_rgbtestsrc_outputs, }; @@ -1232,7 +1232,6 @@ static const AVFilterPad avfilter_vsrc_yuvtestsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = yuvtest_config_props, }, { NULL } @@ -1246,6 +1245,7 @@ AVFilter ff_vsrc_yuvtestsrc = { .init = yuvtest_init, .uninit = uninit, .query_formats = yuvtest_query_formats, + .activate = activate, .inputs = NULL, .outputs = avfilter_vsrc_yuvtestsrc_outputs, }; @@ -1375,7 +1375,6 @@ static const AVFilterPad smptebars_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_props, }, { NULL } @@ -1423,6 +1422,7 @@ AVFilter ff_vsrc_pal75bars = { .init = pal75bars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1469,6 +1469,7 @@ AVFilter ff_vsrc_pal100bars = { .init = pal100bars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1536,6 +1537,7 @@ AVFilter ff_vsrc_smptebars = { .init = smptebars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1641,6 +1643,7 @@ AVFilter ff_vsrc_smptehdbars = { .init = smptehdbars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1709,7 +1712,6 @@ static const AVFilterPad avfilter_vsrc_allyuv_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_props, }, { NULL } @@ -1723,6 +1725,7 @@ AVFilter ff_vsrc_allyuv = { .init = allyuv_init, .uninit = uninit, .query_formats = allyuv_query_formats, + .activate = activate, .inputs = NULL, .outputs = avfilter_vsrc_allyuv_outputs, }; @@ -1790,7 +1793,6 @@ static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = allrgb_config_props, }, { NULL } @@ -1804,6 +1806,7 @@ AVFilter ff_vsrc_allrgb = { .init = allrgb_init, .uninit = uninit, .query_formats = allrgb_query_formats, + .activate = activate, .inputs = NULL, .outputs = avfilter_vsrc_allrgb_outputs, };