From patchwork Wed Jun 14 16:49:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 42072 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp190890pzb; Wed, 14 Jun 2023 09:51:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bY1U73XeihizdyqB4CkdC0IPRJK3v2lY5Oh/0p2OOdVcvHzMJNNQwMJskjLHLUSFR5Ntc X-Received: by 2002:a05:6512:411:b0:4f6:2020:7c24 with SMTP id u17-20020a056512041100b004f620207c24mr7567480lfk.5.1686761498195; Wed, 14 Jun 2023 09:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686761498; cv=none; d=google.com; s=arc-20160816; b=Rb18ifXPFGMMWdPUu08QVsSRjRBGzs16TelDk5BE0OADWnp7VHeIGOim5OKTr9tUE3 pFVKoU4ct95Qs9S04IcnlJQxRZfoazGWwyrul+iJa1hg/E85gUrGFGGynX4W1unGkOI1 FR9mws4vT2M1Hq6roTD2JJBfS7xH2rKRbOuERqszcB8kw5ZbpsXb+fY9S2XAX+iKK4oJ GaSi32q1y9yf5tQH0164A+ytNUhrQaBy2ryOI4qGHKg3bicBu3BLlKJgKcml/PnFUDFa Az85KWYEyjB5eIb2Z15Qb7GNPQ2CYnvDwGvc5bsTOROWpgfVpK7pBjYNn5BA4p8VU8GP 4CIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=S1ySQ2ZY16X/NRvQgFPVkhgwBXFSbjcnNPuaz0pnC6w=; b=A5WP1ReiqkhxamsiffM5VcAIZ4yg2Lzrh3ixU8w3KkrGUcIFcQJMMX72LjcNGsgPT3 J6hFm6ESamkHDQHCF0axtN0puZtv+rsviDbgyfe37rYH5dOCrNDenOiTU9gTKL6D0Sht /1T95CfKviwoL5/8IxDQeQifV+iJaTxN9K0gONoicsigqeDxc+++vKq1KsXCbPbHak0o ugwO4+3RLX53/t0vCYEd7HzLmWH7DtMR3KDbu8qgT43Z2wdvFW9E8CWShnxeTQ7o0iJP DaZx2YjcQje1OQZW3COlTO41JmAFW9t5vJO/oTkU/crpJuobug/4KT1/MX4+UgcUY29y QrHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i4-20020a1709063c4400b00978337254a6si8648608ejg.91.2023.06.14.09.51.37; Wed, 14 Jun 2023 09:51:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D2E6068C4C2; Wed, 14 Jun 2023 19:50:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EDE7F68C472 for ; Wed, 14 Jun 2023 19:50:02 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id BDB282405B5 for ; Wed, 14 Jun 2023 18:50:02 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 4LmPqRYBlPhJ for ; Wed, 14 Jun 2023 18:50:02 +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 20078240705 for ; Wed, 14 Jun 2023 18:49:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E20743A0CDD 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:04 +0200 Message-Id: <20230614164908.28712-17-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 17/21] fftools/ffmpeg: move fix_sub_duration_heartbeat() to ffmpeg_dec 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1AqbQ/P4hKxO This way ffmpeg.c does not need to access InputStream.prev_sub and it can be made private. --- fftools/ffmpeg.c | 18 ------------------ fftools/ffmpeg.h | 2 +- fftools/ffmpeg_dec.c | 20 +++++++++++++++++++- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4e6205e3cb..435e12a37b 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -768,24 +768,6 @@ int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy) return 0; } -static int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts) -{ - int ret = AVERROR_BUG; - AVSubtitle *prev_subtitle = &ist->prev_sub.subtitle; - AVSubtitle subtitle; - - if (!ist->fix_sub_duration || !prev_subtitle->num_rects || - signal_pts <= prev_subtitle->pts) - return 0; - - if ((ret = copy_av_subtitle(&subtitle, prev_subtitle)) < 0) - return ret; - - subtitle.pts = signal_pts; - - return process_subtitle(ist, &subtitle); -} - int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt) { OutputFile *of = output_files[ost->file_index]; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 5d60da085b..b4b55f5a73 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -879,7 +879,7 @@ OutputStream *ost_iter(OutputStream *prev); void close_output_stream(OutputStream *ost); int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt); -int process_subtitle(InputStream *ist, AVSubtitle *subtitle); +int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts); void update_benchmark(const char *fmt, ...); /** diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 996e7318d9..879101fe21 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -376,7 +376,7 @@ static void sub2video_flush(InputStream *ist) } } -int process_subtitle(InputStream *ist, AVSubtitle *subtitle) +static int process_subtitle(InputStream *ist, AVSubtitle *subtitle) { int got_output = 1; int ret = 0; @@ -428,6 +428,24 @@ out: return ret; } +int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts) +{ + int ret = AVERROR_BUG; + AVSubtitle *prev_subtitle = &ist->prev_sub.subtitle; + AVSubtitle subtitle; + + if (!ist->fix_sub_duration || !prev_subtitle->num_rects || + signal_pts <= prev_subtitle->pts) + return 0; + + if ((ret = copy_av_subtitle(&subtitle, prev_subtitle)) < 0) + return ret; + + subtitle.pts = signal_pts; + + return process_subtitle(ist, &subtitle); +} + static int transcode_subtitles(InputStream *ist, const AVPacket *pkt, AVFrame *frame) {