Browse code

sws: print a warning on unaligned input on SSE2+

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/10/31 09:36:02
Showing 1 changed files
... ...
@@ -2539,6 +2539,18 @@ static int swScale(SwsContext *c, const uint8_t* src[],
2539 2539
         }
2540 2540
     }
2541 2541
 
2542
+    if ((int)dst[0]%16 || (int)dst[1]%16 || (int)dst[2]%16 || (int)src[0]%16 || (int)src[1]%16 || (int)src[2]%16
2543
+        || dstStride[0]%16 || dstStride[1]%16 || dstStride[2]%16 || dstStride[3]%16
2544
+        || srcStride[0]%16 || srcStride[1]%16 || srcStride[2]%16 || srcStride[3]%16
2545
+    ) {
2546
+        static int warnedAlready=0;
2547
+        int cpu_flags = av_get_cpu_flags();
2548
+        if (HAVE_MMX2 && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){
2549
+            av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speedloss\n");
2550
+            warnedAlready=1;
2551
+        }
2552
+    }
2553
+
2542 2554
     /* Note the user might start scaling the picture in the middle so this
2543 2555
        will not get executed. This is not really intended but works
2544 2556
        currently, so people might do it. */