* 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@gmail.com>
| ... | ... |
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 |
| 15 | 15 |
|
| 16 | 16 |
API changes, most recent first: |
| 17 | 17 |
|
| 18 |
+2017-09-27 - xxxxxxx - lavu 55.77.100 / lavu 55.31.0 - cpu.h |
|
| 19 |
+ Add av_cpu_max_align() for querying maximum required data alignment. |
|
| 20 |
+ |
|
| 18 | 21 |
2017-09-26 - xxxxxxx - lavc 57.106.102 - avcodec.h |
| 19 | 22 |
Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated |
| 20 | 23 |
API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs |
| ... | ... |
@@ -16,9 +16,11 @@ |
| 16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | 17 |
*/ |
| 18 | 18 |
|
| 19 |
+#include <stddef.h> |
|
| 19 | 20 |
#include <stdint.h> |
| 20 | 21 |
#include <stdatomic.h> |
| 21 | 22 |
|
| 23 |
+#include "attributes.h" |
|
| 22 | 24 |
#include "cpu.h" |
| 23 | 25 |
#include "cpu_internal.h" |
| 24 | 26 |
#include "config.h" |
| ... | ... |
@@ -299,3 +301,40 @@ int av_cpu_count(void) |
| 299 | 299 |
|
| 300 | 300 |
return nb_cpus; |
| 301 | 301 |
} |
| 302 |
+ |
|
| 303 |
+size_t av_cpu_max_align(void) |
|
| 304 |
+{
|
|
| 305 |
+ int av_unused flags = av_get_cpu_flags(); |
|
| 306 |
+ |
|
| 307 |
+#if ARCH_ARM || ARCH_AARCH64 |
|
| 308 |
+ if (flags & AV_CPU_FLAG_NEON) |
|
| 309 |
+ return 16; |
|
| 310 |
+#elif ARCH_PPC |
|
| 311 |
+ if (flags & (AV_CPU_FLAG_ALTIVEC | |
|
| 312 |
+ AV_CPU_FLAG_VSX | |
|
| 313 |
+ AV_CPU_FLAG_POWER8)) |
|
| 314 |
+ return 16; |
|
| 315 |
+#elif ARCH_X86 |
|
| 316 |
+ if (flags & (AV_CPU_FLAG_AVX2 | |
|
| 317 |
+ AV_CPU_FLAG_AVX | |
|
| 318 |
+ AV_CPU_FLAG_XOP | |
|
| 319 |
+ AV_CPU_FLAG_FMA4 | |
|
| 320 |
+ AV_CPU_FLAG_FMA3 | |
|
| 321 |
+ AV_CPU_FLAG_AVXSLOW)) |
|
| 322 |
+ return 32; |
|
| 323 |
+ if (flags & (AV_CPU_FLAG_AESNI | |
|
| 324 |
+ AV_CPU_FLAG_SSE42 | |
|
| 325 |
+ AV_CPU_FLAG_SSE4 | |
|
| 326 |
+ AV_CPU_FLAG_SSSE3 | |
|
| 327 |
+ AV_CPU_FLAG_SSE3 | |
|
| 328 |
+ AV_CPU_FLAG_SSE2 | |
|
| 329 |
+ AV_CPU_FLAG_SSE | |
|
| 330 |
+ AV_CPU_FLAG_ATOM | |
|
| 331 |
+ AV_CPU_FLAG_SSSE3SLOW | |
|
| 332 |
+ AV_CPU_FLAG_SSE3SLOW | |
|
| 333 |
+ AV_CPU_FLAG_SSE2SLOW)) |
|
| 334 |
+ return 16; |
|
| 335 |
+#endif |
|
| 336 |
+ |
|
| 337 |
+ return 8; |
|
| 338 |
+} |
| ... | ... |
@@ -21,6 +21,8 @@ |
| 21 | 21 |
#ifndef AVUTIL_CPU_H |
| 22 | 22 |
#define AVUTIL_CPU_H |
| 23 | 23 |
|
| 24 |
+#include <stddef.h> |
|
| 25 |
+ |
|
| 24 | 26 |
#include "attributes.h" |
| 25 | 27 |
|
| 26 | 28 |
#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); |
| 113 | 113 |
*/ |
| 114 | 114 |
int av_cpu_count(void); |
| 115 | 115 |
|
| 116 |
+/** |
|
| 117 |
+ * Get the maximum data alignment that may be required by FFmpeg. |
|
| 118 |
+ * |
|
| 119 |
+ * Note that this is affected by the build configuration and the CPU flags mask, |
|
| 120 |
+ * so e.g. if the CPU supports AVX, but libavutil has been built with |
|
| 121 |
+ * --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through |
|
| 122 |
+ * av_set_cpu_flags_mask(), then this function will behave as if AVX is not |
|
| 123 |
+ * present. |
|
| 124 |
+ */ |
|
| 125 |
+size_t av_cpu_max_align(void); |
|
| 126 |
+ |
|
| 116 | 127 |
#endif /* AVUTIL_CPU_H */ |