forked from Yahweasel/libav.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bindings.c
658 lines (569 loc) · 18.8 KB
/
bindings.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
/*
* Copyright (C) 2019-2024 Yahweasel and contributors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#ifdef __EMSCRIPTEN_PTHREADS__
#include <emscripten.h>
#include <pthread.h>
#endif
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/buffersink.h"
#include "libavutil/avutil.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/version.h"
#define A(struc, type, field) \
type struc ## _ ## field(struc *a) { return a->field; } \
void struc ## _ ## field ## _s(struc *a, type b) { a->field = b; }
#define AL(struc, type, field) \
uint32_t struc ## _ ## field(struc *a) { return (uint32_t) a->field; } \
uint32_t struc ## _ ## field ## hi(struc *a) { return (uint32_t) (a->field >> 32); } \
void struc ## _ ## field ## _s(struc *a, uint32_t b) { a->field = b; } \
void struc ## _ ## field ## hi_s(struc *a, uint32_t b) { a->field |= (((type) b) << 32); }
#define AA(struc, type, field) \
type struc ## _ ## field ## _a(struc *a, size_t c) { return a->field[c]; } \
void struc ## _ ## field ## _a_s(struc *a, size_t c, type b) { ((type *) a->field)[c] = b; }
#define RAT(struc, field) \
int struc ## _ ## field ## _num(struc *a) { return a->field.num; } \
int struc ## _ ## field ## _den(struc *a) { return a->field.den; } \
void struc ## _ ## field ## _num_s(struc *a, int b) { a->field.num = b; } \
void struc ## _ ## field ## _den_s(struc *a, int b) { a->field.den = b; } \
void struc ## _ ## field ## _s(struc *a, int n, int d) { a->field.num = n; a->field.den = d; }
#define RAT_FAKE(struc, field, num, den) \
int struc ## _ ## field ## _num(struc *a) { (void) a; return num; } \
int struc ## _ ## field ## _den(struc *a) { (void) a; return den; } \
void struc ## _ ## field ## _num_s(struc *a, int b) { (void) a; (void) b; } \
void struc ## _ ## field ## _den_s(struc *a, int b) { (void) a; (void) b; } \
void struc ## _ ## field ## _s(struc *a, int n, int d) { (void) a; (void) n; (void) d; }
/* Not part of libav, just used to ensure a round trip to C for async purposes */
void ff_nothing() {}
/****************************************************************
* libavutil
***************************************************************/
/* AVFrame */
#define B(type, field) A(AVFrame, type, field)
#define BL(type, field) AL(AVFrame, type, field)
#define BA(type, field) AA(AVFrame, type, field)
B(size_t, crop_bottom)
B(size_t, crop_left)
B(size_t, crop_right)
B(size_t, crop_top)
BA(uint8_t *, data)
B(int, format)
B(int, height)
B(int, key_frame)
BA(int, linesize)
B(int, nb_samples)
B(int, pict_type)
BL(int64_t, pts)
B(int, sample_rate)
B(int, width)
#undef B
#undef BL
#undef BA
RAT(AVFrame, sample_aspect_ratio)
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(57, 10, 101)
RAT(AVFrame, time_base)
#else
RAT_FAKE(AVFrame, time_base, 1, 1000)
#endif
/* Either way we expose the old channel layout API, but if the new channel
* layout API is available, we use it */
#if LIBAVUTIL_VERSION_INT > AV_VERSION_INT(57, 23, 100)
/* New API */
#define CHL(struc) \
void struc ## _channel_layoutmask_s(struc *a, uint32_t bl, uint32_t bh) { \
uint64_t mask = (((uint64_t) bl)) | (((uint64_t) bh) << 32); \
av_channel_layout_uninit(&a->ch_layout); \
av_channel_layout_from_mask(&a->ch_layout, mask);\
} \
uint64_t struc ## _channel_layoutmask(struc *a) { \
return a->ch_layout.u.mask; \
}\
int struc ## _channels(struc *a) { \
return a->ch_layout.nb_channels; \
} \
void struc ## _channels_s(struc *a, int b) { \
a->ch_layout.nb_channels = b; \
}\
int struc ## _ch_layout_nb_channels(struc *a) { \
return a->ch_layout.nb_channels; \
}\
void struc ## _ch_layout_nb_channels_s(struc *a, int b) { \
a->ch_layout.nb_channels = b; \
}\
uint32_t struc ## _channel_layout(struc *a) { \
return (uint32_t) a->ch_layout.u.mask; \
}\
uint32_t struc ##_channel_layouthi(struc *a) { \
return (uint32_t) (a->ch_layout.u.mask >> 32);\
}\
void struc ##_channel_layout_s(struc *a, uint32_t b) { \
a->ch_layout.u.mask = (a->ch_layout.u.mask & (0xFFFFFFFFull << 32)) | (((uint64_t) b));\
uint64_t mask = a->ch_layout.u.mask;\
av_channel_layout_uninit(&a->ch_layout);\
av_channel_layout_from_mask(&a->ch_layout, mask);\
}\
void struc ##_channel_layouthi_s(struc *a, uint32_t b) { \
a->ch_layout.u.mask = (a->ch_layout.u.mask & 0xFFFFFFFFull) | (((uint64_t) b) << 32);\
uint64_t mask = a->ch_layout.u.mask;\
av_channel_layout_uninit(&a->ch_layout);\
av_channel_layout_from_mask(&a->ch_layout, mask);\
}
#else
/* Old API */
#define CHL(struc) \
void struc ## _channel_layoutmask_s(struc *a, uint32_t bl, uint32_t bh) { \
a->channel_layout = ((uint16_t) bh << 32) | bl; \
} \
uint64_t struc ## _channel_layoutmask(struc *a) { \
return a->channel_layout; \
}\
int struc ## _channels(struc *a) { \
return a->channels; \
} \
void struc ## _channels_s(struc *a, int b) { \
a->channels = b; \
}\
int struc ## _ch_layout_nb_channels(struc *a) { \
return a->channels; \
}\
void struc ## _ch_layout_nb_channels_s(struc *a, int b) { \
a->channels = b; \
}\
uint32_t struc ## _channel_layout(struc *a) { \
return a->channel_layout; \
}\
uint32_t struc ##_channel_layouthi(struc *a) { \
return a->channel_layout >> 32; \
}\
void struc ##_channel_layout_s(struc *a, uint32_t b) { \
a->channel_layout = \
(a->channel_layout & (0xFFFFFFFFull << 32)) | \
((uint64_t) b); \
}\
void struc ##_channel_layouthi_s(struc *a, uint32_t b) { \
a->channel_layout = \
(((uint64_t) b) << 32) | \
(a->channel_layout & 0xFFFFFFFFull); \
}
#endif /* Channel layout API version */
CHL(AVFrame)
/* This isn't in libav because there's only one property to scale, but this
* scaling is sufficiently painful in JavaScript that it's worth wrapping this
* up in a helper. */
void ff_frame_rescale_ts_js(
AVFrame *frame,
int tb_src_num, int tb_src_den,
int tb_dst_num, int tb_dst_den
) {
AVRational tb_src = {tb_src_num, tb_src_den},
tb_dst = {tb_dst_num, tb_dst_den};
if (frame->pts != AV_NOPTS_VALUE)
frame->pts = av_rescale_q(frame->pts, tb_src, tb_dst);
}
/* AVPixFmtDescriptor */
#define B(type, field) A(AVPixFmtDescriptor, type, field)
B(uint64_t, flags)
B(uint8_t, nb_components)
B(uint8_t, log2_chroma_h)
B(uint8_t, log2_chroma_w)
#undef B
int AVPixFmtDescriptor_comp_depth(AVPixFmtDescriptor *fmt, int comp)
{
return fmt->comp[comp].depth;
}
int av_opt_set_int_list_js(void *obj, const char *name, int width, void *val, int term, int flags)
{
switch (width) {
case 4:
return av_opt_set_int_list(obj, name, ((int32_t *) val), term, flags);
case 8:
return av_opt_set_int_list(obj, name, ((int64_t *) val), term, flags);
default:
return AVERROR(EINVAL);
}
}
/****************************************************************
* libavcodec
***************************************************************/
/* AVCodec */
#define B(type, field) A(AVCodec, type, field)
#define BA(type, field) AA(AVCodec, type, field)
B(const char *, name)
B(const char *, long_name)
B(const enum AVSampleFormat *, sample_fmts)
BA(enum AVSampleFormat, sample_fmts)
B(const int *, supported_samplerates)
BA(int, supported_samplerates)
B(enum AVMediaType, type)
#undef B
#undef BA
/* AVCodecContext */
#define B(type, field) A(AVCodecContext, type, field)
#define BL(type, field) AL(AVCodecContext, type, field)
B(enum AVCodecID, codec_id)
B(enum AVMediaType, codec_type)
BL(int64_t, bit_rate)
B(uint8_t *, extradata)
B(int, extradata_size)
B(int, frame_size)
B(int, gop_size)
B(int, height)
B(int, keyint_min)
B(int, level)
B(int, max_b_frames)
B(int, pix_fmt)
B(int, profile)
BL(int64_t, rc_max_rate)
BL(int64_t, rc_min_rate)
B(int, sample_fmt)
B(int, sample_rate)
B(int, qmax)
B(int, qmin)
B(int, width)
#undef B
#undef BL
RAT(AVCodecContext, framerate)
RAT(AVCodecContext, sample_aspect_ratio)
RAT(AVCodecContext, time_base)
CHL(AVCodecContext)
/* AVCodecDescriptor */
#define B(type, field) A(AVCodecDescriptor, type, field)
B(enum AVCodecID, id)
B(const char *, long_name)
AA(AVCodecDescriptor, const char *, mime_types)
B(const char *, name)
B(int, props)
B(enum AVMediaType, type)
#undef B
/* AVCodecParameters */
#define B(type, field) A(AVCodecParameters, type, field)
B(enum AVCodecID, codec_id)
B(uint32_t, codec_tag)
B(enum AVMediaType, codec_type)
B(uint8_t *, extradata)
B(int, extradata_size)
B(int, format)
B(int64_t, bit_rate)
B(int, profile)
B(int, level)
B(int, width)
B(int, height)
B(enum AVColorRange, color_range)
B(enum AVColorPrimaries, color_primaries)
B(enum AVColorTransferCharacteristic, color_trc)
B(enum AVColorSpace, color_space)
B(enum AVChromaLocation, chroma_location)
B(int, sample_rate)
#undef B
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(60, 10, 100)
RAT(AVCodecParameters, framerate)
#else
RAT_FAKE(AVCodecParameters, framerate, 60, 1)
#endif
CHL(AVCodecParameters)
/* AVPacket */
#define B(type, field) A(AVPacket, type, field)
#define BL(type, field) AL(AVPacket, type, field)
B(uint8_t *, data)
BL(int64_t, dts)
BL(int64_t, duration)
B(int, flags)
BL(int64_t, pos)
BL(int64_t, pts)
B(AVPacketSideData *, side_data)
B(int, side_data_elems)
B(int, size)
B(int, stream_index)
#undef B
#undef BL
#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(59, 4, 100)
RAT(AVPacket, time_base)
#else
RAT_FAKE(AVPacket, time_base, 1, 1000)
#endif
/* AVPacketSideData uses special accessors because it's usually an array */
uint8_t *AVPacketSideData_data(AVPacketSideData *a, int idx) {
return a[idx].data;
}
int AVPacketSideData_size(AVPacketSideData *a, int idx) {
return a[idx].size;
}
enum AVPacketSideDataType AVPacketSideData_type(AVPacketSideData *a, int idx) {
return a[idx].type;
}
int avcodec_open2_js(
AVCodecContext *avctx, const AVCodec *codec, AVDictionary *options
) {
return avcodec_open2(avctx, codec, &options);
}
/* Implemented as a binding so that we don't have to worry about struct copies */
void av_packet_rescale_ts_js(
AVPacket *pkt,
int tb_src_num, int tb_src_den,
int tb_dst_num, int tb_dst_den
) {
AVRational tb_src = {tb_src_num, tb_src_den},
tb_dst = {tb_dst_num, tb_dst_den};
av_packet_rescale_ts(pkt, tb_src, tb_dst);
}
/****************************************************************
* avformat
***************************************************************/
/* AVFormatContext */
#define B(type, field) A(AVFormatContext, type, field)
#define BA(type, field) AA(AVFormatContext, type, field)
#define BL(type, field) AL(AVFormatContext, type, field)
BL(int64_t, duration)
B(int, flags)
B(unsigned int, nb_streams)
B(const struct AVOutputFormat *, oformat)
B(AVIOContext *, pb)
BL(int64_t, start_time)
BA(AVStream *, streams)
#undef B
#undef BA
#undef BL
/* AVStream */
#define B(type, field) A(AVStream, type, field)
#define BL(type, field) AL(AVStream, type, field)
B(AVCodecParameters *, codecpar)
B(enum AVDiscard, discard)
BL(int64_t, duration)
#undef B
#undef BL
RAT(AVStream, time_base)
int avformat_seek_file_min(
AVFormatContext *s, int stream_index, int64_t ts, int flags
) {
return avformat_seek_file(s, stream_index, ts, ts, INT64_MAX, flags);
}
int avformat_seek_file_max(
AVFormatContext *s, int stream_index, int64_t ts, int flags
) {
return avformat_seek_file(s, stream_index, INT64_MIN, ts, ts, flags);
}
int avformat_seek_file_approx(
AVFormatContext *s, int stream_index, int64_t ts, int flags
) {
return avformat_seek_file(s, stream_index, INT64_MIN, ts, INT64_MAX, flags);
}
/****************************************************************
* libavfilter
***************************************************************/
/* AVFilterInOut */
#define B(type, field) A(AVFilterInOut, type, field)
B(AVFilterContext *, filter_ctx)
B(char *, name)
B(AVFilterInOut *, next)
B(int, pad_idx)
#undef B
/* Buffer sink */
int av_buffersink_get_time_base_num(const AVFilterContext *ctx) {
return av_buffersink_get_time_base(ctx).num;
}
int av_buffersink_get_time_base_den(const AVFilterContext *ctx) {
return av_buffersink_get_time_base(ctx).den;
}
#if LIBAVFILTER_VERSION_INT > AV_VERSION_INT(8, 27, 100)
int ff_buffersink_set_ch_layout(AVFilterContext *ctx, unsigned int layoutlo, unsigned int layouthi) {
uint64_t layout;
char layoutStr[20];
layout = ((uint64_t) layouthi << 32) | ((uint64_t) layoutlo);
sprintf(layoutStr, "0x%llx", layout);
return av_opt_set(ctx, "ch_layouts", layoutStr, AV_OPT_SEARCH_CHILDREN);
}
#else
int ff_buffersink_set_ch_layout(AVFilterContext *ctx, unsigned int layoutlo, unsigned int layouthi) {
uint64_t layout[2];
layout[0] = ((uint64_t) layouthi << 32) | ((uint64_t) layoutlo);
layout[1] = -1;
return av_opt_set_int_list(ctx, "channel_layouts", layout, -1, AV_OPT_SEARCH_CHILDREN);
}
#endif
/****************************************************************
* swscale
***************************************************************/
int libavjs_with_swscale() {
#ifdef LIBAVJS_WITH_SWSCALE
return 1;
#else
return 0;
#endif
}
#ifndef LIBAVJS_WITH_SWSCALE
/* swscale isn't included, but we need the symbols */
void sws_getContext() {}
void sws_freeContext() {}
void sws_scale_frame() {}
#elif LIBAVUTIL_VERSION_INT <= AV_VERSION_INT(57, 4, 101)
/* No sws_scale_frame in this version */
void sws_scale_frame() {}
#endif
/****************************************************************
* CLI
***************************************************************/
int libavjs_with_cli() {
#ifdef LIBAVJS_WITH_CLI
return 1;
#else
return 0;
#endif
}
#ifndef LIBAVJS_WITH_CLI
int ffmpeg_main() { return 0; }
int ffprobe_main() { return 0; }
#endif
/****************************************************************
* Threading
***************************************************************/
#ifdef __EMSCRIPTEN_PTHREADS__
EM_JS(void *, libavjs_main_thread, (void *ignore), {
// Avoid exiting the runtime so we can receive normal requests
noExitRuntime = Module.noExitRuntime = true;
// Hijack the event handler
var origOnmessage = onmessage;
onmessage = function(ev) {
var a;
function reply(succ, ret) {
var transfer = [];
if (typeof ret === "object" && ret && ret.libavjsTransfer)
transfer = ret.libavjsTransfer;
postMessage({
c: "libavjs_ret",
a: [a[0], a[1], succ, ret]
}, transfer);
}
if (ev.data && ev.data.c === "libavjs_run") {
a = ev.data.a;
var succ = true;
var ret;
try {
ret = Module[a[1]].apply(Module, a.slice(2));
} catch (ex) {
succ = false;
ret = ex + "\n" + ex.stack;
}
if (succ && ret && ret.then) {
ret
.then(function(ret) { reply(true, ret); })
.catch(function(ret) { reply(false, ret + "\n" + ret.stack); });
} else {
reply(succ, ret);
}
} else if (ev.data && ev.data.c === "libavjs_wait_reader") {
var name = "" + ev.data.fd;
var waiters = Module.ff_reader_dev_waiters[name] || [];
delete Module.ff_reader_dev_waiters[name];
for (var i = 0; i < waiters.length; i++)
waiters[i]();
} else {
return origOnmessage.apply(this, arguments);
}
};
// And indicate that we're ready
postMessage({c: "libavjs_ready"});
});
pthread_t libavjs_create_main_thread()
{
pthread_t ret;
if (pthread_create(&ret, NULL, libavjs_main_thread, NULL))
return NULL;
return ret;
}
#else
void *libavjs_create_main_thread() { return NULL; }
#endif
/****************************************************************
* Other bindings
***************************************************************/
AVFormatContext *avformat_alloc_output_context2_js(AVOutputFormat *oformat,
const char *format_name, const char *filename)
{
AVFormatContext *ret = NULL;
int err = avformat_alloc_output_context2(&ret, oformat, format_name, filename);
if (err < 0)
fprintf(stderr, "[avformat_alloc_output_context2_js] %s\n", av_err2str(err));
return ret;
}
AVFormatContext *avformat_open_input_js(const char *url, AVInputFormat *fmt,
AVDictionary *options)
{
AVFormatContext *ret = NULL;
AVDictionary** options_p = &options;
int err = avformat_open_input(&ret, url, fmt, options_p);
if (err < 0)
fprintf(stderr, "[avformat_open_input_js] %s\n", av_err2str(err));
return ret;
}
AVIOContext *avio_open2_js(const char *url, int flags,
const AVIOInterruptCB *int_cb, AVDictionary *options)
{
AVIOContext *ret = NULL;
AVDictionary** options_p = &options;
int err = avio_open2(&ret, url, flags, int_cb, options_p);
if (err < 0)
fprintf(stderr, "[avio_open2_js] %s\n", av_err2str(err));
return ret;
}
AVFilterContext *avfilter_graph_create_filter_js(const AVFilter *filt,
const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
{
AVFilterContext *ret = NULL;
int err = avfilter_graph_create_filter(&ret, filt, name, args, opaque, graph_ctx);
if (err < 0)
fprintf(stderr, "[avfilter_graph_create_filter_js] %s\n", av_err2str(err));
return ret;
}
AVDictionary *av_dict_copy_js(
AVDictionary *dst, const AVDictionary *src, int flags
) {
av_dict_copy(&dst, src, flags);
return dst;
}
AVDictionary *av_dict_set_js(
AVDictionary *pm, const char *key, const char *value, int flags
) {
av_dict_set(&pm, key, value, flags);
return pm;
}
int av_compare_ts_js(
unsigned int ts_a_lo, int ts_a_hi,
int tb_a_num, int tb_a_den,
unsigned int ts_b_lo, int ts_b_hi,
int tb_b_num, int tb_b_den
) {
int64_t ts_a = (int64_t) ts_a_lo + ((int64_t) ts_a_hi << 32);
int64_t ts_b = (int64_t) ts_b_lo + ((int64_t) ts_b_hi << 32);
AVRational tb_a = {tb_a_num, tb_b_den},
tb_b = {tb_b_num, tb_b_den};
return av_compare_ts(ts_a, tb_a, ts_b, tb_b);
}
/* Errors */
#define ERR_BUF_SZ 256
static char err_buf[ERR_BUF_SZ];
char *ff_error(int err)
{
av_strerror(err, err_buf, ERR_BUF_SZ - 1);
return err_buf;
}
int mallinfo_uordblks()
{
return mallinfo().uordblks;
}