summaryrefslogtreecommitdiff
path: root/libswscale
diff options
context:
space:
mode:
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale.c12
-rw-r--r--libswscale/swscale_internal.h4
-rw-r--r--libswscale/utils.c2
3 files changed, 12 insertions, 6 deletions
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index b9c9647fcb..040172752f 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -312,12 +312,12 @@ static int swscale(SwsContext *c, const uint8_t *src[],
if (dstStride[0]&15 || dstStride[1]&15 ||
dstStride[2]&15 || dstStride[3]&15) {
- static int warnedAlready = 0; // FIXME maybe move this into the context
- if (flags & SWS_PRINT_INFO && !warnedAlready) {
+ SwsContext *const ctx = c->parent ? c->parent : c;
+ if (flags & SWS_PRINT_INFO &&
+ !atomic_exchange_explicit(&ctx->stride_unaligned_warned, 1, memory_order_relaxed)) {
av_log(c, AV_LOG_WARNING,
"Warning: dstStride is not aligned!\n"
" ->cannot do aligned memory accesses anymore\n");
- warnedAlready = 1;
}
}
@@ -326,11 +326,11 @@ static int swscale(SwsContext *c, const uint8_t *src[],
|| dstStride[0]&15 || dstStride[1]&15 || dstStride[2]&15 || dstStride[3]&15
|| srcStride[0]&15 || srcStride[1]&15 || srcStride[2]&15 || srcStride[3]&15
) {
- static int warnedAlready=0;
+ SwsContext *const ctx = c->parent ? c->parent : c;
int cpu_flags = av_get_cpu_flags();
- if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){
+ if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) &&
+ !atomic_exchange_explicit(&ctx->stride_unaligned_warned,1, memory_order_relaxed)) {
av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speed loss\n");
- warnedAlready=1;
}
}
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 0d60dd2e6f..e6e7b934b6 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -21,6 +21,8 @@
#ifndef SWSCALE_SWSCALE_INTERNAL_H
#define SWSCALE_SWSCALE_INTERNAL_H
+#include <stdatomic.h>
+
#include "config.h"
#include "version.h"
@@ -672,6 +674,8 @@ typedef struct SwsContext {
unsigned int xyz_scratch_allocated;
unsigned int dst_slice_align;
+ atomic_int stride_unaligned_warned;
+ atomic_int data_unaligned_warned;
} SwsContext;
//FIXME check init (where 0)
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 84a29c4dc7..fcfba971c6 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1112,6 +1112,8 @@ SwsContext *sws_alloc_context(void)
if (c) {
c->av_class = &ff_sws_context_class;
av_opt_set_defaults(c);
+ atomic_init(&c->stride_unaligned_warned, 0);
+ atomic_init(&c->data_unaligned_warned, 0);
}
return c;