summaryrefslogtreecommitdiff
path: root/libswscale
diff options
context:
space:
mode:
authorPeter Lundblad <plundblad@google.com>2021-04-28 11:51:23 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-07-01 23:49:41 +0200
commitda0abbbb01cae21039e2db028467d0f489c9c9ae (patch)
tree59ae09a703f16f97feb8f40ae4b4cd7acdd8aea9 /libswscale
parentde8e6e67e7523e48bb27ac224a0b446df05e1640 (diff)
libswscale: Make sws_init_context thread safe.
Call ff_sws_rgb2rgb_init via ff_thread_once instead of checking one of the variables it updates. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/utils.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 6bac7b658d..d673209d95 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -49,6 +49,7 @@
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/thread.h"
#include "libavutil/aarch64/cpu.h"
#include "libavutil/ppc/cpu.h"
#include "libavutil/x86/asm.h"
@@ -1189,12 +1190,13 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
int ret = 0;
enum AVPixelFormat tmpFmt;
static const float float_mult = 1.0f / 255.0f;
+ static AVOnce rgb2rgb_once = AV_ONCE_INIT;
cpu_flags = av_get_cpu_flags();
flags = c->flags;
emms_c();
- if (!rgb15to16)
- ff_sws_rgb2rgb_init();
+ if (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0)
+ return AVERROR_UNKNOWN;
unscaled = (srcW == dstW && srcH == dstH);