@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.
Files changed (223) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +124 -0
  3. package/android/CMakeCache.txt +372 -0
  4. package/android/CMakeLists.txt +44 -0
  5. package/android/Makefile +211 -0
  6. package/android/build.gradle +110 -0
  7. package/android/cmake_install.cmake +49 -0
  8. package/android/cpp-adapter.cpp +40 -0
  9. package/android/ffmpeg_16kb/include/config.h +749 -0
  10. package/android/ffmpeg_16kb/include/libavcodec/ac3_parser.h +36 -0
  11. package/android/ffmpeg_16kb/include/libavcodec/adts_parser.h +37 -0
  12. package/android/ffmpeg_16kb/include/libavcodec/arm/mathops.h +108 -0
  13. package/android/ffmpeg_16kb/include/libavcodec/avcodec.h +3192 -0
  14. package/android/ffmpeg_16kb/include/libavcodec/avdct.h +88 -0
  15. package/android/ffmpeg_16kb/include/libavcodec/avfft.h +118 -0
  16. package/android/ffmpeg_16kb/include/libavcodec/bsf.h +332 -0
  17. package/android/ffmpeg_16kb/include/libavcodec/codec.h +375 -0
  18. package/android/ffmpeg_16kb/include/libavcodec/codec_desc.h +128 -0
  19. package/android/ffmpeg_16kb/include/libavcodec/codec_id.h +661 -0
  20. package/android/ffmpeg_16kb/include/libavcodec/codec_par.h +247 -0
  21. package/android/ffmpeg_16kb/include/libavcodec/d3d11va.h +112 -0
  22. package/android/ffmpeg_16kb/include/libavcodec/defs.h +192 -0
  23. package/android/ffmpeg_16kb/include/libavcodec/dirac.h +131 -0
  24. package/android/ffmpeg_16kb/include/libavcodec/dv_profile.h +82 -0
  25. package/android/ffmpeg_16kb/include/libavcodec/dxva2.h +93 -0
  26. package/android/ffmpeg_16kb/include/libavcodec/jni.h +46 -0
  27. package/android/ffmpeg_16kb/include/libavcodec/mathops.h +255 -0
  28. package/android/ffmpeg_16kb/include/libavcodec/mediacodec.h +103 -0
  29. package/android/ffmpeg_16kb/include/libavcodec/packet.h +731 -0
  30. package/android/ffmpeg_16kb/include/libavcodec/qsv.h +109 -0
  31. package/android/ffmpeg_16kb/include/libavcodec/vdpau.h +157 -0
  32. package/android/ffmpeg_16kb/include/libavcodec/version.h +45 -0
  33. package/android/ffmpeg_16kb/include/libavcodec/version_major.h +52 -0
  34. package/android/ffmpeg_16kb/include/libavcodec/videotoolbox.h +150 -0
  35. package/android/ffmpeg_16kb/include/libavcodec/vorbis_parser.h +74 -0
  36. package/android/ffmpeg_16kb/include/libavcodec/x86/mathops.h +133 -0
  37. package/android/ffmpeg_16kb/include/libavcodec/xvmc.h +171 -0
  38. package/android/ffmpeg_16kb/include/libavdevice/avdevice.h +397 -0
  39. package/android/ffmpeg_16kb/include/libavdevice/version.h +45 -0
  40. package/android/ffmpeg_16kb/include/libavdevice/version_major.h +36 -0
  41. package/android/ffmpeg_16kb/include/libavfilter/avfilter.h +1491 -0
  42. package/android/ffmpeg_16kb/include/libavfilter/buffersink.h +173 -0
  43. package/android/ffmpeg_16kb/include/libavfilter/buffersrc.h +218 -0
  44. package/android/ffmpeg_16kb/include/libavfilter/version.h +48 -0
  45. package/android/ffmpeg_16kb/include/libavfilter/version_major.h +38 -0
  46. package/android/ffmpeg_16kb/include/libavformat/avformat.h +2826 -0
  47. package/android/ffmpeg_16kb/include/libavformat/avio.h +837 -0
  48. package/android/ffmpeg_16kb/include/libavformat/network.h +341 -0
  49. package/android/ffmpeg_16kb/include/libavformat/os_support.h +317 -0
  50. package/android/ffmpeg_16kb/include/libavformat/url.h +409 -0
  51. package/android/ffmpeg_16kb/include/libavformat/version.h +47 -0
  52. package/android/ffmpeg_16kb/include/libavformat/version_major.h +52 -0
  53. package/android/ffmpeg_16kb/include/libavutil/aarch64/timer.h +50 -0
  54. package/android/ffmpeg_16kb/include/libavutil/adler32.h +63 -0
  55. package/android/ffmpeg_16kb/include/libavutil/aes.h +69 -0
  56. package/android/ffmpeg_16kb/include/libavutil/aes_ctr.h +99 -0
  57. package/android/ffmpeg_16kb/include/libavutil/ambient_viewing_environment.h +72 -0
  58. package/android/ffmpeg_16kb/include/libavutil/arm/timer.h +46 -0
  59. package/android/ffmpeg_16kb/include/libavutil/attributes.h +173 -0
  60. package/android/ffmpeg_16kb/include/libavutil/attributes_internal.h +34 -0
  61. package/android/ffmpeg_16kb/include/libavutil/audio_fifo.h +186 -0
  62. package/android/ffmpeg_16kb/include/libavutil/avassert.h +75 -0
  63. package/android/ffmpeg_16kb/include/libavutil/avconfig.h +6 -0
  64. package/android/ffmpeg_16kb/include/libavutil/avstring.h +429 -0
  65. package/android/ffmpeg_16kb/include/libavutil/avutil.h +371 -0
  66. package/android/ffmpeg_16kb/include/libavutil/base64.h +72 -0
  67. package/android/ffmpeg_16kb/include/libavutil/blowfish.h +82 -0
  68. package/android/ffmpeg_16kb/include/libavutil/bprint.h +251 -0
  69. package/android/ffmpeg_16kb/include/libavutil/bswap.h +111 -0
  70. package/android/ffmpeg_16kb/include/libavutil/buffer.h +322 -0
  71. package/android/ffmpeg_16kb/include/libavutil/camellia.h +70 -0
  72. package/android/ffmpeg_16kb/include/libavutil/cast5.h +80 -0
  73. package/android/ffmpeg_16kb/include/libavutil/channel_layout.h +783 -0
  74. package/android/ffmpeg_16kb/include/libavutil/common.h +578 -0
  75. package/android/ffmpeg_16kb/include/libavutil/cpu.h +134 -0
  76. package/android/ffmpeg_16kb/include/libavutil/crc.h +102 -0
  77. package/android/ffmpeg_16kb/include/libavutil/csp.h +150 -0
  78. package/android/ffmpeg_16kb/include/libavutil/des.h +81 -0
  79. package/android/ffmpeg_16kb/include/libavutil/detection_bbox.h +108 -0
  80. package/android/ffmpeg_16kb/include/libavutil/dict.h +241 -0
  81. package/android/ffmpeg_16kb/include/libavutil/display.h +109 -0
  82. package/android/ffmpeg_16kb/include/libavutil/dovi_meta.h +236 -0
  83. package/android/ffmpeg_16kb/include/libavutil/downmix_info.h +115 -0
  84. package/android/ffmpeg_16kb/include/libavutil/encryption_info.h +205 -0
  85. package/android/ffmpeg_16kb/include/libavutil/error.h +128 -0
  86. package/android/ffmpeg_16kb/include/libavutil/eval.h +140 -0
  87. package/android/ffmpeg_16kb/include/libavutil/ffversion.h +5 -0
  88. package/android/ffmpeg_16kb/include/libavutil/fifo.h +448 -0
  89. package/android/ffmpeg_16kb/include/libavutil/file.h +115 -0
  90. package/android/ffmpeg_16kb/include/libavutil/film_grain_params.h +260 -0
  91. package/android/ffmpeg_16kb/include/libavutil/frame.h +964 -0
  92. package/android/ffmpeg_16kb/include/libavutil/getenv_utf8.h +86 -0
  93. package/android/ffmpeg_16kb/include/libavutil/hash.h +264 -0
  94. package/android/ffmpeg_16kb/include/libavutil/hdr_dynamic_metadata.h +343 -0
  95. package/android/ffmpeg_16kb/include/libavutil/hdr_dynamic_vivid_metadata.h +285 -0
  96. package/android/ffmpeg_16kb/include/libavutil/hmac.h +99 -0
  97. package/android/ffmpeg_16kb/include/libavutil/hwcontext.h +610 -0
  98. package/android/ffmpeg_16kb/include/libavutil/hwcontext_cuda.h +69 -0
  99. package/android/ffmpeg_16kb/include/libavutil/hwcontext_d3d11va.h +178 -0
  100. package/android/ffmpeg_16kb/include/libavutil/hwcontext_drm.h +169 -0
  101. package/android/ffmpeg_16kb/include/libavutil/hwcontext_dxva2.h +75 -0
  102. package/android/ffmpeg_16kb/include/libavutil/hwcontext_mediacodec.h +61 -0
  103. package/android/ffmpeg_16kb/include/libavutil/hwcontext_opencl.h +100 -0
  104. package/android/ffmpeg_16kb/include/libavutil/hwcontext_qsv.h +64 -0
  105. package/android/ffmpeg_16kb/include/libavutil/hwcontext_vaapi.h +117 -0
  106. package/android/ffmpeg_16kb/include/libavutil/hwcontext_vdpau.h +44 -0
  107. package/android/ffmpeg_16kb/include/libavutil/hwcontext_videotoolbox.h +96 -0
  108. package/android/ffmpeg_16kb/include/libavutil/hwcontext_vulkan.h +281 -0
  109. package/android/ffmpeg_16kb/include/libavutil/imgutils.h +331 -0
  110. package/android/ffmpeg_16kb/include/libavutil/internal.h +190 -0
  111. package/android/ffmpeg_16kb/include/libavutil/intfloat.h +77 -0
  112. package/android/ffmpeg_16kb/include/libavutil/intreadwrite.h +644 -0
  113. package/android/ffmpeg_16kb/include/libavutil/lfg.h +81 -0
  114. package/android/ffmpeg_16kb/include/libavutil/libm.h +471 -0
  115. package/android/ffmpeg_16kb/include/libavutil/log.h +387 -0
  116. package/android/ffmpeg_16kb/include/libavutil/lzo.h +66 -0
  117. package/android/ffmpeg_16kb/include/libavutil/macros.h +80 -0
  118. package/android/ffmpeg_16kb/include/libavutil/mastering_display_metadata.h +128 -0
  119. package/android/ffmpeg_16kb/include/libavutil/mathematics.h +245 -0
  120. package/android/ffmpeg_16kb/include/libavutil/md5.h +89 -0
  121. package/android/ffmpeg_16kb/include/libavutil/mem.h +609 -0
  122. package/android/ffmpeg_16kb/include/libavutil/motion_vector.h +57 -0
  123. package/android/ffmpeg_16kb/include/libavutil/murmur3.h +115 -0
  124. package/android/ffmpeg_16kb/include/libavutil/opt.h +891 -0
  125. package/android/ffmpeg_16kb/include/libavutil/parseutils.h +197 -0
  126. package/android/ffmpeg_16kb/include/libavutil/pixdesc.h +435 -0
  127. package/android/ffmpeg_16kb/include/libavutil/pixelutils.h +51 -0
  128. package/android/ffmpeg_16kb/include/libavutil/pixfmt.h +691 -0
  129. package/android/ffmpeg_16kb/include/libavutil/random_seed.h +43 -0
  130. package/android/ffmpeg_16kb/include/libavutil/rational.h +221 -0
  131. package/android/ffmpeg_16kb/include/libavutil/rc4.h +69 -0
  132. package/android/ffmpeg_16kb/include/libavutil/replaygain.h +50 -0
  133. package/android/ffmpeg_16kb/include/libavutil/reverse.h +28 -0
  134. package/android/ffmpeg_16kb/include/libavutil/ripemd.h +83 -0
  135. package/android/ffmpeg_16kb/include/libavutil/samplefmt.h +269 -0
  136. package/android/ffmpeg_16kb/include/libavutil/sha.h +90 -0
  137. package/android/ffmpeg_16kb/include/libavutil/sha512.h +92 -0
  138. package/android/ffmpeg_16kb/include/libavutil/spherical.h +227 -0
  139. package/android/ffmpeg_16kb/include/libavutil/stereo3d.h +229 -0
  140. package/android/ffmpeg_16kb/include/libavutil/tea.h +71 -0
  141. package/android/ffmpeg_16kb/include/libavutil/thread.h +204 -0
  142. package/android/ffmpeg_16kb/include/libavutil/threadmessage.h +115 -0
  143. package/android/ffmpeg_16kb/include/libavutil/time.h +56 -0
  144. package/android/ffmpeg_16kb/include/libavutil/timecode.h +199 -0
  145. package/android/ffmpeg_16kb/include/libavutil/timer.h +156 -0
  146. package/android/ffmpeg_16kb/include/libavutil/timestamp.h +78 -0
  147. package/android/ffmpeg_16kb/include/libavutil/tree.h +137 -0
  148. package/android/ffmpeg_16kb/include/libavutil/twofish.h +70 -0
  149. package/android/ffmpeg_16kb/include/libavutil/tx.h +176 -0
  150. package/android/ffmpeg_16kb/include/libavutil/uuid.h +146 -0
  151. package/android/ffmpeg_16kb/include/libavutil/version.h +122 -0
  152. package/android/ffmpeg_16kb/include/libavutil/video_enc_params.h +171 -0
  153. package/android/ffmpeg_16kb/include/libavutil/x86/asm.h +154 -0
  154. package/android/ffmpeg_16kb/include/libavutil/x86/emms.h +58 -0
  155. package/android/ffmpeg_16kb/include/libavutil/x86/timer.h +50 -0
  156. package/android/ffmpeg_16kb/include/libavutil/xtea.h +94 -0
  157. package/android/ffmpeg_16kb/include/libswresample/swresample.h +650 -0
  158. package/android/ffmpeg_16kb/include/libswresample/version.h +46 -0
  159. package/android/ffmpeg_16kb/include/libswresample/version_major.h +31 -0
  160. package/android/ffmpeg_16kb/include/libswscale/swscale.h +436 -0
  161. package/android/ffmpeg_16kb/include/libswscale/version.h +44 -0
  162. package/android/ffmpeg_16kb/include/libswscale/version_major.h +35 -0
  163. package/android/ffmpeg_16kb/lib/arm64-v8a/libavcodec.so +0 -0
  164. package/android/ffmpeg_16kb/lib/arm64-v8a/libavdevice.so +0 -0
  165. package/android/ffmpeg_16kb/lib/arm64-v8a/libavfilter.so +0 -0
  166. package/android/ffmpeg_16kb/lib/arm64-v8a/libavformat.so +0 -0
  167. package/android/ffmpeg_16kb/lib/arm64-v8a/libavutil.so +0 -0
  168. package/android/ffmpeg_16kb/lib/arm64-v8a/libswresample.so +0 -0
  169. package/android/ffmpeg_16kb/lib/arm64-v8a/libswscale.so +0 -0
  170. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavcodec_neon.so +0 -0
  171. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavdevice_neon.so +0 -0
  172. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavfilter_neon.so +0 -0
  173. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavformat_neon.so +0 -0
  174. package/android/ffmpeg_16kb/lib/armeabi-v7a/libavutil_neon.so +0 -0
  175. package/android/ffmpeg_16kb/lib/armeabi-v7a/libswresample_neon.so +0 -0
  176. package/android/ffmpeg_16kb/lib/armeabi-v7a/libswscale_neon.so +0 -0
  177. package/android/ffmpeg_16kb/lib/x86/libavcodec.so +0 -0
  178. package/android/ffmpeg_16kb/lib/x86/libavdevice.so +0 -0
  179. package/android/ffmpeg_16kb/lib/x86/libavfilter.so +0 -0
  180. package/android/ffmpeg_16kb/lib/x86/libavformat.so +0 -0
  181. package/android/ffmpeg_16kb/lib/x86/libavutil.so +0 -0
  182. package/android/ffmpeg_16kb/lib/x86/libswresample.so +0 -0
  183. package/android/ffmpeg_16kb/lib/x86/libswscale.so +0 -0
  184. package/android/ffmpeg_16kb/lib/x86_64/libavcodec.so +0 -0
  185. package/android/ffmpeg_16kb/lib/x86_64/libavdevice.so +0 -0
  186. package/android/ffmpeg_16kb/lib/x86_64/libavfilter.so +0 -0
  187. package/android/ffmpeg_16kb/lib/x86_64/libavformat.so +0 -0
  188. package/android/ffmpeg_16kb/lib/x86_64/libavutil.so +0 -0
  189. package/android/ffmpeg_16kb/lib/x86_64/libswresample.so +0 -0
  190. package/android/ffmpeg_16kb/lib/x86_64/libswscale.so +0 -0
  191. package/android/gradle.properties +5 -0
  192. package/android/src/main/AndroidManifest.xml +3 -0
  193. package/android/src/main/AndroidManifestNew.xml +2 -0
  194. package/android/src/main/java/com/audioanalyzer/AmplitudeData.java +20 -0
  195. package/android/src/main/java/com/audioanalyzer/AudioAnalyzerModule.java +52 -0
  196. package/android/src/main/java/com/audioanalyzer/AudioAnalyzerPackage.java +28 -0
  197. package/cpp/react-native-audio-analyzer.cpp +143 -0
  198. package/cpp/react-native-audio-analyzer.h +27 -0
  199. package/ios/AudioAnalyzer.h +19 -0
  200. package/ios/AudioAnalyzer.mm +43 -0
  201. package/lib/commonjs/helpers.js +34 -0
  202. package/lib/commonjs/helpers.js.map +1 -0
  203. package/lib/commonjs/helpers.test.js +49 -0
  204. package/lib/commonjs/helpers.test.js.map +1 -0
  205. package/lib/commonjs/index.js +35 -0
  206. package/lib/commonjs/index.js.map +1 -0
  207. package/lib/module/helpers.js +27 -0
  208. package/lib/module/helpers.js.map +1 -0
  209. package/lib/module/helpers.test.js +47 -0
  210. package/lib/module/helpers.test.js.map +1 -0
  211. package/lib/module/index.js +15 -0
  212. package/lib/module/index.js.map +1 -0
  213. package/lib/typescript/src/helpers.d.ts +3 -0
  214. package/lib/typescript/src/helpers.d.ts.map +1 -0
  215. package/lib/typescript/src/helpers.test.d.ts +2 -0
  216. package/lib/typescript/src/helpers.test.d.ts.map +1 -0
  217. package/lib/typescript/src/index.d.ts +7 -0
  218. package/lib/typescript/src/index.d.ts.map +1 -0
  219. package/package.json +163 -0
  220. package/react-native-audio-analyzer.podspec +44 -0
  221. package/src/helpers.test.ts +59 -0
  222. package/src/helpers.ts +34 -0
  223. package/src/index.tsx +30 -0
@@ -0,0 +1,331 @@
1
+ /*
2
+ * This file is part of FFmpeg.
3
+ *
4
+ * FFmpeg is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * FFmpeg is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ * Lesser General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Lesser General Public
15
+ * License along with FFmpeg; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
+ */
18
+
19
+ #ifndef AVUTIL_IMGUTILS_H
20
+ #define AVUTIL_IMGUTILS_H
21
+
22
+ /**
23
+ * @file
24
+ * misc image utilities
25
+ *
26
+ * @addtogroup lavu_picture
27
+ * @{
28
+ */
29
+
30
+ #include <stddef.h>
31
+ #include <stdint.h>
32
+ #include "pixdesc.h"
33
+ #include "pixfmt.h"
34
+ #include "rational.h"
35
+
36
+ /**
37
+ * Compute the max pixel step for each plane of an image with a
38
+ * format described by pixdesc.
39
+ *
40
+ * The pixel step is the distance in bytes between the first byte of
41
+ * the group of bytes which describe a pixel component and the first
42
+ * byte of the successive group in the same plane for the same
43
+ * component.
44
+ *
45
+ * @param max_pixsteps an array which is filled with the max pixel step
46
+ * for each plane. Since a plane may contain different pixel
47
+ * components, the computed max_pixsteps[plane] is relative to the
48
+ * component in the plane with the max pixel step.
49
+ * @param max_pixstep_comps an array which is filled with the component
50
+ * for each plane which has the max pixel step. May be NULL.
51
+ * @param pixdesc the AVPixFmtDescriptor for the image, describing its format
52
+ */
53
+ void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
54
+ const AVPixFmtDescriptor *pixdesc);
55
+
56
+ /**
57
+ * Compute the size of an image line with format pix_fmt and width
58
+ * width for the plane plane.
59
+ *
60
+ * @return the computed size in bytes
61
+ */
62
+ int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
63
+
64
+ /**
65
+ * Fill plane linesizes for an image with pixel format pix_fmt and
66
+ * width width.
67
+ *
68
+ * @param linesizes array to be filled with the linesize for each plane
69
+ * @param pix_fmt the AVPixelFormat of the image
70
+ * @param width width of the image in pixels
71
+ * @return >= 0 in case of success, a negative error code otherwise
72
+ */
73
+ int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
74
+
75
+ /**
76
+ * Fill plane sizes for an image with pixel format pix_fmt and height height.
77
+ *
78
+ * @param size the array to be filled with the size of each image plane
79
+ * @param pix_fmt the AVPixelFormat of the image
80
+ * @param height height of the image in pixels
81
+ * @param linesizes the array containing the linesize for each
82
+ * plane, should be filled by av_image_fill_linesizes()
83
+ * @return >= 0 in case of success, a negative error code otherwise
84
+ *
85
+ * @note The linesize parameters have the type ptrdiff_t here, while they are
86
+ * int for av_image_fill_linesizes().
87
+ */
88
+ int av_image_fill_plane_sizes(size_t size[4], enum AVPixelFormat pix_fmt,
89
+ int height, const ptrdiff_t linesizes[4]);
90
+
91
+ /**
92
+ * Fill plane data pointers for an image with pixel format pix_fmt and
93
+ * height height.
94
+ *
95
+ * @param data pointers array to be filled with the pointer for each image plane
96
+ * @param pix_fmt the AVPixelFormat of the image
97
+ * @param height height of the image in pixels
98
+ * @param ptr the pointer to a buffer which will contain the image
99
+ * @param linesizes the array containing the linesize for each
100
+ * plane, should be filled by av_image_fill_linesizes()
101
+ * @return the size in bytes required for the image buffer, a negative
102
+ * error code in case of failure
103
+ */
104
+ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
105
+ uint8_t *ptr, const int linesizes[4]);
106
+
107
+ /**
108
+ * Allocate an image with size w and h and pixel format pix_fmt, and
109
+ * fill pointers and linesizes accordingly.
110
+ * The allocated image buffer has to be freed by using
111
+ * av_freep(&pointers[0]).
112
+ *
113
+ * @param pointers array to be filled with the pointer for each image plane
114
+ * @param linesizes the array filled with the linesize for each plane
115
+ * @param w width of the image in pixels
116
+ * @param h height of the image in pixels
117
+ * @param pix_fmt the AVPixelFormat of the image
118
+ * @param align the value to use for buffer size alignment
119
+ * @return the size in bytes required for the image buffer, a negative
120
+ * error code in case of failure
121
+ */
122
+ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
123
+ int w, int h, enum AVPixelFormat pix_fmt, int align);
124
+
125
+ /**
126
+ * Copy image plane from src to dst.
127
+ * That is, copy "height" number of lines of "bytewidth" bytes each.
128
+ * The first byte of each successive line is separated by *_linesize
129
+ * bytes.
130
+ *
131
+ * bytewidth must be contained by both absolute values of dst_linesize
132
+ * and src_linesize, otherwise the function behavior is undefined.
133
+ *
134
+ * @param dst destination plane to copy to
135
+ * @param dst_linesize linesize for the image plane in dst
136
+ * @param src source plane to copy from
137
+ * @param src_linesize linesize for the image plane in src
138
+ * @param height height (number of lines) of the plane
139
+ */
140
+ void av_image_copy_plane(uint8_t *dst, int dst_linesize,
141
+ const uint8_t *src, int src_linesize,
142
+ int bytewidth, int height);
143
+
144
+ /**
145
+ * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where
146
+ * available, this function will use special functionality for reading from such
147
+ * memory, which may result in greatly improved performance compared to plain
148
+ * av_image_copy_plane().
149
+ *
150
+ * bytewidth must be contained by both absolute values of dst_linesize
151
+ * and src_linesize, otherwise the function behavior is undefined.
152
+ *
153
+ * @note The linesize parameters have the type ptrdiff_t here, while they are
154
+ * int for av_image_copy_plane().
155
+ * @note On x86, the linesizes currently need to be aligned to the cacheline
156
+ * size (i.e. 64) to get improved performance.
157
+ */
158
+ void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize,
159
+ const uint8_t *src, ptrdiff_t src_linesize,
160
+ ptrdiff_t bytewidth, int height);
161
+
162
+ /**
163
+ * Copy image in src_data to dst_data.
164
+ *
165
+ * @param dst_data destination image data buffer to copy to
166
+ * @param dst_linesizes linesizes for the image in dst_data
167
+ * @param src_data source image data buffer to copy from
168
+ * @param src_linesizes linesizes for the image in src_data
169
+ * @param pix_fmt the AVPixelFormat of the image
170
+ * @param width width of the image in pixels
171
+ * @param height height of the image in pixels
172
+ */
173
+ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
174
+ const uint8_t *src_data[4], const int src_linesizes[4],
175
+ enum AVPixelFormat pix_fmt, int width, int height);
176
+
177
+ /**
178
+ * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where
179
+ * available, this function will use special functionality for reading from such
180
+ * memory, which may result in greatly improved performance compared to plain
181
+ * av_image_copy().
182
+ *
183
+ * The data pointers and the linesizes must be aligned to the maximum required
184
+ * by the CPU architecture.
185
+ *
186
+ * @note The linesize parameters have the type ptrdiff_t here, while they are
187
+ * int for av_image_copy().
188
+ * @note On x86, the linesizes currently need to be aligned to the cacheline
189
+ * size (i.e. 64) to get improved performance.
190
+ */
191
+ void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
192
+ const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
193
+ enum AVPixelFormat pix_fmt, int width, int height);
194
+
195
+ /**
196
+ * Setup the data pointers and linesizes based on the specified image
197
+ * parameters and the provided array.
198
+ *
199
+ * The fields of the given image are filled in by using the src
200
+ * address which points to the image data buffer. Depending on the
201
+ * specified pixel format, one or multiple image data pointers and
202
+ * line sizes will be set. If a planar format is specified, several
203
+ * pointers will be set pointing to the different picture planes and
204
+ * the line sizes of the different planes will be stored in the
205
+ * lines_sizes array. Call with src == NULL to get the required
206
+ * size for the src buffer.
207
+ *
208
+ * To allocate the buffer and fill in the dst_data and dst_linesize in
209
+ * one call, use av_image_alloc().
210
+ *
211
+ * @param dst_data data pointers to be filled in
212
+ * @param dst_linesize linesizes for the image in dst_data to be filled in
213
+ * @param src buffer which will contain or contains the actual image data, can be NULL
214
+ * @param pix_fmt the pixel format of the image
215
+ * @param width the width of the image in pixels
216
+ * @param height the height of the image in pixels
217
+ * @param align the value used in src for linesize alignment
218
+ * @return the size in bytes required for src, a negative error code
219
+ * in case of failure
220
+ */
221
+ int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
222
+ const uint8_t *src,
223
+ enum AVPixelFormat pix_fmt, int width, int height, int align);
224
+
225
+ /**
226
+ * Return the size in bytes of the amount of data required to store an
227
+ * image with the given parameters.
228
+ *
229
+ * @param pix_fmt the pixel format of the image
230
+ * @param width the width of the image in pixels
231
+ * @param height the height of the image in pixels
232
+ * @param align the assumed linesize alignment
233
+ * @return the buffer size in bytes, a negative error code in case of failure
234
+ */
235
+ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
236
+
237
+ /**
238
+ * Copy image data from an image into a buffer.
239
+ *
240
+ * av_image_get_buffer_size() can be used to compute the required size
241
+ * for the buffer to fill.
242
+ *
243
+ * @param dst a buffer into which picture data will be copied
244
+ * @param dst_size the size in bytes of dst
245
+ * @param src_data pointers containing the source image data
246
+ * @param src_linesize linesizes for the image in src_data
247
+ * @param pix_fmt the pixel format of the source image
248
+ * @param width the width of the source image in pixels
249
+ * @param height the height of the source image in pixels
250
+ * @param align the assumed linesize alignment for dst
251
+ * @return the number of bytes written to dst, or a negative value
252
+ * (error code) on error
253
+ */
254
+ int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
255
+ const uint8_t * const src_data[4], const int src_linesize[4],
256
+ enum AVPixelFormat pix_fmt, int width, int height, int align);
257
+
258
+ /**
259
+ * Check if the given dimension of an image is valid, meaning that all
260
+ * bytes of the image can be addressed with a signed int.
261
+ *
262
+ * @param w the width of the picture
263
+ * @param h the height of the picture
264
+ * @param log_offset the offset to sum to the log level for logging with log_ctx
265
+ * @param log_ctx the parent logging context, it may be NULL
266
+ * @return >= 0 if valid, a negative error code otherwise
267
+ */
268
+ int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
269
+
270
+ /**
271
+ * Check if the given dimension of an image is valid, meaning that all
272
+ * bytes of a plane of an image with the specified pix_fmt can be addressed
273
+ * with a signed int.
274
+ *
275
+ * @param w the width of the picture
276
+ * @param h the height of the picture
277
+ * @param max_pixels the maximum number of pixels the user wants to accept
278
+ * @param pix_fmt the pixel format, can be AV_PIX_FMT_NONE if unknown.
279
+ * @param log_offset the offset to sum to the log level for logging with log_ctx
280
+ * @param log_ctx the parent logging context, it may be NULL
281
+ * @return >= 0 if valid, a negative error code otherwise
282
+ */
283
+ int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx);
284
+
285
+ /**
286
+ * Check if the given sample aspect ratio of an image is valid.
287
+ *
288
+ * It is considered invalid if the denominator is 0 or if applying the ratio
289
+ * to the image size would make the smaller dimension less than 1. If the
290
+ * sar numerator is 0, it is considered unknown and will return as valid.
291
+ *
292
+ * @param w width of the image
293
+ * @param h height of the image
294
+ * @param sar sample aspect ratio of the image
295
+ * @return 0 if valid, a negative AVERROR code otherwise
296
+ */
297
+ int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar);
298
+
299
+ /**
300
+ * Overwrite the image data with black. This is suitable for filling a
301
+ * sub-rectangle of an image, meaning the padding between the right most pixel
302
+ * and the left most pixel on the next line will not be overwritten. For some
303
+ * formats, the image size might be rounded up due to inherent alignment.
304
+ *
305
+ * If the pixel format has alpha, the alpha is cleared to opaque.
306
+ *
307
+ * This can return an error if the pixel format is not supported. Normally, all
308
+ * non-hwaccel pixel formats should be supported.
309
+ *
310
+ * Passing NULL for dst_data is allowed. Then the function returns whether the
311
+ * operation would have succeeded. (It can return an error if the pix_fmt is
312
+ * not supported.)
313
+ *
314
+ * @param dst_data data pointers to destination image
315
+ * @param dst_linesize linesizes for the destination image
316
+ * @param pix_fmt the pixel format of the image
317
+ * @param range the color range of the image (important for colorspaces such as YUV)
318
+ * @param width the width of the image in pixels
319
+ * @param height the height of the image in pixels
320
+ * @return 0 if the image data was cleared, a negative AVERROR code otherwise
321
+ */
322
+ int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
323
+ enum AVPixelFormat pix_fmt, enum AVColorRange range,
324
+ int width, int height);
325
+
326
+ /**
327
+ * @}
328
+ */
329
+
330
+
331
+ #endif /* AVUTIL_IMGUTILS_H */
@@ -0,0 +1,190 @@
1
+ /*
2
+ * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ /**
22
+ * @file
23
+ * common internal API header
24
+ */
25
+
26
+ #ifndef AVUTIL_INTERNAL_H
27
+ #define AVUTIL_INTERNAL_H
28
+
29
+ #if !defined(DEBUG) && !defined(NDEBUG)
30
+ # define NDEBUG
31
+ #endif
32
+
33
+ // This can be enabled to allow detection of additional integer overflows with ubsan
34
+ //#define CHECKED
35
+
36
+ #include <limits.h>
37
+ #include <stdint.h>
38
+ #include <stddef.h>
39
+ #include <assert.h>
40
+ #include <stdio.h>
41
+ #include "config.h"
42
+ #include "attributes.h"
43
+ #include "timer.h"
44
+ #include "macros.h"
45
+ #include "pixfmt.h"
46
+
47
+ #if ARCH_X86
48
+ # include "x86/emms.h"
49
+ #endif
50
+
51
+ #ifndef emms_c
52
+ # define emms_c() do {} while(0)
53
+ #endif
54
+
55
+ #ifndef attribute_align_arg
56
+ #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
57
+ # define attribute_align_arg __attribute__((force_align_arg_pointer))
58
+ #else
59
+ # define attribute_align_arg
60
+ #endif
61
+ #endif
62
+
63
+ #if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avutil)
64
+ # define av_export_avutil __declspec(dllimport)
65
+ #else
66
+ # define av_export_avutil
67
+ #endif
68
+
69
+ #if HAVE_PRAGMA_DEPRECATED
70
+ # if defined(__ICL) || defined (__INTEL_COMPILER)
71
+ # define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478))
72
+ # define FF_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop))
73
+ # elif defined(_MSC_VER)
74
+ # define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996))
75
+ # define FF_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop))
76
+ # else
77
+ # define FF_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
78
+ # define FF_ENABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic pop")
79
+ # endif
80
+ #else
81
+ # define FF_DISABLE_DEPRECATION_WARNINGS
82
+ # define FF_ENABLE_DEPRECATION_WARNINGS
83
+ #endif
84
+
85
+
86
+ #define FF_MEMORY_POISON 0x2a
87
+
88
+ /* Check if the hard coded offset of a struct member still matches reality.
89
+ * Induce a compilation failure if not.
90
+ */
91
+ #define AV_CHECK_OFFSET(s, m, o) struct check_##o { \
92
+ int x_##o[offsetof(s, m) == o? 1: -1]; \
93
+ }
94
+
95
+
96
+ #define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p)))
97
+ #define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p)))
98
+
99
+ #define FF_PTR_ADD(ptr, off) ((off) ? (ptr) + (off) : (ptr))
100
+
101
+ /**
102
+ * Access a field in a structure by its offset.
103
+ */
104
+ #define FF_FIELD_AT(type, off, obj) (*(type *)((char *)&(obj) + (off)))
105
+
106
+ #include "libm.h"
107
+
108
+ /**
109
+ * Return NULL if CONFIG_SMALL is true, otherwise the argument
110
+ * without modification. Used to disable the definition of strings.
111
+ */
112
+ #if CONFIG_SMALL
113
+ # define NULL_IF_CONFIG_SMALL(x) NULL
114
+ #else
115
+ # define NULL_IF_CONFIG_SMALL(x) x
116
+ #endif
117
+
118
+ /**
119
+ * Log a generic warning message about a missing feature.
120
+ *
121
+ * @param[in] avc a pointer to an arbitrary struct of which the first
122
+ * field is a pointer to an AVClass struct
123
+ * @param[in] msg string containing the name of the missing feature
124
+ */
125
+ void avpriv_report_missing_feature(void *avc,
126
+ const char *msg, ...) av_printf_format(2, 3);
127
+
128
+ /**
129
+ * Log a generic warning message about a missing feature.
130
+ * Additionally request that a sample showcasing the feature be uploaded.
131
+ *
132
+ * @param[in] avc a pointer to an arbitrary struct of which the first field is
133
+ * a pointer to an AVClass struct
134
+ * @param[in] msg string containing the name of the missing feature
135
+ */
136
+ void avpriv_request_sample(void *avc,
137
+ const char *msg, ...) av_printf_format(2, 3);
138
+
139
+ #if HAVE_LIBC_MSVCRT
140
+ #include <crtversion.h>
141
+ #if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14
142
+ #pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_strtod")
143
+ #pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_snprintf")
144
+ #endif
145
+
146
+ #define PTRDIFF_SPECIFIER "Id"
147
+ #define SIZE_SPECIFIER "Iu"
148
+ #else
149
+ #define PTRDIFF_SPECIFIER "td"
150
+ #define SIZE_SPECIFIER "zu"
151
+ #endif
152
+
153
+ #ifdef DEBUG
154
+ # define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__)
155
+ #else
156
+ # define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
157
+ #endif
158
+
159
+ #ifdef TRACE
160
+ # define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
161
+ #else
162
+ # define ff_tlog(ctx, ...) do { } while(0)
163
+ #endif
164
+
165
+ // For debuging we use signed operations so overflows can be detected (by ubsan)
166
+ // For production we use unsigned so there are no undefined operations
167
+ #ifdef CHECKED
168
+ #define SUINT int
169
+ #define SUINT32 int32_t
170
+ #else
171
+ #define SUINT unsigned
172
+ #define SUINT32 uint32_t
173
+ #endif
174
+
175
+ int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt);
176
+
177
+ static av_always_inline av_const int avpriv_mirror(int x, int w)
178
+ {
179
+ if (!w)
180
+ return 0;
181
+
182
+ while ((unsigned)x > (unsigned)w) {
183
+ x = -x;
184
+ if (x < 0)
185
+ x += 2 * w;
186
+ }
187
+ return x;
188
+ }
189
+
190
+ #endif /* AVUTIL_INTERNAL_H */
@@ -0,0 +1,77 @@
1
+ /*
2
+ * Copyright (c) 2011 Mans Rullgard
3
+ *
4
+ * This file is part of FFmpeg.
5
+ *
6
+ * FFmpeg is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * FFmpeg is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with FFmpeg; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+
21
+ #ifndef AVUTIL_INTFLOAT_H
22
+ #define AVUTIL_INTFLOAT_H
23
+
24
+ #include <stdint.h>
25
+ #include "attributes.h"
26
+
27
+ union av_intfloat32 {
28
+ uint32_t i;
29
+ float f;
30
+ };
31
+
32
+ union av_intfloat64 {
33
+ uint64_t i;
34
+ double f;
35
+ };
36
+
37
+ /**
38
+ * Reinterpret a 32-bit integer as a float.
39
+ */
40
+ static av_always_inline float av_int2float(uint32_t i)
41
+ {
42
+ union av_intfloat32 v;
43
+ v.i = i;
44
+ return v.f;
45
+ }
46
+
47
+ /**
48
+ * Reinterpret a float as a 32-bit integer.
49
+ */
50
+ static av_always_inline uint32_t av_float2int(float f)
51
+ {
52
+ union av_intfloat32 v;
53
+ v.f = f;
54
+ return v.i;
55
+ }
56
+
57
+ /**
58
+ * Reinterpret a 64-bit integer as a double.
59
+ */
60
+ static av_always_inline double av_int2double(uint64_t i)
61
+ {
62
+ union av_intfloat64 v;
63
+ v.i = i;
64
+ return v.f;
65
+ }
66
+
67
+ /**
68
+ * Reinterpret a double as a 64-bit integer.
69
+ */
70
+ static av_always_inline uint64_t av_double2int(double f)
71
+ {
72
+ union av_intfloat64 v;
73
+ v.f = f;
74
+ return v.i;
75
+ }
76
+
77
+ #endif /* AVUTIL_INTFLOAT_H */