@drutech/react-native-audio-analyzer 1.1.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +124 -0
- package/android/CMakeCache.txt +372 -0
- package/android/CMakeLists.txt +44 -0
- package/android/Makefile +211 -0
- package/android/build.gradle +110 -0
- package/android/cmake_install.cmake +49 -0
- package/android/cpp-adapter.cpp +40 -0
- package/android/ffmpeg_16kb/include/config.h +749 -0
- package/android/ffmpeg_16kb/include/libavcodec/ac3_parser.h +36 -0
- package/android/ffmpeg_16kb/include/libavcodec/adts_parser.h +37 -0
- package/android/ffmpeg_16kb/include/libavcodec/arm/mathops.h +108 -0
- package/android/ffmpeg_16kb/include/libavcodec/avcodec.h +3192 -0
- package/android/ffmpeg_16kb/include/libavcodec/avdct.h +88 -0
- package/android/ffmpeg_16kb/include/libavcodec/avfft.h +118 -0
- package/android/ffmpeg_16kb/include/libavcodec/bsf.h +332 -0
- package/android/ffmpeg_16kb/include/libavcodec/codec.h +375 -0
- package/android/ffmpeg_16kb/include/libavcodec/codec_desc.h +128 -0
- package/android/ffmpeg_16kb/include/libavcodec/codec_id.h +661 -0
- package/android/ffmpeg_16kb/include/libavcodec/codec_par.h +247 -0
- package/android/ffmpeg_16kb/include/libavcodec/d3d11va.h +112 -0
- package/android/ffmpeg_16kb/include/libavcodec/defs.h +192 -0
- package/android/ffmpeg_16kb/include/libavcodec/dirac.h +131 -0
- package/android/ffmpeg_16kb/include/libavcodec/dv_profile.h +82 -0
- package/android/ffmpeg_16kb/include/libavcodec/dxva2.h +93 -0
- package/android/ffmpeg_16kb/include/libavcodec/jni.h +46 -0
- package/android/ffmpeg_16kb/include/libavcodec/mathops.h +255 -0
- package/android/ffmpeg_16kb/include/libavcodec/mediacodec.h +103 -0
- package/android/ffmpeg_16kb/include/libavcodec/packet.h +731 -0
- package/android/ffmpeg_16kb/include/libavcodec/qsv.h +109 -0
- package/android/ffmpeg_16kb/include/libavcodec/vdpau.h +157 -0
- package/android/ffmpeg_16kb/include/libavcodec/version.h +45 -0
- package/android/ffmpeg_16kb/include/libavcodec/version_major.h +52 -0
- package/android/ffmpeg_16kb/include/libavcodec/videotoolbox.h +150 -0
- package/android/ffmpeg_16kb/include/libavcodec/vorbis_parser.h +74 -0
- package/android/ffmpeg_16kb/include/libavcodec/x86/mathops.h +133 -0
- package/android/ffmpeg_16kb/include/libavcodec/xvmc.h +171 -0
- package/android/ffmpeg_16kb/include/libavdevice/avdevice.h +397 -0
- package/android/ffmpeg_16kb/include/libavdevice/version.h +45 -0
- package/android/ffmpeg_16kb/include/libavdevice/version_major.h +36 -0
- package/android/ffmpeg_16kb/include/libavfilter/avfilter.h +1491 -0
- package/android/ffmpeg_16kb/include/libavfilter/buffersink.h +173 -0
- package/android/ffmpeg_16kb/include/libavfilter/buffersrc.h +218 -0
- package/android/ffmpeg_16kb/include/libavfilter/version.h +48 -0
- package/android/ffmpeg_16kb/include/libavfilter/version_major.h +38 -0
- package/android/ffmpeg_16kb/include/libavformat/avformat.h +2826 -0
- package/android/ffmpeg_16kb/include/libavformat/avio.h +837 -0
- package/android/ffmpeg_16kb/include/libavformat/network.h +341 -0
- package/android/ffmpeg_16kb/include/libavformat/os_support.h +317 -0
- package/android/ffmpeg_16kb/include/libavformat/url.h +409 -0
- package/android/ffmpeg_16kb/include/libavformat/version.h +47 -0
- package/android/ffmpeg_16kb/include/libavformat/version_major.h +52 -0
- package/android/ffmpeg_16kb/include/libavutil/aarch64/timer.h +50 -0
- package/android/ffmpeg_16kb/include/libavutil/adler32.h +63 -0
- package/android/ffmpeg_16kb/include/libavutil/aes.h +69 -0
- package/android/ffmpeg_16kb/include/libavutil/aes_ctr.h +99 -0
- package/android/ffmpeg_16kb/include/libavutil/ambient_viewing_environment.h +72 -0
- package/android/ffmpeg_16kb/include/libavutil/arm/timer.h +46 -0
- package/android/ffmpeg_16kb/include/libavutil/attributes.h +173 -0
- package/android/ffmpeg_16kb/include/libavutil/attributes_internal.h +34 -0
- package/android/ffmpeg_16kb/include/libavutil/audio_fifo.h +186 -0
- package/android/ffmpeg_16kb/include/libavutil/avassert.h +75 -0
- package/android/ffmpeg_16kb/include/libavutil/avconfig.h +6 -0
- package/android/ffmpeg_16kb/include/libavutil/avstring.h +429 -0
- package/android/ffmpeg_16kb/include/libavutil/avutil.h +371 -0
- package/android/ffmpeg_16kb/include/libavutil/base64.h +72 -0
- package/android/ffmpeg_16kb/include/libavutil/blowfish.h +82 -0
- package/android/ffmpeg_16kb/include/libavutil/bprint.h +251 -0
- package/android/ffmpeg_16kb/include/libavutil/bswap.h +111 -0
- package/android/ffmpeg_16kb/include/libavutil/buffer.h +322 -0
- package/android/ffmpeg_16kb/include/libavutil/camellia.h +70 -0
- package/android/ffmpeg_16kb/include/libavutil/cast5.h +80 -0
- package/android/ffmpeg_16kb/include/libavutil/channel_layout.h +783 -0
- package/android/ffmpeg_16kb/include/libavutil/common.h +578 -0
- package/android/ffmpeg_16kb/include/libavutil/cpu.h +134 -0
- package/android/ffmpeg_16kb/include/libavutil/crc.h +102 -0
- package/android/ffmpeg_16kb/include/libavutil/csp.h +150 -0
- package/android/ffmpeg_16kb/include/libavutil/des.h +81 -0
- package/android/ffmpeg_16kb/include/libavutil/detection_bbox.h +108 -0
- package/android/ffmpeg_16kb/include/libavutil/dict.h +241 -0
- package/android/ffmpeg_16kb/include/libavutil/display.h +109 -0
- package/android/ffmpeg_16kb/include/libavutil/dovi_meta.h +236 -0
- package/android/ffmpeg_16kb/include/libavutil/downmix_info.h +115 -0
- package/android/ffmpeg_16kb/include/libavutil/encryption_info.h +205 -0
- package/android/ffmpeg_16kb/include/libavutil/error.h +128 -0
- package/android/ffmpeg_16kb/include/libavutil/eval.h +140 -0
- package/android/ffmpeg_16kb/include/libavutil/ffversion.h +5 -0
- package/android/ffmpeg_16kb/include/libavutil/fifo.h +448 -0
- package/android/ffmpeg_16kb/include/libavutil/file.h +115 -0
- package/android/ffmpeg_16kb/include/libavutil/film_grain_params.h +260 -0
- package/android/ffmpeg_16kb/include/libavutil/frame.h +964 -0
- package/android/ffmpeg_16kb/include/libavutil/getenv_utf8.h +86 -0
- package/android/ffmpeg_16kb/include/libavutil/hash.h +264 -0
- package/android/ffmpeg_16kb/include/libavutil/hdr_dynamic_metadata.h +343 -0
- package/android/ffmpeg_16kb/include/libavutil/hdr_dynamic_vivid_metadata.h +285 -0
- package/android/ffmpeg_16kb/include/libavutil/hmac.h +99 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext.h +610 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_cuda.h +69 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_d3d11va.h +178 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_drm.h +169 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_dxva2.h +75 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_mediacodec.h +61 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_opencl.h +100 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_qsv.h +64 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_vaapi.h +117 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_vdpau.h +44 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_videotoolbox.h +96 -0
- package/android/ffmpeg_16kb/include/libavutil/hwcontext_vulkan.h +281 -0
- package/android/ffmpeg_16kb/include/libavutil/imgutils.h +331 -0
- package/android/ffmpeg_16kb/include/libavutil/internal.h +190 -0
- package/android/ffmpeg_16kb/include/libavutil/intfloat.h +77 -0
- package/android/ffmpeg_16kb/include/libavutil/intreadwrite.h +644 -0
- package/android/ffmpeg_16kb/include/libavutil/lfg.h +81 -0
- package/android/ffmpeg_16kb/include/libavutil/libm.h +471 -0
- package/android/ffmpeg_16kb/include/libavutil/log.h +387 -0
- package/android/ffmpeg_16kb/include/libavutil/lzo.h +66 -0
- package/android/ffmpeg_16kb/include/libavutil/macros.h +80 -0
- package/android/ffmpeg_16kb/include/libavutil/mastering_display_metadata.h +128 -0
- package/android/ffmpeg_16kb/include/libavutil/mathematics.h +245 -0
- package/android/ffmpeg_16kb/include/libavutil/md5.h +89 -0
- package/android/ffmpeg_16kb/include/libavutil/mem.h +609 -0
- package/android/ffmpeg_16kb/include/libavutil/motion_vector.h +57 -0
- package/android/ffmpeg_16kb/include/libavutil/murmur3.h +115 -0
- package/android/ffmpeg_16kb/include/libavutil/opt.h +891 -0
- package/android/ffmpeg_16kb/include/libavutil/parseutils.h +197 -0
- package/android/ffmpeg_16kb/include/libavutil/pixdesc.h +435 -0
- package/android/ffmpeg_16kb/include/libavutil/pixelutils.h +51 -0
- package/android/ffmpeg_16kb/include/libavutil/pixfmt.h +691 -0
- package/android/ffmpeg_16kb/include/libavutil/random_seed.h +43 -0
- package/android/ffmpeg_16kb/include/libavutil/rational.h +221 -0
- package/android/ffmpeg_16kb/include/libavutil/rc4.h +69 -0
- package/android/ffmpeg_16kb/include/libavutil/replaygain.h +50 -0
- package/android/ffmpeg_16kb/include/libavutil/reverse.h +28 -0
- package/android/ffmpeg_16kb/include/libavutil/ripemd.h +83 -0
- package/android/ffmpeg_16kb/include/libavutil/samplefmt.h +269 -0
- package/android/ffmpeg_16kb/include/libavutil/sha.h +90 -0
- package/android/ffmpeg_16kb/include/libavutil/sha512.h +92 -0
- package/android/ffmpeg_16kb/include/libavutil/spherical.h +227 -0
- package/android/ffmpeg_16kb/include/libavutil/stereo3d.h +229 -0
- package/android/ffmpeg_16kb/include/libavutil/tea.h +71 -0
- package/android/ffmpeg_16kb/include/libavutil/thread.h +204 -0
- package/android/ffmpeg_16kb/include/libavutil/threadmessage.h +115 -0
- package/android/ffmpeg_16kb/include/libavutil/time.h +56 -0
- package/android/ffmpeg_16kb/include/libavutil/timecode.h +199 -0
- package/android/ffmpeg_16kb/include/libavutil/timer.h +156 -0
- package/android/ffmpeg_16kb/include/libavutil/timestamp.h +78 -0
- package/android/ffmpeg_16kb/include/libavutil/tree.h +137 -0
- package/android/ffmpeg_16kb/include/libavutil/twofish.h +70 -0
- package/android/ffmpeg_16kb/include/libavutil/tx.h +176 -0
- package/android/ffmpeg_16kb/include/libavutil/uuid.h +146 -0
- package/android/ffmpeg_16kb/include/libavutil/version.h +122 -0
- package/android/ffmpeg_16kb/include/libavutil/video_enc_params.h +171 -0
- package/android/ffmpeg_16kb/include/libavutil/x86/asm.h +154 -0
- package/android/ffmpeg_16kb/include/libavutil/x86/emms.h +58 -0
- package/android/ffmpeg_16kb/include/libavutil/x86/timer.h +50 -0
- package/android/ffmpeg_16kb/include/libavutil/xtea.h +94 -0
- package/android/ffmpeg_16kb/include/libswresample/swresample.h +650 -0
- package/android/ffmpeg_16kb/include/libswresample/version.h +46 -0
- package/android/ffmpeg_16kb/include/libswresample/version_major.h +31 -0
- package/android/ffmpeg_16kb/include/libswscale/swscale.h +436 -0
- package/android/ffmpeg_16kb/include/libswscale/version.h +44 -0
- package/android/ffmpeg_16kb/include/libswscale/version_major.h +35 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libavcodec.so +0 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libavdevice.so +0 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libavfilter.so +0 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libavformat.so +0 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libavutil.so +0 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libswresample.so +0 -0
- package/android/ffmpeg_16kb/lib/arm64-v8a/libswscale.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libavcodec_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libavdevice_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libavfilter_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libavformat_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libavutil_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libswresample_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/armeabi-v7a/libswscale_neon.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libavcodec.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libavdevice.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libavfilter.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libavformat.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libavutil.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libswresample.so +0 -0
- package/android/ffmpeg_16kb/lib/x86/libswscale.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libavcodec.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libavdevice.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libavfilter.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libavformat.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libavutil.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libswresample.so +0 -0
- package/android/ffmpeg_16kb/lib/x86_64/libswscale.so +0 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/audioanalyzer/AmplitudeData.java +20 -0
- package/android/src/main/java/com/audioanalyzer/AudioAnalyzerModule.java +52 -0
- package/android/src/main/java/com/audioanalyzer/AudioAnalyzerPackage.java +28 -0
- package/cpp/react-native-audio-analyzer.cpp +143 -0
- package/cpp/react-native-audio-analyzer.h +27 -0
- package/ios/AudioAnalyzer.h +19 -0
- package/ios/AudioAnalyzer.mm +43 -0
- package/lib/commonjs/helpers.js +34 -0
- package/lib/commonjs/helpers.js.map +1 -0
- package/lib/commonjs/helpers.test.js +49 -0
- package/lib/commonjs/helpers.test.js.map +1 -0
- package/lib/commonjs/index.js +35 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/helpers.js +27 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/helpers.test.js +47 -0
- package/lib/module/helpers.test.js.map +1 -0
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/helpers.d.ts +3 -0
- package/lib/typescript/src/helpers.d.ts.map +1 -0
- package/lib/typescript/src/helpers.test.d.ts +2 -0
- package/lib/typescript/src/helpers.test.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +163 -0
- package/react-native-audio-analyzer.podspec +44 -0
- package/src/helpers.test.ts +59 -0
- package/src/helpers.ts +34 -0
- package/src/index.tsx +30 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Lagged Fibonacci PRNG
|
|
3
|
+
* Copyright (c) 2008 Michael Niedermayer
|
|
4
|
+
*
|
|
5
|
+
* This file is part of FFmpeg.
|
|
6
|
+
*
|
|
7
|
+
* FFmpeg is free software; you can redistribute it and/or
|
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
9
|
+
* License as published by the Free Software Foundation; either
|
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* FFmpeg is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15
|
+
* Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
18
|
+
* License along with FFmpeg; if not, write to the Free Software
|
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#ifndef AVUTIL_LFG_H
|
|
23
|
+
#define AVUTIL_LFG_H
|
|
24
|
+
|
|
25
|
+
#include <stdint.h>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Context structure for the Lagged Fibonacci PRNG.
|
|
29
|
+
* The exact layout, types and content of this struct may change and should
|
|
30
|
+
* not be accessed directly. Only its `sizeof()` is guaranteed to stay the same
|
|
31
|
+
* to allow easy instanciation.
|
|
32
|
+
*/
|
|
33
|
+
typedef struct AVLFG {
|
|
34
|
+
unsigned int state[64];
|
|
35
|
+
int index;
|
|
36
|
+
} AVLFG;
|
|
37
|
+
|
|
38
|
+
void av_lfg_init(AVLFG *c, unsigned int seed);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Seed the state of the ALFG using binary data.
|
|
42
|
+
*
|
|
43
|
+
* @return 0 on success, negative value (AVERROR) on failure.
|
|
44
|
+
*/
|
|
45
|
+
int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the next random unsigned 32-bit number using an ALFG.
|
|
49
|
+
*
|
|
50
|
+
* Please also consider a simple LCG like state= state*1664525+1013904223,
|
|
51
|
+
* it may be good enough and faster for your specific use case.
|
|
52
|
+
*/
|
|
53
|
+
static inline unsigned int av_lfg_get(AVLFG *c){
|
|
54
|
+
unsigned a = c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
|
|
55
|
+
c->index += 1U;
|
|
56
|
+
return a;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the next random unsigned 32-bit number using a MLFG.
|
|
61
|
+
*
|
|
62
|
+
* Please also consider av_lfg_get() above, it is faster.
|
|
63
|
+
*/
|
|
64
|
+
static inline unsigned int av_mlfg_get(AVLFG *c){
|
|
65
|
+
unsigned int a= c->state[(c->index-55) & 63];
|
|
66
|
+
unsigned int b= c->state[(c->index-24) & 63];
|
|
67
|
+
a = c->state[c->index & 63] = 2*a*b+a+b;
|
|
68
|
+
c->index += 1U;
|
|
69
|
+
return a;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get the next two numbers generated by a Box-Muller Gaussian
|
|
74
|
+
* generator using the random numbers issued by lfg.
|
|
75
|
+
*
|
|
76
|
+
* @param lfg pointer to the contex structure
|
|
77
|
+
* @param out array where the two generated numbers are placed
|
|
78
|
+
*/
|
|
79
|
+
void av_bmg_get(AVLFG *lfg, double out[2]);
|
|
80
|
+
|
|
81
|
+
#endif /* AVUTIL_LFG_H */
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* erf function: Copyright (c) 2006 John Maddock
|
|
3
|
+
* This file is part of FFmpeg.
|
|
4
|
+
*
|
|
5
|
+
* FFmpeg is free software; you can redistribute it and/or
|
|
6
|
+
* modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
* License as published by the Free Software Foundation; either
|
|
8
|
+
* version 2.1 of the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* FFmpeg is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with FFmpeg; if not, write to the Free Software
|
|
17
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @file
|
|
22
|
+
* Replacements for frequently missing libm functions
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#ifndef AVUTIL_LIBM_H
|
|
26
|
+
#define AVUTIL_LIBM_H
|
|
27
|
+
|
|
28
|
+
#include <math.h>
|
|
29
|
+
#include "config.h"
|
|
30
|
+
#include "attributes.h"
|
|
31
|
+
#include "intfloat.h"
|
|
32
|
+
#include "mathematics.h"
|
|
33
|
+
|
|
34
|
+
#if HAVE_MIPSFPU && HAVE_INLINE_ASM
|
|
35
|
+
#include "libavutil/mips/libm_mips.h"
|
|
36
|
+
#endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM*/
|
|
37
|
+
|
|
38
|
+
#if !HAVE_ATANF
|
|
39
|
+
#undef atanf
|
|
40
|
+
#define atanf(x) ((float)atan(x))
|
|
41
|
+
#endif /* HAVE_ATANF */
|
|
42
|
+
|
|
43
|
+
#if !HAVE_ATAN2F
|
|
44
|
+
#undef atan2f
|
|
45
|
+
#define atan2f(y, x) ((float)atan2(y, x))
|
|
46
|
+
#endif /* HAVE_ATAN2F */
|
|
47
|
+
|
|
48
|
+
#if !HAVE_POWF
|
|
49
|
+
#undef powf
|
|
50
|
+
#define powf(x, y) ((float)pow(x, y))
|
|
51
|
+
#endif /* HAVE_POWF */
|
|
52
|
+
|
|
53
|
+
#if !HAVE_CBRT
|
|
54
|
+
static av_always_inline double cbrt(double x)
|
|
55
|
+
{
|
|
56
|
+
return x < 0 ? -pow(-x, 1.0 / 3.0) : pow(x, 1.0 / 3.0);
|
|
57
|
+
}
|
|
58
|
+
#endif /* HAVE_CBRT */
|
|
59
|
+
|
|
60
|
+
#if !HAVE_CBRTF
|
|
61
|
+
static av_always_inline float cbrtf(float x)
|
|
62
|
+
{
|
|
63
|
+
return x < 0 ? -powf(-x, 1.0 / 3.0) : powf(x, 1.0 / 3.0);
|
|
64
|
+
}
|
|
65
|
+
#endif /* HAVE_CBRTF */
|
|
66
|
+
|
|
67
|
+
#if !HAVE_COPYSIGN
|
|
68
|
+
static av_always_inline double copysign(double x, double y)
|
|
69
|
+
{
|
|
70
|
+
uint64_t vx = av_double2int(x);
|
|
71
|
+
uint64_t vy = av_double2int(y);
|
|
72
|
+
return av_int2double((vx & UINT64_C(0x7fffffffffffffff)) | (vy & UINT64_C(0x8000000000000000)));
|
|
73
|
+
}
|
|
74
|
+
#endif /* HAVE_COPYSIGN */
|
|
75
|
+
|
|
76
|
+
#if !HAVE_COSF
|
|
77
|
+
#undef cosf
|
|
78
|
+
#define cosf(x) ((float)cos(x))
|
|
79
|
+
#endif /* HAVE_COSF */
|
|
80
|
+
|
|
81
|
+
#if !HAVE_ERF
|
|
82
|
+
static inline double ff_eval_poly(const double *coeff, int size, double x) {
|
|
83
|
+
double sum = coeff[size-1];
|
|
84
|
+
int i;
|
|
85
|
+
for (i = size-2; i >= 0; --i) {
|
|
86
|
+
sum *= x;
|
|
87
|
+
sum += coeff[i];
|
|
88
|
+
}
|
|
89
|
+
return sum;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* erf function
|
|
94
|
+
* Algorithm taken from the Boost project, source:
|
|
95
|
+
* http://www.boost.org/doc/libs/1_46_1/boost/math/special_functions/erf.hpp
|
|
96
|
+
* Use, modification and distribution are subject to the
|
|
97
|
+
* Boost Software License, Version 1.0 (see notice below).
|
|
98
|
+
* Boost Software License - Version 1.0 - August 17th, 2003
|
|
99
|
+
Permission is hereby granted, free of charge, to any person or organization
|
|
100
|
+
obtaining a copy of the software and accompanying documentation covered by
|
|
101
|
+
this license (the "Software") to use, reproduce, display, distribute,
|
|
102
|
+
execute, and transmit the Software, and to prepare derivative works of the
|
|
103
|
+
Software, and to permit third-parties to whom the Software is furnished to
|
|
104
|
+
do so, all subject to the following:
|
|
105
|
+
|
|
106
|
+
The copyright notices in the Software and this entire statement, including
|
|
107
|
+
the above license grant, this restriction and the following disclaimer,
|
|
108
|
+
must be included in all copies of the Software, in whole or in part, and
|
|
109
|
+
all derivative works of the Software, unless such copies or derivative
|
|
110
|
+
works are solely in the form of machine-executable object code generated by
|
|
111
|
+
a source language processor.
|
|
112
|
+
|
|
113
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
114
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
115
|
+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
116
|
+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
117
|
+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
118
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
119
|
+
DEALINGS IN THE SOFTWARE.
|
|
120
|
+
*/
|
|
121
|
+
static inline double erf(double z)
|
|
122
|
+
{
|
|
123
|
+
#ifndef FF_ARRAY_ELEMS
|
|
124
|
+
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
|
|
125
|
+
#endif
|
|
126
|
+
double result;
|
|
127
|
+
|
|
128
|
+
/* handle the symmetry: erf(-x) = -erf(x) */
|
|
129
|
+
if (z < 0)
|
|
130
|
+
return -erf(-z);
|
|
131
|
+
|
|
132
|
+
/* branch based on range of z, and pick appropriate approximation */
|
|
133
|
+
if (z == 0)
|
|
134
|
+
return 0;
|
|
135
|
+
else if (z < 1e-10)
|
|
136
|
+
return z * 1.125 + z * 0.003379167095512573896158903121545171688;
|
|
137
|
+
else if (z < 0.5) {
|
|
138
|
+
// Maximum Deviation Found: 1.561e-17
|
|
139
|
+
// Expected Error Term: 1.561e-17
|
|
140
|
+
// Maximum Relative Change in Control Points: 1.155e-04
|
|
141
|
+
// Max Error found at double precision = 2.961182e-17
|
|
142
|
+
|
|
143
|
+
static const double y = 1.044948577880859375;
|
|
144
|
+
static const double p[] = {
|
|
145
|
+
0.0834305892146531832907,
|
|
146
|
+
-0.338165134459360935041,
|
|
147
|
+
-0.0509990735146777432841,
|
|
148
|
+
-0.00772758345802133288487,
|
|
149
|
+
-0.000322780120964605683831,
|
|
150
|
+
};
|
|
151
|
+
static const double q[] = {
|
|
152
|
+
1,
|
|
153
|
+
0.455004033050794024546,
|
|
154
|
+
0.0875222600142252549554,
|
|
155
|
+
0.00858571925074406212772,
|
|
156
|
+
0.000370900071787748000569,
|
|
157
|
+
};
|
|
158
|
+
double zz = z * z;
|
|
159
|
+
return z * (y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), zz) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), zz));
|
|
160
|
+
}
|
|
161
|
+
/* here onwards compute erfc */
|
|
162
|
+
else if (z < 1.5) {
|
|
163
|
+
// Maximum Deviation Found: 3.702e-17
|
|
164
|
+
// Expected Error Term: 3.702e-17
|
|
165
|
+
// Maximum Relative Change in Control Points: 2.845e-04
|
|
166
|
+
// Max Error found at double precision = 4.841816e-17
|
|
167
|
+
static const double y = 0.405935764312744140625;
|
|
168
|
+
static const double p[] = {
|
|
169
|
+
-0.098090592216281240205,
|
|
170
|
+
0.178114665841120341155,
|
|
171
|
+
0.191003695796775433986,
|
|
172
|
+
0.0888900368967884466578,
|
|
173
|
+
0.0195049001251218801359,
|
|
174
|
+
0.00180424538297014223957,
|
|
175
|
+
};
|
|
176
|
+
static const double q[] = {
|
|
177
|
+
1,
|
|
178
|
+
1.84759070983002217845,
|
|
179
|
+
1.42628004845511324508,
|
|
180
|
+
0.578052804889902404909,
|
|
181
|
+
0.12385097467900864233,
|
|
182
|
+
0.0113385233577001411017,
|
|
183
|
+
0.337511472483094676155e-5,
|
|
184
|
+
};
|
|
185
|
+
result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), z - 0.5) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), z - 0.5);
|
|
186
|
+
result *= exp(-z * z) / z;
|
|
187
|
+
return 1 - result;
|
|
188
|
+
}
|
|
189
|
+
else if (z < 2.5) {
|
|
190
|
+
// Max Error found at double precision = 6.599585e-18
|
|
191
|
+
// Maximum Deviation Found: 3.909e-18
|
|
192
|
+
// Expected Error Term: 3.909e-18
|
|
193
|
+
// Maximum Relative Change in Control Points: 9.886e-05
|
|
194
|
+
static const double y = 0.50672817230224609375;
|
|
195
|
+
static const double p[] = {
|
|
196
|
+
-0.0243500476207698441272,
|
|
197
|
+
0.0386540375035707201728,
|
|
198
|
+
0.04394818964209516296,
|
|
199
|
+
0.0175679436311802092299,
|
|
200
|
+
0.00323962406290842133584,
|
|
201
|
+
0.000235839115596880717416,
|
|
202
|
+
};
|
|
203
|
+
static const double q[] = {
|
|
204
|
+
1,
|
|
205
|
+
1.53991494948552447182,
|
|
206
|
+
0.982403709157920235114,
|
|
207
|
+
0.325732924782444448493,
|
|
208
|
+
0.0563921837420478160373,
|
|
209
|
+
0.00410369723978904575884,
|
|
210
|
+
};
|
|
211
|
+
result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), z - 1.5) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), z - 1.5);
|
|
212
|
+
result *= exp(-z * z) / z;
|
|
213
|
+
return 1 - result;
|
|
214
|
+
}
|
|
215
|
+
else if (z < 4.5) {
|
|
216
|
+
// Maximum Deviation Found: 1.512e-17
|
|
217
|
+
// Expected Error Term: 1.512e-17
|
|
218
|
+
// Maximum Relative Change in Control Points: 2.222e-04
|
|
219
|
+
// Max Error found at double precision = 2.062515e-17
|
|
220
|
+
static const double y = 0.5405750274658203125;
|
|
221
|
+
static const double p[] = {
|
|
222
|
+
0.00295276716530971662634,
|
|
223
|
+
0.0137384425896355332126,
|
|
224
|
+
0.00840807615555585383007,
|
|
225
|
+
0.00212825620914618649141,
|
|
226
|
+
0.000250269961544794627958,
|
|
227
|
+
0.113212406648847561139e-4,
|
|
228
|
+
};
|
|
229
|
+
static const double q[] = {
|
|
230
|
+
1,
|
|
231
|
+
1.04217814166938418171,
|
|
232
|
+
0.442597659481563127003,
|
|
233
|
+
0.0958492726301061423444,
|
|
234
|
+
0.0105982906484876531489,
|
|
235
|
+
0.000479411269521714493907,
|
|
236
|
+
};
|
|
237
|
+
result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), z - 3.5) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), z - 3.5);
|
|
238
|
+
result *= exp(-z * z) / z;
|
|
239
|
+
return 1 - result;
|
|
240
|
+
}
|
|
241
|
+
/* differ from Boost here, the claim of underflow of erfc(x) past 5.8 is
|
|
242
|
+
* slightly incorrect, change to 5.92
|
|
243
|
+
* (really somewhere between 5.9125 and 5.925 is when it saturates) */
|
|
244
|
+
else if (z < 5.92) {
|
|
245
|
+
// Max Error found at double precision = 2.997958e-17
|
|
246
|
+
// Maximum Deviation Found: 2.860e-17
|
|
247
|
+
// Expected Error Term: 2.859e-17
|
|
248
|
+
// Maximum Relative Change in Control Points: 1.357e-05
|
|
249
|
+
static const double y = 0.5579090118408203125;
|
|
250
|
+
static const double p[] = {
|
|
251
|
+
0.00628057170626964891937,
|
|
252
|
+
0.0175389834052493308818,
|
|
253
|
+
-0.212652252872804219852,
|
|
254
|
+
-0.687717681153649930619,
|
|
255
|
+
-2.5518551727311523996,
|
|
256
|
+
-3.22729451764143718517,
|
|
257
|
+
-2.8175401114513378771,
|
|
258
|
+
};
|
|
259
|
+
static const double q[] = {
|
|
260
|
+
1,
|
|
261
|
+
2.79257750980575282228,
|
|
262
|
+
11.0567237927800161565,
|
|
263
|
+
15.930646027911794143,
|
|
264
|
+
22.9367376522880577224,
|
|
265
|
+
13.5064170191802889145,
|
|
266
|
+
5.48409182238641741584,
|
|
267
|
+
};
|
|
268
|
+
result = y + ff_eval_poly(p, FF_ARRAY_ELEMS(p), 1 / z) / ff_eval_poly(q, FF_ARRAY_ELEMS(q), 1 / z);
|
|
269
|
+
result *= exp(-z * z) / z;
|
|
270
|
+
return 1 - result;
|
|
271
|
+
}
|
|
272
|
+
/* handle the nan case, but don't use isnan for max portability */
|
|
273
|
+
else if (z != z)
|
|
274
|
+
return z;
|
|
275
|
+
/* finally return saturated result */
|
|
276
|
+
else
|
|
277
|
+
return 1;
|
|
278
|
+
}
|
|
279
|
+
#endif /* HAVE_ERF */
|
|
280
|
+
|
|
281
|
+
#if !HAVE_EXPF
|
|
282
|
+
#undef expf
|
|
283
|
+
#define expf(x) ((float)exp(x))
|
|
284
|
+
#endif /* HAVE_EXPF */
|
|
285
|
+
|
|
286
|
+
#if !HAVE_EXP2
|
|
287
|
+
#undef exp2
|
|
288
|
+
#define exp2(x) exp((x) * M_LN2)
|
|
289
|
+
#endif /* HAVE_EXP2 */
|
|
290
|
+
|
|
291
|
+
#if !HAVE_EXP2F
|
|
292
|
+
#undef exp2f
|
|
293
|
+
#define exp2f(x) ((float)exp2(x))
|
|
294
|
+
#endif /* HAVE_EXP2F */
|
|
295
|
+
|
|
296
|
+
#if !HAVE_ISINF
|
|
297
|
+
#undef isinf
|
|
298
|
+
/* Note: these do not follow the BSD/Apple/GNU convention of returning -1 for
|
|
299
|
+
-Inf, +1 for Inf, 0 otherwise, but merely follow the POSIX/ISO mandated spec of
|
|
300
|
+
returning a non-zero value for +/-Inf, 0 otherwise. */
|
|
301
|
+
static av_always_inline av_const int avpriv_isinff(float x)
|
|
302
|
+
{
|
|
303
|
+
uint32_t v = av_float2int(x);
|
|
304
|
+
if ((v & 0x7f800000) != 0x7f800000)
|
|
305
|
+
return 0;
|
|
306
|
+
return !(v & 0x007fffff);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
static av_always_inline av_const int avpriv_isinf(double x)
|
|
310
|
+
{
|
|
311
|
+
uint64_t v = av_double2int(x);
|
|
312
|
+
if ((v & 0x7ff0000000000000) != 0x7ff0000000000000)
|
|
313
|
+
return 0;
|
|
314
|
+
return !(v & 0x000fffffffffffff);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
#define isinf(x) \
|
|
318
|
+
(sizeof(x) == sizeof(float) \
|
|
319
|
+
? avpriv_isinff(x) \
|
|
320
|
+
: avpriv_isinf(x))
|
|
321
|
+
#endif /* HAVE_ISINF */
|
|
322
|
+
|
|
323
|
+
#if !HAVE_ISNAN
|
|
324
|
+
static av_always_inline av_const int avpriv_isnanf(float x)
|
|
325
|
+
{
|
|
326
|
+
uint32_t v = av_float2int(x);
|
|
327
|
+
if ((v & 0x7f800000) != 0x7f800000)
|
|
328
|
+
return 0;
|
|
329
|
+
return v & 0x007fffff;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
static av_always_inline av_const int avpriv_isnan(double x)
|
|
333
|
+
{
|
|
334
|
+
uint64_t v = av_double2int(x);
|
|
335
|
+
if ((v & 0x7ff0000000000000) != 0x7ff0000000000000)
|
|
336
|
+
return 0;
|
|
337
|
+
return (v & 0x000fffffffffffff) && 1;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
#define isnan(x) \
|
|
341
|
+
(sizeof(x) == sizeof(float) \
|
|
342
|
+
? avpriv_isnanf(x) \
|
|
343
|
+
: avpriv_isnan(x))
|
|
344
|
+
#endif /* HAVE_ISNAN */
|
|
345
|
+
|
|
346
|
+
#if !HAVE_ISFINITE
|
|
347
|
+
static av_always_inline av_const int avpriv_isfinitef(float x)
|
|
348
|
+
{
|
|
349
|
+
uint32_t v = av_float2int(x);
|
|
350
|
+
return (v & 0x7f800000) != 0x7f800000;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
static av_always_inline av_const int avpriv_isfinite(double x)
|
|
354
|
+
{
|
|
355
|
+
uint64_t v = av_double2int(x);
|
|
356
|
+
return (v & 0x7ff0000000000000) != 0x7ff0000000000000;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
#define isfinite(x) \
|
|
360
|
+
(sizeof(x) == sizeof(float) \
|
|
361
|
+
? avpriv_isfinitef(x) \
|
|
362
|
+
: avpriv_isfinite(x))
|
|
363
|
+
#endif /* HAVE_ISFINITE */
|
|
364
|
+
|
|
365
|
+
#if !HAVE_HYPOT
|
|
366
|
+
static inline av_const double hypot(double x, double y)
|
|
367
|
+
{
|
|
368
|
+
double ret, temp;
|
|
369
|
+
x = fabs(x);
|
|
370
|
+
y = fabs(y);
|
|
371
|
+
|
|
372
|
+
if (isinf(x) || isinf(y))
|
|
373
|
+
return av_int2double(0x7ff0000000000000);
|
|
374
|
+
if (x == 0 || y == 0)
|
|
375
|
+
return x + y;
|
|
376
|
+
if (x < y) {
|
|
377
|
+
temp = x;
|
|
378
|
+
x = y;
|
|
379
|
+
y = temp;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
y = y/x;
|
|
383
|
+
return x*sqrt(1 + y*y);
|
|
384
|
+
}
|
|
385
|
+
#endif /* HAVE_HYPOT */
|
|
386
|
+
|
|
387
|
+
#if !HAVE_LDEXPF
|
|
388
|
+
#undef ldexpf
|
|
389
|
+
#define ldexpf(x, exp) ((float)ldexp(x, exp))
|
|
390
|
+
#endif /* HAVE_LDEXPF */
|
|
391
|
+
|
|
392
|
+
#if !HAVE_LLRINT
|
|
393
|
+
#undef llrint
|
|
394
|
+
#define llrint(x) ((long long)rint(x))
|
|
395
|
+
#endif /* HAVE_LLRINT */
|
|
396
|
+
|
|
397
|
+
#if !HAVE_LLRINTF
|
|
398
|
+
#undef llrintf
|
|
399
|
+
#define llrintf(x) ((long long)rint(x))
|
|
400
|
+
#endif /* HAVE_LLRINT */
|
|
401
|
+
|
|
402
|
+
#if !HAVE_LOG2
|
|
403
|
+
#undef log2
|
|
404
|
+
#define log2(x) (log(x) * 1.44269504088896340736)
|
|
405
|
+
#endif /* HAVE_LOG2 */
|
|
406
|
+
|
|
407
|
+
#if !HAVE_LOG2F
|
|
408
|
+
#undef log2f
|
|
409
|
+
#define log2f(x) ((float)log2(x))
|
|
410
|
+
#endif /* HAVE_LOG2F */
|
|
411
|
+
|
|
412
|
+
#if !HAVE_LOG10F
|
|
413
|
+
#undef log10f
|
|
414
|
+
#define log10f(x) ((float)log10(x))
|
|
415
|
+
#endif /* HAVE_LOG10F */
|
|
416
|
+
|
|
417
|
+
#if !HAVE_SINF
|
|
418
|
+
#undef sinf
|
|
419
|
+
#define sinf(x) ((float)sin(x))
|
|
420
|
+
#endif /* HAVE_SINF */
|
|
421
|
+
|
|
422
|
+
#if !HAVE_RINT
|
|
423
|
+
static inline double rint(double x)
|
|
424
|
+
{
|
|
425
|
+
return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
|
|
426
|
+
}
|
|
427
|
+
#endif /* HAVE_RINT */
|
|
428
|
+
|
|
429
|
+
#if !HAVE_LRINT
|
|
430
|
+
static av_always_inline av_const long int lrint(double x)
|
|
431
|
+
{
|
|
432
|
+
return rint(x);
|
|
433
|
+
}
|
|
434
|
+
#endif /* HAVE_LRINT */
|
|
435
|
+
|
|
436
|
+
#if !HAVE_LRINTF
|
|
437
|
+
static av_always_inline av_const long int lrintf(float x)
|
|
438
|
+
{
|
|
439
|
+
return (int)(rint(x));
|
|
440
|
+
}
|
|
441
|
+
#endif /* HAVE_LRINTF */
|
|
442
|
+
|
|
443
|
+
#if !HAVE_ROUND
|
|
444
|
+
static av_always_inline av_const double round(double x)
|
|
445
|
+
{
|
|
446
|
+
return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
|
|
447
|
+
}
|
|
448
|
+
#endif /* HAVE_ROUND */
|
|
449
|
+
|
|
450
|
+
#if !HAVE_ROUNDF
|
|
451
|
+
static av_always_inline av_const float roundf(float x)
|
|
452
|
+
{
|
|
453
|
+
return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
|
|
454
|
+
}
|
|
455
|
+
#endif /* HAVE_ROUNDF */
|
|
456
|
+
|
|
457
|
+
#if !HAVE_TRUNC
|
|
458
|
+
static av_always_inline av_const double trunc(double x)
|
|
459
|
+
{
|
|
460
|
+
return (x > 0) ? floor(x) : ceil(x);
|
|
461
|
+
}
|
|
462
|
+
#endif /* HAVE_TRUNC */
|
|
463
|
+
|
|
464
|
+
#if !HAVE_TRUNCF
|
|
465
|
+
static av_always_inline av_const float truncf(float x)
|
|
466
|
+
{
|
|
467
|
+
return (x > 0) ? floor(x) : ceil(x);
|
|
468
|
+
}
|
|
469
|
+
#endif /* HAVE_TRUNCF */
|
|
470
|
+
|
|
471
|
+
#endif /* AVUTIL_LIBM_H */
|