From patchwork Tue Jan 11 09:58:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 33210 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp3545337iog; Tue, 11 Jan 2022 02:00:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzq1vE21PII+fp7nya0ePFxffv+ckQJW63+OIoUGQNVjW1XaWMLtxPLtfOxxuLNDlXC4MRX X-Received: by 2002:a05:6402:1d54:: with SMTP id dz20mr3506713edb.395.1641895217534; Tue, 11 Jan 2022 02:00:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641895217; cv=none; d=google.com; s=arc-20160816; b=wKb0/almfJpY8sUCuv/iOHCAmUT+r4pm0uJJJQ9YoIDskGbG1SCGniLKz3Jkvhp/bf vYvOjYD8PZ6QVzxkO6PT9cYDQ3pC3Akzr/7hIrcZrdUhD6F9yaBqBotxuzYysyr3AstT v7ZK7bFdceHPrGjSxheSX1Vh/lCifrdx7YIYumtKLSNP1PrdWkBqKvDxkTh0SV5uZlON a2Y33OtHQGlJDsjiK7YjlWlzxnC9umB0g9CbVl0IUpo7jci5MdZWytoAknHF266k0nO8 YBVcUKwpbS50LWYKkd5jHPfzAJdT3OQIbmVt/1u9imIQUtBn1bCy/RCNNPlg3tv32UY6 SkbQ== 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=+nD6KQdNGEkek3Lv1RKEZlQuze24ZuD/evSnooQxQjQ=; b=IVQO+gepwSN86C9nW0+ZgOvhhp9FGaKiWWFIE07c8FadyWA2wfFK+5XpCQKaNgqxAs J0ayHD08y7AKbxcFswgIxQWo+9uBUw4sVYCnhyIFZhvYRIVYDZylFMHjYmiyGf3pnV9b 9HAhcHR1uyRy7haw3sbfbV4nSu0s9udrRcX44nkNpSB7nj5trFCkUtmbTKgNV8cWhmRw G4KaqAoH3l4aSi5T+JaZv9Jlwg4Ssy2Zay0ktGD7A8PYeIkGVlZShtgPyv7pPAHL2L5f UxLDBlj4tlEz6X0S+P7BpsUCb44ln34UjJRaOq+yjm3vrQxcph1EK6un5eF482dRYGEj TkPA== 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 hc17si2615550ejc.400.2022.01.11.02.00.16; Tue, 11 Jan 2022 02:00:17 -0800 (PST) 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 E38FB68AF41; Tue, 11 Jan 2022 11:59:16 +0200 (EET) 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 5BCF568AF3B for ; Tue, 11 Jan 2022 11:59:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D9009240506 for ; Tue, 11 Jan 2022 10:59:05 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id FduQUQHnKXnV for ; Tue, 11 Jan 2022 10:59:05 +0100 (CET) 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 874AD24050B for ; Tue, 11 Jan 2022 10:59:02 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id CDC3E3A038C; Tue, 11 Jan 2022 10:59:01 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 10:58:04 +0100 Message-Id: <20220111095830.31542-2-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220111095830.31542-1-anton@khirnov.net> References: <20220111095830.31542-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/28] ffmpeg: store the output file index in OutputFile 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: TrB+MeSmRz3p Use it to simplify check_init_output_file(). Will allow further simplifications in the following commits. --- fftools/ffmpeg.c | 10 +++++----- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_opt.c | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 5d134b025f..1961653dcc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2941,7 +2941,7 @@ static int compare_int64(const void *a, const void *b) } /* open the muxer when all the streams are initialized */ -static int check_init_output_file(OutputFile *of, int file_index) +static int check_init_output_file(OutputFile *of) { int ret, i; @@ -2956,13 +2956,13 @@ static int check_init_output_file(OutputFile *of, int file_index) av_log(NULL, AV_LOG_ERROR, "Could not write header for output file #%d " "(incorrect codec parameters ?): %s\n", - file_index, av_err2str(ret)); + of->index, av_err2str(ret)); return ret; } //assert_avoptions(of->opts); of->header_written = 1; - av_dump_format(of->ctx, file_index, of->ctx->url, 1); + av_dump_format(of->ctx, of->index, of->ctx->url, 1); nb_output_dumped++; if (sdp_filename || want_sdp) { @@ -3565,7 +3565,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, ost->initialized = 1; - ret = check_init_output_file(output_files[ost->file_index], ost->file_index); + ret = check_init_output_file(output_files[ost->file_index]); if (ret < 0) return ret; @@ -3668,7 +3668,7 @@ static int transcode_init(void) for (i = 0; i < nb_output_files; i++) { oc = output_files[i]->ctx; if (oc->oformat->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) { - ret = check_init_output_file(output_files[i], i); + ret = check_init_output_file(output_files[i]); if (ret < 0) goto dump_format; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9b200b806a..5fd5d2606b 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -574,6 +574,8 @@ typedef struct OutputStream { } OutputStream; typedef struct OutputFile { + int index; + AVFormatContext *ctx; AVDictionary *opts; int ost_index; /* index of the first stream in output_streams */ diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f638edace9..e8db515e0c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2283,6 +2283,7 @@ static int open_output_file(OptionsContext *o, const char *filename) of = ALLOC_ARRAY_ELEM(output_files, nb_output_files); + of->index = nb_output_files - 1; of->ost_index = nb_output_streams; of->recording_time = o->recording_time; of->start_time = o->start_time;