@scrypted/libav 1.0.171 → 1.0.173
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/package.json +1 -1
- package/.vscode/launch.json +0 -23
- package/.vscode/settings.json +0 -32
- package/darwin.md +0 -24
- package/src/bsf.cpp +0 -213
- package/src/bsf.h +0 -35
- package/src/build-ffmpeg-darwin.sh +0 -13
- package/src/build-ffmpeg-linux.sh +0 -52
- package/src/build-ffmpeg-msys.sh +0 -41
- package/src/build-ffmpeg-windows.bat +0 -8
- package/src/codeccontext.cpp +0 -602
- package/src/codeccontext.h +0 -50
- package/src/error.cpp +0 -33
- package/src/error.h +0 -19
- package/src/ffmpeg-graphparser.cpp +0 -302
- package/src/filter.cpp +0 -487
- package/src/filter.h +0 -37
- package/src/flags.ts +0 -63
- package/src/formatcontext.cpp +0 -899
- package/src/formatcontext.h +0 -47
- package/src/frame.cpp +0 -667
- package/src/frame.h +0 -55
- package/src/index.ts +0 -356
- package/src/packet.cpp +0 -182
- package/src/packet.h +0 -42
- package/src/pkgconfig/glslang.pc +0 -10
- package/src/profiles.ts +0 -108
- package/src/tsconfig.json +0 -26
- package/tsconfig.json +0 -26
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
extern "C"
|
|
2
|
-
{
|
|
3
|
-
#include <libavfilter/avfilter.h>
|
|
4
|
-
#include <libavfilter/buffersrc.h>
|
|
5
|
-
#include <libavfilter/buffersink.h>
|
|
6
|
-
#include <libavutil/opt.h>
|
|
7
|
-
#include <libavutil/avassert.h>
|
|
8
|
-
#include <libavutil/avstring.h>
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
#include "error.h"
|
|
12
|
-
|
|
13
|
-
#define WHITESPACES " \n\t\r"
|
|
14
|
-
|
|
15
|
-
// print an error message if some options were not found
|
|
16
|
-
static void log_unknown_opt(const AVFilterGraphSegment *seg)
|
|
17
|
-
{
|
|
18
|
-
for (size_t i = 0; i < seg->nb_chains; i++) {
|
|
19
|
-
const AVFilterChain *ch = seg->chains[i];
|
|
20
|
-
|
|
21
|
-
for (size_t j = 0; j < ch->nb_filters; j++) {
|
|
22
|
-
const AVFilterParams *p = ch->filters[j];
|
|
23
|
-
const AVDictionaryEntry *e;
|
|
24
|
-
|
|
25
|
-
if (!p->filter)
|
|
26
|
-
continue;
|
|
27
|
-
|
|
28
|
-
e = av_dict_iterate(p->opts, NULL);
|
|
29
|
-
|
|
30
|
-
if (e) {
|
|
31
|
-
av_log(p->filter, AV_LOG_ERROR,
|
|
32
|
-
"Could not set non-existent option '%s' to value '%s'\n",
|
|
33
|
-
e->key, e->value);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Parse the name of a link, which has the format "[linkname]".
|
|
43
|
-
*
|
|
44
|
-
* @return a pointer (that need to be freed after use) to the name
|
|
45
|
-
* between parenthesis
|
|
46
|
-
*/
|
|
47
|
-
static char *parse_link_name(const char **buf, void *log_ctx)
|
|
48
|
-
{
|
|
49
|
-
const char *start = *buf;
|
|
50
|
-
char *name;
|
|
51
|
-
(*buf)++;
|
|
52
|
-
|
|
53
|
-
name = av_get_token(buf, "]");
|
|
54
|
-
if (!name)
|
|
55
|
-
return NULL;
|
|
56
|
-
|
|
57
|
-
if (!name[0]) {
|
|
58
|
-
av_log(log_ctx, AV_LOG_ERROR,
|
|
59
|
-
"Bad (empty?) label found in the following: \"%s\".\n", start);
|
|
60
|
-
goto fail;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (**buf != ']') {
|
|
64
|
-
av_log(log_ctx, AV_LOG_ERROR,
|
|
65
|
-
"Mismatched '[' found in the following: \"%s\".\n", start);
|
|
66
|
-
fail:
|
|
67
|
-
av_freep(&name);
|
|
68
|
-
return NULL;
|
|
69
|
-
}
|
|
70
|
-
(*buf)++;
|
|
71
|
-
|
|
72
|
-
return name;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static void pad_params_free(AVFilterPadParams **pfpp)
|
|
76
|
-
{
|
|
77
|
-
AVFilterPadParams *fpp = *pfpp;
|
|
78
|
-
|
|
79
|
-
if (!fpp)
|
|
80
|
-
return;
|
|
81
|
-
|
|
82
|
-
av_freep(&fpp->label);
|
|
83
|
-
|
|
84
|
-
av_freep(pfpp);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static int linklabels_parse(void *logctx, const char **linklabels,
|
|
88
|
-
AVFilterPadParams ***res, unsigned *nb_res)
|
|
89
|
-
{
|
|
90
|
-
AVFilterPadParams **pp = NULL;
|
|
91
|
-
int nb = 0;
|
|
92
|
-
int ret;
|
|
93
|
-
|
|
94
|
-
while (**linklabels == '[') {
|
|
95
|
-
char *label;
|
|
96
|
-
AVFilterPadParams *par;
|
|
97
|
-
|
|
98
|
-
label = parse_link_name(linklabels, logctx);
|
|
99
|
-
if (!label) {
|
|
100
|
-
ret = AVERROR(EINVAL);
|
|
101
|
-
goto fail;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
par = (AVFilterPadParams *)av_mallocz(sizeof(*par));
|
|
105
|
-
if (!par) {
|
|
106
|
-
av_freep(&label);
|
|
107
|
-
ret = AVERROR(ENOMEM);
|
|
108
|
-
goto fail;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
par->label = label;
|
|
112
|
-
|
|
113
|
-
ret = av_dynarray_add_nofree(&pp, &nb, par);
|
|
114
|
-
if (ret < 0) {
|
|
115
|
-
pad_params_free(&par);
|
|
116
|
-
goto fail;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
*linklabels += strspn(*linklabels, WHITESPACES);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
*res = pp;
|
|
123
|
-
*nb_res = nb;
|
|
124
|
-
|
|
125
|
-
return 0;
|
|
126
|
-
fail:
|
|
127
|
-
for (int i = 0; i < nb; i++)
|
|
128
|
-
pad_params_free(&pp[i]);
|
|
129
|
-
av_freep(&pp);
|
|
130
|
-
return ret;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
static AVFilterInOut *extract_inout(const char *label, AVFilterInOut **links)
|
|
134
|
-
{
|
|
135
|
-
AVFilterInOut *ret;
|
|
136
|
-
|
|
137
|
-
while (*links && (!(*links)->name || strcmp((*links)->name, label)))
|
|
138
|
-
links = &((*links)->next);
|
|
139
|
-
|
|
140
|
-
ret = *links;
|
|
141
|
-
|
|
142
|
-
if (ret) {
|
|
143
|
-
*links = ret->next;
|
|
144
|
-
ret->next = NULL;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return ret;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
|
|
151
|
-
{
|
|
152
|
-
while (*inouts && (*inouts)->next)
|
|
153
|
-
inouts = &((*inouts)->next);
|
|
154
|
-
|
|
155
|
-
if (!*inouts)
|
|
156
|
-
*inouts = *element;
|
|
157
|
-
else
|
|
158
|
-
(*inouts)->next = *element;
|
|
159
|
-
*element = NULL;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
int avfilter_graph_parse_ptr2(AVFilterGraph *graph, const char *filters,
|
|
163
|
-
AVFilterInOut **open_inputs_ptr, AVFilterInOut **open_outputs_ptr,
|
|
164
|
-
AVBufferRef *hw_device)
|
|
165
|
-
{
|
|
166
|
-
AVFilterInOut *user_inputs = open_inputs_ptr ? *open_inputs_ptr : NULL;
|
|
167
|
-
AVFilterInOut *user_outputs = open_outputs_ptr ? *open_outputs_ptr : NULL;
|
|
168
|
-
|
|
169
|
-
AVFilterInOut *inputs = NULL, *outputs = NULL;
|
|
170
|
-
AVFilterGraphSegment *seg = NULL;
|
|
171
|
-
AVFilterChain *ch;
|
|
172
|
-
AVFilterParams *p;
|
|
173
|
-
int ret;
|
|
174
|
-
|
|
175
|
-
ret = avfilter_graph_segment_parse(graph, filters, 0, &seg);
|
|
176
|
-
if (ret < 0)
|
|
177
|
-
goto end;
|
|
178
|
-
|
|
179
|
-
ret = avfilter_graph_segment_create_filters(seg, 0);
|
|
180
|
-
if (ret < 0)
|
|
181
|
-
goto end;
|
|
182
|
-
|
|
183
|
-
ret = avfilter_graph_segment_apply_opts(seg, 0);
|
|
184
|
-
if (ret < 0) {
|
|
185
|
-
if (ret == AVERROR_OPTION_NOT_FOUND)
|
|
186
|
-
log_unknown_opt(seg);
|
|
187
|
-
goto end;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (hw_device) {
|
|
191
|
-
for (unsigned int i = 0; i < graph->nb_filters; i++) {
|
|
192
|
-
AVFilterContext *f = graph->filters[i];
|
|
193
|
-
|
|
194
|
-
if (!(f->filter->flags & AVFILTER_FLAG_HWDEVICE))
|
|
195
|
-
continue;
|
|
196
|
-
if (f->hw_device_ctx)
|
|
197
|
-
{
|
|
198
|
-
av_log(NULL, AV_LOG_ERROR, "Hardware device context ref already set on %s\n", f->name);
|
|
199
|
-
}
|
|
200
|
-
f->hw_device_ctx = av_buffer_ref(hw_device);
|
|
201
|
-
if (!f->hw_device_ctx) {
|
|
202
|
-
ret = AVERROR(ENOMEM);
|
|
203
|
-
goto end;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
ret = avfilter_graph_segment_init(seg, 0);
|
|
209
|
-
if (ret < 0)
|
|
210
|
-
goto end;
|
|
211
|
-
|
|
212
|
-
/* First input pad, assume it is "[in]" if not specified */
|
|
213
|
-
p = seg->chains[0]->filters[0];
|
|
214
|
-
if (p->filter->nb_inputs == 1 && !p->inputs) {
|
|
215
|
-
const char *tmp = "[in]";
|
|
216
|
-
|
|
217
|
-
ret = linklabels_parse(graph, &tmp, &p->inputs, &p->nb_inputs);
|
|
218
|
-
if (ret < 0)
|
|
219
|
-
goto end;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/* Last output pad, assume it is "[out]" if not specified */
|
|
223
|
-
ch = seg->chains[seg->nb_chains - 1];
|
|
224
|
-
p = ch->filters[ch->nb_filters - 1];
|
|
225
|
-
if (p->filter->nb_outputs == 1 && !p->outputs) {
|
|
226
|
-
const char *tmp = "[out]";
|
|
227
|
-
|
|
228
|
-
ret = linklabels_parse(graph, &tmp, &p->outputs, &p->nb_outputs);
|
|
229
|
-
if (ret < 0)
|
|
230
|
-
goto end;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
ret = avfilter_graph_segment_apply(seg, 0, &inputs, &outputs);
|
|
234
|
-
avfilter_graph_segment_free(&seg);
|
|
235
|
-
if (ret < 0)
|
|
236
|
-
goto end;
|
|
237
|
-
|
|
238
|
-
// process user-supplied inputs/outputs
|
|
239
|
-
while (inputs) {
|
|
240
|
-
AVFilterInOut *cur, *match = NULL;
|
|
241
|
-
|
|
242
|
-
cur = inputs;
|
|
243
|
-
inputs = cur->next;
|
|
244
|
-
cur->next = NULL;
|
|
245
|
-
|
|
246
|
-
if (cur->name)
|
|
247
|
-
match = extract_inout(cur->name, &user_outputs);
|
|
248
|
-
|
|
249
|
-
if (match) {
|
|
250
|
-
ret = avfilter_link(match->filter_ctx, match->pad_idx,
|
|
251
|
-
cur->filter_ctx, cur->pad_idx);
|
|
252
|
-
avfilter_inout_free(&match);
|
|
253
|
-
avfilter_inout_free(&cur);
|
|
254
|
-
if (ret < 0)
|
|
255
|
-
goto end;
|
|
256
|
-
} else
|
|
257
|
-
append_inout(&user_inputs, &cur);
|
|
258
|
-
}
|
|
259
|
-
while (outputs) {
|
|
260
|
-
AVFilterInOut *cur, *match = NULL;
|
|
261
|
-
|
|
262
|
-
cur = outputs;
|
|
263
|
-
outputs = cur->next;
|
|
264
|
-
cur->next = NULL;
|
|
265
|
-
|
|
266
|
-
if (cur->name)
|
|
267
|
-
match = extract_inout(cur->name, &user_inputs);
|
|
268
|
-
|
|
269
|
-
if (match) {
|
|
270
|
-
ret = avfilter_link(cur->filter_ctx, cur->pad_idx,
|
|
271
|
-
match->filter_ctx, match->pad_idx);
|
|
272
|
-
avfilter_inout_free(&match);
|
|
273
|
-
avfilter_inout_free(&cur);
|
|
274
|
-
if (ret < 0)
|
|
275
|
-
goto end;
|
|
276
|
-
} else
|
|
277
|
-
append_inout(&user_outputs, &cur);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
end:
|
|
281
|
-
avfilter_graph_segment_free(&seg);
|
|
282
|
-
|
|
283
|
-
if (ret < 0) {
|
|
284
|
-
av_log(graph, AV_LOG_ERROR, "Error processing filtergraph: %s\n",
|
|
285
|
-
AVErrorString(ret).c_str());
|
|
286
|
-
|
|
287
|
-
while (graph->nb_filters)
|
|
288
|
-
avfilter_free(graph->filters[0]);
|
|
289
|
-
av_freep(&graph->filters);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/* clear open_in/outputs only if not passed as parameters */
|
|
293
|
-
if (open_inputs_ptr) *open_inputs_ptr = user_inputs;
|
|
294
|
-
else avfilter_inout_free(&user_inputs);
|
|
295
|
-
if (open_outputs_ptr) *open_outputs_ptr = user_outputs;
|
|
296
|
-
else avfilter_inout_free(&user_outputs);
|
|
297
|
-
|
|
298
|
-
avfilter_inout_free(&inputs);
|
|
299
|
-
avfilter_inout_free(&outputs);
|
|
300
|
-
|
|
301
|
-
return ret;
|
|
302
|
-
}
|