bare-ffmpeg 1.0.0-26 → 1.0.0-28

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/binding.cc CHANGED
@@ -1,3 +1,4 @@
1
+ #include <optional>
1
2
  #include <tuple>
2
3
  #include <vector>
3
4
 
@@ -16,6 +17,9 @@ extern "C" {
16
17
  #include <libavcodec/codec_par.h>
17
18
  #include <libavcodec/packet.h>
18
19
  #include <libavdevice/avdevice.h>
20
+ #include <libavfilter/avfilter.h>
21
+ #include <libavfilter/buffersink.h>
22
+ #include <libavfilter/buffersrc.h>
19
23
  #include <libavformat/avformat.h>
20
24
  #include <libavformat/avio.h>
21
25
  #include <libavutil/audio_fifo.h>
@@ -107,6 +111,22 @@ typedef struct {
107
111
  AVPacketSideData *handle;
108
112
  } bare_ffmpeg_side_data_t;
109
113
 
114
+ typedef struct {
115
+ const AVFilter *handle;
116
+ } bare_ffmpeg_filter_t;
117
+
118
+ typedef struct {
119
+ AVFilterContext *handle;
120
+ } bare_ffmpeg_filter_context_t;
121
+
122
+ typedef struct {
123
+ AVFilterGraph *handle;
124
+ } bare_ffmpeg_filter_graph_t;
125
+
126
+ typedef struct {
127
+ AVFilterInOut *handle;
128
+ } bare_ffmpeg_filter_inout_t;
129
+
110
130
  static uv_once_t bare_ffmpeg__init_guard = UV_ONCE_INIT;
111
131
 
112
132
  static inline bool
@@ -356,6 +376,24 @@ bare_ffmpeg_input_format_get_flags(
356
376
  return format->handle->flags;
357
377
  }
358
378
 
379
+ static std::string
380
+ bare_ffmpeg_input_format_get_extensions(
381
+ js_env_t *env,
382
+ js_receiver_t,
383
+ js_arraybuffer_span_of_t<bare_ffmpeg_input_format_t, 1> context
384
+ ) {
385
+ return context->handle->extensions;
386
+ }
387
+
388
+ static std::string
389
+ bare_ffmpeg_input_format_get_mime_type(
390
+ js_env_t *env,
391
+ js_receiver_t,
392
+ js_arraybuffer_span_of_t<bare_ffmpeg_input_format_t, 1> context
393
+ ) {
394
+ return context->handle->mime_type;
395
+ }
396
+
359
397
  static js_arraybuffer_t
360
398
  bare_ffmpeg_format_context_open_input_with_io(
361
399
  js_env_t *env,
@@ -483,6 +521,24 @@ bare_ffmpeg_format_context_open_output(
483
521
  return handle;
484
522
  }
485
523
 
524
+ static std::string
525
+ bare_ffmpeg_output_format_get_extensions(
526
+ js_env_t *env,
527
+ js_receiver_t,
528
+ js_arraybuffer_span_of_t<bare_ffmpeg_output_format_t, 1> context
529
+ ) {
530
+ return context->handle->extensions;
531
+ }
532
+
533
+ static std::string
534
+ bare_ffmpeg_output_format_get_mime_type(
535
+ js_env_t *env,
536
+ js_receiver_t,
537
+ js_arraybuffer_span_of_t<bare_ffmpeg_output_format_t, 1> context
538
+ ) {
539
+ return context->handle->mime_type;
540
+ }
541
+
486
542
  static void
487
543
  bare_ffmpeg_format_context_close_output(
488
544
  js_env_t *env,
@@ -826,6 +882,155 @@ bare_ffmpeg_get_sample_format_name_by_id(js_env_t *env, js_receiver_t, uint32_t
826
882
  return av_get_sample_fmt_name(static_cast<enum AVSampleFormat>(id));
827
883
  }
828
884
 
885
+ static std::vector<int32_t>
886
+ bare_ffmpeg_codec_get_supported_config(
887
+ js_env_t *env,
888
+ js_receiver_t,
889
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_context_t, 1> context,
890
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_t, 1> codec,
891
+ int32_t cfg
892
+ ) {
893
+ int err;
894
+
895
+ int count = 0;
896
+ const void *list = nullptr;
897
+
898
+ err = avcodec_get_supported_config(context->handle, codec->handle, static_cast<AVCodecConfig>(cfg), 0, &list, &count);
899
+ if (err < 0) {
900
+ err = js_throw_error(env, NULL, av_err2str(err));
901
+ assert(err == 0);
902
+
903
+ throw js_pending_exception;
904
+ }
905
+
906
+ std::vector<int32_t> values;
907
+
908
+ if (count > 0 && list) {
909
+ const int32_t *int_list = static_cast<const int32_t *>(list);
910
+ for (int i = 0; i < count; i++) {
911
+ values.push_back(int_list[i]);
912
+ }
913
+ return values;
914
+ }
915
+
916
+ switch (static_cast<AVCodecConfig>(cfg)) {
917
+ case AV_CODEC_CONFIG_PIX_FORMAT:
918
+ for (int i = 0; i < AV_PIX_FMT_NB; i++) {
919
+ if (av_pix_fmt_desc_get(static_cast<AVPixelFormat>(i)) != nullptr) {
920
+ values.push_back(i);
921
+ }
922
+ }
923
+ break;
924
+ case AV_CODEC_CONFIG_SAMPLE_FORMAT:
925
+ for (int i = 0; i < AV_SAMPLE_FMT_NB; i++) {
926
+ values.push_back(i);
927
+ }
928
+ break;
929
+ case AV_CODEC_CONFIG_COLOR_RANGE:
930
+ values.push_back(AVCOL_RANGE_UNSPECIFIED);
931
+ values.push_back(AVCOL_RANGE_MPEG);
932
+ values.push_back(AVCOL_RANGE_JPEG);
933
+ break;
934
+ case AV_CODEC_CONFIG_COLOR_SPACE:
935
+ for (int i = 0; i < AVCOL_SPC_NB; i++) {
936
+ values.push_back(i);
937
+ }
938
+ break;
939
+ case AV_CODEC_CONFIG_SAMPLE_RATE:
940
+ values.push_back(0);
941
+ break;
942
+ default:
943
+ break;
944
+ }
945
+
946
+ return values;
947
+ }
948
+
949
+ static std::optional<js_arraybuffer_t>
950
+ bare_ffmpeg_codec_get_supported_frame_rates(
951
+ js_env_t *env,
952
+ js_receiver_t,
953
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_context_t, 1> context,
954
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_t, 1> codec
955
+ ) {
956
+ int err;
957
+
958
+ const AVCodecContext *ctx = context->handle;
959
+ const AVCodec *c = codec->handle;
960
+
961
+ int count = 0;
962
+ const void *list = nullptr;
963
+
964
+ err = avcodec_get_supported_config(ctx, c, AV_CODEC_CONFIG_FRAME_RATE, 0, &list, &count);
965
+ if (err < 0) {
966
+ err = js_throw_error(env, NULL, av_err2str(err));
967
+ assert(err == 0);
968
+
969
+ throw js_pending_exception;
970
+ }
971
+
972
+ if (!list || count == 0) {
973
+ return std::nullopt;
974
+ }
975
+
976
+ js_arraybuffer_t result;
977
+ int32_t *data;
978
+ err = js_create_arraybuffer(env, static_cast<size_t>(count * 2), data, result);
979
+ assert(err == 0);
980
+
981
+ const AVRational *rational_list = static_cast<const AVRational *>(list);
982
+ for (int i = 0; i < count; i++) {
983
+ data[i * 2] = rational_list[i].num;
984
+ data[i * 2 + 1] = rational_list[i].den;
985
+ }
986
+
987
+ return result;
988
+ }
989
+
990
+ static std::optional<std::vector<js_arraybuffer_t>>
991
+ bare_ffmpeg_codec_get_supported_channel_layouts(
992
+ js_env_t *env,
993
+ js_receiver_t,
994
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_context_t, 1> context,
995
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_t, 1> codec
996
+ ) {
997
+ int err;
998
+ std::vector<js_arraybuffer_t> result;
999
+
1000
+ const AVCodecContext *ctx = context->handle;
1001
+ const AVCodec *c = codec->handle;
1002
+
1003
+ int count = 0;
1004
+ const void *list = nullptr;
1005
+
1006
+ err = avcodec_get_supported_config(ctx, c, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, &list, &count);
1007
+ if (err < 0) {
1008
+ err = js_throw_error(env, NULL, av_err2str(err));
1009
+ assert(err == 0);
1010
+
1011
+ throw js_pending_exception;
1012
+ }
1013
+
1014
+ if (!list || count == 0) {
1015
+ return std::nullopt;
1016
+ }
1017
+
1018
+ const AVChannelLayout *layout_list = static_cast<const AVChannelLayout *>(list);
1019
+ for (int i = 0; i < count; i++) {
1020
+ js_arraybuffer_t handle;
1021
+ bare_ffmpeg_channel_layout_t *layout;
1022
+ err = js_create_arraybuffer(env, layout, handle);
1023
+ assert(err == 0);
1024
+
1025
+ err = av_channel_layout_copy(&layout->handle, &layout_list[i]);
1026
+ assert(err >= 0);
1027
+
1028
+ result.push_back(handle);
1029
+ }
1030
+
1031
+ return result;
1032
+ }
1033
+
829
1034
  static js_arraybuffer_t
830
1035
  bare_ffmpeg_codec_context_init(
831
1036
  js_env_t *env,
@@ -988,6 +1193,23 @@ bare_ffmpeg_frame_set_channel_layout(
988
1193
  assert(err == 0);
989
1194
  }
990
1195
 
1196
+ static void
1197
+ bare_ffmpeg_frame_copy_properties(
1198
+ js_env_t *env,
1199
+ js_receiver_t,
1200
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> dst,
1201
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> src
1202
+ ) {
1203
+ int err = av_frame_copy_props(dst->handle, src->handle);
1204
+
1205
+ if (err < 0) {
1206
+ err = js_throw_error(env, NULL, av_err2str(err));
1207
+ assert(err == 0);
1208
+
1209
+ throw js_pending_exception;
1210
+ }
1211
+ }
1212
+
991
1213
  static bool
992
1214
  bare_ffmpeg_codec_context_open_with_options(
993
1215
  js_env_t *env,
@@ -1187,6 +1409,24 @@ bare_ffmpeg_codec_context_set_gop_size(
1187
1409
  context->handle->gop_size = gop_size;
1188
1410
  }
1189
1411
 
1412
+ static int
1413
+ bare_ffmpeg_codec_context_get_frame_size(
1414
+ js_env_t *env,
1415
+ js_receiver_t,
1416
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_context_t, 1> context
1417
+ ) {
1418
+ return context->handle->frame_size;
1419
+ }
1420
+
1421
+ static int64_t
1422
+ bare_ffmpeg_codec_context_get_frame_num(
1423
+ js_env_t *env,
1424
+ js_receiver_t,
1425
+ js_arraybuffer_span_of_t<bare_ffmpeg_codec_context_t, 1> context
1426
+ ) {
1427
+ return context->handle->frame_num;
1428
+ }
1429
+
1190
1430
  static js_arraybuffer_t
1191
1431
  bare_ffmpeg_codec_context_get_framerate(
1192
1432
  js_env_t *env,
@@ -2200,71 +2440,60 @@ bare_ffmpeg_image_get_line_size(
2200
2440
  );
2201
2441
  }
2202
2442
 
2203
- static js_arraybuffer_t
2204
- bare_ffmpeg_samples_init(
2443
+ static int
2444
+ bare_ffmpeg_samples_buffer_size(
2205
2445
  js_env_t *env,
2206
2446
  js_receiver_t,
2207
2447
  int32_t sample_format,
2208
2448
  int32_t nb_channels,
2209
2449
  int32_t nb_samples,
2210
- int32_t align
2450
+ bool no_alignment
2211
2451
  ) {
2212
- int err;
2213
-
2214
2452
  auto len = av_samples_get_buffer_size(
2215
2453
  NULL,
2216
2454
  nb_channels,
2217
2455
  nb_samples,
2218
2456
  static_cast<AVSampleFormat>(sample_format),
2219
- align
2457
+ no_alignment
2220
2458
  );
2221
2459
 
2222
2460
  if (len < 0) {
2223
- err = js_throw_error(env, NULL, av_err2str(len));
2461
+ int err = js_throw_error(env, NULL, av_err2str(len));
2224
2462
  assert(err == 0);
2225
2463
 
2226
2464
  throw js_pending_exception;
2227
2465
  }
2228
2466
 
2229
- js_arraybuffer_t handle;
2230
- err = js_create_arraybuffer(env, static_cast<size_t>(len), handle);
2231
- assert(err == 0);
2232
-
2233
- return handle;
2467
+ return len;
2234
2468
  }
2235
2469
 
2236
2470
  static int
2237
2471
  bare_ffmpeg_samples_fill(
2238
2472
  js_env_t *env,
2239
2473
  js_receiver_t,
2240
- int32_t sample_format,
2241
- int32_t nb_channels,
2242
- int32_t nb_samples,
2243
- int32_t align,
2244
- js_arraybuffer_span_t data,
2474
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> frame,
2475
+ js_arraybuffer_span_t target,
2245
2476
  uint64_t offset,
2246
- js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> frame
2477
+ bool no_alignment
2247
2478
  ) {
2248
- int err;
2249
-
2250
- auto len = av_samples_fill_arrays(
2479
+ auto res = av_samples_fill_arrays(
2251
2480
  frame->handle->data,
2252
2481
  frame->handle->linesize,
2253
- &data[static_cast<size_t>(offset)],
2254
- nb_channels,
2255
- nb_samples,
2256
- static_cast<AVSampleFormat>(sample_format),
2257
- align
2482
+ &target[offset],
2483
+ frame->handle->ch_layout.nb_channels,
2484
+ frame->handle->nb_samples,
2485
+ static_cast<AVSampleFormat>(frame->handle->format),
2486
+ no_alignment
2258
2487
  );
2259
2488
 
2260
- if (len < 0) {
2261
- err = js_throw_error(env, NULL, av_err2str(len));
2489
+ if (res < 0) {
2490
+ int err = js_throw_error(env, NULL, av_err2str(res));
2262
2491
  assert(err == 0);
2263
2492
 
2264
2493
  throw js_pending_exception;
2265
2494
  }
2266
2495
 
2267
- return len;
2496
+ return res;
2268
2497
  }
2269
2498
 
2270
2499
  static js_arraybuffer_t
@@ -2610,6 +2839,24 @@ bare_ffmpeg_packet_set_flags(
2610
2839
  packet->handle->flags = value;
2611
2840
  }
2612
2841
 
2842
+ static void
2843
+ bare_ffmpeg_packet_copy_props(
2844
+ js_env_t *env,
2845
+ js_receiver_t,
2846
+ js_arraybuffer_span_of_t<bare_ffmpeg_packet_t, 1> dst,
2847
+ js_arraybuffer_span_of_t<bare_ffmpeg_packet_t, 1> src
2848
+ ) {
2849
+ int err;
2850
+
2851
+ err = av_packet_copy_props(dst->handle, src->handle);
2852
+ if (err < 0) {
2853
+ err = js_throw_error(env, NULL, av_err2str(err));
2854
+ assert(err == 0);
2855
+
2856
+ throw js_pending_exception;
2857
+ }
2858
+ }
2859
+
2613
2860
  static int
2614
2861
  bare_ffmpeg_side_data_get_type(
2615
2862
  js_env_t *env,
@@ -2868,8 +3115,6 @@ bare_ffmpeg_resampler_convert_frames(
2868
3115
  throw js_pending_exception;
2869
3116
  }
2870
3117
 
2871
- out_frame->handle->nb_samples = result;
2872
-
2873
3118
  return result;
2874
3119
  }
2875
3120
 
@@ -3148,6 +3393,246 @@ bare_ffmpeg_rational_d2q(
3148
3393
  return result;
3149
3394
  }
3150
3395
 
3396
+ static js_arraybuffer_t
3397
+ bare_ffmpeg_filter_get_by_name(
3398
+ js_env_t *env,
3399
+ js_receiver_t,
3400
+ std::string name
3401
+ ) {
3402
+ int err;
3403
+
3404
+ js_arraybuffer_t handle;
3405
+ bare_ffmpeg_filter_t *filter;
3406
+ err = js_create_arraybuffer(env, filter, handle);
3407
+ assert(err == 0);
3408
+
3409
+ filter->handle = avfilter_get_by_name(name.c_str());
3410
+ if (filter->handle == nullptr) {
3411
+ err = js_throw_errorf(env, nullptr, "No Filter found for '%s' name", name.c_str());
3412
+ assert(err == 0);
3413
+
3414
+ throw js_pending_exception;
3415
+ }
3416
+
3417
+ return handle;
3418
+ }
3419
+
3420
+ static js_arraybuffer_t
3421
+ bare_ffmpeg_filter_context_init(
3422
+ js_env_t *env,
3423
+ js_receiver_t
3424
+ ) {
3425
+ js_arraybuffer_t handle;
3426
+ bare_ffmpeg_filter_context_t *filter_ctx;
3427
+ int err = js_create_arraybuffer(env, filter_ctx, handle);
3428
+ assert(err == 0);
3429
+
3430
+ return handle;
3431
+ }
3432
+
3433
+ static js_arraybuffer_t
3434
+ bare_ffmpeg_filter_graph_init(
3435
+ js_env_t *env,
3436
+ js_receiver_t
3437
+ ) {
3438
+ js_arraybuffer_t handle;
3439
+ bare_ffmpeg_filter_graph_t *filter_graph;
3440
+ int err = js_create_arraybuffer(env, filter_graph, handle);
3441
+ assert(err == 0);
3442
+
3443
+ filter_graph->handle = avfilter_graph_alloc();
3444
+ assert(filter_graph->handle != nullptr);
3445
+
3446
+ return handle;
3447
+ }
3448
+
3449
+ static void
3450
+ bare_ffmpeg_filter_graph_destroy(
3451
+ js_env_t *env,
3452
+ js_receiver_t,
3453
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_graph_t, 1> filter_graph
3454
+ ) {
3455
+ avfilter_graph_free(&filter_graph->handle);
3456
+ }
3457
+
3458
+ static void
3459
+ bare_ffmpeg_filter_graph_create_filter(
3460
+ js_env_t *env,
3461
+ js_receiver_t,
3462
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_graph_t, 1> graph,
3463
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_context_t, 1> filter_context,
3464
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_t, 1> filter,
3465
+ std::string name,
3466
+ std::optional<std::string> args
3467
+ ) {
3468
+ int err = avfilter_graph_create_filter(
3469
+ &filter_context->handle,
3470
+ filter->handle,
3471
+ name.c_str(),
3472
+ args.has_value() ? args.value().c_str() : nullptr,
3473
+ nullptr,
3474
+ graph->handle
3475
+ );
3476
+
3477
+ if (err < 0) {
3478
+ err = js_throw_error(env, nullptr, av_err2str(err));
3479
+ assert(err == 0);
3480
+
3481
+ throw js_pending_exception;
3482
+ }
3483
+ }
3484
+
3485
+ static void
3486
+ bare_ffmpeg_filter_graph_parse(
3487
+ js_env_t *env,
3488
+ js_receiver_t,
3489
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_graph_t, 1> graph,
3490
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> inputs,
3491
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> outputs,
3492
+ std::string filter_description
3493
+ ) {
3494
+ int err = avfilter_graph_parse(graph->handle, filter_description.c_str(), inputs->handle, outputs->handle, nullptr);
3495
+ if (err < 0) {
3496
+ err = js_throw_error(env, nullptr, av_err2str(err));
3497
+ assert(err == 0);
3498
+
3499
+ throw js_pending_exception;
3500
+ }
3501
+ }
3502
+
3503
+ static void
3504
+ bare_ffmpeg_filter_graph_configure(
3505
+ js_env_t *env,
3506
+ js_receiver_t,
3507
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_graph_t, 1> graph
3508
+ ) {
3509
+ int err = avfilter_graph_config(graph->handle, nullptr);
3510
+ if (err < 0) {
3511
+ err = js_throw_error(env, nullptr, av_err2str(err));
3512
+ assert(err == 0);
3513
+
3514
+ throw js_pending_exception;
3515
+ }
3516
+ }
3517
+
3518
+ static int
3519
+ bare_ffmpeg_filter_graph_push_frame(
3520
+ js_env_t *env,
3521
+ js_receiver_t,
3522
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_context_t, 1> ctx,
3523
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> frame
3524
+ ) {
3525
+ return av_buffersrc_add_frame(ctx->handle, frame->handle);
3526
+ }
3527
+
3528
+ static int
3529
+ bare_ffmpeg_filter_graph_pull_frame(
3530
+ js_env_t *env,
3531
+ js_receiver_t,
3532
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_context_t, 1> ctx,
3533
+ js_arraybuffer_span_of_t<bare_ffmpeg_frame_t, 1> frame
3534
+ ) {
3535
+ return av_buffersink_get_frame(ctx->handle, frame->handle);
3536
+ }
3537
+
3538
+ static js_arraybuffer_t
3539
+ bare_ffmpeg_filter_inout_init(
3540
+ js_env_t *env,
3541
+ js_receiver_t
3542
+ ) {
3543
+ js_arraybuffer_t handle;
3544
+ bare_ffmpeg_filter_inout_t *filter_inout;
3545
+ int err = js_create_arraybuffer(env, filter_inout, handle);
3546
+ assert(err == 0);
3547
+
3548
+ filter_inout->handle = avfilter_inout_alloc();
3549
+ assert(filter_inout->handle);
3550
+
3551
+ return handle;
3552
+ }
3553
+
3554
+ static void
3555
+ bare_ffmpeg_filter_inout_destroy(
3556
+ js_env_t *env,
3557
+ js_receiver_t,
3558
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout
3559
+ ) {
3560
+ avfilter_inout_free(&filter_inout->handle);
3561
+ }
3562
+
3563
+ static std::optional<std::string>
3564
+ bare_ffmpeg_filter_inout_get_name(
3565
+ js_env_t *env,
3566
+ js_receiver_t,
3567
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout
3568
+ ) {
3569
+ if (!filter_inout->handle->name) return std::nullopt;
3570
+ return filter_inout->handle->name;
3571
+ }
3572
+
3573
+ static void
3574
+ bare_ffmpeg_filter_inout_set_name(
3575
+ js_env_t *env,
3576
+ js_receiver_t,
3577
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout,
3578
+ std::string name
3579
+ ) {
3580
+ if (filter_inout->handle->name) {
3581
+ av_free(filter_inout->handle->name);
3582
+ }
3583
+ filter_inout->handle->name = av_strdup(name.c_str());
3584
+ }
3585
+
3586
+ static void
3587
+ bare_ffmpeg_filter_inout_set_filter_context(
3588
+ js_env_t *env,
3589
+ js_receiver_t,
3590
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout,
3591
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_context_t, 1> filter_ctx
3592
+ ) {
3593
+ filter_inout->handle->filter_ctx = filter_ctx->handle;
3594
+ }
3595
+
3596
+ static int
3597
+ bare_ffmpeg_filter_inout_get_pad_idx(
3598
+ js_env_t *env,
3599
+ js_receiver_t,
3600
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout
3601
+ ) {
3602
+ return filter_inout->handle->pad_idx;
3603
+ }
3604
+
3605
+ static void
3606
+ bare_ffmpeg_filter_inout_set_pad_idx(
3607
+ js_env_t *env,
3608
+ js_receiver_t,
3609
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout,
3610
+ int pad_idx
3611
+ ) {
3612
+ filter_inout->handle->pad_idx = pad_idx;
3613
+ }
3614
+
3615
+ static void
3616
+ bare_ffmpeg_filter_inout_set_next(
3617
+ js_env_t *env,
3618
+ js_receiver_t,
3619
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> filter_inout,
3620
+ js_arraybuffer_span_of_t<bare_ffmpeg_filter_inout_t, 1> next
3621
+ ) {
3622
+ filter_inout->handle->next = next->handle;
3623
+ }
3624
+
3625
+ static int64_t
3626
+ bare_ffmpeg_rational_rescale_q(
3627
+ int64_t ts,
3628
+ int32_t bq_num,
3629
+ int32_t bq_den,
3630
+ int32_t cq_num,
3631
+ int32_t cq_den
3632
+ ) {
3633
+ return av_rescale_q(ts, {bq_num, bq_den}, {cq_num, cq_den});
3634
+ }
3635
+
3151
3636
  static js_value_t *
3152
3637
  bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3153
3638
  uv_once(&bare_ffmpeg__init_guard, bare_ffmpeg__on_init);
@@ -3164,16 +3649,23 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3164
3649
  V("initIOContext", bare_ffmpeg_io_context_init)
3165
3650
  V("destroyIOContext", bare_ffmpeg_io_context_destroy)
3166
3651
 
3167
- V("initOutputFormat", bare_ffmpeg_output_format_init)
3168
3652
  V("initInputFormat", bare_ffmpeg_input_format_init)
3169
- V("getOutputFormatFlags", bare_ffmpeg_output_format_get_flags)
3170
3653
  V("getInputFormatFlags", bare_ffmpeg_input_format_get_flags)
3654
+ V("getInputFormatExtensions", bare_ffmpeg_input_format_get_extensions)
3655
+ V("getInputFormatMimeType", bare_ffmpeg_input_format_get_mime_type)
3656
+
3657
+ V("initOutputFormat", bare_ffmpeg_output_format_init)
3658
+ V("getOutputFormatFlags", bare_ffmpeg_output_format_get_flags)
3659
+ V("getOutputFormatExtensions", bare_ffmpeg_output_format_get_extensions)
3660
+ V("getOutputFormatMimeType", bare_ffmpeg_output_format_get_mime_type)
3171
3661
 
3172
3662
  V("openInputFormatContextWithIO", bare_ffmpeg_format_context_open_input_with_io)
3173
3663
  V("openInputFormatContextWithFormat", bare_ffmpeg_format_context_open_input_with_format)
3174
3664
  V("closeInputFormatContext", bare_ffmpeg_format_context_close_input)
3665
+
3175
3666
  V("openOutputFormatContext", bare_ffmpeg_format_context_open_output)
3176
3667
  V("closeOutputFormatContext", bare_ffmpeg_format_context_close_output)
3668
+
3177
3669
  V("getFormatContextStreams", bare_ffmpeg_format_context_get_streams)
3178
3670
  V("getFormatContextBestStreamIndex", bare_ffmpeg_format_context_get_best_stream_index)
3179
3671
  V("createFormatContextStream", bare_ffmpeg_format_context_create_stream)
@@ -3196,6 +3688,9 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3196
3688
  V("findEncoderByID", bare_ffmpeg_find_encoder_by_id)
3197
3689
  V("getCodecNameByID", bare_ffmpeg_get_codec_name_by_id)
3198
3690
  V("getSampleFormatNameByID", bare_ffmpeg_get_sample_format_name_by_id)
3691
+ V("getSupportedConfig", bare_ffmpeg_codec_get_supported_config)
3692
+ V("getSupportedFrameRates", bare_ffmpeg_codec_get_supported_frame_rates)
3693
+ V("getSupportedChannelLayouts", bare_ffmpeg_codec_get_supported_channel_layouts)
3199
3694
 
3200
3695
  V("initCodecContext", bare_ffmpeg_codec_context_init)
3201
3696
  V("destroyCodecContext", bare_ffmpeg_codec_context_destroy)
@@ -3223,6 +3718,8 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3223
3718
  V("setCodecContextFramerate", bare_ffmpeg_codec_context_set_framerate)
3224
3719
  V("getCodecContextExtraData", bare_ffmpeg_codec_context_get_extra_data)
3225
3720
  V("setCodecContextExtraData", bare_ffmpeg_codec_context_set_extra_data)
3721
+ V("getCodecContextFrameSize", bare_ffmpeg_codec_context_get_frame_size)
3722
+ V("getCodecContextFrameNum", bare_ffmpeg_codec_context_get_frame_num)
3226
3723
 
3227
3724
  V("sendCodecContextPacket", bare_ffmpeg_codec_context_send_packet)
3228
3725
  V("receiveCodecContextPacket", bare_ffmpeg_codec_context_receive_packet)
@@ -3300,6 +3797,7 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3300
3797
  V("setFramePacketDTS", bare_ffmpeg_frame_set_pkt_dts)
3301
3798
  V("getFrameTimeBase", bare_ffmpeg_frame_get_time_base)
3302
3799
  V("setFrameTimeBase", bare_ffmpeg_frame_set_time_base)
3800
+ V("copyFrameProperties", bare_ffmpeg_frame_copy_properties)
3303
3801
  V("allocFrame", bare_ffmpeg_frame_alloc)
3304
3802
 
3305
3803
  V("initImage", bare_ffmpeg_image_init)
@@ -3307,7 +3805,7 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3307
3805
  V("readImage", bare_ffmpeg_image_read)
3308
3806
  V("getImageLineSize", bare_ffmpeg_image_get_line_size)
3309
3807
 
3310
- V("initSamples", bare_ffmpeg_samples_init)
3808
+ V("samplesBufferSize", bare_ffmpeg_samples_buffer_size)
3311
3809
  V("fillSamples", bare_ffmpeg_samples_fill)
3312
3810
 
3313
3811
  V("initPacket", bare_ffmpeg_packet_init)
@@ -3333,6 +3831,7 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3333
3831
  V("setPacketDuration", bare_ffmpeg_packet_set_duration)
3334
3832
  V("getPacketFlags", bare_ffmpeg_packet_get_flags)
3335
3833
  V("setPacketFlags", bare_ffmpeg_packet_set_flags)
3834
+ V("copyPacketProps", bare_ffmpeg_packet_copy_props)
3336
3835
 
3337
3836
  V("getSideDataType", bare_ffmpeg_side_data_get_type)
3338
3837
  V("getSideDataName", bare_ffmpeg_side_data_get_name)
@@ -3370,6 +3869,28 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3370
3869
  V("getAudioFifoSpace", bare_ffmpeg_audio_fifo_space)
3371
3870
 
3372
3871
  V("rationalD2Q", bare_ffmpeg_rational_d2q)
3872
+ V("rationalRescaleQ", bare_ffmpeg_rational_rescale_q)
3873
+
3874
+ V("getFilterByName", bare_ffmpeg_filter_get_by_name)
3875
+
3876
+ V("initFilterContext", bare_ffmpeg_filter_context_init)
3877
+
3878
+ V("initFilterGraph", bare_ffmpeg_filter_graph_init)
3879
+ V("destroyFilterGraph", bare_ffmpeg_filter_graph_destroy)
3880
+ V("createFilterGraphFilter", bare_ffmpeg_filter_graph_create_filter)
3881
+ V("parseFilterGraph", bare_ffmpeg_filter_graph_parse)
3882
+ V("configureFilterGraph", bare_ffmpeg_filter_graph_configure)
3883
+ V("pushFilterGraphFrame", bare_ffmpeg_filter_graph_push_frame)
3884
+ V("pullFilterGraphFrame", bare_ffmpeg_filter_graph_pull_frame)
3885
+
3886
+ V("initFilterInout", bare_ffmpeg_filter_inout_init)
3887
+ V("destroyFilterInOut", bare_ffmpeg_filter_inout_destroy)
3888
+ V("getFilterInOutName", bare_ffmpeg_filter_inout_get_name)
3889
+ V("setFilterInOutName", bare_ffmpeg_filter_inout_set_name)
3890
+ V("setFilterInOutFilterContext", bare_ffmpeg_filter_inout_set_filter_context)
3891
+ V("getFilterInOutPadIdx", bare_ffmpeg_filter_inout_get_pad_idx)
3892
+ V("setFilterInOutPadIdx", bare_ffmpeg_filter_inout_set_pad_idx)
3893
+ V("setFilterInOutNext", bare_ffmpeg_filter_inout_set_next)
3373
3894
  #undef V
3374
3895
 
3375
3896
  #define V(name) \
@@ -3647,6 +4168,14 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
3647
4168
  V(AV_PKT_DATA_RTCP_SR)
3648
4169
  V(AV_PKT_DATA_NB)
3649
4170
 
4171
+ V(AV_CODEC_CONFIG_PIX_FORMAT)
4172
+ V(AV_CODEC_CONFIG_FRAME_RATE)
4173
+ V(AV_CODEC_CONFIG_SAMPLE_RATE)
4174
+ V(AV_CODEC_CONFIG_SAMPLE_FORMAT)
4175
+ V(AV_CODEC_CONFIG_CHANNEL_LAYOUT)
4176
+ V(AV_CODEC_CONFIG_COLOR_RANGE)
4177
+ V(AV_CODEC_CONFIG_COLOR_SPACE)
4178
+
3650
4179
  #undef V
3651
4180
 
3652
4181
  return exports;