aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_enc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-12-14 20:15:02 +0100
committerAnton Khirnov <anton@khirnov.net>2023-12-18 08:50:02 +0100
commit2ad0b8e0ea36115595f16bca203a5fdaabafb4ab (patch)
tree75ad2d82a24166d723b2056b84a12fbc5eb329db /fftools/ffmpeg_enc.c
parent244d2fcc49452f3c5aa0f4899c7c0c03ccc6a69e (diff)
downloadffmpeg-2ad0b8e0ea36115595f16bca203a5fdaabafb4ab.tar.gz
fftools/ffmpeg: use a mutex for enc_stats_write()
It may be called concurrently from different threads to write into the same file.
Diffstat (limited to 'fftools/ffmpeg_enc.c')
-rw-r--r--fftools/ffmpeg_enc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index d774a7e008..57590a43a3 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -491,6 +491,8 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
ptsi = fd->dec.pts;
}
+ pthread_mutex_lock(&es->lock);
+
for (size_t i = 0; i < es->nb_components; i++) {
const EncStatsComponent *c = &es->components[i];
@@ -538,6 +540,8 @@ void enc_stats_write(OutputStream *ost, EncStats *es,
}
avio_w8(io, '\n');
avio_flush(io);
+
+ pthread_mutex_unlock(&es->lock);
}
static inline double psnr(double d)