From patchwork Fri Jun 26 13:51:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 20630 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0E73F44BC7E for ; Fri, 26 Jun 2020 16:51:59 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DDD4D68AF42; Fri, 26 Jun 2020 16:51:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0CF7D68AC37 for ; Fri, 26 Jun 2020 16:51:53 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 05QDpqsr016908 for ; Fri, 26 Jun 2020 15:51:52 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 325CCEB5C5; Fri, 26 Jun 2020 15:51:52 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 Jun 2020 15:51:50 +0200 Message-Id: <20200626135150.1708519-1-george@nsup.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Fri, 26 Jun 2020 15:51:52 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH] lavfi/vsrc_testsrc: switch to activate. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Allow to set the EOF timestamp. Also: doc/filters/testsrc*: specify the rounding of the duration option. The changes in the ref files are right. For filter-fps-down, the graph is testsrc2=r=7:d=3.5,fps=3. 3.5=24.5/7, so the EOF of testsrc2 will have PTS 25/7. 25/7=(10+5/7)/3, so the EOF PTS for fps should be 11/7, and the output should contain a frame at PTS 10. For filter-fps-up, the graph is testsrc2=r=3:d=2,fps=7, for filter-fps-up-round-down and filter-fps-up-round-up it is the same with explicit rounding options. But there is no rounding: testsrc2 produces exactly 6 frames and 2 seconds, fps converts it into exactly 14 frames. The tests should probably be adjusted to restore them to a useful coverage. Signed-off-by: Nicolas George --- doc/filters.texi | 4 +++ libavfilter/vsrc_testsrc.c | 37 +++++++++++++++---------- tests/ref/fate/filter-fps-down | 1 + tests/ref/fate/filter-fps-up | 2 ++ tests/ref/fate/filter-fps-up-round-down | 3 ++ tests/ref/fate/filter-fps-up-round-up | 2 ++ tests/ref/fate/filter-mpdecimate | 1 + 7 files changed, 36 insertions(+), 14 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 67892e0afb..280e78687d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -22836,6 +22836,10 @@ for the accepted syntax. If not specified, or the expressed duration is negative, the video is supposed to be generated forever. +Since the frame rate is used as time base, all frames including the last one +will have their full duration. If the specified duration is not a multiple +of the frame duration, it will be rounded up. + @item sar Set the sample aspect ratio of the sourced video. diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c index e8c33b00a0..cf9fa4b2b2 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" @@ -138,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) { @@ -250,7 +256,6 @@ static const AVFilterPad color_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = color_config_props, }, { NULL } @@ -263,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, @@ -384,7 +390,6 @@ static const AVFilterPad haldclutsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = haldclutsrc_config_props, }, { NULL } @@ -398,6 +403,7 @@ AVFilter ff_vsrc_haldclutsrc = { .init = haldclutsrc_init, .uninit = uninit, .query_formats = haldclutsrc_query_formats, + .activate = activate, .inputs = NULL, .outputs = haldclutsrc_outputs, }; @@ -422,7 +428,6 @@ static const AVFilterPad nullsrc_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_props, }, { NULL }, @@ -433,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, @@ -658,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 } @@ -672,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, }; @@ -931,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 } @@ -945,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, }; @@ -1050,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 } @@ -1064,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, }; @@ -1226,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 } @@ -1240,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, }; @@ -1369,7 +1375,6 @@ static const AVFilterPad smptebars_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, - .request_frame = request_frame, .config_props = config_props, }, { NULL } @@ -1417,6 +1422,7 @@ AVFilter ff_vsrc_pal75bars = { .init = pal75bars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1463,6 +1469,7 @@ AVFilter ff_vsrc_pal100bars = { .init = pal100bars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1530,6 +1537,7 @@ AVFilter ff_vsrc_smptebars = { .init = smptebars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1635,6 +1643,7 @@ AVFilter ff_vsrc_smptehdbars = { .init = smptehdbars_init, .uninit = uninit, .query_formats = smptebars_query_formats, + .activate = activate, .inputs = NULL, .outputs = smptebars_outputs, }; @@ -1703,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 } @@ -1717,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, }; @@ -1784,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 } @@ -1798,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, }; diff --git a/tests/ref/fate/filter-fps-down b/tests/ref/fate/filter-fps-down index eb8b368985..0b6725f037 100644 --- a/tests/ref/fate/filter-fps-down +++ b/tests/ref/fate/filter-fps-down @@ -13,3 +13,4 @@ 0, 7, 7, 1, 115200, 0xc705ccd9 0, 8, 8, 1, 115200, 0x5635daa5 0, 9, 9, 1, 115200, 0x7161ef8f +0, 10, 10, 1, 115200, 0xccf02fed diff --git a/tests/ref/fate/filter-fps-up b/tests/ref/fate/filter-fps-up index f1a847864f..dfb957c63a 100644 --- a/tests/ref/fate/filter-fps-up +++ b/tests/ref/fate/filter-fps-up @@ -15,3 +15,5 @@ 0, 9, 9, 1, 115200, 0xb0dfacf8 0, 10, 10, 1, 115200, 0xb0dfacf8 0, 11, 11, 1, 115200, 0xb0dfacf8 +0, 12, 12, 1, 115200, 0x53d5b181 +0, 13, 13, 1, 115200, 0x53d5b181 diff --git a/tests/ref/fate/filter-fps-up-round-down b/tests/ref/fate/filter-fps-up-round-down index daecb125e3..b68e4fe972 100644 --- a/tests/ref/fate/filter-fps-up-round-down +++ b/tests/ref/fate/filter-fps-up-round-down @@ -14,3 +14,6 @@ 0, 8, 8, 1, 115200, 0x33f15918 0, 9, 9, 1, 115200, 0xb0dfacf8 0, 10, 10, 1, 115200, 0xb0dfacf8 +0, 11, 11, 1, 115200, 0x53d5b181 +0, 12, 12, 1, 115200, 0x53d5b181 +0, 13, 13, 1, 115200, 0x53d5b181 diff --git a/tests/ref/fate/filter-fps-up-round-up b/tests/ref/fate/filter-fps-up-round-up index d69dbf67ff..692c1d6c69 100644 --- a/tests/ref/fate/filter-fps-up-round-up +++ b/tests/ref/fate/filter-fps-up-round-up @@ -15,3 +15,5 @@ 0, 9, 9, 1, 115200, 0x33f15918 0, 10, 10, 1, 115200, 0xb0dfacf8 0, 11, 11, 1, 115200, 0xb0dfacf8 +0, 12, 12, 1, 115200, 0x53d5b181 +0, 13, 13, 1, 115200, 0x53d5b181 diff --git a/tests/ref/fate/filter-mpdecimate b/tests/ref/fate/filter-mpdecimate index 9c1dc36562..d438dacc2e 100644 --- a/tests/ref/fate/filter-mpdecimate +++ b/tests/ref/fate/filter-mpdecimate @@ -22,3 +22,4 @@ 0, 24, 24, 1, 115200, 0x056d40ca 0, 26, 26, 1, 115200, 0xa4374737 0, 27, 27, 1, 115200, 0x3eaa3ae8 +0, 29, 29, 1, 115200, 0x7551e9ee