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 C40E545E82 for ; Thu, 13 Apr 2023 14:19:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D342068BEEE; Thu, 13 Apr 2023 17:16:17 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D7FA68BE5A for ; Thu, 13 Apr 2023 17:16:05 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 078C22404F5 for ; Thu, 13 Apr 2023 16:16:05 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id DxG3hL18Le7A for ; Thu, 13 Apr 2023 16:16:04 +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 00C2D2404EE for ; Thu, 13 Apr 2023 16:15:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E48B33A039B for ; Thu, 13 Apr 2023 16:15:53 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Apr 2023 16:12:23 +0200 Message-Id: <20230413141223.17245-25-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230413141223.17245-1-anton@khirnov.net> References: <20230413141223.17245-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 25/25] fftools/ffmpeg_enc: make data_size_enc private to encoding 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: It is no longer used outside of ffmpeg_enc.c --- fftools/ffmpeg.h | 2 -- fftools/ffmpeg_enc.c | 14 ++++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 494ea4abd3..a9302a95f0 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -662,8 +662,6 @@ typedef struct OutputStream { int keep_pix_fmt; /* stats */ - // combined size of all the packets received from the encoder - uint64_t data_size_enc; // number of packets send to the muxer atomic_uint_least64_t packets_written; // number of frames/samples sent to the encoder diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 2462f53a82..45bf4b127f 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -56,6 +56,9 @@ struct Encoder { int64_t frames_prev_hist[3]; AVFrame *sq_frame; + + // combined size of all the packets received from the encoder + uint64_t data_size; }; static uint64_t dup_warning = 1000; @@ -513,6 +516,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, const AVFrame *frame, const AVPacket *pkt, uint64_t frame_num) { + Encoder *e = ost->enc; AVIOContext *io = es->io; AVRational tb = frame ? frame->time_base : pkt->time_base; int64_t pts = frame ? frame->pts : pkt->pts; @@ -564,7 +568,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, } case ENC_STATS_AVG_BITRATE: { double duration = pkt->dts * av_q2d(tb); - avio_printf(io, "%g", duration > 0 ? 8.0 * ost->data_size_enc / duration : -1.); + avio_printf(io, "%g", duration > 0 ? 8.0 * e->data_size / duration : -1.); continue; } default: av_assert0(0); @@ -577,6 +581,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write_vstats) { + Encoder *e = ost->enc; const uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, NULL); AVCodecContext *enc = ost->enc_ctx; @@ -624,14 +629,15 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write ti1 = 0.01; bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0; - avg_bitrate = (double)(ost->data_size_enc * 8) / ti1 / 1000.0; + avg_bitrate = (double)(e->data_size * 8) / ti1 / 1000.0; fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", - (double)ost->data_size_enc / 1024, ti1, bitrate, avg_bitrate); + (double)e->data_size / 1024, ti1, bitrate, avg_bitrate); fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); } static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) { + Encoder *e = ost->enc; AVCodecContext *enc = ost->enc_ctx; AVPacket *pkt = ost->pkt; const char *type_desc = av_get_media_type_string(enc->codec_type); @@ -725,7 +731,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) exit_program(1); } - ost->data_size_enc += pkt->size; + e->data_size += pkt->size; ost->packets_encoded++; -- 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".