noobs 0.0.6
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/COPYING +339 -0
- package/README.md +46 -0
- package/bin/64bit/obs.lib +0 -0
- package/binding.gyp +23 -0
- package/dist/bin/Qt6Core.dll +0 -0
- package/dist/bin/Qt6Gui.dll +0 -0
- package/dist/bin/Qt6Network.dll +0 -0
- package/dist/bin/Qt6Svg.dll +0 -0
- package/dist/bin/Qt6Widgets.dll +0 -0
- package/dist/bin/Qt6Xml.dll +0 -0
- package/dist/bin/avcodec-61.dll +0 -0
- package/dist/bin/avdevice-61.dll +0 -0
- package/dist/bin/avfilter-10.dll +0 -0
- package/dist/bin/avformat-61.dll +0 -0
- package/dist/bin/avutil-59.dll +0 -0
- package/dist/bin/datachannel.dll +0 -0
- package/dist/bin/libcurl.dll +0 -0
- package/dist/bin/libobs-d3d11.dll +0 -0
- package/dist/bin/libobs-opengl.dll +0 -0
- package/dist/bin/libobs-winrt.dll +0 -0
- package/dist/bin/librist.dll +0 -0
- package/dist/bin/libx264-164.dll +0 -0
- package/dist/bin/lua51.dll +0 -0
- package/dist/bin/obs-amf-test.exe +0 -0
- package/dist/bin/obs-ffmpeg-mux.exe +0 -0
- package/dist/bin/obs-frontend-api.dll +0 -0
- package/dist/bin/obs-scripting.dll +0 -0
- package/dist/bin/obs.dll +0 -0
- package/dist/bin/srt.dll +0 -0
- package/dist/bin/swresample-5.dll +0 -0
- package/dist/bin/swscale-8.dll +0 -0
- package/dist/bin/w32-pthreads.dll +0 -0
- package/dist/bin/zlib.dll +0 -0
- package/dist/effects/area.effect +250 -0
- package/dist/effects/bicubic_scale.effect +236 -0
- package/dist/effects/bilinear_lowres_scale.effect +123 -0
- package/dist/effects/color.effect +172 -0
- package/dist/effects/default.effect +254 -0
- package/dist/effects/default_rect.effect +84 -0
- package/dist/effects/deinterlace_base.effect +325 -0
- package/dist/effects/deinterlace_blend.effect +21 -0
- package/dist/effects/deinterlace_blend_2x.effect +21 -0
- package/dist/effects/deinterlace_discard.effect +21 -0
- package/dist/effects/deinterlace_discard_2x.effect +21 -0
- package/dist/effects/deinterlace_linear.effect +21 -0
- package/dist/effects/deinterlace_linear_2x.effect +21 -0
- package/dist/effects/deinterlace_yadif.effect +21 -0
- package/dist/effects/deinterlace_yadif_2x.effect +21 -0
- package/dist/effects/format_conversion.effect +1823 -0
- package/dist/effects/lanczos_scale.effect +292 -0
- package/dist/effects/opaque.effect +159 -0
- package/dist/effects/premultiplied_alpha.effect +38 -0
- package/dist/effects/repeat.effect +36 -0
- package/dist/effects/solid.effect +80 -0
- package/dist/noobs.node +0 -0
- package/dist/plugins/obs-ffmpeg.dll +0 -0
- package/dist/plugins/obs-x264.dll +0 -0
- package/dist/plugins/win-capture.dll +0 -0
- package/include/audio-monitoring/osx/mac-helpers.h +13 -0
- package/include/audio-monitoring/pulse/pulseaudio-wrapper.h +212 -0
- package/include/audio-monitoring/win32/wasapi-output.h +22 -0
- package/include/callback/calldata.h +195 -0
- package/include/callback/decl.h +61 -0
- package/include/callback/proc.h +52 -0
- package/include/callback/signal.h +73 -0
- package/include/graphics/axisang.h +65 -0
- package/include/graphics/bounds.h +108 -0
- package/include/graphics/device-exports.h +177 -0
- package/include/graphics/effect-parser.h +290 -0
- package/include/graphics/effect.h +190 -0
- package/include/graphics/graphics-internal.h +335 -0
- package/include/graphics/graphics.h +1024 -0
- package/include/graphics/half.h +100 -0
- package/include/graphics/image-file.h +124 -0
- package/include/graphics/input.h +34 -0
- package/include/graphics/libnsgif/libnsgif.h +142 -0
- package/include/graphics/math-defs.h +45 -0
- package/include/graphics/math-extra.h +61 -0
- package/include/graphics/matrix3.h +98 -0
- package/include/graphics/matrix4.h +102 -0
- package/include/graphics/plane.h +85 -0
- package/include/graphics/quat.h +170 -0
- package/include/graphics/shader-parser.h +273 -0
- package/include/graphics/srgb.h +177 -0
- package/include/graphics/vec2.h +148 -0
- package/include/graphics/vec3.h +224 -0
- package/include/graphics/vec4.h +241 -0
- package/include/media-io/audio-io.h +228 -0
- package/include/media-io/audio-math.h +43 -0
- package/include/media-io/audio-resampler.h +44 -0
- package/include/media-io/format-conversion.h +50 -0
- package/include/media-io/frame-rate.h +29 -0
- package/include/media-io/media-io-defs.h +20 -0
- package/include/media-io/media-remux.h +37 -0
- package/include/media-io/video-frame.h +64 -0
- package/include/media-io/video-io.h +338 -0
- package/include/media-io/video-scaler.h +43 -0
- package/include/obs-audio-controls.h +250 -0
- package/include/obs-av1.h +47 -0
- package/include/obs-avc.h +55 -0
- package/include/obs-config.h +52 -0
- package/include/obs-data.h +311 -0
- package/include/obs-defs.h +52 -0
- package/include/obs-encoder.h +361 -0
- package/include/obs-ffmpeg-compat.h +13 -0
- package/include/obs-hevc.h +81 -0
- package/include/obs-hotkey.h +271 -0
- package/include/obs-hotkeys.h +653 -0
- package/include/obs-interaction.h +56 -0
- package/include/obs-internal.h +1459 -0
- package/include/obs-missing-files.h +53 -0
- package/include/obs-module.h +181 -0
- package/include/obs-nal.h +37 -0
- package/include/obs-nix-platform.h +53 -0
- package/include/obs-nix-wayland.h +24 -0
- package/include/obs-nix-x11.h +22 -0
- package/include/obs-nix.h +42 -0
- package/include/obs-output.h +96 -0
- package/include/obs-properties.h +364 -0
- package/include/obs-scene.h +127 -0
- package/include/obs-service.h +115 -0
- package/include/obs-source.h +568 -0
- package/include/obs.h +2608 -0
- package/include/obsconfig.h +13 -0
- package/include/obsversion.h +5 -0
- package/include/util/apple/cfstring-utils.h +16 -0
- package/include/util/array-serializer.h +37 -0
- package/include/util/base.h +97 -0
- package/include/util/bitstream.h +28 -0
- package/include/util/bmem.h +94 -0
- package/include/util/buffered-file-serializer.h +32 -0
- package/include/util/c99defs.h +75 -0
- package/include/util/cf-lexer.h +199 -0
- package/include/util/cf-parser.h +281 -0
- package/include/util/circlebuf.h +319 -0
- package/include/util/config-file.h +103 -0
- package/include/util/crc32.h +29 -0
- package/include/util/curl/curl-helper.h +35 -0
- package/include/util/darray.h +606 -0
- package/include/util/deque.h +319 -0
- package/include/util/dstr.h +320 -0
- package/include/util/file-serializer.h +34 -0
- package/include/util/lexer.h +273 -0
- package/include/util/pipe.h +52 -0
- package/include/util/platform.h +223 -0
- package/include/util/profiler.h +97 -0
- package/include/util/serializer.h +158 -0
- package/include/util/simde/check.h +285 -0
- package/include/util/simde/debug-trap.h +117 -0
- package/include/util/simde/hedley.h +2123 -0
- package/include/util/simde/simde-align.h +481 -0
- package/include/util/simde/simde-arch.h +537 -0
- package/include/util/simde/simde-common.h +918 -0
- package/include/util/simde/simde-constify.h +925 -0
- package/include/util/simde/simde-detect-clang.h +114 -0
- package/include/util/simde/simde-diagnostic.h +447 -0
- package/include/util/simde/simde-features.h +550 -0
- package/include/util/simde/simde-math.h +1858 -0
- package/include/util/simde/x86/mmx.h +2456 -0
- package/include/util/simde/x86/sse.h +4479 -0
- package/include/util/simde/x86/sse2.h +7549 -0
- package/include/util/source-profiler.h +66 -0
- package/include/util/sse-intrin.h +32 -0
- package/include/util/task.h +22 -0
- package/include/util/text-lookup.h +45 -0
- package/include/util/threading-posix.h +77 -0
- package/include/util/threading-windows.h +142 -0
- package/include/util/threading.h +103 -0
- package/include/util/utf8.h +35 -0
- package/include/util/uthash.h +34 -0
- package/include/util/util_uint128.h +108 -0
- package/include/util/util_uint64.h +34 -0
- package/include/util/windows/device-enum.h +14 -0
- package/include/util/windows/obfuscate.h +16 -0
- package/include/util/windows/win-registry.h +37 -0
- package/include/util/windows/win-version.h +57 -0
- package/include/util/windows/window-helpers.h +47 -0
- package/index.d.ts +38 -0
- package/index.js +8 -0
- package/package.json +31 -0
- package/src/main.cpp +321 -0
- package/src/obs_interface.cpp +605 -0
- package/src/obs_interface.h +74 -0
- package/src/utils.cpp +80 -0
- package/src/utils.h +3 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program 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
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include <math.h>
|
|
21
|
+
#include <string.h>
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
extern "C" {
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
static inline float gs_srgb_nonlinear_to_linear(float u)
|
|
28
|
+
{
|
|
29
|
+
return (u <= 0.04045f) ? (u / 12.92f) : powf((u + 0.055f) / 1.055f, 2.4f);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static inline float gs_srgb_linear_to_nonlinear(float u)
|
|
33
|
+
{
|
|
34
|
+
return (u <= 0.0031308f) ? (12.92f * u) : ((1.055f * powf(u, 1.0f / 2.4f)) - 0.055f);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static inline float gs_u8_to_float(uint8_t u)
|
|
38
|
+
{
|
|
39
|
+
return (float)u / 255.0f;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static inline void gs_u8x4_to_float4(float *f, const uint8_t *u)
|
|
43
|
+
{
|
|
44
|
+
f[0] = gs_u8_to_float(u[0]);
|
|
45
|
+
f[1] = gs_u8_to_float(u[1]);
|
|
46
|
+
f[2] = gs_u8_to_float(u[2]);
|
|
47
|
+
f[3] = gs_u8_to_float(u[3]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static inline uint8_t gs_float_to_u8(float f)
|
|
51
|
+
{
|
|
52
|
+
return (uint8_t)(f * 255.0f + 0.5f);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static inline void gs_premultiply_float4(float *f)
|
|
56
|
+
{
|
|
57
|
+
f[0] *= f[3];
|
|
58
|
+
f[1] *= f[3];
|
|
59
|
+
f[2] *= f[3];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static inline void gs_float3_to_u8x3(uint8_t *u, const float *f)
|
|
63
|
+
{
|
|
64
|
+
u[0] = gs_float_to_u8(f[0]);
|
|
65
|
+
u[1] = gs_float_to_u8(f[1]);
|
|
66
|
+
u[2] = gs_float_to_u8(f[2]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static inline void gs_float4_to_u8x4(uint8_t *u, const float *f)
|
|
70
|
+
{
|
|
71
|
+
u[0] = gs_float_to_u8(f[0]);
|
|
72
|
+
u[1] = gs_float_to_u8(f[1]);
|
|
73
|
+
u[2] = gs_float_to_u8(f[2]);
|
|
74
|
+
u[3] = gs_float_to_u8(f[3]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static inline void gs_float3_srgb_nonlinear_to_linear(float *f)
|
|
78
|
+
{
|
|
79
|
+
f[0] = gs_srgb_nonlinear_to_linear(f[0]);
|
|
80
|
+
f[1] = gs_srgb_nonlinear_to_linear(f[1]);
|
|
81
|
+
f[2] = gs_srgb_nonlinear_to_linear(f[2]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static inline void gs_float3_srgb_linear_to_nonlinear(float *f)
|
|
85
|
+
{
|
|
86
|
+
f[0] = gs_srgb_linear_to_nonlinear(f[0]);
|
|
87
|
+
f[1] = gs_srgb_linear_to_nonlinear(f[1]);
|
|
88
|
+
f[2] = gs_srgb_linear_to_nonlinear(f[2]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static inline void gs_premultiply_xyza(uint8_t *data)
|
|
92
|
+
{
|
|
93
|
+
uint8_t u[4];
|
|
94
|
+
float f[4];
|
|
95
|
+
memcpy(&u, data, sizeof(u));
|
|
96
|
+
gs_u8x4_to_float4(f, u);
|
|
97
|
+
gs_premultiply_float4(f);
|
|
98
|
+
gs_float3_to_u8x3(u, f);
|
|
99
|
+
memcpy(data, &u, sizeof(u));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static inline void gs_premultiply_xyza_srgb(uint8_t *data)
|
|
103
|
+
{
|
|
104
|
+
uint8_t u[4];
|
|
105
|
+
float f[4];
|
|
106
|
+
memcpy(&u, data, sizeof(u));
|
|
107
|
+
gs_u8x4_to_float4(f, u);
|
|
108
|
+
gs_float3_srgb_nonlinear_to_linear(f);
|
|
109
|
+
gs_premultiply_float4(f);
|
|
110
|
+
gs_float3_srgb_linear_to_nonlinear(f);
|
|
111
|
+
gs_float3_to_u8x3(u, f);
|
|
112
|
+
memcpy(data, &u, sizeof(u));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static inline void gs_premultiply_xyza_restrict(uint8_t *__restrict dst, const uint8_t *__restrict src)
|
|
116
|
+
{
|
|
117
|
+
uint8_t u[4];
|
|
118
|
+
float f[4];
|
|
119
|
+
memcpy(&u, src, sizeof(u));
|
|
120
|
+
gs_u8x4_to_float4(f, u);
|
|
121
|
+
gs_premultiply_float4(f);
|
|
122
|
+
gs_float3_to_u8x3(u, f);
|
|
123
|
+
memcpy(dst, &u, sizeof(u));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
static inline void gs_premultiply_xyza_srgb_restrict(uint8_t *__restrict dst, const uint8_t *__restrict src)
|
|
127
|
+
{
|
|
128
|
+
uint8_t u[4];
|
|
129
|
+
float f[4];
|
|
130
|
+
memcpy(&u, src, sizeof(u));
|
|
131
|
+
gs_u8x4_to_float4(f, u);
|
|
132
|
+
gs_float3_srgb_nonlinear_to_linear(f);
|
|
133
|
+
gs_premultiply_float4(f);
|
|
134
|
+
gs_float3_srgb_linear_to_nonlinear(f);
|
|
135
|
+
gs_float3_to_u8x3(u, f);
|
|
136
|
+
memcpy(dst, &u, sizeof(u));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static inline void gs_premultiply_xyza_loop(uint8_t *data, size_t texel_count)
|
|
140
|
+
{
|
|
141
|
+
for (size_t i = 0; i < texel_count; ++i) {
|
|
142
|
+
gs_premultiply_xyza(data);
|
|
143
|
+
data += 4;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
static inline void gs_premultiply_xyza_srgb_loop(uint8_t *data, size_t texel_count)
|
|
148
|
+
{
|
|
149
|
+
for (size_t i = 0; i < texel_count; ++i) {
|
|
150
|
+
gs_premultiply_xyza_srgb(data);
|
|
151
|
+
data += 4;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static inline void gs_premultiply_xyza_loop_restrict(uint8_t *__restrict dst, const uint8_t *__restrict src,
|
|
156
|
+
size_t texel_count)
|
|
157
|
+
{
|
|
158
|
+
for (size_t i = 0; i < texel_count; ++i) {
|
|
159
|
+
gs_premultiply_xyza_restrict(dst, src);
|
|
160
|
+
dst += 4;
|
|
161
|
+
src += 4;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static inline void gs_premultiply_xyza_srgb_loop_restrict(uint8_t *__restrict dst, const uint8_t *__restrict src,
|
|
166
|
+
size_t texel_count)
|
|
167
|
+
{
|
|
168
|
+
for (size_t i = 0; i < texel_count; ++i) {
|
|
169
|
+
gs_premultiply_xyza_srgb_restrict(dst, src);
|
|
170
|
+
dst += 4;
|
|
171
|
+
src += 4;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#ifdef __cplusplus
|
|
176
|
+
}
|
|
177
|
+
#endif
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program 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
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "../util/c99defs.h"
|
|
21
|
+
#include <math.h>
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
extern "C" {
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
struct vec2 {
|
|
28
|
+
union {
|
|
29
|
+
struct {
|
|
30
|
+
float x, y;
|
|
31
|
+
};
|
|
32
|
+
float ptr[2];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
static inline void vec2_zero(struct vec2 *dst)
|
|
37
|
+
{
|
|
38
|
+
dst->x = 0.0f;
|
|
39
|
+
dst->y = 0.0f;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static inline void vec2_set(struct vec2 *dst, float x, float y)
|
|
43
|
+
{
|
|
44
|
+
dst->x = x;
|
|
45
|
+
dst->y = y;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static inline void vec2_copy(struct vec2 *dst, const struct vec2 *v)
|
|
49
|
+
{
|
|
50
|
+
dst->x = v->x;
|
|
51
|
+
dst->y = v->y;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static inline void vec2_add(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
|
|
55
|
+
{
|
|
56
|
+
vec2_set(dst, v1->x + v2->x, v1->y + v2->y);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static inline void vec2_sub(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
|
|
60
|
+
{
|
|
61
|
+
vec2_set(dst, v1->x - v2->x, v1->y - v2->y);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static inline void vec2_mul(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
|
|
65
|
+
{
|
|
66
|
+
vec2_set(dst, v1->x * v2->x, v1->y * v2->y);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static inline void vec2_div(struct vec2 *dst, const struct vec2 *v1, const struct vec2 *v2)
|
|
70
|
+
{
|
|
71
|
+
vec2_set(dst, v1->x / v2->x, v1->y / v2->y);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static inline void vec2_addf(struct vec2 *dst, const struct vec2 *v, float f)
|
|
75
|
+
{
|
|
76
|
+
vec2_set(dst, v->x + f, v->y + f);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static inline void vec2_subf(struct vec2 *dst, const struct vec2 *v, float f)
|
|
80
|
+
{
|
|
81
|
+
vec2_set(dst, v->x - f, v->y - f);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static inline void vec2_mulf(struct vec2 *dst, const struct vec2 *v, float f)
|
|
85
|
+
{
|
|
86
|
+
vec2_set(dst, v->x * f, v->y * f);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static inline void vec2_divf(struct vec2 *dst, const struct vec2 *v, float f)
|
|
90
|
+
{
|
|
91
|
+
vec2_set(dst, v->x / f, v->y / f);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static inline void vec2_neg(struct vec2 *dst, const struct vec2 *v)
|
|
95
|
+
{
|
|
96
|
+
vec2_set(dst, -v->x, -v->y);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static inline float vec2_dot(const struct vec2 *v1, const struct vec2 *v2)
|
|
100
|
+
{
|
|
101
|
+
return v1->x * v2->x + v1->y * v2->y;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static inline float vec2_len(const struct vec2 *v)
|
|
105
|
+
{
|
|
106
|
+
return sqrtf(v->x * v->x + v->y * v->y);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static inline float vec2_dist(const struct vec2 *v1, const struct vec2 *v2)
|
|
110
|
+
{
|
|
111
|
+
struct vec2 temp;
|
|
112
|
+
vec2_sub(&temp, v1, v2);
|
|
113
|
+
return vec2_len(&temp);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static inline void vec2_minf(struct vec2 *dst, const struct vec2 *v, float val)
|
|
117
|
+
{
|
|
118
|
+
dst->x = (v->x < val) ? v->x : val;
|
|
119
|
+
dst->y = (v->y < val) ? v->y : val;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static inline void vec2_min(struct vec2 *dst, const struct vec2 *v, const struct vec2 *min_v)
|
|
123
|
+
{
|
|
124
|
+
dst->x = (v->x < min_v->x) ? v->x : min_v->x;
|
|
125
|
+
dst->y = (v->y < min_v->y) ? v->y : min_v->y;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static inline void vec2_maxf(struct vec2 *dst, const struct vec2 *v, float val)
|
|
129
|
+
{
|
|
130
|
+
dst->x = (v->x > val) ? v->x : val;
|
|
131
|
+
dst->y = (v->y > val) ? v->y : val;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static inline void vec2_max(struct vec2 *dst, const struct vec2 *v, const struct vec2 *max_v)
|
|
135
|
+
{
|
|
136
|
+
dst->x = (v->x > max_v->x) ? v->x : max_v->x;
|
|
137
|
+
dst->y = (v->y > max_v->y) ? v->y : max_v->y;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
EXPORT void vec2_abs(struct vec2 *dst, const struct vec2 *v);
|
|
141
|
+
EXPORT void vec2_floor(struct vec2 *dst, const struct vec2 *v);
|
|
142
|
+
EXPORT void vec2_ceil(struct vec2 *dst, const struct vec2 *v);
|
|
143
|
+
EXPORT int vec2_close(const struct vec2 *v1, const struct vec2 *v2, float epsilon);
|
|
144
|
+
EXPORT void vec2_norm(struct vec2 *dst, const struct vec2 *v);
|
|
145
|
+
|
|
146
|
+
#ifdef __cplusplus
|
|
147
|
+
}
|
|
148
|
+
#endif
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program 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
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "math-defs.h"
|
|
21
|
+
#include "vec4.h"
|
|
22
|
+
|
|
23
|
+
#include "../util/sse-intrin.h"
|
|
24
|
+
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
struct plane;
|
|
30
|
+
struct matrix3;
|
|
31
|
+
struct matrix4;
|
|
32
|
+
struct quat;
|
|
33
|
+
|
|
34
|
+
struct vec3 {
|
|
35
|
+
union {
|
|
36
|
+
struct {
|
|
37
|
+
float x, y, z, w;
|
|
38
|
+
};
|
|
39
|
+
float ptr[4];
|
|
40
|
+
__m128 m;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
static inline void vec3_zero(struct vec3 *v)
|
|
45
|
+
{
|
|
46
|
+
v->m = _mm_setzero_ps();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static inline void vec3_set(struct vec3 *dst, float x, float y, float z)
|
|
50
|
+
{
|
|
51
|
+
dst->m = _mm_set_ps(0.0f, z, y, x);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static inline void vec3_copy(struct vec3 *dst, const struct vec3 *v)
|
|
55
|
+
{
|
|
56
|
+
dst->m = v->m;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
EXPORT void vec3_from_vec4(struct vec3 *dst, const struct vec4 *v);
|
|
60
|
+
|
|
61
|
+
static inline void vec3_add(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
62
|
+
{
|
|
63
|
+
dst->m = _mm_add_ps(v1->m, v2->m);
|
|
64
|
+
dst->w = 0.0f;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static inline void vec3_sub(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
68
|
+
{
|
|
69
|
+
dst->m = _mm_sub_ps(v1->m, v2->m);
|
|
70
|
+
dst->w = 0.0f;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static inline void vec3_mul(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
74
|
+
{
|
|
75
|
+
dst->m = _mm_mul_ps(v1->m, v2->m);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static inline void vec3_div(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
79
|
+
{
|
|
80
|
+
dst->m = _mm_div_ps(v1->m, v2->m);
|
|
81
|
+
dst->w = 0.0f;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static inline void vec3_addf(struct vec3 *dst, const struct vec3 *v, float f)
|
|
85
|
+
{
|
|
86
|
+
dst->m = _mm_add_ps(v->m, _mm_set1_ps(f));
|
|
87
|
+
dst->w = 0.0f;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static inline void vec3_subf(struct vec3 *dst, const struct vec3 *v, float f)
|
|
91
|
+
{
|
|
92
|
+
dst->m = _mm_sub_ps(v->m, _mm_set1_ps(f));
|
|
93
|
+
dst->w = 0.0f;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static inline void vec3_mulf(struct vec3 *dst, const struct vec3 *v, float f)
|
|
97
|
+
{
|
|
98
|
+
dst->m = _mm_mul_ps(v->m, _mm_set1_ps(f));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static inline void vec3_divf(struct vec3 *dst, const struct vec3 *v, float f)
|
|
102
|
+
{
|
|
103
|
+
dst->m = _mm_div_ps(v->m, _mm_set1_ps(f));
|
|
104
|
+
dst->w = 0.0f;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static inline float vec3_dot(const struct vec3 *v1, const struct vec3 *v2)
|
|
108
|
+
{
|
|
109
|
+
struct vec3 add;
|
|
110
|
+
__m128 mul = _mm_mul_ps(v1->m, v2->m);
|
|
111
|
+
add.m = _mm_add_ps(_mm_movehl_ps(mul, mul), mul);
|
|
112
|
+
add.m = _mm_add_ps(_mm_shuffle_ps(add.m, add.m, 0x55), add.m);
|
|
113
|
+
return add.x;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static inline void vec3_cross(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
117
|
+
{
|
|
118
|
+
__m128 s1v1 = _mm_shuffle_ps(v1->m, v1->m, _MM_SHUFFLE(3, 0, 2, 1));
|
|
119
|
+
__m128 s1v2 = _mm_shuffle_ps(v2->m, v2->m, _MM_SHUFFLE(3, 1, 0, 2));
|
|
120
|
+
__m128 s2v1 = _mm_shuffle_ps(v1->m, v1->m, _MM_SHUFFLE(3, 1, 0, 2));
|
|
121
|
+
__m128 s2v2 = _mm_shuffle_ps(v2->m, v2->m, _MM_SHUFFLE(3, 0, 2, 1));
|
|
122
|
+
dst->m = _mm_sub_ps(_mm_mul_ps(s1v1, s1v2), _mm_mul_ps(s2v1, s2v2));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static inline void vec3_neg(struct vec3 *dst, const struct vec3 *v)
|
|
126
|
+
{
|
|
127
|
+
dst->x = -v->x;
|
|
128
|
+
dst->y = -v->y;
|
|
129
|
+
dst->z = -v->z;
|
|
130
|
+
dst->w = 0.0f;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static inline float vec3_len(const struct vec3 *v)
|
|
134
|
+
{
|
|
135
|
+
float dot_val = vec3_dot(v, v);
|
|
136
|
+
return (dot_val > 0.0f) ? sqrtf(dot_val) : 0.0f;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static inline float vec3_dist(const struct vec3 *v1, const struct vec3 *v2)
|
|
140
|
+
{
|
|
141
|
+
struct vec3 temp;
|
|
142
|
+
float dot_val;
|
|
143
|
+
|
|
144
|
+
vec3_sub(&temp, v1, v2);
|
|
145
|
+
dot_val = vec3_dot(&temp, &temp);
|
|
146
|
+
return (dot_val > 0.0f) ? sqrtf(dot_val) : 0.0f;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static inline void vec3_norm(struct vec3 *dst, const struct vec3 *v)
|
|
150
|
+
{
|
|
151
|
+
float dot_val = vec3_dot(v, v);
|
|
152
|
+
dst->m = (dot_val > 0.0f) ? _mm_mul_ps(v->m, _mm_set1_ps(1.0f / sqrtf(dot_val))) : _mm_setzero_ps();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static inline bool vec3_close(const struct vec3 *v1, const struct vec3 *v2, float epsilon)
|
|
156
|
+
{
|
|
157
|
+
struct vec3 test;
|
|
158
|
+
vec3_sub(&test, v1, v2);
|
|
159
|
+
return test.x < epsilon && test.y < epsilon && test.z < epsilon;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static inline void vec3_min(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
163
|
+
{
|
|
164
|
+
dst->m = _mm_min_ps(v1->m, v2->m);
|
|
165
|
+
dst->w = 0.0f;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static inline void vec3_minf(struct vec3 *dst, const struct vec3 *v, float f)
|
|
169
|
+
{
|
|
170
|
+
dst->m = _mm_min_ps(v->m, _mm_set1_ps(f));
|
|
171
|
+
dst->w = 0.0f;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static inline void vec3_max(struct vec3 *dst, const struct vec3 *v1, const struct vec3 *v2)
|
|
175
|
+
{
|
|
176
|
+
dst->m = _mm_max_ps(v1->m, v2->m);
|
|
177
|
+
dst->w = 0.0f;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static inline void vec3_maxf(struct vec3 *dst, const struct vec3 *v, float f)
|
|
181
|
+
{
|
|
182
|
+
dst->m = _mm_max_ps(v->m, _mm_set1_ps(f));
|
|
183
|
+
dst->w = 0.0f;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static inline void vec3_abs(struct vec3 *dst, const struct vec3 *v)
|
|
187
|
+
{
|
|
188
|
+
dst->x = fabsf(v->x);
|
|
189
|
+
dst->y = fabsf(v->y);
|
|
190
|
+
dst->z = fabsf(v->z);
|
|
191
|
+
dst->w = 0.0f;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static inline void vec3_floor(struct vec3 *dst, const struct vec3 *v)
|
|
195
|
+
{
|
|
196
|
+
dst->x = floorf(v->x);
|
|
197
|
+
dst->y = floorf(v->y);
|
|
198
|
+
dst->z = floorf(v->z);
|
|
199
|
+
dst->w = 0.0f;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static inline void vec3_ceil(struct vec3 *dst, const struct vec3 *v)
|
|
203
|
+
{
|
|
204
|
+
dst->x = ceilf(v->x);
|
|
205
|
+
dst->y = ceilf(v->y);
|
|
206
|
+
dst->z = ceilf(v->z);
|
|
207
|
+
dst->w = 0.0f;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
EXPORT float vec3_plane_dist(const struct vec3 *v, const struct plane *p);
|
|
211
|
+
|
|
212
|
+
EXPORT void vec3_transform(struct vec3 *dst, const struct vec3 *v, const struct matrix4 *m);
|
|
213
|
+
|
|
214
|
+
EXPORT void vec3_rotate(struct vec3 *dst, const struct vec3 *v, const struct matrix3 *m);
|
|
215
|
+
EXPORT void vec3_transform3x4(struct vec3 *dst, const struct vec3 *v, const struct matrix3 *m);
|
|
216
|
+
|
|
217
|
+
EXPORT void vec3_mirror(struct vec3 *dst, const struct vec3 *v, const struct plane *p);
|
|
218
|
+
EXPORT void vec3_mirrorv(struct vec3 *dst, const struct vec3 *v, const struct vec3 *vec);
|
|
219
|
+
|
|
220
|
+
EXPORT void vec3_rand(struct vec3 *dst, int positive_only);
|
|
221
|
+
|
|
222
|
+
#ifdef __cplusplus
|
|
223
|
+
}
|
|
224
|
+
#endif
|