fftools/ffmpeg_enc: make data_size_enc private to encoding code

It is no longer used outside of ffmpeg_enc.c
This commit is contained in:
Anton Khirnov 2023-04-13 14:45:58 +02:00
parent 30699c103f
commit 0b0fa5c2a8
2 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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++;