From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 57112444AE for ; Thu, 13 Oct 2022 13:51:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8CAB268BD98; Thu, 13 Oct 2022 16:49:32 +0300 (EEST) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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); -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".