* 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.
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines | ||
| 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 @@ · 15 unmodified lines | ||
| 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) · 274 unmodified lines | ||
| 299 | 301 | |
| 300 | 302 | return nb_cpus; |
| 301 | 303 | } |
| 304 | + | |
| 305 | +size_t av_cpu_max_align(void) | |
| 306 | +{ | |
| 307 | + int av_unused flags = av_get_cpu_flags(); | |
| 308 | + | |
| 309 | +#if ARCH_ARM || ARCH_AARCH64 | |
| 310 | + if (flags & AV_CPU_FLAG_NEON) | |
| 311 | + return 16; | |
| 312 | +#elif ARCH_PPC | |
| 313 | + if (flags & (AV_CPU_FLAG_ALTIVEC | | |
| 314 | + AV_CPU_FLAG_VSX | | |
| 315 | + AV_CPU_FLAG_POWER8)) | |
| 316 | + return 16; | |
| 317 | +#elif ARCH_X86 | |
| 318 | + if (flags & (AV_CPU_FLAG_AVX2 | | |
| 319 | + AV_CPU_FLAG_AVX | | |
| 320 | + AV_CPU_FLAG_XOP | | |
| 321 | + AV_CPU_FLAG_FMA4 | | |
| 322 | + AV_CPU_FLAG_FMA3 | | |
| 323 | + AV_CPU_FLAG_AVXSLOW)) | |
| 324 | + return 32; | |
| 325 | + if (flags & (AV_CPU_FLAG_AESNI | | |
| 326 | + AV_CPU_FLAG_SSE42 | | |
| 327 | + AV_CPU_FLAG_SSE4 | | |
| 328 | + AV_CPU_FLAG_SSSE3 | | |
| 329 | + AV_CPU_FLAG_SSE3 | | |
| 330 | + AV_CPU_FLAG_SSE2 | | |
| 331 | + AV_CPU_FLAG_SSE | | |
| 332 | + AV_CPU_FLAG_ATOM | | |
| 333 | + AV_CPU_FLAG_SSSE3SLOW | | |
| 334 | + AV_CPU_FLAG_SSE3SLOW | | |
| 335 | + AV_CPU_FLAG_SSE2SLOW)) | |
| 336 | + return 16; | |
| 337 | +#endif | |
| 338 | + | |
| 339 | + return 8; | |
| 340 | +} | |
| @@ -21,6 +21,8 @@ · 20 unmodified lines | ||
| 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); · 86 unmodified lines | ||
| 113 | 115 | */ |
| 114 | 116 | int av_cpu_count(void); |
| 115 | 117 | |
| 118 | +/** | |
| 119 | + * Get the maximum data alignment that may be required by FFmpeg. | |
| 120 | + * | |
| 121 | + * Note that this is affected by the build configuration and the CPU flags mask, | |
| 122 | + * so e.g. if the CPU supports AVX, but libavutil has been built with | |
| 123 | + * --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through | |
| 124 | + * av_set_cpu_flags_mask(), then this function will behave as if AVX is not | |
| 125 | + * present. | |
| 126 | + */ | |
| 127 | +size_t av_cpu_max_align(void); | |
| 128 | + | |
| 116 | 129 | #endif /* AVUTIL_CPU_H */ |
| @@ -80,7 +80,7 @@ · 79 unmodified lines | ||
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | #define LIBAVUTIL_VERSION_MAJOR 55 |
| 83 | −#define LIBAVUTIL_VERSION_MINOR 76 | |
| 83 | +#define LIBAVUTIL_VERSION_MINOR 77 | |
| 84 | 84 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 85 | 85 | |
| 86 | 86 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |