@@ -35,6 +35,7 @@ extern "C" {
3535#include < libavutil/mathematics.h>
3636#include < libavutil/mem.h>
3737#include < libavutil/opt.h>
38+ #include < libavutil/pixdesc.h>
3839#include < libavutil/pixfmt.h>
3940#include < libavutil/rational.h>
4041#include < libavutil/samplefmt.h>
@@ -641,7 +642,6 @@ bare_ffmpeg_format_context_create_stream(
641642 assert (err == 0 );
642643
643644 stream->handle = avformat_new_stream (context->handle , NULL );
644-
645645 return handle;
646646}
647647
@@ -2452,6 +2452,87 @@ bare_ffmpeg_codec_parameters_set_color_trc(
24522452 parameters->handle ->color_trc = static_cast <AVColorTransferCharacteristic>(color_trc);
24532453}
24542454
2455+ static std::string
2456+ bare_ffmpeg_color_space_name (
2457+ js_env_t *env,
2458+ js_receiver_t ,
2459+ int color_space
2460+ ) {
2461+ return av_color_space_name (static_cast <AVColorSpace>(color_space));
2462+ }
2463+
2464+ static int
2465+ bare_ffmpeg_color_space_from_name (
2466+ js_env_t *env,
2467+ js_receiver_t ,
2468+ std::string color_space_name
2469+ ) {
2470+ int id = av_color_space_from_name (color_space_name.c_str ());
2471+
2472+ if (id < 0 ) {
2473+ int err = js_throw_error (env, NULL , av_err2str (id));
2474+ assert (err == 0 );
2475+
2476+ throw js_pending_exception;
2477+ }
2478+
2479+ return id;
2480+ }
2481+
2482+ static std::string
2483+ bare_ffmpeg_color_primaries_name (
2484+ js_env_t *env,
2485+ js_receiver_t ,
2486+ int color_primaries
2487+ ) {
2488+ return av_color_primaries_name (static_cast <AVColorPrimaries>(color_primaries));
2489+ }
2490+
2491+ static int
2492+ bare_ffmpeg_color_primaries_from_name (
2493+ js_env_t *env,
2494+ js_receiver_t ,
2495+ std::string color_primaries_name
2496+ ) {
2497+ int id = av_color_primaries_from_name (color_primaries_name.c_str ());
2498+
2499+ if (id < 0 ) {
2500+ int err = js_throw_error (env, NULL , av_err2str (id));
2501+ assert (err == 0 );
2502+
2503+ throw js_pending_exception;
2504+ }
2505+
2506+ return id;
2507+ }
2508+
2509+ static std::string
2510+ bare_ffmpeg_color_transfer_name (
2511+ js_env_t *env,
2512+ js_receiver_t ,
2513+ int color_trc
2514+ ) {
2515+ return av_color_transfer_name (static_cast <AVColorTransferCharacteristic>(color_trc));
2516+ }
2517+
2518+ static int
2519+ bare_ffmpeg_color_transfer_from_name (
2520+ js_env_t *env,
2521+ js_receiver_t ,
2522+ std::string color_trc_name
2523+ ) {
2524+ int id = av_color_transfer_from_name (color_trc_name.c_str ());
2525+
2526+ if (id < 0 ) {
2527+ int err = js_throw_error (env, NULL , av_err2str (id));
2528+ assert (err == 0 );
2529+
2530+ throw js_pending_exception;
2531+ }
2532+
2533+ return id;
2534+ }
2535+
24552536static int
24562537bare_ffmpeg_codec_parameters_get_color_range (
24572538 js_env_t *env,
@@ -4734,6 +4815,12 @@ bare_ffmpeg_exports(js_env_t *env, js_value_t *exports) {
47344815 V (" getCodecParametersColorRange" , bare_ffmpeg_codec_parameters_get_color_range)
47354816 V (" setCodecParametersColorRange" , bare_ffmpeg_codec_parameters_set_color_range)
47364817
4818+ V (" getColorSpaceNameByID" , bare_ffmpeg_color_space_name)
4819+ V (" getColorSpaceFromName" , bare_ffmpeg_color_space_from_name)
4820+ V (" getColorPrimariesNameByID" , bare_ffmpeg_color_primaries_name)
4821+ V (" getColorPrimariesFromName" , bare_ffmpeg_color_primaries_from_name)
4822+ V (" getColorTransferNameByID" , bare_ffmpeg_color_transfer_name)
4823+ V (" getColorTransferFromName" , bare_ffmpeg_color_transfer_from_name)
47374824
47384825 V (" initFrame" , bare_ffmpeg_frame_init)
47394826 V (" destroyFrame" , bare_ffmpeg_frame_destroy)
0 commit comments