From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 14E8943DC9 for ; Mon, 10 Oct 2022 16:12:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADBB068BD3A; Mon, 10 Oct 2022 19:11:24 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33A9D68BD22 for ; Mon, 10 Oct 2022 19:11:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4BC9E2405EC for ; Mon, 10 Oct 2022 18:11:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id lDZgIPqwWP6G for ; Mon, 10 Oct 2022 18:11:11 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 6F7752405F9 for ; Mon, 10 Oct 2022 18:11:08 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 06F983A13BB for ; Mon, 10 Oct 2022 18:11:02 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Oct 2022 18:10:52 +0200 Message-Id: <20221010161055.18948-5-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221010161055.18948-1-anton@khirnov.net> References: <20221010161055.18948-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/8] lavfi/vf_decimate: use inverse of output framerate as timebase X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This filter currently keeps the input timebase, but produces CFR output. It is thus simpler to use 1/output fps as the output timebase. Also, set output frame durations. --- libavfilter/vf_decimate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c index 01404e6fec..f61e501c96 100644 --- a/libavfilter/vf_decimate.c +++ b/libavfilter/vf_decimate.c @@ -43,7 +43,6 @@ typedef struct DecimateContext { AVFrame *last; ///< last frame from the previous queue AVFrame **clean_src; ///< frame queue for the clean source int got_frame[2]; ///< frame request flag for each input stream - AVRational ts_unit; ///< timestamp units for the output frames int64_t last_pts; ///< last output timestamp int64_t start_pts; ///< base for output timestamps uint32_t eof; ///< bitmask for end of stream @@ -213,6 +212,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) /* push all frames except the drop */ ret = 0; for (i = 0; i < dm->cycle && dm->queue[i].frame; i++) { + AVRational in_tb = ctx->inputs[INPUT_MAIN]->time_base; if (i == drop) { if (dm->ppsrc) av_frame_free(&dm->clean_src[i]); @@ -221,7 +221,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFrame *frame = dm->queue[i].frame; dm->queue[i].frame = NULL; if (frame->pts != AV_NOPTS_VALUE && dm->start_pts == AV_NOPTS_VALUE) - dm->start_pts = frame->pts; + dm->start_pts = av_rescale_q(frame->pts, in_tb, outlink->time_base); + if (dm->ppsrc) { av_frame_free(&frame); frame = dm->clean_src[i]; @@ -229,8 +230,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) continue; dm->clean_src[i] = NULL; } - frame->pts = av_rescale_q(outlink->frame_count_in, dm->ts_unit, (AVRational){1,1}) + + frame->pts = outlink->frame_count_in + (dm->start_pts == AV_NOPTS_VALUE ? 0 : dm->start_pts); + frame->duration = 1; dm->last_pts = frame->pts; ret = ff_filter_frame(outlink, frame); if (ret < 0) @@ -404,7 +406,7 @@ static int config_output(AVFilterLink *outlink) fps = av_mul_q(fps, (AVRational){dm->cycle - 1, dm->cycle}); av_log(ctx, AV_LOG_VERBOSE, "FPS: %d/%d -> %d/%d\n", inlink->frame_rate.num, inlink->frame_rate.den, fps.num, fps.den); - outlink->time_base = inlink->time_base; + outlink->time_base = av_inv_q(fps); outlink->frame_rate = fps; outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; if (dm->ppsrc) { @@ -414,7 +416,6 @@ static int config_output(AVFilterLink *outlink) outlink->w = inlink->w; outlink->h = inlink->h; } - dm->ts_unit = av_inv_q(av_mul_q(fps, outlink->time_base)); return 0; } -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".