aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-08-25 10:44:55 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-29 15:42:11 +0200
commit4fce3bab64699092100a65e957be4d1394c0b4d3 (patch)
treeb2b4ae4b25f2bedd2c7e7754bc2cd49f3196ee76 /fftools/ffmpeg.h
parent0dd7347963041667e07366c83460fda8f19f4037 (diff)
downloadffmpeg-4fce3bab64699092100a65e957be4d1394c0b4d3.tar.gz
fftools/ffmpeg: use a separate counter for encoded packet data size
update_video_stats() currently uses OutputStream.data_size to print the total size of the encoded stream so far and the average bitrate. However, that field is updated in the muxer thread, right before the packet is sent to the muxer. Not only is this racy, but the numbers may not match even if muxing was in the main thread due to bitstream filters, filesize limiting, etc. Introduce a new counter, data_size_enc, for total size of the packets received from the encoder and use that in update_video_stats(). Rename data_size to data_size_mux to indicate its semantics more clearly. No synchronization is needed for data_size_mux, because it is only read in the main thread in print_final_stats(), which runs after the muxer threads are terminated.
Diffstat (limited to 'fftools/ffmpeg.h')
-rw-r--r--fftools/ffmpeg.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 74bc9220fc..ede0b2bd96 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -585,8 +585,10 @@ typedef struct OutputStream {
int keep_pix_fmt;
/* stats */
- // combined size of all the packets written
- uint64_t data_size;
+ // combined size of all the packets sent to the muxer
+ uint64_t data_size_mux;
+ // 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