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 6723445A08 for ; Sun, 9 Apr 2023 14:09:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C7B568BD27; Sun, 9 Apr 2023 17:09:20 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 410F868A6B5 for ; Sun, 9 Apr 2023 17:09:12 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 071A82404EC for ; Sun, 9 Apr 2023 16:09:12 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 9xB-qYEu_n7b for ; Sun, 9 Apr 2023 16:09:11 +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 18BE52404F5 for ; Sun, 9 Apr 2023 16:09:10 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id D10263A03E5 for ; Sun, 9 Apr 2023 16:09:09 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Apr 2023 16:08:27 +0200 Message-Id: <20230409140853.28858-3-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230409140853.28858-1-anton@khirnov.net> References: <20230409140853.28858-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/29] fftools/ffmpeg: move OutputStream.sq_frame to Encoder 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 is audio/video encoding-only and does not need to be visible outside of ffmpeg_enc.c --- fftools/ffmpeg.h | 1 - fftools/ffmpeg_enc.c | 17 ++++++++++++++--- fftools/ffmpeg_mux.c | 1 - fftools/ffmpeg_mux_init.c | 4 ---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index e7e7d88577..84418d8da5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -588,7 +588,6 @@ typedef struct OutputStream { Encoder *enc; AVCodecContext *enc_ctx; AVFrame *filtered_frame; - AVFrame *sq_frame; AVPacket *pkt; int64_t last_dropped; int64_t last_nb0_frames[3]; diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index bb11cdf42a..5c56ad0325 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -50,6 +50,8 @@ struct Encoder { AVFrame *last_frame; /* number of frames emitted by the video-encoding sync code */ int64_t vsync_frame_number; + + AVFrame *sq_frame; }; static uint64_t dup_warning = 1000; @@ -62,6 +64,7 @@ void enc_free(Encoder **penc) return; av_frame_free(&enc->last_frame); + av_frame_free(&enc->sq_frame); av_freep(penc); } @@ -139,6 +142,7 @@ static void init_encoder_time_base(OutputStream *ost, AVRational default_time_ba int enc_open(OutputStream *ost, AVFrame *frame) { InputStream *ist = ost->ist; + Encoder *e = ost->enc; AVCodecContext *enc_ctx = ost->enc_ctx; AVCodecContext *dec_ctx = NULL; const AVCodec *enc = enc_ctx->codec; @@ -328,6 +332,12 @@ int enc_open(OutputStream *ost, AVFrame *frame) return ret; } + if (ost->sq_idx_encode >= 0) { + e->sq_frame = av_frame_alloc(); + if (!e->sq_frame) + return AVERROR(ENOMEM); + } + if (ost->enc_ctx->frame_size) { av_assert0(ost->sq_idx_encode >= 0); sq_frame_samples(output_files[ost->file_index]->sq_encode, @@ -718,16 +728,17 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) static int submit_encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) { + Encoder *e = ost->enc; int ret; if (ost->sq_idx_encode < 0) return encode_frame(of, ost, frame); if (frame) { - ret = av_frame_ref(ost->sq_frame, frame); + ret = av_frame_ref(e->sq_frame, frame); if (ret < 0) return ret; - frame = ost->sq_frame; + frame = e->sq_frame; } ret = sq_send(of->sq_encode, ost->sq_idx_encode, @@ -740,7 +751,7 @@ static int submit_encode_frame(OutputFile *of, OutputStream *ost, } while (1) { - AVFrame *enc_frame = ost->sq_frame; + AVFrame *enc_frame = e->sq_frame; ret = sq_receive(of->sq_encode, ost->sq_idx_encode, SQFRAME(enc_frame)); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 527567831f..5663b8f11d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -663,7 +663,6 @@ static void ost_free(OutputStream **post) av_bsf_free(&ms->bsf_ctx); av_frame_free(&ost->filtered_frame); - av_frame_free(&ost->sq_frame); av_packet_free(&ost->pkt); av_dict_free(&ost->encoder_opts); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6c53a8810d..ee5829c7fe 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1505,10 +1505,6 @@ static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_u if (ost->sq_idx_encode < 0) return ost->sq_idx_encode; - ost->sq_frame = av_frame_alloc(); - if (!ost->sq_frame) - return AVERROR(ENOMEM); - if (ms->max_frames != INT64_MAX) sq_limit_frames(of->sq_encode, ost->sq_idx_encode, ms->max_frames); } -- 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".