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
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182017-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
182017-09-26 - xxxxxxx - lavc 57.106.102 - avcodec.h212017-09-26 - xxxxxxx - lavc 57.106.102 - avcodec.h
19 Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated22 Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
20 API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs23 API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
libavutil/cpu.c+39−0
@@ -16,9 +16,11 @@ · 15 unmodified lines
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */17 */
18 18
19#include <stddef.h>
19#include <stdint.h>20#include <stdint.h>
20#include <stdatomic.h>21#include <stdatomic.h>
21 22
23#include "attributes.h"
22#include "cpu.h"24#include "cpu.h"
23#include "cpu_internal.h"25#include "cpu_internal.h"
24#include "config.h"26#include "config.h"
@@ -299,3 +301,40 @@ int av_cpu_count(void) · 274 unmodified lines
299 301
300 return nb_cpus;302 return nb_cpus;
301}303}
304
305size_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
21#ifndef AVUTIL_CPU_H21#ifndef AVUTIL_CPU_H
22#define AVUTIL_CPU_H22#define AVUTIL_CPU_H
23 23
24#include <stddef.h>
25
24#include "attributes.h"26#include "attributes.h"
25 27
26#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */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 */
114int av_cpu_count(void);116int 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 */
127size_t av_cpu_max_align(void);
128
116#endif /* AVUTIL_CPU_H */129#endif /* AVUTIL_CPU_H */
libavutil/version.h+1−1
@@ -80,7 +80,7 @@ · 79 unmodified lines
80 80
81 81
82#define LIBAVUTIL_VERSION_MAJOR 5582#define LIBAVUTIL_VERSION_MAJOR 55
83#define LIBAVUTIL_VERSION_MINOR 7683#define LIBAVUTIL_VERSION_MINOR 77
84#define LIBAVUTIL_VERSION_MICRO 10084#define LIBAVUTIL_VERSION_MICRO 100
85 85
86#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \86#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