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,319 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "c99defs.h"
|
|
20
|
+
#include <string.h>
|
|
21
|
+
#include <stdlib.h>
|
|
22
|
+
#include <assert.h>
|
|
23
|
+
|
|
24
|
+
#include "bmem.h"
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/* Double-ended Queue */
|
|
31
|
+
|
|
32
|
+
struct deque {
|
|
33
|
+
void *data;
|
|
34
|
+
size_t size;
|
|
35
|
+
|
|
36
|
+
size_t start_pos;
|
|
37
|
+
size_t end_pos;
|
|
38
|
+
size_t capacity;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
static inline void deque_init(struct deque *dq)
|
|
42
|
+
{
|
|
43
|
+
memset(dq, 0, sizeof(struct deque));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static inline void deque_free(struct deque *dq)
|
|
47
|
+
{
|
|
48
|
+
bfree(dq->data);
|
|
49
|
+
memset(dq, 0, sizeof(struct deque));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static inline void deque_reorder_data(struct deque *dq, size_t new_capacity)
|
|
53
|
+
{
|
|
54
|
+
size_t difference;
|
|
55
|
+
uint8_t *data;
|
|
56
|
+
|
|
57
|
+
if (!dq->size || !dq->start_pos || dq->end_pos > dq->start_pos)
|
|
58
|
+
return;
|
|
59
|
+
|
|
60
|
+
difference = new_capacity - dq->capacity;
|
|
61
|
+
data = (uint8_t *)dq->data + dq->start_pos;
|
|
62
|
+
memmove(data + difference, data, dq->capacity - dq->start_pos);
|
|
63
|
+
dq->start_pos += difference;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static inline void deque_ensure_capacity(struct deque *dq)
|
|
67
|
+
{
|
|
68
|
+
size_t new_capacity;
|
|
69
|
+
if (dq->size <= dq->capacity)
|
|
70
|
+
return;
|
|
71
|
+
|
|
72
|
+
new_capacity = dq->capacity * 2;
|
|
73
|
+
if (dq->size > new_capacity)
|
|
74
|
+
new_capacity = dq->size;
|
|
75
|
+
|
|
76
|
+
dq->data = brealloc(dq->data, new_capacity);
|
|
77
|
+
deque_reorder_data(dq, new_capacity);
|
|
78
|
+
dq->capacity = new_capacity;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static inline void deque_reserve(struct deque *dq, size_t capacity)
|
|
82
|
+
{
|
|
83
|
+
if (capacity <= dq->capacity)
|
|
84
|
+
return;
|
|
85
|
+
|
|
86
|
+
dq->data = brealloc(dq->data, capacity);
|
|
87
|
+
deque_reorder_data(dq, capacity);
|
|
88
|
+
dq->capacity = capacity;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static inline void deque_upsize(struct deque *dq, size_t size)
|
|
92
|
+
{
|
|
93
|
+
size_t add_size = size - dq->size;
|
|
94
|
+
size_t new_end_pos = dq->end_pos + add_size;
|
|
95
|
+
|
|
96
|
+
if (size <= dq->size)
|
|
97
|
+
return;
|
|
98
|
+
|
|
99
|
+
dq->size = size;
|
|
100
|
+
deque_ensure_capacity(dq);
|
|
101
|
+
|
|
102
|
+
if (new_end_pos > dq->capacity) {
|
|
103
|
+
size_t back_size = dq->capacity - dq->end_pos;
|
|
104
|
+
size_t loop_size = add_size - back_size;
|
|
105
|
+
|
|
106
|
+
if (back_size)
|
|
107
|
+
memset((uint8_t *)dq->data + dq->end_pos, 0, back_size);
|
|
108
|
+
|
|
109
|
+
memset(dq->data, 0, loop_size);
|
|
110
|
+
new_end_pos -= dq->capacity;
|
|
111
|
+
} else {
|
|
112
|
+
memset((uint8_t *)dq->data + dq->end_pos, 0, add_size);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
dq->end_pos = new_end_pos;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Overwrites data at a specific point in the buffer (relative). */
|
|
119
|
+
static inline void deque_place(struct deque *dq, size_t position, const void *data, size_t size)
|
|
120
|
+
{
|
|
121
|
+
size_t end_point = position + size;
|
|
122
|
+
size_t data_end_pos;
|
|
123
|
+
|
|
124
|
+
if (end_point > dq->size)
|
|
125
|
+
deque_upsize(dq, end_point);
|
|
126
|
+
|
|
127
|
+
position += dq->start_pos;
|
|
128
|
+
if (position >= dq->capacity)
|
|
129
|
+
position -= dq->capacity;
|
|
130
|
+
|
|
131
|
+
data_end_pos = position + size;
|
|
132
|
+
if (data_end_pos > dq->capacity) {
|
|
133
|
+
size_t back_size = data_end_pos - dq->capacity;
|
|
134
|
+
size_t loop_size = size - back_size;
|
|
135
|
+
|
|
136
|
+
memcpy((uint8_t *)dq->data + position, data, loop_size);
|
|
137
|
+
memcpy(dq->data, (uint8_t *)data + loop_size, back_size);
|
|
138
|
+
} else {
|
|
139
|
+
memcpy((uint8_t *)dq->data + position, data, size);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static inline void deque_push_back(struct deque *dq, const void *data, size_t size)
|
|
144
|
+
{
|
|
145
|
+
size_t new_end_pos = dq->end_pos + size;
|
|
146
|
+
|
|
147
|
+
dq->size += size;
|
|
148
|
+
deque_ensure_capacity(dq);
|
|
149
|
+
|
|
150
|
+
if (new_end_pos > dq->capacity) {
|
|
151
|
+
size_t back_size = dq->capacity - dq->end_pos;
|
|
152
|
+
size_t loop_size = size - back_size;
|
|
153
|
+
|
|
154
|
+
if (back_size)
|
|
155
|
+
memcpy((uint8_t *)dq->data + dq->end_pos, data, back_size);
|
|
156
|
+
memcpy(dq->data, (uint8_t *)data + back_size, loop_size);
|
|
157
|
+
|
|
158
|
+
new_end_pos -= dq->capacity;
|
|
159
|
+
} else {
|
|
160
|
+
memcpy((uint8_t *)dq->data + dq->end_pos, data, size);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
dq->end_pos = new_end_pos;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static inline void deque_push_front(struct deque *dq, const void *data, size_t size)
|
|
167
|
+
{
|
|
168
|
+
dq->size += size;
|
|
169
|
+
deque_ensure_capacity(dq);
|
|
170
|
+
|
|
171
|
+
if (dq->size == size) {
|
|
172
|
+
dq->start_pos = 0;
|
|
173
|
+
dq->end_pos = size;
|
|
174
|
+
memcpy((uint8_t *)dq->data, data, size);
|
|
175
|
+
|
|
176
|
+
} else if (dq->start_pos < size) {
|
|
177
|
+
size_t back_size = size - dq->start_pos;
|
|
178
|
+
|
|
179
|
+
if (dq->start_pos)
|
|
180
|
+
memcpy(dq->data, (uint8_t *)data + back_size, dq->start_pos);
|
|
181
|
+
|
|
182
|
+
dq->start_pos = dq->capacity - back_size;
|
|
183
|
+
memcpy((uint8_t *)dq->data + dq->start_pos, data, back_size);
|
|
184
|
+
} else {
|
|
185
|
+
dq->start_pos -= size;
|
|
186
|
+
memcpy((uint8_t *)dq->data + dq->start_pos, data, size);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static inline void deque_push_back_zero(struct deque *dq, size_t size)
|
|
191
|
+
{
|
|
192
|
+
size_t new_end_pos = dq->end_pos + size;
|
|
193
|
+
|
|
194
|
+
dq->size += size;
|
|
195
|
+
deque_ensure_capacity(dq);
|
|
196
|
+
|
|
197
|
+
if (new_end_pos > dq->capacity) {
|
|
198
|
+
size_t back_size = dq->capacity - dq->end_pos;
|
|
199
|
+
size_t loop_size = size - back_size;
|
|
200
|
+
|
|
201
|
+
if (back_size)
|
|
202
|
+
memset((uint8_t *)dq->data + dq->end_pos, 0, back_size);
|
|
203
|
+
memset(dq->data, 0, loop_size);
|
|
204
|
+
|
|
205
|
+
new_end_pos -= dq->capacity;
|
|
206
|
+
} else {
|
|
207
|
+
memset((uint8_t *)dq->data + dq->end_pos, 0, size);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
dq->end_pos = new_end_pos;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
static inline void deque_push_front_zero(struct deque *dq, size_t size)
|
|
214
|
+
{
|
|
215
|
+
dq->size += size;
|
|
216
|
+
deque_ensure_capacity(dq);
|
|
217
|
+
|
|
218
|
+
if (dq->size == size) {
|
|
219
|
+
dq->start_pos = 0;
|
|
220
|
+
dq->end_pos = size;
|
|
221
|
+
memset((uint8_t *)dq->data, 0, size);
|
|
222
|
+
|
|
223
|
+
} else if (dq->start_pos < size) {
|
|
224
|
+
size_t back_size = size - dq->start_pos;
|
|
225
|
+
|
|
226
|
+
if (dq->start_pos)
|
|
227
|
+
memset(dq->data, 0, dq->start_pos);
|
|
228
|
+
|
|
229
|
+
dq->start_pos = dq->capacity - back_size;
|
|
230
|
+
memset((uint8_t *)dq->data + dq->start_pos, 0, back_size);
|
|
231
|
+
} else {
|
|
232
|
+
dq->start_pos -= size;
|
|
233
|
+
memset((uint8_t *)dq->data + dq->start_pos, 0, size);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static inline void deque_peek_front(struct deque *dq, void *data, size_t size)
|
|
238
|
+
{
|
|
239
|
+
assert(size <= dq->size);
|
|
240
|
+
|
|
241
|
+
if (data) {
|
|
242
|
+
size_t start_size = dq->capacity - dq->start_pos;
|
|
243
|
+
|
|
244
|
+
if (start_size < size) {
|
|
245
|
+
memcpy(data, (uint8_t *)dq->data + dq->start_pos, start_size);
|
|
246
|
+
memcpy((uint8_t *)data + start_size, dq->data, size - start_size);
|
|
247
|
+
} else {
|
|
248
|
+
memcpy(data, (uint8_t *)dq->data + dq->start_pos, size);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
static inline void deque_peek_back(struct deque *dq, void *data, size_t size)
|
|
254
|
+
{
|
|
255
|
+
assert(size <= dq->size);
|
|
256
|
+
|
|
257
|
+
if (data) {
|
|
258
|
+
size_t back_size = (dq->end_pos ? dq->end_pos : dq->capacity);
|
|
259
|
+
|
|
260
|
+
if (back_size < size) {
|
|
261
|
+
size_t front_size = size - back_size;
|
|
262
|
+
size_t new_end_pos = dq->capacity - front_size;
|
|
263
|
+
|
|
264
|
+
memcpy((uint8_t *)data + (size - back_size), dq->data, back_size);
|
|
265
|
+
memcpy(data, (uint8_t *)dq->data + new_end_pos, front_size);
|
|
266
|
+
} else {
|
|
267
|
+
memcpy(data, (uint8_t *)dq->data + dq->end_pos - size, size);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
static inline void deque_pop_front(struct deque *dq, void *data, size_t size)
|
|
273
|
+
{
|
|
274
|
+
deque_peek_front(dq, data, size);
|
|
275
|
+
|
|
276
|
+
dq->size -= size;
|
|
277
|
+
if (!dq->size) {
|
|
278
|
+
dq->start_pos = dq->end_pos = 0;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
dq->start_pos += size;
|
|
283
|
+
if (dq->start_pos >= dq->capacity)
|
|
284
|
+
dq->start_pos -= dq->capacity;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
static inline void deque_pop_back(struct deque *dq, void *data, size_t size)
|
|
288
|
+
{
|
|
289
|
+
deque_peek_back(dq, data, size);
|
|
290
|
+
|
|
291
|
+
dq->size -= size;
|
|
292
|
+
if (!dq->size) {
|
|
293
|
+
dq->start_pos = dq->end_pos = 0;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (dq->end_pos <= size)
|
|
298
|
+
dq->end_pos = dq->capacity - (size - dq->end_pos);
|
|
299
|
+
else
|
|
300
|
+
dq->end_pos -= size;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
static inline void *deque_data(struct deque *dq, size_t idx)
|
|
304
|
+
{
|
|
305
|
+
uint8_t *ptr = (uint8_t *)dq->data;
|
|
306
|
+
size_t offset = dq->start_pos + idx;
|
|
307
|
+
|
|
308
|
+
if (idx >= dq->size)
|
|
309
|
+
return NULL;
|
|
310
|
+
|
|
311
|
+
if (offset >= dq->capacity)
|
|
312
|
+
offset -= dq->capacity;
|
|
313
|
+
|
|
314
|
+
return ptr + offset;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
#ifdef __cplusplus
|
|
318
|
+
}
|
|
319
|
+
#endif
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include <string.h>
|
|
20
|
+
#include <stdarg.h>
|
|
21
|
+
#include "c99defs.h"
|
|
22
|
+
#include "bmem.h"
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Dynamic string
|
|
26
|
+
*
|
|
27
|
+
* Helper struct/functions for dynamically sizing string buffers.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifdef __cplusplus
|
|
31
|
+
extern "C" {
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
struct strref;
|
|
35
|
+
|
|
36
|
+
struct dstr {
|
|
37
|
+
char *array;
|
|
38
|
+
size_t len; /* number of characters, excluding null terminator */
|
|
39
|
+
size_t capacity;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
#ifndef _MSC_VER
|
|
43
|
+
#define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
|
|
44
|
+
#else
|
|
45
|
+
#define PRINTFATTR(f, a)
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
EXPORT int astrcmpi(const char *str1, const char *str2);
|
|
49
|
+
EXPORT int wstrcmpi(const wchar_t *str1, const wchar_t *str2);
|
|
50
|
+
EXPORT int astrcmp_n(const char *str1, const char *str2, size_t n);
|
|
51
|
+
EXPORT int wstrcmp_n(const wchar_t *str1, const wchar_t *str2, size_t n);
|
|
52
|
+
EXPORT int astrcmpi_n(const char *str1, const char *str2, size_t n);
|
|
53
|
+
EXPORT int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n);
|
|
54
|
+
|
|
55
|
+
EXPORT char *astrstri(const char *str, const char *find);
|
|
56
|
+
EXPORT wchar_t *wstrstri(const wchar_t *str, const wchar_t *find);
|
|
57
|
+
|
|
58
|
+
EXPORT char *strdepad(char *str);
|
|
59
|
+
EXPORT wchar_t *wcsdepad(wchar_t *str);
|
|
60
|
+
|
|
61
|
+
EXPORT char **strlist_split(const char *str, char split_ch, bool include_empty);
|
|
62
|
+
EXPORT void strlist_free(char **strlist);
|
|
63
|
+
|
|
64
|
+
static inline void dstr_init(struct dstr *dst);
|
|
65
|
+
static inline void dstr_init_move(struct dstr *dst, struct dstr *src);
|
|
66
|
+
static inline void dstr_init_move_array(struct dstr *dst, char *str);
|
|
67
|
+
static inline void dstr_init_copy(struct dstr *dst, const char *src);
|
|
68
|
+
static inline void dstr_init_copy_dstr(struct dstr *dst, const struct dstr *src);
|
|
69
|
+
EXPORT void dstr_init_copy_strref(struct dstr *dst, const struct strref *src);
|
|
70
|
+
|
|
71
|
+
static inline void dstr_free(struct dstr *dst);
|
|
72
|
+
static inline void dstr_array_free(struct dstr *array, const size_t count);
|
|
73
|
+
|
|
74
|
+
static inline void dstr_move(struct dstr *dst, struct dstr *src);
|
|
75
|
+
static inline void dstr_move_array(struct dstr *dst, char *str);
|
|
76
|
+
|
|
77
|
+
EXPORT void dstr_copy(struct dstr *dst, const char *array);
|
|
78
|
+
static inline void dstr_copy_dstr(struct dstr *dst, const struct dstr *src);
|
|
79
|
+
EXPORT void dstr_copy_strref(struct dstr *dst, const struct strref *src);
|
|
80
|
+
|
|
81
|
+
EXPORT void dstr_ncopy(struct dstr *dst, const char *array, const size_t len);
|
|
82
|
+
EXPORT void dstr_ncopy_dstr(struct dstr *dst, const struct dstr *src, const size_t len);
|
|
83
|
+
|
|
84
|
+
static inline void dstr_resize(struct dstr *dst, const size_t num);
|
|
85
|
+
static inline void dstr_reserve(struct dstr *dst, const size_t num);
|
|
86
|
+
|
|
87
|
+
static inline bool dstr_is_empty(const struct dstr *str);
|
|
88
|
+
|
|
89
|
+
static inline void dstr_cat(struct dstr *dst, const char *array);
|
|
90
|
+
EXPORT void dstr_cat_dstr(struct dstr *dst, const struct dstr *str);
|
|
91
|
+
EXPORT void dstr_cat_strref(struct dstr *dst, const struct strref *str);
|
|
92
|
+
|
|
93
|
+
static inline void dstr_cat_ch(struct dstr *dst, char ch);
|
|
94
|
+
|
|
95
|
+
EXPORT void dstr_ncat(struct dstr *dst, const char *array, const size_t len);
|
|
96
|
+
EXPORT void dstr_ncat_dstr(struct dstr *dst, const struct dstr *str, const size_t len);
|
|
97
|
+
|
|
98
|
+
EXPORT void dstr_insert(struct dstr *dst, const size_t idx, const char *array);
|
|
99
|
+
EXPORT void dstr_insert_dstr(struct dstr *dst, const size_t idx, const struct dstr *str);
|
|
100
|
+
EXPORT void dstr_insert_ch(struct dstr *dst, const size_t idx, const char ch);
|
|
101
|
+
|
|
102
|
+
EXPORT void dstr_remove(struct dstr *dst, const size_t idx, const size_t count);
|
|
103
|
+
|
|
104
|
+
PRINTFATTR(2, 3)
|
|
105
|
+
EXPORT void dstr_printf(struct dstr *dst, const char *format, ...);
|
|
106
|
+
PRINTFATTR(2, 3)
|
|
107
|
+
EXPORT void dstr_catf(struct dstr *dst, const char *format, ...);
|
|
108
|
+
|
|
109
|
+
EXPORT void dstr_vprintf(struct dstr *dst, const char *format, va_list args);
|
|
110
|
+
EXPORT void dstr_vcatf(struct dstr *dst, const char *format, va_list args);
|
|
111
|
+
|
|
112
|
+
EXPORT void dstr_safe_printf(struct dstr *dst, const char *format, const char *val1, const char *val2, const char *val3,
|
|
113
|
+
const char *val4);
|
|
114
|
+
|
|
115
|
+
static inline const char *dstr_find_i(const struct dstr *str, const char *find);
|
|
116
|
+
static inline const char *dstr_find(const struct dstr *str, const char *find);
|
|
117
|
+
|
|
118
|
+
EXPORT void dstr_replace(struct dstr *str, const char *find, const char *replace);
|
|
119
|
+
|
|
120
|
+
static inline int dstr_cmp(const struct dstr *str1, const char *str2);
|
|
121
|
+
static inline int dstr_cmpi(const struct dstr *str1, const char *str2);
|
|
122
|
+
static inline int dstr_ncmp(const struct dstr *str1, const char *str2, const size_t n);
|
|
123
|
+
static inline int dstr_ncmpi(const struct dstr *str1, const char *str2, const size_t n);
|
|
124
|
+
|
|
125
|
+
EXPORT void dstr_depad(struct dstr *dst);
|
|
126
|
+
|
|
127
|
+
EXPORT void dstr_left(struct dstr *dst, const struct dstr *str, const size_t pos);
|
|
128
|
+
EXPORT void dstr_mid(struct dstr *dst, const struct dstr *str, const size_t start, const size_t count);
|
|
129
|
+
EXPORT void dstr_right(struct dstr *dst, const struct dstr *str, const size_t pos);
|
|
130
|
+
|
|
131
|
+
static inline char dstr_end(const struct dstr *str);
|
|
132
|
+
|
|
133
|
+
EXPORT void dstr_from_mbs(struct dstr *dst, const char *mbstr);
|
|
134
|
+
EXPORT char *dstr_to_mbs(const struct dstr *str);
|
|
135
|
+
EXPORT void dstr_from_wcs(struct dstr *dst, const wchar_t *wstr);
|
|
136
|
+
EXPORT wchar_t *dstr_to_wcs(const struct dstr *str);
|
|
137
|
+
|
|
138
|
+
EXPORT void dstr_to_upper(struct dstr *str);
|
|
139
|
+
EXPORT void dstr_to_lower(struct dstr *str);
|
|
140
|
+
|
|
141
|
+
#undef PRINTFATTR
|
|
142
|
+
|
|
143
|
+
/* ------------------------------------------------------------------------- */
|
|
144
|
+
|
|
145
|
+
static inline void dstr_init(struct dstr *dst)
|
|
146
|
+
{
|
|
147
|
+
dst->array = NULL;
|
|
148
|
+
dst->len = 0;
|
|
149
|
+
dst->capacity = 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static inline void dstr_init_move_array(struct dstr *dst, char *str)
|
|
153
|
+
{
|
|
154
|
+
dst->array = str;
|
|
155
|
+
dst->len = (!str) ? 0 : strlen(str);
|
|
156
|
+
dst->capacity = dst->len + 1;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static inline void dstr_init_move(struct dstr *dst, struct dstr *src)
|
|
160
|
+
{
|
|
161
|
+
*dst = *src;
|
|
162
|
+
dstr_init(src);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static inline void dstr_init_copy(struct dstr *dst, const char *str)
|
|
166
|
+
{
|
|
167
|
+
dstr_init(dst);
|
|
168
|
+
dstr_copy(dst, str);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static inline void dstr_init_copy_dstr(struct dstr *dst, const struct dstr *src)
|
|
172
|
+
{
|
|
173
|
+
dstr_init(dst);
|
|
174
|
+
dstr_copy_dstr(dst, src);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
static inline void dstr_free(struct dstr *dst)
|
|
178
|
+
{
|
|
179
|
+
bfree(dst->array);
|
|
180
|
+
dst->array = NULL;
|
|
181
|
+
dst->len = 0;
|
|
182
|
+
dst->capacity = 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static inline void dstr_array_free(struct dstr *array, const size_t count)
|
|
186
|
+
{
|
|
187
|
+
size_t i;
|
|
188
|
+
for (i = 0; i < count; i++)
|
|
189
|
+
dstr_free(array + i);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
static inline void dstr_move_array(struct dstr *dst, char *str)
|
|
193
|
+
{
|
|
194
|
+
dstr_free(dst);
|
|
195
|
+
dst->array = str;
|
|
196
|
+
dst->len = (!str) ? 0 : strlen(str);
|
|
197
|
+
dst->capacity = dst->len + 1;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
static inline void dstr_move(struct dstr *dst, struct dstr *src)
|
|
201
|
+
{
|
|
202
|
+
dstr_free(dst);
|
|
203
|
+
dstr_init_move(dst, src);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static inline void dstr_ensure_capacity(struct dstr *dst, const size_t new_size)
|
|
207
|
+
{
|
|
208
|
+
size_t new_cap;
|
|
209
|
+
if (new_size <= dst->capacity)
|
|
210
|
+
return;
|
|
211
|
+
|
|
212
|
+
new_cap = (!dst->capacity) ? new_size : dst->capacity * 2;
|
|
213
|
+
if (new_size > new_cap)
|
|
214
|
+
new_cap = new_size;
|
|
215
|
+
dst->array = (char *)brealloc(dst->array, new_cap);
|
|
216
|
+
dst->capacity = new_cap;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static inline void dstr_copy_dstr(struct dstr *dst, const struct dstr *src)
|
|
220
|
+
{
|
|
221
|
+
dstr_free(dst);
|
|
222
|
+
|
|
223
|
+
if (src->len) {
|
|
224
|
+
dstr_ensure_capacity(dst, src->len + 1);
|
|
225
|
+
memcpy(dst->array, src->array, src->len + 1);
|
|
226
|
+
dst->len = src->len;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static inline void dstr_reserve(struct dstr *dst, const size_t capacity)
|
|
231
|
+
{
|
|
232
|
+
if (capacity == 0 || capacity <= dst->len)
|
|
233
|
+
return;
|
|
234
|
+
|
|
235
|
+
dst->array = (char *)brealloc(dst->array, capacity);
|
|
236
|
+
dst->capacity = capacity;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
static inline void dstr_resize(struct dstr *dst, const size_t num)
|
|
240
|
+
{
|
|
241
|
+
if (!num) {
|
|
242
|
+
dstr_free(dst);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
dstr_ensure_capacity(dst, num + 1);
|
|
247
|
+
dst->array[num] = 0;
|
|
248
|
+
dst->len = num;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
static inline bool dstr_is_empty(const struct dstr *str)
|
|
252
|
+
{
|
|
253
|
+
if (!str->array || !str->len)
|
|
254
|
+
return true;
|
|
255
|
+
if (!*str->array)
|
|
256
|
+
return true;
|
|
257
|
+
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
static inline void dstr_cat(struct dstr *dst, const char *array)
|
|
262
|
+
{
|
|
263
|
+
size_t len;
|
|
264
|
+
if (!array || !*array)
|
|
265
|
+
return;
|
|
266
|
+
|
|
267
|
+
len = strlen(array);
|
|
268
|
+
dstr_ncat(dst, array, len);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
static inline void dstr_cat_ch(struct dstr *dst, char ch)
|
|
272
|
+
{
|
|
273
|
+
dstr_ensure_capacity(dst, ++dst->len + 1);
|
|
274
|
+
dst->array[dst->len - 1] = ch;
|
|
275
|
+
dst->array[dst->len] = 0;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
static inline const char *dstr_find_i(const struct dstr *str, const char *find)
|
|
279
|
+
{
|
|
280
|
+
return astrstri(str->array, find);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
static inline const char *dstr_find(const struct dstr *str, const char *find)
|
|
284
|
+
{
|
|
285
|
+
return strstr(str->array, find);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
static inline int dstr_cmp(const struct dstr *str1, const char *str2)
|
|
289
|
+
{
|
|
290
|
+
const char *s1 = str1->array ? str1->array : "";
|
|
291
|
+
const char *s2 = str2 ? str2 : "";
|
|
292
|
+
return strcmp(s1, s2);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
static inline int dstr_cmpi(const struct dstr *str1, const char *str2)
|
|
296
|
+
{
|
|
297
|
+
return astrcmpi(str1->array, str2);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
static inline int dstr_ncmp(const struct dstr *str1, const char *str2, const size_t n)
|
|
301
|
+
{
|
|
302
|
+
return astrcmp_n(str1->array, str2, n);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
static inline int dstr_ncmpi(const struct dstr *str1, const char *str2, const size_t n)
|
|
306
|
+
{
|
|
307
|
+
return astrcmpi_n(str1->array, str2, n);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
static inline char dstr_end(const struct dstr *str)
|
|
311
|
+
{
|
|
312
|
+
if (dstr_is_empty(str))
|
|
313
|
+
return 0;
|
|
314
|
+
|
|
315
|
+
return str->array[str->len - 1];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
#ifdef __cplusplus
|
|
319
|
+
}
|
|
320
|
+
#endif
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "serializer.h"
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
extern "C" {
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
EXPORT bool file_input_serializer_init(struct serializer *s, const char *path);
|
|
26
|
+
EXPORT void file_input_serializer_free(struct serializer *s);
|
|
27
|
+
|
|
28
|
+
EXPORT bool file_output_serializer_init(struct serializer *s, const char *path);
|
|
29
|
+
EXPORT bool file_output_serializer_init_safe(struct serializer *s, const char *path, const char *temp_ext);
|
|
30
|
+
EXPORT void file_output_serializer_free(struct serializer *s);
|
|
31
|
+
|
|
32
|
+
#ifdef __cplusplus
|
|
33
|
+
}
|
|
34
|
+
#endif
|