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 C58E245A27 for ; Sun, 9 Apr 2023 14:12:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 068AA68BE56; Sun, 9 Apr 2023 17:09:37 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 38DCE68BD2C for ; Sun, 9 Apr 2023 17:09:16 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 2C8A02405B5 for ; Sun, 9 Apr 2023 16:09:13 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ozwA3pyUbN02 for ; Sun, 9 Apr 2023 16:09:12 +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 2EBA82405EC for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E7CCF3A042D for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:29 +0200 Message-Id: <20230409140853.28858-5-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/29] fftools/ffmpeg: move OutputStream.last_filter_pts to OutputFilter 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 value is associated with the filtergraph output rather than the output stream, so this is a more appropriate place for it. --- fftools/ffmpeg.c | 8 ++++---- fftools/ffmpeg.h | 5 +++-- fftools/ffmpeg_filter.c | 21 +++++++++++++++------ fftools/ffmpeg_mux_init.c | 1 - 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 750ab76693..1f50b82794 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -697,8 +697,8 @@ static int reap_filters(int flush) if (filtered_frame->pts != AV_NOPTS_VALUE) { AVRational tb = av_buffersink_get_time_base(filter); - ost->last_filter_pts = av_rescale_q(filtered_frame->pts, tb, - AV_TIME_BASE_Q); + ost->filter->last_pts = av_rescale_q(filtered_frame->pts, tb, + AV_TIME_BASE_Q); filtered_frame->time_base = tb; if (debug_ts) @@ -2391,8 +2391,8 @@ static OutputStream *choose_output(void) for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { int64_t opts; - if (ost->filter && ost->last_filter_pts != AV_NOPTS_VALUE) { - opts = ost->last_filter_pts; + if (ost->filter && ost->filter->last_pts != AV_NOPTS_VALUE) { + opts = ost->filter->last_pts; } else { opts = ost->last_mux_dts == AV_NOPTS_VALUE ? INT64_MIN : ost->last_mux_dts; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index b45a2039ce..84ce017320 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -314,6 +314,9 @@ typedef struct OutputFilter { const int *formats; const AVChannelLayout *ch_layouts; const int *sample_rates; + + /* pts of the last frame received from this filter, in AV_TIME_BASE_Q */ + int64_t last_pts; } OutputFilter; typedef struct FilterGraph { @@ -573,8 +576,6 @@ typedef struct OutputStream { AVStream *st; /* stream in the output file */ /* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */ int64_t last_mux_dts; - /* pts of the last frame received from the filters, in AV_TIME_BASE_Q */ - int64_t last_filter_pts; // timestamp from which the streamcopied streams should start, // in AV_TIME_BASE_Q; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index c9fd65e902..f48ae83a40 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -176,6 +176,18 @@ static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint) av_bprint_chars(bprint, ':', 1); } +static OutputFilter *ofilter_alloc(FilterGraph *fg) +{ + OutputFilter *ofilter; + + ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); + ofilter->graph = fg; + ofilter->format = -1; + ofilter->last_pts = AV_NOPTS_VALUE; + + return ofilter; +} + int init_simple_filtergraph(InputStream *ist, OutputStream *ost) { FilterGraph *fg = av_mallocz(sizeof(*fg)); @@ -186,10 +198,8 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost) report_and_exit(AVERROR(ENOMEM)); fg->index = nb_filtergraphs; - ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); - ofilter->ost = ost; - ofilter->graph = fg; - ofilter->format = -1; + ofilter = ofilter_alloc(fg); + ofilter->ost = ost; ost->filter = ofilter; @@ -502,9 +512,8 @@ int init_complex_filtergraph(FilterGraph *fg) init_input_filter(fg, cur); for (cur = outputs; cur;) { - OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs); + OutputFilter *const ofilter = ofilter_alloc(fg); - ofilter->graph = fg; ofilter->out_tmp = cur; ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads, cur->pad_idx); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index ee5829c7fe..3490c99c94 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -649,7 +649,6 @@ static OutputStream *new_output_stream(Muxer *mux, const OptionsContext *o, ost->ist->st->discard = ost->ist->user_set_discard; } ost->last_mux_dts = AV_NOPTS_VALUE; - ost->last_filter_pts = AV_NOPTS_VALUE; MATCH_PER_STREAM_OPT(copy_initial_nonkeyframes, i, ost->copy_initial_nonkeyframes, oc, st); -- 2.39.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".