History

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.

James Almer committed 9 years ago

Commit 522f8772 parents 5256a86 e6bff234 files · +56 −1Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavutil/cpu.c +39 −0
  3. libavutil/cpu.h +13 −0
  4. libavutil/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
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+
1821 2017-09-26 - xxxxxxx - lavc 57.106.102 - avcodec.h
1922 Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
2023 API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
libavutil/cpu.c+39−0
@@ -16,9 +16,11 @@ · 15 unmodified lines
1616 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717 */
1818
19+#include <stddef.h>
1920 #include <stdint.h>
2021 #include <stdatomic.h>
2122
23+#include "attributes.h"
2224 #include "cpu.h"
2325 #include "cpu_internal.h"
2426 #include "config.h"
@@ -299,3 +301,40 @@ int av_cpu_count(void) · 274 unmodified lines
299301
300302 return nb_cpus;
301303 }
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+}
libavutil/cpu.h+13−0
@@ -21,6 +21,8 @@ · 20 unmodified lines
2121 #ifndef AVUTIL_CPU_H
2222 #define AVUTIL_CPU_H
2323
24+#include <stddef.h>
25+
2426 #include "attributes.h"
2527
2628 #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
113115 */
114116 int av_cpu_count(void);
115117
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+
116129 #endif /* AVUTIL_CPU_H */
libavutil/version.h+1−1
@@ -80,7 +80,7 @@ · 79 unmodified lines
8080
8181
8282 #define LIBAVUTIL_VERSION_MAJOR 55
83−#define LIBAVUTIL_VERSION_MINOR 76
83+#define LIBAVUTIL_VERSION_MINOR 77
8484 #define LIBAVUTIL_VERSION_MICRO 100
8585
8686 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t