From patchwork Thu Oct 13 13:49: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: 38726 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp349411pzb; Thu, 13 Oct 2022 06:51:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4carKgpO0wlpK6wsDiTNAb2JJgP+FztqRERpCPzwE0EZf6UKvfKRoHKgRCd+jWyn3BwqIe X-Received: by 2002:a17:907:9804:b0:78e:676:f1a1 with SMTP id ji4-20020a170907980400b0078e0676f1a1mr3393418ejc.744.1665669066780; Thu, 13 Oct 2022 06:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665669066; cv=none; d=google.com; s=arc-20160816; b=AL9ChaQtXSW14H4WlbskFWW9N4RbEp6f2OOhQ57oAMJwhB7viyJOfr0i+RkfVPwKSe wLJdpeCvfV2/e0clivHDrgSHzFBEcy2M8Ce/JtfcoBbj9rnciUlU96Nqqq0IIF6/zMGn xnWZe1eleonrgffKXIKZ8+6Lz5W5jP8RqtFCEOR8D9/SDliGK0ADkk6XeiA9K6pgKZ50 4g2UwB1oosgwY95Nih01Pg/3n8OLZjHdsRpCqwa5S21Y0kYmrB2u7DCO1tq603HVi4aW PSQwz6wGxRKttiRanmm0QS+fUrhBd/F7VZ0YH7GKJ7yzLqnschQWI1diLcLwDNU6wtQ7 7AYw== 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=0broGa6lfXKlgpUmcJCHXHPpZ4yf+vYowX4rc6ZA/lw=; b=BvguxU8eIs56KMr0moHshWRlZoaVm2fBpq5HD5cIey9p3ndfpmN3uTByWhHm/VBgUF MPLs4vtgTti8KSlMOINPPIK8ovCBC5MNBHMTDlQMCW6r22c4gY6qGNJkqOKxtzHIjjqe knpsJDd8z2D/akraf1d2xB0TXUYj7is6mgqbYN4RzVhv11j5eY89tSFZ9NspIDb7M0lu AsibnOcQiD9PZOiOH1Tu2cB/yZ+ZsKurzec8/JiiHAYAFiEVh2mpRVTpfQqpv9wolo/C lwjsWNhO+7PI4LT9M033ngqPDy02iAgkk/Vy6tmvkjKnv6UV9uD7Hb+S7klsnTV+3w8W +HGA== 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 kw1-20020a170907770100b0077547abf08fsi17198435ejc.169.2022.10.13.06.51.06; Thu, 13 Oct 2022 06:51:06 -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 BF18E68BD99; Thu, 13 Oct 2022 16:49:32 +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 79F2C68BD71 for ; Thu, 13 Oct 2022 16:49:20 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5511F2404F5 for ; Thu, 13 Oct 2022 15:49:18 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id X43q_qXBP41N for ; Thu, 13 Oct 2022 15:49: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 7BD302406CB for ; Thu, 13 Oct 2022 15:49:13 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3D1263A1A26 for ; Thu, 13 Oct 2022 15:49:08 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Oct 2022 15:49:04 +0200 Message-Id: <20221013134904.10104-13-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221013134904.10104-1-anton@khirnov.net> References: <20221013134904.10104-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/13] fftools/ffmpeg: move init_output_bsfs() to ffmpeg_mux 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: W9zagsm1M7DA Bitstream filtering is done as a part of muxing, so this is the more proper place for this. --- fftools/ffmpeg.c | 36 ------------------------------------ fftools/ffmpeg_mux.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9bb877fb34..46d2912d07 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2651,35 +2651,6 @@ static int compare_int64(const void *a, const void *b) return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b); } -static int init_output_bsfs(OutputStream *ost) -{ - AVBSFContext *ctx = ost->bsf_ctx; - int ret; - - if (!ctx) - return 0; - - ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar); - if (ret < 0) - return ret; - - ctx->time_base_in = ost->st->time_base; - - ret = av_bsf_init(ctx); - if (ret < 0) { - av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n", - ctx->filter->name); - return ret; - } - - ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out); - if (ret < 0) - return ret; - ost->st->time_base = ctx->time_base_out; - - return 0; -} - static int init_output_stream_streamcopy(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; @@ -3212,13 +3183,6 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return ret; } - /* initialize bitstream filters for the output stream - * needs to be done here, because the codec id for streamcopy is not - * known until now */ - ret = init_output_bsfs(ost); - if (ret < 0) - return ret; - ret = of_stream_init(output_files[ost->file_index], ost); if (ret < 0) return ret; diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 652628185e..5418cd3000 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -536,12 +536,50 @@ int mux_check_init(Muxer *mux) return 0; } +static int bsf_init(OutputStream *ost) +{ + AVBSFContext *ctx = ost->bsf_ctx; + int ret; + + if (!ctx) + return 0; + + ret = avcodec_parameters_copy(ctx->par_in, ost->st->codecpar); + if (ret < 0) + return ret; + + ctx->time_base_in = ost->st->time_base; + + ret = av_bsf_init(ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error initializing bitstream filter: %s\n", + ctx->filter->name); + return ret; + } + + ret = avcodec_parameters_copy(ost->st->codecpar, ctx->par_out); + if (ret < 0) + return ret; + ost->st->time_base = ctx->time_base_out; + + return 0; +} + int of_stream_init(OutputFile *of, OutputStream *ost) { Muxer *mux = mux_from_of(of); + int ret; + if (ost->sq_idx_mux >= 0) sq_set_tb(mux->sq_mux, ost->sq_idx_mux, ost->mux_timebase); + /* initialize bitstream filters for the output stream + * needs to be done here, because the codec id for streamcopy is not + * known until now */ + ret = bsf_init(ost); + if (ret < 0) + return ret; + ost->initialized = 1; return mux_check_init(mux);