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 6AB0A45BF2 for ; Sat, 25 Mar 2023 19:18:06 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2DDF968CA0F; Sat, 25 Mar 2023 21:16:22 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3438E68C990 for ; Sat, 25 Mar 2023 21:16:12 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F28042404F5 for ; Sat, 25 Mar 2023 20:16:11 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id EqdRzXQ8aG0N for ; Sat, 25 Mar 2023 20:16:11 +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 4013C240706 for ; Sat, 25 Mar 2023 20:16:01 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id CB6BB3A0616 for ; Sat, 25 Mar 2023 20:15:54 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 25 Mar 2023 20:15:17 +0100 Message-Id: <20230325191529.10578-11-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230325191529.10578-1-anton@khirnov.net> References: <20230325191529.10578-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/23] fftools/ffmpeg: use stack variables to shorten code 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: --- fftools/ffmpeg.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 77c41c7cc9..7b7db03bde 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3018,6 +3018,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) InputStream *ist = ost->ist; AVCodecContext *enc_ctx = ost->enc_ctx; AVCodecContext *dec_ctx = NULL; + const AVCodec *enc = enc_ctx->codec; OutputFile *of = output_files[ost->file_index]; int ret; @@ -3044,9 +3045,9 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) !ost->frame_rate.den)) ost->frame_rate = ost->max_frame_rate; - if (enc_ctx->codec->supported_framerates && !ost->force_fps) { - int idx = av_find_nearest_q_idx(ost->frame_rate, enc_ctx->codec->supported_framerates); - ost->frame_rate = enc_ctx->codec->supported_framerates[idx]; + if (enc->supported_framerates && !ost->force_fps) { + int idx = av_find_nearest_q_idx(ost->frame_rate, enc->supported_framerates); + ost->frame_rate = enc->supported_framerates[idx]; } // reduce frame rate for mpeg4 to be within the spec limits if (enc_ctx->codec_id == AV_CODEC_ID_MPEG4) { @@ -3119,7 +3120,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) frame->top_field_first = !!ost->top_field_first; if (frame->interlaced_frame) { - if (enc_ctx->codec->id == AV_CODEC_ID_MJPEG) + if (enc->id == AV_CODEC_ID_MJPEG) enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TT:AV_FIELD_BB; else enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TB:AV_FIELD_BT; @@ -3143,12 +3144,12 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) } if (dec_ctx && dec_ctx->subtitle_header) { /* ASS code assumes this buffer is null terminated so add extra byte. */ - ost->enc_ctx->subtitle_header = av_mallocz(dec_ctx->subtitle_header_size + 1); - if (!ost->enc_ctx->subtitle_header) + enc_ctx->subtitle_header = av_mallocz(dec_ctx->subtitle_header_size + 1); + if (!enc_ctx->subtitle_header) return AVERROR(ENOMEM); - memcpy(ost->enc_ctx->subtitle_header, dec_ctx->subtitle_header, + memcpy(enc_ctx->subtitle_header, dec_ctx->subtitle_header, dec_ctx->subtitle_header_size); - ost->enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size; + enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size; } if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { @@ -3156,7 +3157,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) AVCodecDescriptor const *input_descriptor = avcodec_descriptor_get(ist->dec->id); AVCodecDescriptor const *output_descriptor = - avcodec_descriptor_get(ost->enc_ctx->codec_id); + avcodec_descriptor_get(enc_ctx->codec_id); if (input_descriptor) input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); if (output_descriptor) -- 2.39.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".