From patchwork Mon Dec 13 15:20:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 32429 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5574191iog; Mon, 13 Dec 2021 07:23:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtazkJmJ5u6dt5LHKKlJUhv7Zm0oZuWwTAJ7v0T0UQv4maME1XOiggAkExOfZ3iWBO/oaa X-Received: by 2002:a05:6402:50c7:: with SMTP id h7mr66305047edb.277.1639409036550; Mon, 13 Dec 2021 07:23:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639409036; cv=none; d=google.com; s=arc-20160816; b=KRh8lhfuonPpJDO2TdE9USTKkeAbkuCOHQrUtd5ys9LBeURU7TMu/RZZFQSIi6dlGx YtJh/ffaDPiUV4tPfbAsdv7ACzqsZ/ZRRxNXWdkjUArGUSO30JnvP2Scg32nTDwcRjsd BznVp+r9ss2GaS5ECH/R6BnD5jw+LA88DQD0aMoJXc3MsWLYi4uORd6XaOrKH+1iokV9 hd9kOGLKdR3VEQdNToCNBuTjeGsOyZJUL62S1e/rn7e2xoZWkwY/+54oNcCVufFuDC3l AsSktXotqcyBU7qS4OVJpL0F2mOtgH3rJe49lE0n7cn6NuWXxhRCii7Ervt9dkG006HT l9Kw== 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=6rJ8gOael32n2UybwjXDLerwOebjWt/h7KcK3DxFRZw=; b=EYtXez5oi25ELh2GJzRcHQRgzs9yg1j1QFqy/VAHk+ABFn1Q6sNQj2A3M57vPrYqiH 5RI/+VErbB+WAUyPL8l30qcU7WO+uMpQ1ajYEWaGCPckTLYifj7Im6uzXrhZS2Wnqe+U QS7hYOGOXkLa8bf1BTGYX4P/qB5vUur+mQtmP67DBn3ryZJVpVkcHeSVgksiAZNFJAzk 2SXqN0h34Bkox62eN3trjaJ3LBTWh4ZGSxB20C4F2Q+3U/g6l55Go4zm7EXV+vsxWZZL WXgGol2TztJdt9ZLk9Q8wwRQhlm/rjTVqvkwTVr6/6U1ckb87lPNnX5X0oi8YL/Sv6Ip U+jw== 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 ji10si22022574ejc.539.2021.12.13.07.23.54; Mon, 13 Dec 2021 07:23:56 -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 D040668AF9F; Mon, 13 Dec 2021 17:22:23 +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 5DC7368AFAA for ; Mon, 13 Dec 2021 17:22:14 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id BCC05240512 for ; Mon, 13 Dec 2021 16:22:10 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Q39kKl36e-05 for ; Mon, 13 Dec 2021 16:22:10 +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 94730240511 for ; Mon, 13 Dec 2021 16:22:07 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 281A93A0804; Mon, 13 Dec 2021 16:22:07 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Dec 2021 16:20:26 +0100 Message-Id: <20211213152042.5900-8-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 08/24] ffmpeg: store output format separately from the muxer context 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: 8rJtz6bIbd9Y Allows accessing it without going through the muxer context. This will be useful in the following commits, where the muxer context will be hidden. --- fftools/ffmpeg.c | 18 ++++++++++-------- fftools/ffmpeg.h | 2 ++ fftools/ffmpeg_opt.c | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 86f7b11654..8a7cab3fab 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2779,9 +2779,9 @@ static int init_output_stream_streamcopy(OutputStream *ost) if (!codec_tag) { unsigned int codec_tag_tmp; - if (!of->ctx->oformat->codec_tag || - av_codec_get_id (of->ctx->oformat->codec_tag, par_src->codec_tag) == par_src->codec_id || - !av_codec_get_tag2(of->ctx->oformat->codec_tag, par_src->codec_id, &codec_tag_tmp)) + if (!of->format->codec_tag || + av_codec_get_id (of->format->codec_tag, par_src->codec_tag) == par_src->codec_id || + !av_codec_get_tag2(of->format->codec_tag, par_src->codec_id, &codec_tag_tmp)) codec_tag = par_src->codec_tag; } @@ -2799,7 +2799,7 @@ static int init_output_stream_streamcopy(OutputStream *ost) else ost->st->avg_frame_rate = ist->st->avg_frame_rate; - ret = avformat_transfer_internal_stream_timing_info(of->ctx->oformat, ost->st, ist->st, copy_tb); + ret = avformat_transfer_internal_stream_timing_info(of->format, ost->st, ist->st, copy_tb); if (ret < 0) return ret; @@ -3001,7 +3001,8 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) InputStream *ist = get_input_stream(ost); AVCodecContext *enc_ctx = ost->enc_ctx; AVCodecContext *dec_ctx = NULL; - AVFormatContext *oc = output_files[ost->file_index]->ctx; + OutputFile *of = output_files[ost->file_index]; + AVFormatContext *oc = of->ctx; int ret; set_encoder_id(output_files[ost->file_index], ost); @@ -3061,7 +3062,8 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) if (!(enc_ctx->time_base.num && enc_ctx->time_base.den)) enc_ctx->time_base = av_buffersink_get_time_base(ost->filter->filter); if ( av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH - && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){ + && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || + (video_sync_method == VSYNC_AUTO && !(of->format->flags & AVFMT_VARIABLE_FPS)))){ av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n" "Please consider specifying a lower framerate, a different muxer or -vsync 2\n"); } @@ -3394,7 +3396,7 @@ static int transcode_init(void) /* write headers for files with no streams */ for (i = 0; i < nb_output_files; i++) { oc = output_files[i]->ctx; - if (oc->oformat->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) { + if (output_files[i]->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) { ret = of_check_init(output_files[i]); if (ret < 0) goto dump_format; @@ -4601,7 +4603,7 @@ int main(int argc, char **argv) } for (i = 0; i < nb_output_files; i++) { - if (strcmp(output_files[i]->ctx->oformat->name, "rtp")) + if (strcmp(output_files[i]->format->name, "rtp")) want_sdp = 0; } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 288e0f2981..c28acad4f1 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -576,6 +576,8 @@ typedef struct OutputStream { typedef struct OutputFile { int index; + const AVOutputFormat *format; + 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 e8db515e0c..433102bb49 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2301,6 +2301,7 @@ static int open_output_file(OptionsContext *o, const char *filename) } of->ctx = oc; + of->format = oc->oformat; if (o->recording_time != INT64_MAX) oc->duration = o->recording_time;