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 874CE46633 for ; Sun, 28 May 2023 09:17:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BB78C68C26B; Sun, 28 May 2023 12:15:12 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 276D368C223 for ; Sun, 28 May 2023 12:14:54 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A65762405F9 for ; Sun, 28 May 2023 11:14:51 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id BMv7fzFkbzM7 for ; Sun, 28 May 2023 11:14:51 +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 93A632405EC for ; Sun, 28 May 2023 11:14:47 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id A64053A0BC6 for ; Sun, 28 May 2023 11:14:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 May 2023 11:14:06 +0200 Message-Id: <20230528091416.17927-14-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230528091416.17927-1-anton@khirnov.net> References: <20230528091416.17927-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/24] fftools/ffmpeg_filter: move sub2video subtitle queue to InputFilterPriv 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 queue should be associated with a specific filtergraph input - if a subtitle stream is sent to multiple filters then each should have its own queue. --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_filter.c | 26 +++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fa5824ee7b..d4aff5cc7c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -374,7 +374,6 @@ typedef struct InputStream { struct sub2video { int64_t last_pts; int64_t end_pts; - AVFifo *sub_queue; ///< queue of AVSubtitle* before filter init AVFrame *frame; int w, h; unsigned int initialize; ///< marks if sub2video_update should force an initialization diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index acfd83244b..2a73e3a3e3 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -104,6 +104,10 @@ typedef struct InputFilterPriv { AVChannelLayout ch_layout; } fallback; + struct { + ///< queue of AVSubtitle* before filter init + AVFifo *queue; + } sub2video; } InputFilterPriv; static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter) @@ -593,7 +597,6 @@ void fg_free(FilterGraph **pfg) for (int j = 0; j < fg->nb_inputs; j++) { InputFilter *ifilter = fg->inputs[j]; InputFilterPriv *ifp = ifp_from_ifilter(ifilter); - InputStream *ist = ifp->ist; if (ifp->frame_queue) { AVFrame *frame; @@ -601,11 +604,11 @@ void fg_free(FilterGraph **pfg) av_frame_free(&frame); av_fifo_freep2(&ifp->frame_queue); } - if (ist && ist->sub2video.sub_queue) { + if (ifp->sub2video.queue) { AVSubtitle sub; - while (av_fifo_read(ist->sub2video.sub_queue, &sub, 1) >= 0) + while (av_fifo_read(ifp->sub2video.queue, &sub, 1) >= 0) avsubtitle_free(&sub); - av_fifo_freep2(&ist->sub2video.sub_queue); + av_fifo_freep2(&ifp->sub2video.queue); } av_channel_layout_uninit(&ifp->fallback.ch_layout); @@ -1495,10 +1498,11 @@ int configure_filtergraph(FilterGraph *fg) /* process queued up subtitle packets */ for (i = 0; i < fg->nb_inputs; i++) { - InputStream *ist = ifp_from_ifilter(fg->inputs[i])->ist; - if (ist->sub2video.sub_queue && ist->sub2video.frame) { + InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]); + InputStream *ist = ifp->ist; + if (ifp->sub2video.queue && ist->sub2video.frame) { AVSubtitle tmp; - while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) { + while (av_fifo_read(ifp->sub2video.queue, &tmp, 1) >= 0) { sub2video_update(ist, INT64_MIN, &tmp); avsubtitle_free(&tmp); } @@ -1649,16 +1653,16 @@ int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *subtitle) } else { AVSubtitle sub; - if (!ist->sub2video.sub_queue) - ist->sub2video.sub_queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW); - if (!ist->sub2video.sub_queue) + if (!ifp->sub2video.queue) + ifp->sub2video.queue = av_fifo_alloc2(8, sizeof(AVSubtitle), AV_FIFO_FLAG_AUTO_GROW); + if (!ifp->sub2video.queue) return AVERROR(ENOMEM); ret = copy_av_subtitle(&sub, subtitle); if (ret < 0) return ret; - ret = av_fifo_write(ist->sub2video.sub_queue, &sub, 1); + ret = av_fifo_write(ifp->sub2video.queue, &sub, 1); if (ret < 0) { avsubtitle_free(&sub); return ret; -- 2.40.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".