Commit 0b0fa5c2 authored by Anton Khirnov's avatar Anton Khirnov

fftools/ffmpeg_enc: make data_size_enc private to encoding code

It is no longer used outside of ffmpeg_enc.c
parent 30699c10
...@@ -662,8 +662,6 @@ typedef struct OutputStream { ...@@ -662,8 +662,6 @@ typedef struct OutputStream {
int keep_pix_fmt; int keep_pix_fmt;
/* stats */ /* stats */
// combined size of all the packets received from the encoder
uint64_t data_size_enc;
// number of packets send to the muxer // number of packets send to the muxer
atomic_uint_least64_t packets_written; atomic_uint_least64_t packets_written;
// number of frames/samples sent to the encoder // number of frames/samples sent to the encoder
......
...@@ -56,6 +56,9 @@ struct Encoder { ...@@ -56,6 +56,9 @@ struct Encoder {
int64_t frames_prev_hist[3]; int64_t frames_prev_hist[3];
AVFrame *sq_frame; AVFrame *sq_frame;
// combined size of all the packets received from the encoder
uint64_t data_size;
}; };
static uint64_t dup_warning = 1000; static uint64_t dup_warning = 1000;
...@@ -513,6 +516,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, ...@@ -513,6 +516,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
const AVFrame *frame, const AVPacket *pkt, const AVFrame *frame, const AVPacket *pkt,
uint64_t frame_num) uint64_t frame_num)
{ {
Encoder *e = ost->enc;
AVIOContext *io = es->io; AVIOContext *io = es->io;
AVRational tb = frame ? frame->time_base : pkt->time_base; AVRational tb = frame ? frame->time_base : pkt->time_base;
int64_t pts = frame ? frame->pts : pkt->pts; int64_t pts = frame ? frame->pts : pkt->pts;
...@@ -564,7 +568,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, ...@@ -564,7 +568,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
} }
case ENC_STATS_AVG_BITRATE: { case ENC_STATS_AVG_BITRATE: {
double duration = pkt->dts * av_q2d(tb); 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; continue;
} }
default: av_assert0(0); default: av_assert0(0);
...@@ -577,6 +581,7 @@ void enc_stats_write(OutputStream *ost, EncStats *es, ...@@ -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) 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, const uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
NULL); NULL);
AVCodecContext *enc = ost->enc_ctx; AVCodecContext *enc = ost->enc_ctx;
...@@ -624,14 +629,15 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write ...@@ -624,14 +629,15 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write
ti1 = 0.01; ti1 = 0.01;
bitrate = (pkt->size * 8) / av_q2d(enc->time_base) / 1000.0; 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 ", 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)); fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type));
} }
static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
{ {
Encoder *e = ost->enc;
AVCodecContext *enc = ost->enc_ctx; AVCodecContext *enc = ost->enc_ctx;
AVPacket *pkt = ost->pkt; AVPacket *pkt = ost->pkt;
const char *type_desc = av_get_media_type_string(enc->codec_type); 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) ...@@ -725,7 +731,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame)
exit_program(1); exit_program(1);
} }
ost->data_size_enc += pkt->size; e->data_size += pkt->size;
ost->packets_encoded++; ost->packets_encoded++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment