From patchwork Mon Dec 13 15:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 32421 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5572033iog; Mon, 13 Dec 2021 07:22:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXB5CbfdFfWwuy0VX6I913S0tphunu0OcwhCcdK3Cpb44LnfKlnHK/wbpIvnGmM1qv9ckD X-Received: by 2002:a17:906:2b47:: with SMTP id b7mr1197261ejg.618.1639408942335; Mon, 13 Dec 2021 07:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639408942; cv=none; d=google.com; s=arc-20160816; b=feIc2TQxD6sTwL54k9pMFn22kCiuA1JxcEqWlQXbuMKQRlSZckQxdLUvwND6cE52ji RCBNFc91LumQzpEiIIyqqBS60DHwfd8PqUpqY4owRY845ipGfSzFGIkcUwjfjbtCSttx QDZhuz+r+vb0szfC+HEJexMMHrv2ThNfaUQ+HLjzvivLxdUu/JLI3tXwJzHe0KU4wJVd rFzyYHwo3SKkCfbYbdvomew0yK1UZfQ9z5i/UvZbYN8OcP47w7oQjKi1ykq+dvPMkc4N S1VwxIqwNsaFM+g5I9c/LsZhmNJxeP0ng8OgQp7wm+o9U2n1/Qsi5CPTpDi1WivsKxSZ 3N5w== 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=DVS54A5kJdocCGaXugf8vxYe7POG82IINRlRrULnP3U=; b=0wuL1GoCvHnXbtrRkeU/L4z8r3Spphqyr8LK8NaowOPx+sWr+3rHUsXlSjKfJpixbW YYnc6FT/kbdBu5cf4x/eMHN5qQu9s4GiHBdlOzEJMulm9u0B4tBuOJC2Z2tvMRCW/0GT XaARiPBFsCspKEZDeG7Ps+xEXQ6TqCL8zRfn59aCLGW8AJe9uRRrdfLt4C7RabXIqra1 HsFKWucv6OAefo/Wgt4fg7wxuPReDXXhnxy9F16gkPgFXFnf/5o8x91MPO57bbuEDEx3 MROJkXMvdlvBN6A6JIcmAeUTW7syTRrSxjf8jMoEwx127l05sqySnOEaz0k52tkrf/xE cZlg== 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 m15si21519595edc.235.2021.12.13.07.22.20; Mon, 13 Dec 2021 07:22:22 -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 E306168AF81; Mon, 13 Dec 2021 17:22:15 +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 E218F68807F for ; Mon, 13 Dec 2021 17:22:08 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7195B24068F for ; Mon, 13 Dec 2021 16:22:08 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id YXNKqvRmeemU for ; Mon, 13 Dec 2021 16:22:07 +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 3459D24017C for ; Mon, 13 Dec 2021 16:22:07 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 167A63A0743; Mon, 13 Dec 2021 16:22:07 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Dec 2021 16:20:22 +0100 Message-Id: <20211213152042.5900-4-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211213152042.5900-1-anton@khirnov.net> References: <20211213152042.5900-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/24] 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: YCnpi7SBKfDG 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 fb017a1e37..564ab01335 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2937,7 +2937,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; @@ -2952,13 +2952,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) { @@ -3561,7 +3561,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; @@ -3664,7 +3664,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;