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 0BD0A462C8 for ; Wed, 14 Jun 2023 16:53:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E431E68C529; Wed, 14 Jun 2023 19:50:20 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7021268C4C1 for ; Wed, 14 Jun 2023 19:50:01 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 396C62404EC for ; Wed, 14 Jun 2023 18:50:01 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1D8O7YTm7Lts for ; Wed, 14 Jun 2023 18:50:00 +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 F2F1F2406CC for ; Wed, 14 Jun 2023 18:49:53 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id EDEA53A0CE0 for ; Wed, 14 Jun 2023 18:49:47 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Jun 2023 18:49:05 +0200 Message-Id: <20230614164908.28712-18-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614164908.28712-1-anton@khirnov.net> References: <20230614164908.28712-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/21] fftools/ffmpeg_dec: move InputStream.prev_sub to Decoder 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: It does not need to be visible outside of decoding code. --- fftools/ffmpeg.h | 4 ---- fftools/ffmpeg_dec.c | 26 ++++++++++++++++++-------- fftools/ffmpeg_demux.c | 1 - 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index b4b55f5a73..63ca542337 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -359,10 +359,6 @@ typedef struct InputStream { int autorotate; int fix_sub_duration; - struct { /* previous decoded subtitle and related variables */ - int got_output; - AVSubtitle subtitle; - } prev_sub; struct sub2video { int w, h; diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 879101fe21..36e28aaa07 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -47,6 +47,12 @@ struct Decoder { int64_t last_filter_in_rescale_delta; int last_frame_sample_rate; + /* previous decoded subtitle and related variables */ + struct { + int got_output; + AVSubtitle subtitle; + } prev_sub; + pthread_t thread; /** * Queue for sending coded packets from the main thread to @@ -102,6 +108,8 @@ void dec_free(Decoder **pdec) av_frame_free(&dec->frame); av_packet_free(&dec->pkt); + avsubtitle_free(&dec->prev_sub.subtitle); + av_freep(pdec); } @@ -378,24 +386,25 @@ static void sub2video_flush(InputStream *ist) static int process_subtitle(InputStream *ist, AVSubtitle *subtitle) { + Decoder *d = ist->decoder; int got_output = 1; int ret = 0; if (ist->fix_sub_duration) { int end = 1; - if (ist->prev_sub.got_output) { - end = av_rescale(subtitle->pts - ist->prev_sub.subtitle.pts, + if (d->prev_sub.got_output) { + end = av_rescale(subtitle->pts - d->prev_sub.subtitle.pts, 1000, AV_TIME_BASE); - if (end < ist->prev_sub.subtitle.end_display_time) { + if (end < d->prev_sub.subtitle.end_display_time) { av_log(NULL, AV_LOG_DEBUG, "Subtitle duration reduced from %"PRId32" to %d%s\n", - ist->prev_sub.subtitle.end_display_time, end, + d->prev_sub.subtitle.end_display_time, end, end <= 0 ? ", dropping it" : ""); - ist->prev_sub.subtitle.end_display_time = end; + d->prev_sub.subtitle.end_display_time = end; } } - FFSWAP(int, got_output, ist->prev_sub.got_output); - FFSWAP(AVSubtitle, *subtitle, ist->prev_sub.subtitle); + FFSWAP(int, got_output, d->prev_sub.got_output); + FFSWAP(AVSubtitle, *subtitle, d->prev_sub.subtitle); if (end <= 0) goto out; } @@ -430,8 +439,9 @@ out: int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts) { + Decoder *d = ist->decoder; int ret = AVERROR_BUG; - AVSubtitle *prev_subtitle = &ist->prev_sub.subtitle; + AVSubtitle *prev_subtitle = &d->prev_sub.subtitle; AVSubtitle subtitle; if (!ist->fix_sub_duration || !prev_subtitle->num_rects || diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1c6a5aab7b..5d3e043793 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -816,7 +816,6 @@ static void ist_free(InputStream **pist) dec_free(&ist->decoder); av_dict_free(&ist->decoder_opts); - avsubtitle_free(&ist->prev_sub.subtitle); av_freep(&ist->filters); av_freep(&ist->outputs); av_freep(&ist->hwaccel_device); -- 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".