]> git.sesse.net Git - ffmpeg/commitdiff
cpu: add a function for querying maximum required data alignment
authorAnton Khirnov <anton@khirnov.net>
Wed, 8 Feb 2017 08:32:17 +0000 (09:32 +0100)
committerAnton Khirnov <anton@khirnov.net>
Sat, 11 Feb 2017 10:37:45 +0000 (11:37 +0100)
doc/APIchanges
libavutil/cpu.c
libavutil/cpu.h
libavutil/version.h

index 8c7d279fec89e555da1b1db52dba337ddaca7c72..be34c92d3f72505c8e08d555609bc5ea5b808276 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2017-02-xx - xxxxxxx - lavu 55.31.0 - cpu.h
+  Add av_cpu_max_align() for querying maximum required data alignment.
+
 2016-xx-xx - xxxxxxx - lavf 57.11.0 - avio.h
   Add avio_context_free(). From now on it must be used for freeing AVIOContext.
 
index 0109c9e8d1a26200f458faf16e20e9aace488fc1..5aef6af217c984484dcf8186236addf7446b458c 100644 (file)
@@ -16,6 +16,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stddef.h>
 #include <stdint.h>
 #include <stdatomic.h>
 
@@ -180,3 +181,15 @@ int av_cpu_count(void)
 
     return nb_cpus;
 }
+
+size_t av_cpu_max_align(void)
+{
+    int flags = av_get_cpu_flags();
+
+    if (flags & AV_CPU_FLAG_AVX)
+        return 32;
+    if (flags & (AV_CPU_FLAG_ALTIVEC | AV_CPU_FLAG_SSE | AV_CPU_FLAG_NEON))
+        return 16;
+
+    return 8;
+}
index c205ee16f6631edb3ecd275853a927cb07c3d217..4dcde27dbecd48c454e28536fa8a62bdf6cbb762 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef AVUTIL_CPU_H
 #define AVUTIL_CPU_H
 
+#include <stddef.h>
+
 #include "version.h"
 
 #define AV_CPU_FLAG_FORCE    0x80000000 /* force usage of selected flags (OR) */
@@ -88,4 +90,15 @@ int av_parse_cpu_flags(const char *s);
  */
 int av_cpu_count(void);
 
+/**
+ * Get the maximum data alignment that may be required by Libav.
+ *
+ * Note that this is affected by the build configuration and the CPU flags mask,
+ * so e.g. if the CPU supports AVX, but libavutil has been built with
+ * --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through
+ *  av_set_cpu_flags_mask(), then this function will behave as if AVX is not
+ *  present.
+ */
+size_t av_cpu_max_align(void);
+
 #endif /* AVUTIL_CPU_H */
index 7856a0acc3f9f2c0061b9f6faab6f0321ede83de..0fcd19a1eb2b71ee6d262311df714873fce73c92 100644 (file)
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 30
+#define LIBAVUTIL_VERSION_MINOR 31
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \