diff mbox series

[FFmpeg-devel,26/28] ffmpeg_mux: stop using av_stream_get_end_pts() in do_video_stats()

Message ID 20220111095830.31542-26-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/28] ffmpeg: pass the muxer context explicitly to some functions | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished

Commit Message

Anton Khirnov Jan. 11, 2022, 9:58 a.m. UTC
It retrieves libavformat's internal dts value (contrary to the
function's name), which is not necessary here because we can access the
packet directly.
---
 fftools/ffmpeg_mux.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index ef6b7ddd97..54020880eb 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -56,7 +56,7 @@  struct Muxer {
 
 static int want_sdp = 1;
 
-static void do_video_stats(OutputStream *ost, int frame_size)
+static void do_video_stats(OutputStream *ost, const AVPacket *pkt)
 {
     AVCodecContext *enc;
     int frame_number;
@@ -84,13 +84,13 @@  static void do_video_stats(OutputStream *ost, int frame_size)
     if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
         fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
 
-    fprintf(vstats_file,"f_size= %6d ", frame_size);
+    fprintf(vstats_file,"f_size= %6d ", pkt->size);
     /* compute pts value */
-    ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
+    ti1 = pkt->dts * av_q2d(ost->st->time_base);
     if (ti1 < 0.01)
         ti1 = 0.01;
 
-    bitrate     = (frame_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 * 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 / 1024, ti1, bitrate, avg_bitrate);
@@ -223,7 +223,7 @@  static void write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
 
     if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
         ost->encoding_needed && vstats_filename)
-        do_video_stats(ost, pkt->size);
+        do_video_stats(ost, pkt);
 
     pkt->stream_index = ost->index;