X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvsrc_testsrc.c;h=1383550e91844bb8eb641e2ff8e4b5829cb25540;hb=dd1fb6528791b32ac9d6b3c2d81707cf1949ec5d;hp=0f38ca5bc13b5031fdbf85e4ce9ad5fe8b4e55f1;hpb=0a23067ab41326dfa1da41d18923ea8547a51ff5;p=ffmpeg diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index 0f38ca5bc13..1383550e918 100644 --- a/libavfilter/vsrc_testsrc.c +++ b/libavfilter/vsrc_testsrc.c @@ -24,7 +24,7 @@ * Misc test sources. * * testsrc is based on the test pattern generator demuxer by Nicolas George: - * http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-October/037845.html + * http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2007-October/037845.html * * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by * Michael Niedermayer. @@ -57,12 +57,12 @@ typedef struct { #define OFFSET(x) offsetof(TestSourceContext, x) static const AVOption testsrc_options[]= { - { "size", "set video size", OFFSET(size), FF_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, - { "s", "set video size", OFFSET(size), FF_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, - { "rate", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, - { "r", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, - { "duration", "set video duration", OFFSET(duration), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, - { "sar", "set video sample aspect ratio", OFFSET(sar), FF_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX }, + { "size", "set video size", OFFSET(size), AV_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, + { "s", "set video size", OFFSET(size), AV_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, + { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, + { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX }, { NULL }, }; @@ -127,7 +127,7 @@ static int request_frame(AVFilterLink *outlink) TestSourceContext *test = outlink->src->priv; AVFilterBufferRef *picref; - if (test->max_pts >= 0 && test->pts > test->max_pts) + if (test->max_pts >= 0 && test->pts >= test->max_pts) return AVERROR_EOF; picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h); @@ -137,8 +137,8 @@ static int request_frame(AVFilterLink *outlink) picref->video->interlaced = 0; picref->video->pict_type = AV_PICTURE_TYPE_I; picref->video->sample_aspect_ratio = test->sar; - test->nb_frame++; test->fill_picture_fn(outlink->src, picref); + test->nb_frame++; avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); avfilter_draw_slice(outlink, 0, picref->video->h, 1); @@ -148,6 +148,46 @@ static int request_frame(AVFilterLink *outlink) return 0; } +#if CONFIG_NULLSRC_FILTER + +static const char *nullsrc_get_name(void *ctx) +{ + return "nullsrc"; +} + +static const AVClass nullsrc_class = { + .class_name = "NullSourceContext", + .item_name = nullsrc_get_name, + .option = testsrc_options, +}; + +static void nullsrc_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) { } + +static av_cold int nullsrc_init(AVFilterContext *ctx, const char *args, void *opaque) +{ + TestSourceContext *test = ctx->priv; + + test->class = &nullsrc_class; + test->fill_picture_fn = nullsrc_fill_picture; + return init(ctx, args, opaque); +} + +AVFilter avfilter_vsrc_nullsrc = { + .name = "nullsrc", + .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."), + .init = nullsrc_init, + .priv_size = sizeof(TestSourceContext), + + .inputs = (const AVFilterPad[]) {{ .name = NULL}}, + .outputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_props, }, + { .name = NULL}}, +}; + +#endif /* CONFIG_NULLSRC_FILTER */ + #if CONFIG_TESTSRC_FILTER static const char *testsrc_get_name(void *ctx) @@ -156,9 +196,9 @@ static const char *testsrc_get_name(void *ctx) } static const AVClass testsrc_class = { - "TestSourceContext", - testsrc_get_name, - testsrc_options + .class_name = "TestSourceContext", + .item_name = testsrc_get_name, + .option = testsrc_options, }; /** @@ -283,7 +323,7 @@ static void test_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) } /* draw sliding color line */ - p = data + picref->linesize[0] * height * 3/4; + p0 = p = data + picref->linesize[0] * height * 3/4; grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) % GRADIENT_SIZE; rgrad = 0; @@ -311,8 +351,9 @@ static void test_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) if (grad >= GRADIENT_SIZE) grad -= GRADIENT_SIZE; } + p = p0; for (y = height / 8; y > 0; y--) { - memcpy(p, p - picref->linesize[0], 3 * width); + memcpy(p+picref->linesize[0], p, 3 * width); p += picref->linesize[0]; } @@ -359,9 +400,9 @@ AVFilter avfilter_vsrc_testsrc = { .query_formats = test_query_formats, - .inputs = (AVFilterPad[]) {{ .name = NULL}}, + .inputs = (const AVFilterPad[]) {{ .name = NULL}}, - .outputs = (AVFilterPad[]) {{ .name = "default", + .outputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .request_frame = request_frame, .config_props = config_props, }, @@ -378,9 +419,9 @@ static const char *rgbtestsrc_get_name(void *ctx) } static const AVClass rgbtestsrc_class = { - "RGBTestSourceContext", - rgbtestsrc_get_name, - testsrc_options + .class_name = "RGBTestSourceContext", + .item_name = rgbtestsrc_get_name, + .option = testsrc_options, }; #define R 0 @@ -486,9 +527,9 @@ AVFilter avfilter_vsrc_rgbtestsrc = { .query_formats = rgbtest_query_formats, - .inputs = (AVFilterPad[]) {{ .name = NULL}}, + .inputs = (const AVFilterPad[]) {{ .name = NULL}}, - .outputs = (AVFilterPad[]) {{ .name = "default", + .outputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .request_frame = request_frame, .config_props = rgbtest_config_props, },