aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-11-19 05:44:44 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-11-24 20:58:21 +0100
commitbaccc1c5417f990ebfc1b6780e2dab255a72ee3c (patch)
treea4ad7d6ea30f0d975cd84b8dab605ce826512660 /libswscale
parent8ee071122806724a00eecb6b1eff639890c4be48 (diff)
downloadffmpeg-baccc1c5417f990ebfc1b6780e2dab255a72ee3c.tar.gz
swscale/utils: Avoid calling ff_thread_once() unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/utils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 053c6bb76b..fb788fc330 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1340,13 +1340,10 @@ static av_cold int sws_init_single_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 (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0)
- return AVERROR_UNKNOWN;
unscaled = (srcW == dstW && srcH == dstH);
@@ -2043,6 +2040,7 @@ fail: // FIXME replace things by appropriate error codes
av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
SwsFilter *dstFilter)
{
+ static AVOnce rgb2rgb_once = AV_ONCE_INIT;
int ret;
c->frame_src = av_frame_alloc();
@@ -2050,6 +2048,9 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
if (!c->frame_src || !c->frame_dst)
return AVERROR(ENOMEM);
+ if (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0)
+ return AVERROR_UNKNOWN;
+
if (c->nb_threads != 1) {
ret = context_init_threaded(c, srcFilter, dstFilter);
if (ret < 0 || c->nb_threads > 1)