From patchwork Mon Apr 4 11:29:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35175 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1913227pzb; Mon, 4 Apr 2022 04:35:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRD2+EhjKVZVyRtbWRjPNWwrcq5A1FNbyjM8dolxLoyiGY1dgAFCJVqQFMeRmjc7JGqo/A X-Received: by 2002:aa7:d553:0:b0:416:4dfc:126d with SMTP id u19-20020aa7d553000000b004164dfc126dmr32341932edr.213.1649072154139; Mon, 04 Apr 2022 04:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649072154; cv=none; d=google.com; s=arc-20160816; b=fQe7yUBq7Na+A4FVvUGK8iUOv5cJkq93LAgol2nqn+16x9y5mf09JAs/wE6bhTQlD9 mWaNwFZcv4zSR0J8CFkEQn29SJJ9GJfH+9JXnvKeoFbOst4uXz5QT4yATFUYeMqzTrW0 v/tMgb5Pfu8X+5/gPrjGn11vVsWhZ78d0OoD2kmDNsp/YTZMrwJppRf2e1RHMHkVu1d2 KMos8DZIoxRde8nIgf5VwMFAZ9IhwhxZiUJ6a1/aaV9KeQOA5Kt+awV0ehZQp3jeEmQl eBd9D5Sf9OBvmy2C8gT9rJH9GAs2vdwPIikZxFZbhpeyDK8cPeG8TNBOrg9kxQ3EY/9I XFGQ== 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=tZVBFn/Fx2hYsEeiggkMso80WwndJQAWBBGTHhT7w10=; b=ZJWZnPLWT2OXPsBDQLip1AkkcuV9jOCp3W8XmWyh79A6Au9JBkgDEHiGJ4iKD+3FLr fM2hATby+PMK+pvLm0wMtty7EUeA4qII3DKq3pKJUIgi2MKVbQfJVCfzPJMi7spDYr6P B/TCzF8nBZ0HQ7REVtVA/eVperXeAfA+T0vFKdPTVSBDQljK2H1RuTwA4nDFEiKhJEeH ThFLMAdMz9wxdkgguqOCKLgq1sDfCwKM/4NbiHFTUM3O/t9cCf5vrQ+6A+xwIOIMZ0YM Ptd3hHJUtrMQ0227GRKnrRF7EqopzxqNKyjPgyuIAiBW6cqBkFLOifTz3X4A9OvZGfeM uPYg== 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 u1-20020a50c2c1000000b0041cd94de942si879007edf.591.2022.04.04.04.35.53; Mon, 04 Apr 2022 04:35:54 -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 2A2B368B30A; Mon, 4 Apr 2022 14:32:43 +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 2E37368B255 for ; Mon, 4 Apr 2022 14:32:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id DD6042400F5 for ; Mon, 4 Apr 2022 13:32:17 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id awBSYeZpubcs for ; Mon, 4 Apr 2022 13:32:17 +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 CA632240506 for ; Mon, 4 Apr 2022 13:32:14 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id AAF7D3A0763; Mon, 4 Apr 2022 13:32:11 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Apr 2022 13:29:53 +0200 Message-Id: <20220404113037.13070-6-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220404113037.13070-1-anton@khirnov.net> References: <20220404113037.13070-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/49] fftools/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: Gao+Q7q9h1Po 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 29b01f9d93..bc700052b6 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2947,7 +2947,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; @@ -2962,13 +2962,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) { @@ -3571,7 +3571,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; @@ -3674,7 +3674,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 04369df139..0eee6f4da8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -577,6 +577,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 8e217af4ab..daecba9e57 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2314,6 +2314,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;