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 0DC3543C26 for ; Sat, 23 Jul 2022 14:14:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 49ED468B900; Sat, 23 Jul 2022 17:10:51 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8EC8168B7C9 for ; Sat, 23 Jul 2022 17:10:27 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 08C51240512 for ; Sat, 23 Jul 2022 16:10:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ok0-NzkEl_g0 for ; Sat, 23 Jul 2022 16:10:23 +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 9A39024055A for ; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 6CC1C3A0404; Sat, 23 Jul 2022 16:10:19 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 23 Jul 2022 16:09:32 +0200 Message-Id: <20220723140952.31814-7-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220723140952.31814-1-anton@khirnov.net> References: <20220723140952.31814-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/27] fftools/ffmpeg: drop OutputStream.ref_par 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: It serves no purpose, codec parameters can be written directly to AVStream.codecpar with the same effect. --- fftools/ffmpeg.c | 37 ++++++++++++++++--------------------- fftools/ffmpeg.h | 1 - fftools/ffmpeg_opt.c | 6 ------ 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 1780e535ae..cad9f1e885 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -587,7 +587,6 @@ static void ffmpeg_cleanup(int ret) if (ost->enc_ctx) av_freep(&ost->enc_ctx->stats_in); avcodec_free_context(&ost->enc_ctx); - avcodec_parameters_free(&ost->ref_par); av_freep(&output_streams[i]); } @@ -2757,11 +2756,10 @@ static int init_output_stream_streamcopy(OutputStream *ost) { OutputFile *of = output_files[ost->file_index]; InputStream *ist = get_input_stream(ost); - AVCodecParameters *par_dst = ost->st->codecpar; - AVCodecParameters *par_src = ost->ref_par; + AVCodecParameters *par = ost->st->codecpar; AVRational sar; int i, ret; - uint32_t codec_tag = par_dst->codec_tag; + uint32_t codec_tag = par->codec_tag; av_assert0(ist && !ost->filter); @@ -2774,7 +2772,7 @@ static int init_output_stream_streamcopy(OutputStream *ost) return ret; } - ret = avcodec_parameters_from_context(par_src, ost->enc_ctx); + ret = avcodec_parameters_from_context(par, ost->enc_ctx); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error getting reference codec parameters.\n"); @@ -2784,16 +2782,12 @@ static int init_output_stream_streamcopy(OutputStream *ost) if (!codec_tag) { unsigned int 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; + av_codec_get_id (of->format->codec_tag, par->codec_tag) == par->codec_id || + !av_codec_get_tag2(of->format->codec_tag, par->codec_id, &codec_tag_tmp)) + codec_tag = par->codec_tag; } - ret = avcodec_parameters_copy(par_dst, par_src); - if (ret < 0) - return ret; - - par_dst->codec_tag = codec_tag; + par->codec_tag = codec_tag; if (!ost->frame_rate.num) ost->frame_rate = ist->framerate; @@ -2838,26 +2832,27 @@ static int init_output_stream_streamcopy(OutputStream *ost) av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value); } - switch (par_dst->codec_type) { + switch (par->codec_type) { case AVMEDIA_TYPE_AUDIO: - if((par_dst->block_align == 1 || par_dst->block_align == 1152 || par_dst->block_align == 576) && par_dst->codec_id == AV_CODEC_ID_MP3) - par_dst->block_align= 0; - if(par_dst->codec_id == AV_CODEC_ID_AC3) - par_dst->block_align= 0; + if ((par->block_align == 1 || par->block_align == 1152 || par->block_align == 576) && + par->codec_id == AV_CODEC_ID_MP3) + par->block_align = 0; + if (par->codec_id == AV_CODEC_ID_AC3) + par->block_align = 0; break; case AVMEDIA_TYPE_VIDEO: if (ost->frame_aspect_ratio.num) { // overridden by the -aspect cli option sar = av_mul_q(ost->frame_aspect_ratio, - (AVRational){ par_dst->height, par_dst->width }); + (AVRational){ par->height, par->width }); av_log(NULL, AV_LOG_WARNING, "Overriding aspect ratio " "with stream copy may produce invalid files\n"); } else if (ist->st->sample_aspect_ratio.num) sar = ist->st->sample_aspect_ratio; else - sar = par_src->sample_aspect_ratio; - ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar; + sar = par->sample_aspect_ratio; + ost->st->sample_aspect_ratio = par->sample_aspect_ratio = sar; ost->st->avg_frame_rate = ist->st->avg_frame_rate; ost->st->r_frame_rate = ist->st->r_frame_rate; break; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0c9498c23e..59c2f47a66 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -481,7 +481,6 @@ typedef struct OutputStream { AVBSFContext *bsf_ctx; AVCodecContext *enc_ctx; - AVCodecParameters *ref_par; /* associated input codec parameters with encoders options applied */ const AVCodec *enc; int64_t max_frames; AVFrame *filtered_frame; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 81754f7d91..32e0d9a7ff 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1573,12 +1573,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e } ost->enc_ctx->codec_type = type; - ost->ref_par = avcodec_parameters_alloc(); - if (!ost->ref_par) { - av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n"); - exit_program(1); - } - ost->filtered_frame = av_frame_alloc(); if (!ost->filtered_frame) exit_program(1); -- 2.34.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".