[FFmpeg-cvslog] Merge commit 'e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e'
James Almer
git at videolan.org
Thu Sep 28 05:15:29 EEST 2017
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Sep 27 22:56:53 2017 -0300| [522f87708653af3badcdc33be983bcc6009de49b] | committer: James Almer
Merge commit 'e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e'
* commit 'e6bff23f1e11aefb16a2b5d6ee72bf7469c5a66e':
cpu: add a function for querying maximum required data alignment
Adapted to work with the arbitrary runtime cpuflag changes av_force_cpu_flags()
can generate.
Merged-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=522f87708653af3badcdc33be983bcc6009de49b
---
doc/APIchanges | 3 +++
libavutil/cpu.c | 39 +++++++++++++++++++++++++++++++++++++++
libavutil/cpu.h | 13 +++++++++++++
libavutil/version.h | 2 +-
4 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 52336d1dec..4838ec3728 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
API changes, most recent first:
+2017-09-27 - xxxxxxx - lavu 55.77.100 / lavu 55.31.0 - cpu.h
+ Add av_cpu_max_align() for querying maximum required data alignment.
+
2017-09-26 - xxxxxxx - lavc 57.106.102 - avcodec.h
Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index a22da0fa8c..ab04494acf 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -16,9 +16,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stddef.h>
#include <stdint.h>
#include <stdatomic.h>
+#include "attributes.h"
#include "cpu.h"
#include "cpu_internal.h"
#include "config.h"
@@ -299,3 +301,40 @@ int av_cpu_count(void)
return nb_cpus;
}
+
+size_t av_cpu_max_align(void)
+{
+ int av_unused flags = av_get_cpu_flags();
+
+#if ARCH_ARM || ARCH_AARCH64
+ if (flags & AV_CPU_FLAG_NEON)
+ return 16;
+#elif ARCH_PPC
+ if (flags & (AV_CPU_FLAG_ALTIVEC |
+ AV_CPU_FLAG_VSX |
+ AV_CPU_FLAG_POWER8))
+ return 16;
+#elif ARCH_X86
+ if (flags & (AV_CPU_FLAG_AVX2 |
+ AV_CPU_FLAG_AVX |
+ AV_CPU_FLAG_XOP |
+ AV_CPU_FLAG_FMA4 |
+ AV_CPU_FLAG_FMA3 |
+ AV_CPU_FLAG_AVXSLOW))
+ return 32;
+ if (flags & (AV_CPU_FLAG_AESNI |
+ AV_CPU_FLAG_SSE42 |
+ AV_CPU_FLAG_SSE4 |
+ AV_CPU_FLAG_SSSE3 |
+ AV_CPU_FLAG_SSE3 |
+ AV_CPU_FLAG_SSE2 |
+ AV_CPU_FLAG_SSE |
+ AV_CPU_FLAG_ATOM |
+ AV_CPU_FLAG_SSSE3SLOW |
+ AV_CPU_FLAG_SSE3SLOW |
+ AV_CPU_FLAG_SSE2SLOW))
+ return 16;
+#endif
+
+ return 8;
+}
diff --git a/libavutil/cpu.h b/libavutil/cpu.h
index de05593446..9e5d40affe 100644
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@ -21,6 +21,8 @@
#ifndef AVUTIL_CPU_H
#define AVUTIL_CPU_H
+#include <stddef.h>
+
#include "attributes.h"
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
@@ -113,4 +115,15 @@ int av_parse_cpu_caps(unsigned *flags, const char *s);
*/
int av_cpu_count(void);
+/**
+ * Get the maximum data alignment that may be required by FFmpeg.
+ *
+ * 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 */
diff --git a/libavutil/version.h b/libavutil/version.h
index 8ac41f49f5..9dbcdc4a8c 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -80,7 +80,7 @@
#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 76
+#define LIBAVUTIL_VERSION_MINOR 77
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
======================================================================
diff --cc doc/APIchanges
index 52336d1dec,be34c92d3f..4838ec3728
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@@ -15,7 -13,13 +15,10 @@@ libavutil: 2015-08-2
API changes, most recent first:
-2017-02-xx - xxxxxxx - lavu 55.31.0 - cpu.h
++2017-09-27 - xxxxxxx - lavu 55.77.100 / 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.
-
-2017-02-01 - xxxxxxx - lavc - avcodec.h
+2017-09-26 - xxxxxxx - lavc 57.106.102 - avcodec.h
Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
(avcodec_send_packet/avcodec_receive_frame) always work with reference
diff --cc libavutil/cpu.c
index a22da0fa8c,5aef6af217..ab04494acf
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@@ -19,6 -20,6 +20,7 @@@
#include <stdint.h>
#include <stdatomic.h>
++#include "attributes.h"
#include "cpu.h"
#include "cpu_internal.h"
#include "config.h"
@@@ -287,15 -177,19 +289,52 @@@ int av_cpu_count(void
nb_cpus = sysconf(_SC_NPROC_ONLN);
#elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
nb_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+#elif HAVE_WINRT
+ GetNativeSystemInfo(&sysinfo);
+ nb_cpus = sysinfo.dwNumberOfProcessors;
#endif
+ if (!printed) {
+ av_log(NULL, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
+ printed = 1;
+ }
+
return nb_cpus;
}
+
+ size_t av_cpu_max_align(void)
+ {
- int flags = av_get_cpu_flags();
++ int av_unused flags = av_get_cpu_flags();
+
- if (flags & AV_CPU_FLAG_AVX)
++#if ARCH_ARM || ARCH_AARCH64
++ if (flags & AV_CPU_FLAG_NEON)
++ return 16;
++#elif ARCH_PPC
++ if (flags & (AV_CPU_FLAG_ALTIVEC |
++ AV_CPU_FLAG_VSX |
++ AV_CPU_FLAG_POWER8))
++ return 16;
++#elif ARCH_X86
++ if (flags & (AV_CPU_FLAG_AVX2 |
++ AV_CPU_FLAG_AVX |
++ AV_CPU_FLAG_XOP |
++ AV_CPU_FLAG_FMA4 |
++ AV_CPU_FLAG_FMA3 |
++ AV_CPU_FLAG_AVXSLOW))
+ return 32;
- if (flags & (AV_CPU_FLAG_ALTIVEC | AV_CPU_FLAG_SSE | AV_CPU_FLAG_NEON))
++ if (flags & (AV_CPU_FLAG_AESNI |
++ AV_CPU_FLAG_SSE42 |
++ AV_CPU_FLAG_SSE4 |
++ AV_CPU_FLAG_SSSE3 |
++ AV_CPU_FLAG_SSE3 |
++ AV_CPU_FLAG_SSE2 |
++ AV_CPU_FLAG_SSE |
++ AV_CPU_FLAG_ATOM |
++ AV_CPU_FLAG_SSSE3SLOW |
++ AV_CPU_FLAG_SSE3SLOW |
++ AV_CPU_FLAG_SSE2SLOW))
+ return 16;
++#endif
+
+ return 8;
+ }
diff --cc libavutil/cpu.h
index de05593446,4dcde27dbe..9e5d40affe
--- a/libavutil/cpu.h
+++ b/libavutil/cpu.h
@@@ -21,7 -21,9 +21,9 @@@
#ifndef AVUTIL_CPU_H
#define AVUTIL_CPU_H
+ #include <stddef.h>
+
-#include "version.h"
+#include "attributes.h"
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
@@@ -113,4 -90,15 +115,15 @@@ int av_parse_cpu_caps(unsigned *flags,
*/
int av_cpu_count(void);
+ /**
- * Get the maximum data alignment that may be required by Libav.
++ * Get the maximum data alignment that may be required by FFmpeg.
+ *
+ * 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 */
diff --cc libavutil/version.h
index 8ac41f49f5,0fcd19a1eb..9dbcdc4a8c
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@@ -78,10 -53,9 +78,10 @@@
* @{
*/
-#define LIBAVUTIL_VERSION_MAJOR 55
-#define LIBAVUTIL_VERSION_MINOR 31
-#define LIBAVUTIL_VERSION_MICRO 0
+
+#define LIBAVUTIL_VERSION_MAJOR 55
- #define LIBAVUTIL_VERSION_MINOR 76
++#define LIBAVUTIL_VERSION_MINOR 77
+#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list