From patchwork Wed Aug 3 13:58:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 37110 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp458751pzb; Wed, 3 Aug 2022 07:01:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tbayKwq5ePVNXehL1Bnqlv/uLPRJMmkvW0MCC1QkamLgSMIODBGJMJCYkd06pKQCEb/iYx X-Received: by 2002:a05:6402:b85:b0:43c:f8e8:96ba with SMTP id cf5-20020a0564020b8500b0043cf8e896bamr26334122edb.183.1659535272384; Wed, 03 Aug 2022 07:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659535272; cv=none; d=google.com; s=arc-20160816; b=U0fSFPT3PzsDJg3uXgx1XTc2i4lGl22C+K8kEck1hENhangE/1IPghUlGpqTboCv3h hOV8jzgvn0lEGiOT8eoPtqI31uVVv4zQpS4UZXckn976R9mufEYR4bRsaOoZKQCsQIj9 qqhcClpKXAi588yLlU//vPnVrFTT3T4YeSxDwv6yvAvFdYnr3AwEVp2n66E+oY9iJuQS E0WsfDyquBL3K2DbkJoDF7b+mDE9THsM75bFHtteysMp25XNMOzkpXeQMg5bavZopqPO Vsl3DdsjOcNKXNp5g1t8VJfm1U6pJ8Rhn5JD8rK/tQDdBbkWtnL+59VxfZc7g0B3dIjw J9lw== 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=qx9Poi7KwUJAYJi7+ItP2qeWkNyRY0ngjr9G4JJaZgI=; b=q+l+vEr7G9DlYKoiWnkK+0HDg7JcZrfNo+/1r7a3w0nm/oHh22I5iAMmzLwiCRL0Cj enizX8ubSb4MSj0BEjU9LLhnmFi6zcMH3ENmkokNYerxzkLb1VoDaPINQikp4ZjsdnQW ASIk9NhBc9FQEXrXx5+4MgtZqYkOqqdNvbInEZYefZ51rlOWvJPI6DEiORnDWk2+/2lX Z3nFAfb9bUT9OQi72IWNADt8jkXtOrSI9xD5xp2VeP7+tL3PrDfiTYBDkag1pYJ4B7/K Q0foOAlEfnuszqzVKmXMiyBFweofEouoylOkpddoJ1up+ccXkrExITxFEFgcPSv2P9E0 CpYQ== 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 hs19-20020a1709073e9300b007309621c10fsi6382576ejc.699.2022.08.03.07.01.11; Wed, 03 Aug 2022 07:01:12 -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 8BE9368B0A6; Wed, 3 Aug 2022 16:59:15 +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 A7C9368B89E for ; Wed, 3 Aug 2022 16:59:01 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E0E1F240511 for ; Wed, 3 Aug 2022 15:58:58 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id XXVRIBetsHtu for ; Wed, 3 Aug 2022 15:58:58 +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 D014224050B for ; Wed, 3 Aug 2022 15:58:54 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 081553A046F; Wed, 3 Aug 2022 15:58:52 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Aug 2022 15:58:27 +0200 Message-Id: <20220803135844.16662-8-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220803135844.16662-1-anton@khirnov.net> References: <20220803135844.16662-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/25] fftools/ffmpeg: remove OutputStream.encoding_needed 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: GZAWMdROiiVL It is unnecessary, as it is always exactly equivalent to !!ost->enc_ctx --- fftools/ffmpeg.c | 10 +++++----- fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 8 ++------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0a1dc5bb3b..6124197580 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1536,7 +1536,7 @@ static void print_final_stats(int64_t total_size) av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", i, j, av_get_media_type_string(type)); - if (ost->encoding_needed) { + if (ost->enc_ctx) { av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", ost->frames_encoded); if (type == AVMEDIA_TYPE_AUDIO) @@ -1788,7 +1788,7 @@ static void flush_encoders(void) AVCodecContext *enc = ost->enc_ctx; OutputFile *of = output_files[ost->file_index]; - if (!ost->encoding_needed) + if (!enc) continue; // Try to enable encoding with no input frames. @@ -2359,7 +2359,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; - if (!check_output_constraints(ist, ost) || !ost->encoding_needed + if (!check_output_constraints(ist, ost) || !ost->enc_ctx || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) continue; @@ -2568,7 +2568,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; - if (!check_output_constraints(ist, ost) || ost->encoding_needed || + if (!check_output_constraints(ist, ost) || ost->enc_ctx || (!pkt && no_eof)) continue; @@ -3137,7 +3137,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, OutputFile *of = output_files[ost->file_index]; int ret = 0; - if (ost->encoding_needed) { + if (ost->enc_ctx) { const AVCodec *codec = ost->enc; AVCodecContext *dec = NULL; InputStream *ist; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 713de42e2b..69e4758a2d 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -464,7 +464,6 @@ typedef struct OutputStream { int index; /* stream index in the output file */ int source_index; /* InputStream index */ AVStream *st; /* stream in the output file */ - int encoding_needed; /* true if encoding needed for this stream */ /* number of frames emitted by the video-encoding sync code */ int64_t vsync_frame_number; /* input pts and corresponding output pts diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 784209e770..ffa320da87 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1559,10 +1559,6 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o ost->enc = find_codec_or_die(codec_name, ost->st->codecpar->codec_type, 1); ost->st->codecpar->codec_id = ost->enc->id; } - ost->encoding_needed = !!ost->enc; - } else { - /* no encoding supported for other media types */ - ost->encoding_needed = 0; } return 0; @@ -2433,7 +2429,7 @@ static int setup_sync_queues(OutputFile *of, AVFormatContext *oc, int64_t buf_si int limit_frames = 0, limit_frames_av_enc = 0; #define IS_AV_ENC(ost, type) \ - (ost->encoding_needed && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) + (ost->enc_ctx && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) #define IS_INTERLEAVED(type) (type != AVMEDIA_TYPE_ATTACHMENT) for (int i = 0; i < oc->nb_streams; i++) { @@ -3043,7 +3039,7 @@ static int open_output_file(OptionsContext *o, const char *filename) for (i = of->ost_index; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; - if (ost->encoding_needed && ost->source_index >= 0) { + if (ost->enc_ctx && ost->source_index >= 0) { InputStream *ist = input_streams[ost->source_index]; ist->decoding_needed |= DECODING_FOR_OST; ist->processing_needed = 1;