diff --git a/.eslintignore b/.eslintignore index c4eb0fbcd..ff09245b1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,4 @@ src/lib/rlottie/rlottie-wasm.js -src/lib/video-preview/libav* src/lib/video-preview/polyfill src/lib/webp/webp_wasm.js src/lib/fasttextweb/fasttext-wasm.js diff --git a/README.md b/README.md index 6ab16ea2f..30c5039ab 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,6 @@ Publish configuration in `src/electron/config.yml` config file allows to set Git * [qr-code-styling](https://github.com/kozakdenys/qr-code-styling) ([MIT License](https://github.com/kozakdenys/qr-code-styling/blob/master/LICENSE)) * [croppie](https://github.com/Foliotek/Croppie) ([MIT License](https://github.com/Foliotek/Croppie/blob/master/LICENSE)) * [mp4box](https://github.com/gpac/mp4box.js) ([BSD-3-Clause license](https://github.com/gpac/mp4box.js/blob/master/LICENSE)) -* [libav.js](https://github.com/Yahweasel/libav.js/) (Various Licenses) * [music-metadata-browser](https://github.com/Borewit/music-metadata-browser) ([MIT License](https://github.com/Borewit/music-metadata-browser/blob/master/LICENSE.txt)) * [lowlight](https://github.com/wooorm/lowlight) ([MIT License](https://github.com/wooorm/lowlight/blob/main/license)) * [idb-keyval](https://github.com/jakearchibald/idb-keyval) ([Apache License 2.0](https://github.com/jakearchibald/idb-keyval/blob/main/LICENCE)) diff --git a/deploy/copy_to_dist.sh b/deploy/copy_to_dist.sh index 4d798ffa4..69af033ab 100755 --- a/deploy/copy_to_dist.sh +++ b/deploy/copy_to_dist.sh @@ -4,9 +4,6 @@ cp -R ./public/* ${1:-"dist"} cp ./src/lib/rlottie/rlottie-wasm.wasm ${1:-"dist"} -cp ./src/lib/video-preview/libav-3.10.5.1.2-webcodecs.wasm.js ${1:-"dist"} -cp ./src/lib/video-preview/libav-3.10.5.1.2-webcodecs.wasm.wasm ${1:-"dist"} - cp ./src/lib/webp/webp_wasm.wasm ${1:-"dist"} cp ./node_modules/opus-recorder/dist/decoderWorker.min.wasm ${1:-"dist"} diff --git a/src/components/mediaViewer/MediaViewerContent.tsx b/src/components/mediaViewer/MediaViewerContent.tsx index 30ef45a85..736e82a65 100644 --- a/src/components/mediaViewer/MediaViewerContent.tsx +++ b/src/components/mediaViewer/MediaViewerContent.tsx @@ -7,9 +7,7 @@ import type { } from '../../api/types'; import { MediaViewerOrigin } from '../../types'; -import { - IS_TOUCH_ENV, IS_IOS, IS_ANDROID, ARE_WEBCODECS_SUPPORTED, -} from '../../util/windowEnvironment'; +import { IS_TOUCH_ENV, ARE_WEBCODECS_SUPPORTED } from '../../util/windowEnvironment'; import { selectChat, selectChatMessage, selectTabState, selectIsMessageProtected, selectScheduledMessage, selectUser, } from '../../global/selectors'; @@ -60,7 +58,6 @@ type StateProps = { const ANIMATION_DURATION = 350; const MOBILE_VERSION_CONTROL_WIDTH = 350; -const IS_PREVIEW_DISABLED = (IS_IOS || IS_ANDROID) && !ARE_WEBCODECS_SUPPORTED; const MediaViewerContent: FC = (props) => { const { @@ -133,7 +130,7 @@ const MediaViewerContent: FC = (props) => { fileSize={videoSize!} isMediaViewerOpen={isOpen && isActive} isProtected={isProtected} - isPreviewDisabled={IS_PREVIEW_DISABLED || isLocal} + isPreviewDisabled={!ARE_WEBCODECS_SUPPORTED || isLocal} noPlay={!isActive} onClose={onClose} isMuted @@ -183,7 +180,7 @@ const MediaViewerContent: FC = (props) => { fileSize={videoSize!} isMediaViewerOpen={isOpen && isActive} noPlay={!isActive} - isPreviewDisabled={IS_PREVIEW_DISABLED || isLocal} + isPreviewDisabled={!ARE_WEBCODECS_SUPPORTED || isLocal} onClose={onClose} isMuted={isMuted} isHidden={isHidden} diff --git a/src/electron/config.yml b/src/electron/config.yml index 650a8652c..5f647cc97 100644 --- a/src/electron/config.yml +++ b/src/electron/config.yml @@ -11,7 +11,6 @@ files: - "!dist/**/statoscope-report.html" - "!dist/**/reference.json" - "!dist/img-apple-*" - - "!dist/libav-*" - "!node_modules" directories: buildResources: "./public" diff --git a/src/lib/video-preview/VideoPreview.ts b/src/lib/video-preview/VideoPreview.ts index 464c70518..c399ad3e1 100644 --- a/src/lib/video-preview/VideoPreview.ts +++ b/src/lib/video-preview/VideoPreview.ts @@ -2,12 +2,12 @@ import { requestMutation } from '../fasterdom/fasterdom'; import { callApi } from '../../api/gramjs'; import { ApiMediaFormat } from '../../api/types'; -import { IS_ANDROID, IS_IOS, ARE_WEBCODECS_SUPPORTED } from '../../util/windowEnvironment'; +import { IS_ANDROID, IS_IOS } from '../../util/windowEnvironment'; import launchMediaWorkers, { MAX_WORKERS } from '../../util/launchMediaWorkers'; const IS_MOBILE = IS_ANDROID || IS_IOS; const PREVIEW_SIZE_RATIO = (IS_ANDROID || IS_IOS) ? 0.3 : 0.25; -const MAX_FRAMES = ARE_WEBCODECS_SUPPORTED && !IS_MOBILE ? 80 : 40; +const MAX_FRAMES = IS_MOBILE ? 40 : 80; const PREVIEW_MAX_SIDE = 200; const connections = launchMediaWorkers(); diff --git a/src/lib/video-preview/libav-3.10.5.1.2-webcodecs.js b/src/lib/video-preview/libav-3.10.5.1.2-webcodecs.js deleted file mode 100644 index eec283286..000000000 --- a/src/lib/video-preview/libav-3.10.5.1.2-webcodecs.js +++ /dev/null @@ -1 +0,0 @@ -(function(){function r(e){e=e||[0,97,115,109,1,0,0,0];if(typeof WebAssembly!=="object"||typeof WebAssembly.instantiate!=="function")return false;try{var e=new WebAssembly.Module(new Uint8Array(e));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}catch(e){}return false}function o(){try{var e=new WebAssembly.Memory({initial:1,maximum:1,shared:true});if(!(e.buffer instanceof SharedArrayBuffer))return false;return true}catch(e){}return false}function n(){return r([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])}var t;var _=".";var c=typeof process!=="undefined";if(typeof LibAV==="undefined")LibAV={};t=LibAV;if(t.base)_=t.base;t.isWebAssemblySupported=r;t.isThreadingSupported=o;t.isSIMDSupported=n;function s(e){e=e||{};var _=!e.nowasm&&r();var t=e.yesthreads&&_&&!e.nothreads&&o();var a=_&&!e.nosimd&&n();if(!_)return"asm";else if(!t&&!a)return"wasm";else return(t?"thr":"")+(a?"simd":"")}t.target=s;t.LibAV=function(e){e=e||{};var a=_+"/libav-3.10.5.1.2-webcodecs."+s(e)+".js";var o;return Promise.all([]).then(function(){if(!t.LibAVFactory){if(c){t.LibAVFactory=require(a)}else if(typeof Worker!=="undefined"&&!e.noworker){}else if(typeof importScripts!=="undefined"){importScripts(a);t.LibAVFactory=LibAVFactory}else{return new Promise(function(e,_){var t=document.createElement("script");t.src=a;t.addEventListener("load",e);t.addEventListener("error",_);t.async=true;document.body.appendChild(t)}).then(function(){t.LibAVFactory=LibAVFactory})}}}).then(function(){if(!c&&typeof Worker!=="undefined"&&!e.noworker){o={};o.worker=new Worker(a);return new Promise(function(e,_){var t=0;o.on=1;o.handlers={onready:[function(){e()},null],onwrite:[function(e){if(o.onwrite)o.onwrite.apply(o,e)},null]};o.c=function(){var a=Array.prototype.slice.call(arguments);return new Promise(function(e,_){var t=o.on++;a=[t].concat(a);o.handlers[t]=[e,_];o.worker.postMessage(a)})};function a(e){var _=e.data[0];var t=o.handlers[_];if(t){if(e.data[2])t[0](e.data[3]);else t[1](e.data[3]);if(typeof _==="number")delete o.handlers[_]}}o.worker.onmessage=a;o.terminate=function(){o.worker.terminate()}})}else{return Promise.all([]).then(function(){return new Promise(function(_){t.LibAVFactory().then(function(e){delete e.then;_(e)})})}).then(function(e){o=e;o.worker=false;o.c=function(t){var a=Array.prototype.slice.call(arguments,1);return new Promise(function(e,_){try{e(o[t].apply(o,a))}catch(e){_(e)}})};o.terminate=function(){}})}}).then(function(){["av_get_bytes_per_sample","av_opt_set_int_list_js","av_frame_alloc","av_frame_free","av_frame_get_buffer","av_frame_make_writable","av_frame_unref","av_packet_alloc","av_packet_free","av_packet_new_side_data","av_packet_unref","av_strdup","av_buffersink_get_frame","av_buffersink_set_frame_size","av_buffersrc_add_frame_flags","avfilter_free","avfilter_get_by_name","avfilter_graph_alloc","avfilter_graph_config","avfilter_graph_create_filter_js","avfilter_graph_free","avfilter_graph_parse","avfilter_inout_alloc","avfilter_inout_free","avfilter_link","avcodec_alloc_context3","avcodec_close","avcodec_find_decoder","avcodec_find_decoder_by_name","avcodec_find_encoder","avcodec_find_encoder_by_name","avcodec_free_context","avcodec_get_name","avcodec_open2","ff_calloc_AVCodecParameters","avcodec_parameters_from_context","avcodec_parameters_to_context","avcodec_receive_frame","avcodec_receive_packet","avcodec_send_frame","avcodec_send_packet","av_find_input_format","avformat_alloc_context","avformat_alloc_output_context2_js","avformat_close_input","avformat_find_stream_info","avformat_free_context","avformat_new_stream","avformat_open_input","avformat_open_input_js","avformat_write_header","avio_open2_js","avio_close","av_find_best_stream","av_grow_packet","av_interleaved_write_frame","av_packet_make_writable","av_pix_fmt_desc_get","av_read_frame","av_shrink_packet","av_write_frame","av_write_trailer","av_dict_set","av_dict_free","sws_getContext","sws_freeContext","sws_scale_frame","AVFrame_sample_aspect_ratio_num","AVFrame_sample_aspect_ratio_den","AVFrame_sample_aspect_ratio_s","AVCodecContext_framerate_num","AVCodecContext_framerate_den","AVCodecContext_framerate_num_s","AVCodecContext_framerate_den_s","AVCodecContext_framerate_s","AVCodecContext_sample_aspect_ratio_num","AVCodecContext_sample_aspect_ratio_den","AVCodecContext_sample_aspect_ratio_num_s","AVCodecContext_sample_aspect_ratio_den_s","AVCodecContext_sample_aspect_ratio_s","AVCodecContext_time_base_s","AVStream_time_base_num","AVStream_time_base_den","AVStream_time_base_s","AVPacketSideData_data","AVPacketSideData_size","AVPacketSideData_type","ff_error","ff_nothing","calloc","free","malloc","mallinfo_uordblks","libavjs_with_swscale","AVFrame_channel_layout","AVFrame_channel_layout_s","AVFrame_channel_layouthi","AVFrame_channel_layouthi_s","AVFrame_channels","AVFrame_channels_s","AVFrame_data_a","AVFrame_data_a_s","AVFrame_format","AVFrame_format_s","AVFrame_height","AVFrame_height_s","AVFrame_key_frame","AVFrame_key_frame_s","AVFrame_linesize_a","AVFrame_linesize_a_s","AVFrame_nb_samples","AVFrame_nb_samples_s","AVFrame_pict_type","AVFrame_pict_type_s","AVFrame_pts","AVFrame_pts_s","AVFrame_ptshi","AVFrame_ptshi_s","AVFrame_sample_rate","AVFrame_sample_rate_s","AVFrame_width","AVFrame_width_s","AVPixFmtDescriptor_log2_chroma_h","AVPixFmtDescriptor_log2_chroma_h_s","AVCodecContext_bit_rate","AVCodecContext_bit_rate_s","AVCodecContext_bit_ratehi","AVCodecContext_bit_ratehi_s","AVCodecContext_channel_layout","AVCodecContext_channel_layout_s","AVCodecContext_channel_layouthi","AVCodecContext_channel_layouthi_s","AVCodecContext_channels","AVCodecContext_channels_s","AVCodecContext_extradata","AVCodecContext_extradata_s","AVCodecContext_extradata_size","AVCodecContext_extradata_size_s","AVCodecContext_frame_size","AVCodecContext_frame_size_s","AVCodecContext_gop_size","AVCodecContext_gop_size_s","AVCodecContext_height","AVCodecContext_height_s","AVCodecContext_keyint_min","AVCodecContext_keyint_min_s","AVCodecContext_level","AVCodecContext_level_s","AVCodecContext_pix_fmt","AVCodecContext_pix_fmt_s","AVCodecContext_profile","AVCodecContext_profile_s","AVCodecContext_rc_max_rate","AVCodecContext_rc_max_rate_s","AVCodecContext_rc_max_ratehi","AVCodecContext_rc_max_ratehi_s","AVCodecContext_rc_min_rate","AVCodecContext_rc_min_rate_s","AVCodecContext_rc_min_ratehi","AVCodecContext_rc_min_ratehi_s","AVCodecContext_sample_fmt","AVCodecContext_sample_fmt_s","AVCodecContext_sample_rate","AVCodecContext_sample_rate_s","AVCodecContext_qmax","AVCodecContext_qmax_s","AVCodecContext_qmin","AVCodecContext_qmin_s","AVCodecContext_width","AVCodecContext_width_s","AVCodecParameters_codec_id","AVCodecParameters_codec_id_s","AVCodecParameters_codec_type","AVCodecParameters_codec_type_s","AVCodecParameters_extradata","AVCodecParameters_extradata_s","AVCodecParameters_extradata_size","AVCodecParameters_extradata_size_s","AVCodecParameters_format","AVCodecParameters_format_s","AVCodecParameters_bit_rate","AVCodecParameters_bit_rate_s","AVCodecParameters_profile","AVCodecParameters_profile_s","AVCodecParameters_level","AVCodecParameters_level_s","AVCodecParameters_width","AVCodecParameters_width_s","AVCodecParameters_height","AVCodecParameters_height_s","AVCodecParameters_color_range","AVCodecParameters_color_range_s","AVCodecParameters_color_primaries","AVCodecParameters_color_primaries_s","AVCodecParameters_color_trc","AVCodecParameters_color_trc_s","AVCodecParameters_color_space","AVCodecParameters_color_space_s","AVCodecParameters_chroma_location","AVCodecParameters_chroma_location_s","AVCodecParameters_channels","AVCodecParameters_channels_s","AVCodecParameters_sample_rate","AVCodecParameters_sample_rate_s","AVPacket_pts","AVPacket_pts_s","AVPacket_ptshi","AVPacket_ptshi_s","AVPacket_dts","AVPacket_dts_s","AVPacket_dtshi","AVPacket_dtshi_s","AVPacket_data","AVPacket_data_s","AVPacket_size","AVPacket_size_s","AVPacket_stream_index","AVPacket_stream_index_s","AVPacket_flags","AVPacket_flags_s","AVPacket_side_data","AVPacket_side_data_s","AVPacket_side_data_elems","AVPacket_side_data_elems_s","AVPacket_duration","AVPacket_duration_s","AVPacket_durationhi","AVPacket_durationhi_s","AVFormatContext_nb_streams","AVFormatContext_nb_streams_s","AVFormatContext_oformat","AVFormatContext_oformat_s","AVFormatContext_pb","AVFormatContext_pb_s","AVFormatContext_streams_a","AVFormatContext_streams_a_s","AVStream_codecpar","AVStream_codecpar_s","AVStream_duration","AVStream_duration_s","AVStream_durationhi","AVStream_durationhi_s","AVFilterInOut_filter_ctx","AVFilterInOut_filter_ctx_s","AVFilterInOut_name","AVFilterInOut_name_s","AVFilterInOut_next","AVFilterInOut_next_s","AVFilterInOut_pad_idx","AVFilterInOut_pad_idx_s","readFile","writeFile","unlink","mkdev","mkreaderdev","mkwriterdev","ff_reader_dev_send","ff_reader_dev_waiting","ff_init_encoder","ff_init_decoder","ff_free_encoder","ff_free_decoder","ff_encode_multi","ff_decode_multi","ff_set_packet","ff_init_muxer","ff_free_muxer","ff_init_demuxer_file","ff_write_multi","ff_read_multi","ff_init_filter_graph","ff_filter_multi","ff_copyout_frame","ff_copyin_frame","ff_copyout_packet","ff_copyin_packet","ff_malloc_int32_list","ff_malloc_int64_list","av_frame_free_js","av_packet_free_js","avformat_close_input_js","avcodec_free_context_js","avfilter_graph_free_js","avfilter_inout_free_js","copyin_u8","copyout_u8","copyin_s16","copyout_s16","copyin_s32","copyout_s32","copyin_f32","copyout_f32"].forEach(function(e){if(o[e]){var r=o[e+"_sync"]=o[e];o[e]=function(){var a=arguments;return new Promise(function(e,_){try{var t=r.apply(o,a);if(typeof t==="object"&&t!==null&&t.then)t.then(e).catch(_);else e(t)}catch(e){_(e)}})}}else{o[e]=function(){return o.c.apply(o,[e].concat(Array.prototype.slice.call(arguments)))}}});function e(e,_){if(typeof _===undefined)_=0;var t=_;e.forEach(function(e){o[e]=t++})}o.AV_OPT_SEARCH_CHILDREN=1;e(["AVMEDIA_TYPE_UNKNOWN","AVMEDIA_TYPE_VIDEO","AVMEDIA_TYPE_AUDIO","AVMEDIA_TYPE_DATA","AVMEDIA_TYPE_SUBTITLE","AVMEDIA_TYPE_ATTACHMENT"],-1);e(["AV_SAMPLE_FMT_NONE","AV_SAMPLE_FMT_U8","AV_SAMPLE_FMT_S16","AV_SAMPLE_FMT_S32","AV_SAMPLE_FMT_FLT","AV_SAMPLE_FMT_DBL","AV_SAMPLE_FMT_U8P","AV_SAMPLE_FMT_S16P","AV_SAMPLE_FMT_S32P","AV_SAMPLE_FMT_FLTP","AV_SAMPLE_FMT_DBLP","AV_SAMPLE_FMT_S64","AV_SAMPLE_FMT_S64P","AV_SAMPLE_FMT_NB"],-1);e(["AV_PIX_FMT_NONE","AV_PIX_FMT_YUV420P","AV_PIX_FMT_YUYV422","AV_PIX_FMT_RGB24","AV_PIX_FMT_BGR24","AV_PIX_FMT_YUV422P","AV_PIX_FMT_YUV444P","AV_PIX_FMT_YUV410P","AV_PIX_FMT_YUV411P","AV_PIX_FMT_GRAY8","AV_PIX_FMT_MONOWHITE","AV_PIX_FMT_MONOBLACK","AV_PIX_FMT_PAL8","AV_PIX_FMT_YUVJ420P","AV_PIX_FMT_YUVJ422P","AV_PIX_FMT_YUVJ444P","AV_PIX_FMT_UYVY422","AV_PIX_FMT_UYYVYY411","AV_PIX_FMT_BGR8","AV_PIX_FMT_BGR4","AV_PIX_FMT_BGR4_BYTE","AV_PIX_FMT_RGB8","AV_PIX_FMT_RGB4","AV_PIX_FMT_RGB4_BYTE","AV_PIX_FMT_NV12","AV_PIX_FMT_NV21","AV_PIX_FMT_ARGB","AV_PIX_FMT_RGBA","AV_PIX_FMT_ABGR","AV_PIX_FMT_BGRA","AV_PIX_FMT_GRAY16BE","AV_PIX_FMT_GRAY16LE","AV_PIX_FMT_YUV440P","AV_PIX_FMT_YUVJ440P","AV_PIX_FMT_YUVA420P","AV_PIX_FMT_RGB48BE","AV_PIX_FMT_RGB48LE","AV_PIX_FMT_RGB565BE","AV_PIX_FMT_RGB565LE","AV_PIX_FMT_RGB555BE","AV_PIX_FMT_RGB555LE","AV_PIX_FMT_BGR565BE","AV_PIX_FMT_BGR565LE","AV_PIX_FMT_BGR555BE","AV_PIX_FMT_BGR555LE"],-1);o.AVIO_FLAG_READ=1;o.AVIO_FLAG_WRITE=2;o.AVIO_FLAG_READ_WRITE=3;o.AVIO_FLAG_NONBLOCK=8;o.AVIO_FLAG_DIRECT=32768;o.EAGAIN=6;o.AVERROR_EOF=-541478725;return o})};if(c)module.exports=t})(); diff --git a/src/lib/video-preview/libav-3.10.5.1.2-webcodecs.wasm.js b/src/lib/video-preview/libav-3.10.5.1.2-webcodecs.wasm.js deleted file mode 100644 index 397f0f2fb..000000000 --- a/src/lib/video-preview/libav-3.10.5.1.2-webcodecs.wasm.js +++ /dev/null @@ -1,814 +0,0 @@ -/* - * This software is compiled from several sources, the licenses for which are - * included herein. - * - * --- - * - * ffmpeg: - * - * Copyright (c) 2000-2022 Fabrice Bellard et al - * - * GNU LESSER GENERAL PUBLIC LICENSE - * Version 2.1, February 1999 - * - * Copyright (C) 1991, 1999 Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * Everyone is permitted to copy and distribute verbatim copies - * of this license document, but changing it is not allowed. - * - * [This is the first released version of the Lesser GPL. It also counts - * as the successor of the GNU Library Public License, version 2, hence - * the version number 2.1.] - * - * Preamble - * - * The licenses for most software are designed to take away your - * freedom to share and change it. By contrast, the GNU General Public - * Licenses are intended to guarantee your freedom to share and change - * free software--to make sure the software is free for all its users. - * - * This license, the Lesser General Public License, applies to some - * specially designated software packages--typically libraries--of the - * Free Software Foundation and other authors who decide to use it. You - * can use it too, but we suggest you first think carefully about whether - * this license or the ordinary General Public License is the better - * strategy to use in any particular case, based on the explanations below. - * - * When we speak of free software, we are referring to freedom of use, - * not price. Our General Public Licenses are designed to make sure that - * you have the freedom to distribute copies of free software (and charge - * for this service if you wish); that you receive source code or can get - * it if you want it; that you can change the software and use pieces of - * it in new free programs; and that you are informed that you can do - * these things. - * - * To protect your rights, we need to make restrictions that forbid - * distributors to deny you these rights or to ask you to surrender these - * rights. These restrictions translate to certain responsibilities for - * you if you distribute copies of the library or if you modify it. - * - * For example, if you distribute copies of the library, whether gratis - * or for a fee, you must give the recipients all the rights that we gave - * you. You must make sure that they, too, receive or can get the source - * code. If you link other code with the library, you must provide - * complete object files to the recipients, so that they can relink them - * with the library after making changes to the library and recompiling - * it. And you must show them these terms so they know their rights. - * - * We protect your rights with a two-step method: (1) we copyright the - * library, and (2) we offer you this license, which gives you legal - * permission to copy, distribute and/or modify the library. - * - * To protect each distributor, we want to make it very clear that - * there is no warranty for the free library. Also, if the library is - * modified by someone else and passed on, the recipients should know - * that what they have is not the original version, so that the original - * author's reputation will not be affected by problems that might be - * introduced by others. - * - * Finally, software patents pose a constant threat to the existence of - * any free program. We wish to make sure that a company cannot - * effectively restrict the users of a free program by obtaining a - * restrictive license from a patent holder. Therefore, we insist that - * any patent license obtained for a version of the library must be - * consistent with the full freedom of use specified in this license. - * - * Most GNU software, including some libraries, is covered by the - * ordinary GNU General Public License. This license, the GNU Lesser - * General Public License, applies to certain designated libraries, and - * is quite different from the ordinary General Public License. We use - * this license for certain libraries in order to permit linking those - * libraries into non-free programs. - * - * When a program is linked with a library, whether statically or using - * a shared library, the combination of the two is legally speaking a - * combined work, a derivative of the original library. The ordinary - * General Public License therefore permits such linking only if the - * entire combination fits its criteria of freedom. The Lesser General - * Public License permits more lax criteria for linking other code with - * the library. - * - * We call this license the "Lesser" General Public License because it - * does Less to protect the user's freedom than the ordinary General - * Public License. It also provides other free software developers Less - * of an advantage over competing non-free programs. These disadvantages - * are the reason we use the ordinary General Public License for many - * libraries. However, the Lesser license provides advantages in certain - * special circumstances. - * - * For example, on rare occasions, there may be a special need to - * encourage the widest possible use of a certain library, so that it becomes - * a de-facto standard. To achieve this, non-free programs must be - * allowed to use the library. A more frequent case is that a free - * library does the same job as widely used non-free libraries. In this - * case, there is little to gain by limiting the free library to free - * software only, so we use the Lesser General Public License. - * - * In other cases, permission to use a particular library in non-free - * programs enables a greater number of people to use a large body of - * free software. For example, permission to use the GNU C Library in - * non-free programs enables many more people to use the whole GNU - * operating system, as well as its variant, the GNU/Linux operating - * system. - * - * Although the Lesser General Public License is Less protective of the - * users' freedom, it does ensure that the user of a program that is - * linked with the Library has the freedom and the wherewithal to run - * that program using a modified version of the Library. - * - * The precise terms and conditions for copying, distribution and - * modification follow. Pay close attention to the difference between a - * "work based on the library" and a "work that uses the library". The - * former contains code derived from the library, whereas the latter must - * be combined with the library in order to run. - * - * GNU LESSER GENERAL PUBLIC LICENSE - * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - * - * 0. This License Agreement applies to any software library or other - * program which contains a notice placed by the copyright holder or - * other authorized party saying it may be distributed under the terms of - * this Lesser General Public License (also called "this License"). - * Each licensee is addressed as "you". - * - * A "library" means a collection of software functions and/or data - * prepared so as to be conveniently linked with application programs - * (which use some of those functions and data) to form executables. - * - * The "Library", below, refers to any such software library or work - * which has been distributed under these terms. A "work based on the - * Library" means either the Library or any derivative work under - * copyright law: that is to say, a work containing the Library or a - * portion of it, either verbatim or with modifications and/or translated - * straightforwardly into another language. (Hereinafter, translation is - * included without limitation in the term "modification".) - * - * "Source code" for a work means the preferred form of the work for - * making modifications to it. For a library, complete source code means - * all the source code for all modules it contains, plus any associated - * interface definition files, plus the scripts used to control compilation - * and installation of the library. - * - * Activities other than copying, distribution and modification are not - * covered by this License; they are outside its scope. The act of - * running a program using the Library is not restricted, and output from - * such a program is covered only if its contents constitute a work based - * on the Library (independent of the use of the Library in a tool for - * writing it). Whether that is true depends on what the Library does - * and what the program that uses the Library does. - * - * 1. You may copy and distribute verbatim copies of the Library's - * complete source code as you receive it, in any medium, provided that - * you conspicuously and appropriately publish on each copy an - * appropriate copyright notice and disclaimer of warranty; keep intact - * all the notices that refer to this License and to the absence of any - * warranty; and distribute a copy of this License along with the - * Library. - * - * You may charge a fee for the physical act of transferring a copy, - * and you may at your option offer warranty protection in exchange for a - * fee. - * - * 2. You may modify your copy or copies of the Library or any portion - * of it, thus forming a work based on the Library, and copy and - * distribute such modifications or work under the terms of Section 1 - * above, provided that you also meet all of these conditions: - * - * a) The modified work must itself be a software library. - * - * b) You must cause the files modified to carry prominent notices - * stating that you changed the files and the date of any change. - * - * c) You must cause the whole of the work to be licensed at no - * charge to all third parties under the terms of this License. - * - * d) If a facility in the modified Library refers to a function or a - * table of data to be supplied by an application program that uses - * the facility, other than as an argument passed when the facility - * is invoked, then you must make a good faith effort to ensure that, - * in the event an application does not supply such function or - * table, the facility still operates, and performs whatever part of - * its purpose remains meaningful. - * - * (For example, a function in a library to compute square roots has - * a purpose that is entirely well-defined independent of the - * application. Therefore, Subsection 2d requires that any - * application-supplied function or table used by this function must - * be optional: if the application does not supply it, the square - * root function must still compute square roots.) - * - * These requirements apply to the modified work as a whole. If - * identifiable sections of that work are not derived from the Library, - * and can be reasonably considered independent and separate works in - * themselves, then this License, and its terms, do not apply to those - * sections when you distribute them as separate works. But when you - * distribute the same sections as part of a whole which is a work based - * on the Library, the distribution of the whole must be on the terms of - * this License, whose permissions for other licensees extend to the - * entire whole, and thus to each and every part regardless of who wrote - * it. - * - * Thus, it is not the intent of this section to claim rights or contest - * your rights to work written entirely by you; rather, the intent is to - * exercise the right to control the distribution of derivative or - * collective works based on the Library. - * - * In addition, mere aggregation of another work not based on the Library - * with the Library (or with a work based on the Library) on a volume of - * a storage or distribution medium does not bring the other work under - * the scope of this License. - * - * 3. You may opt to apply the terms of the ordinary GNU General Public - * License instead of this License to a given copy of the Library. To do - * this, you must alter all the notices that refer to this License, so - * that they refer to the ordinary GNU General Public License, version 2, - * instead of to this License. (If a newer version than version 2 of the - * ordinary GNU General Public License has appeared, then you can specify - * that version instead if you wish.) Do not make any other change in - * these notices. - * - * Once this change is made in a given copy, it is irreversible for - * that copy, so the ordinary GNU General Public License applies to all - * subsequent copies and derivative works made from that copy. - * - * This option is useful when you wish to copy part of the code of - * the Library into a program that is not a library. - * - * 4. You may copy and distribute the Library (or a portion or - * derivative of it, under Section 2) in object code or executable form - * under the terms of Sections 1 and 2 above provided that you accompany - * it with the complete corresponding machine-readable source code, which - * must be distributed under the terms of Sections 1 and 2 above on a - * medium customarily used for software interchange. - * - * If distribution of object code is made by offering access to copy - * from a designated place, then offering equivalent access to copy the - * source code from the same place satisfies the requirement to - * distribute the source code, even though third parties are not - * compelled to copy the source along with the object code. - * - * 5. A program that contains no derivative of any portion of the - * Library, but is designed to work with the Library by being compiled or - * linked with it, is called a "work that uses the Library". Such a - * work, in isolation, is not a derivative work of the Library, and - * therefore falls outside the scope of this License. - * - * However, linking a "work that uses the Library" with the Library - * creates an executable that is a derivative of the Library (because it - * contains portions of the Library), rather than a "work that uses the - * library". The executable is therefore covered by this License. - * Section 6 states terms for distribution of such executables. - * - * When a "work that uses the Library" uses material from a header file - * that is part of the Library, the object code for the work may be a - * derivative work of the Library even though the source code is not. - * Whether this is true is especially significant if the work can be - * linked without the Library, or if the work is itself a library. The - * threshold for this to be true is not precisely defined by law. - * - * If such an object file uses only numerical parameters, data - * structure layouts and accessors, and small macros and small inline - * functions (ten lines or less in length), then the use of the object - * file is unrestricted, regardless of whether it is legally a derivative - * work. (Executables containing this object code plus portions of the - * Library will still fall under Section 6.) - * - * Otherwise, if the work is a derivative of the Library, you may - * distribute the object code for the work under the terms of Section 6. - * Any executables containing that work also fall under Section 6, - * whether or not they are linked directly with the Library itself. - * - * 6. As an exception to the Sections above, you may also combine or - * link a "work that uses the Library" with the Library to produce a - * work containing portions of the Library, and distribute that work - * under terms of your choice, provided that the terms permit - * modification of the work for the customer's own use and reverse - * engineering for debugging such modifications. - * - * You must give prominent notice with each copy of the work that the - * Library is used in it and that the Library and its use are covered by - * this License. You must supply a copy of this License. If the work - * during execution displays copyright notices, you must include the - * copyright notice for the Library among them, as well as a reference - * directing the user to the copy of this License. Also, you must do one - * of these things: - * - * a) Accompany the work with the complete corresponding - * machine-readable source code for the Library including whatever - * changes were used in the work (which must be distributed under - * Sections 1 and 2 above); and, if the work is an executable linked - * with the Library, with the complete machine-readable "work that - * uses the Library", as object code and/or source code, so that the - * user can modify the Library and then relink to produce a modified - * executable containing the modified Library. (It is understood - * that the user who changes the contents of definitions files in the - * Library will not necessarily be able to recompile the application - * to use the modified definitions.) - * - * b) Use a suitable shared library mechanism for linking with the - * Library. A suitable mechanism is one that (1) uses at run time a - * copy of the library already present on the user's computer system, - * rather than copying library functions into the executable, and (2) - * will operate properly with a modified version of the library, if - * the user installs one, as long as the modified version is - * interface-compatible with the version that the work was made with. - * - * c) Accompany the work with a written offer, valid for at - * least three years, to give the same user the materials - * specified in Subsection 6a, above, for a charge no more - * than the cost of performing this distribution. - * - * d) If distribution of the work is made by offering access to copy - * from a designated place, offer equivalent access to copy the above - * specified materials from the same place. - * - * e) Verify that the user has already received a copy of these - * materials or that you have already sent this user a copy. - * - * For an executable, the required form of the "work that uses the - * Library" must include any data and utility programs needed for - * reproducing the executable from it. However, as a special exception, - * the materials to be distributed need not include anything that is - * normally distributed (in either source or binary form) with the major - * components (compiler, kernel, and so on) of the operating system on - * which the executable runs, unless that component itself accompanies - * the executable. - * - * It may happen that this requirement contradicts the license - * restrictions of other proprietary libraries that do not normally - * accompany the operating system. Such a contradiction means you cannot - * use both them and the Library together in an executable that you - * distribute. - * - * 7. You may place library facilities that are a work based on the - * Library side-by-side in a single library together with other library - * facilities not covered by this License, and distribute such a combined - * library, provided that the separate distribution of the work based on - * the Library and of the other library facilities is otherwise - * permitted, and provided that you do these two things: - * - * a) Accompany the combined library with a copy of the same work - * based on the Library, uncombined with any other library - * facilities. This must be distributed under the terms of the - * Sections above. - * - * b) Give prominent notice with the combined library of the fact - * that part of it is a work based on the Library, and explaining - * where to find the accompanying uncombined form of the same work. - * - * 8. You may not copy, modify, sublicense, link with, or distribute - * the Library except as expressly provided under this License. Any - * attempt otherwise to copy, modify, sublicense, link with, or - * distribute the Library is void, and will automatically terminate your - * rights under this License. However, parties who have received copies, - * or rights, from you under this License will not have their licenses - * terminated so long as such parties remain in full compliance. - * - * 9. You are not required to accept this License, since you have not - * signed it. However, nothing else grants you permission to modify or - * distribute the Library or its derivative works. These actions are - * prohibited by law if you do not accept this License. Therefore, by - * modifying or distributing the Library (or any work based on the - * Library), you indicate your acceptance of this License to do so, and - * all its terms and conditions for copying, distributing or modifying - * the Library or works based on it. - * - * 10. Each time you redistribute the Library (or any work based on the - * Library), the recipient automatically receives a license from the - * original licensor to copy, distribute, link with or modify the Library - * subject to these terms and conditions. You may not impose any further - * restrictions on the recipients' exercise of the rights granted herein. - * You are not responsible for enforcing compliance by third parties with - * this License. - * - * 11. If, as a consequence of a court judgment or allegation of patent - * infringement or for any other reason (not limited to patent issues), - * conditions are imposed on you (whether by court order, agreement or - * otherwise) that contradict the conditions of this License, they do not - * excuse you from the conditions of this License. If you cannot - * distribute so as to satisfy simultaneously your obligations under this - * License and any other pertinent obligations, then as a consequence you - * may not distribute the Library at all. For example, if a patent - * license would not permit royalty-free redistribution of the Library by - * all those who receive copies directly or indirectly through you, then - * the only way you could satisfy both it and this License would be to - * refrain entirely from distribution of the Library. - * - * If any portion of this section is held invalid or unenforceable under any - * particular circumstance, the balance of the section is intended to apply, - * and the section as a whole is intended to apply in other circumstances. - * - * It is not the purpose of this section to induce you to infringe any - * patents or other property right claims or to contest validity of any - * such claims; this section has the sole purpose of protecting the - * integrity of the free software distribution system which is - * implemented by public license practices. Many people have made - * generous contributions to the wide range of software distributed - * through that system in reliance on consistent application of that - * system; it is up to the author/donor to decide if he or she is willing - * to distribute software through any other system and a licensee cannot - * impose that choice. - * - * This section is intended to make thoroughly clear what is believed to - * be a consequence of the rest of this License. - * - * 12. If the distribution and/or use of the Library is restricted in - * certain countries either by patents or by copyrighted interfaces, the - * original copyright holder who places the Library under this License may add - * an explicit geographical distribution limitation excluding those countries, - * so that distribution is permitted only in or among countries not thus - * excluded. In such case, this License incorporates the limitation as if - * written in the body of this License. - * - * 13. The Free Software Foundation may publish revised and/or new - * versions of the Lesser General Public License from time to time. - * Such new versions will be similar in spirit to the present version, - * but may differ in detail to address new problems or concerns. - * - * Each version is given a distinguishing version number. If the Library - * specifies a version number of this License which applies to it and - * "any later version", you have the option of following the terms and - * conditions either of that version or of any later version published by - * the Free Software Foundation. If the Library does not specify a - * license version number, you may choose any version ever published by - * the Free Software Foundation. - * - * 14. If you wish to incorporate parts of the Library into other free - * programs whose distribution conditions are incompatible with these, - * write to the author to ask for permission. For software which is - * copyrighted by the Free Software Foundation, write to the Free - * Software Foundation; we sometimes make exceptions for this. Our - * decision will be guided by the two goals of preserving the free status - * of all derivatives of our free software and of promoting the sharing - * and reuse of software generally. - * - * NO WARRANTY - * - * 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO - * WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. - * EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR - * OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE - * LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME - * THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - * - * 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - * WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY - * AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU - * FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR - * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - * LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - * RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - * FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF - * SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGES. - * - * END OF TERMS AND CONDITIONS - * - * How to Apply These Terms to Your New Libraries - * - * If you develop a new library, and you want it to be of the greatest - * possible use to the public, we recommend making it free software that - * everyone can redistribute and change. You can do so by permitting - * redistribution under these terms (or, alternatively, under the terms of the - * ordinary General Public License). - * - * To apply these terms, attach the following notices to the library. It is - * safest to attach them to the start of each source file to most effectively - * convey the exclusion of warranty; and each file should have at least the - * "copyright" line and a pointer to where the full notice is found. - * - * - * Copyright (C) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Also add information on how to contact you by electronic and paper mail. - * - * You should also get your employer (if you work as a programmer) or your - * school, if any, to sign a "copyright disclaimer" for the library, if - * necessary. Here is a sample; alter the names: - * - * Yoyodyne, Inc., hereby disclaims all copyright interest in the - * library `Frob' (a library for tweaking knobs) written by James Random Hacker. - * - * , 1 April 1990 - * Ty Coon, President of Vice - * - * That's all there is to it! - * - * - * --- - * - * ffmpeg-faandct: - * - * Copyright (c) 2003 Michael Niedermayer - * Copyright (c) 2003 Roman Shaposhnik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * 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. - * - * - * --- - * - * ffmepg (JPEG components): - * - * The authors make NO WARRANTY or representation, either express or implied, - * with respect to this software, its quality, accuracy, merchantability, or - * fitness for a particular purpose. This software is provided "AS IS", and - * you, its user, assume the entire risk as to its quality and accuracy. - * - * This software is copyright (C) 1991, 1992, Thomas G. Lane. - * All Rights Reserved except as specified below. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * software (or portions thereof) for any purpose, without fee, subject to - * these conditions: - * (1) If any part of the source code for this software is distributed, then - * this README file must be included, with this copyright and no-warranty - * notice unaltered; and any additions, deletions, or changes to the original - * files must be clearly indicated in accompanying documentation. - * (2) If only executable code is distributed, then the accompanying - * documentation must state that "this software is based in part on the work - * of the Independent JPEG Group". - * (3) Permission for use of this software is granted only if the user accepts - * full responsibility for any undesirable consequences; the authors accept - * NO LIABILITY for damages of any kind. - * - * These conditions apply to any software derived from or based on the IJG - * code, not just to the unmodified library. If you use our work, you ought - * to acknowledge us. - * - * Permission is NOT granted for the use of any IJG author's name or company - * name in advertising or publicity relating to this software or products - * derived from it. This software may be referred to only as "the Independent - * JPEG Group's software". - * - * We specifically permit and encourage the use of this software as the basis - * of commercial products, provided that all warranty or liability claims are - * assumed by the product vendor. - * - * - * --- - * - * ffmpeg-avsscanf: - * - * Copyright (c) 2005-2014 Rich Felker, et al. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * --- - * - * ffmpeg oggdec: - * - * Copyright (C) 2005 Michael Ahlberg, Måns Rullgård - * Copyright (C) 2005 Matthieu CASTET, Alex Beregszaszi - * Copyright (C) 2008 Reimar Döffinger - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * --- - * - * opus: - * - * Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, - * Jean-Marc Valin, Timothy B. Terriberry, - * CSIRO, Gregory Maxwell, Mark Borgerding, - * Erik de Castro Lopo - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of Internet Society, IETF or IETF Trust, nor the names of - * specific contributors, may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS - * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Opus is subject to the royalty-free patent licenses which are specified at: - * - * Xiph.Org Foundation: - * https://datatracker.ietf.org/ipr/1524/ - * - * Microsoft Corporation: - * https://datatracker.ietf.org/ipr/1914/ - * - * Broadcom Corporation: - * https://datatracker.ietf.org/ipr/1526/ - * - * - * --- - * - * libvpx: - * - * Copyright (c) 2010, The WebM Project authors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Google, nor the WebM Project, nor the names - * of its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * --- - * - * emscripten and musl: - * - * Copyright (c) 2010-2022 Emscripten authors, see AUTHORS file. - * Copyright © 2005-2022 Rich Felker, et al. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -var LibAVFactory = (() => { - var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; - if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; - return ( -function(config) { - var LibAVFactory = config || {}; - -var Module=typeof LibAVFactory!="undefined"?LibAVFactory:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;function logExceptionOnExit(e){if(e instanceof ExitStatus)return;let toLog=e;err("exiting due to exception: "+toLog)}if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer)})};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",function(reason){throw reason});quit_=(status,toThrow)=>{if(keepRuntimeAlive()){process["exitCode"]=status;throw toThrow}logExceptionOnExit(toThrow);process["exit"](status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;var wasmTable;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function keepRuntimeAlive(){return noExitRuntime}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="libav-3.10.5.1.2-webcodecs.wasm.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(wasmBinaryFile)){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+wasmBinaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(wasmBinaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(wasmBinaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(wasmBinaryFile)})}function createWasm(){var info={"a":asmLibraryArg};function receiveInstance(instance,module){var exports=instance.exports;exports=Asyncify.instrumentWasmExports(exports);Module["asm"]=exports;wasmMemory=Module["asm"]["G"];updateMemoryViews();wasmTable=Module["asm"]["ld"];addOnInit(Module["asm"]["H"]);removeRunDependency("wasm-instantiate")}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}function instantiateArrayBuffer(receiver){return getBinaryPromise().then(function(binary){return WebAssembly.instantiate(binary,info)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(){if(!wasmBinary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(wasmBinaryFile)&&!isFileURI(wasmBinaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(wasmBinaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,info);return result.then(receiveInstantiationResult,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(receiveInstantiationResult)})})}else{return instantiateArrayBuffer(receiveInstantiationResult)}}if(Module["instantiateWasm"]){try{var exports=Module["instantiateWasm"](info,receiveInstance);exports=Asyncify.instrumentWasmExports(exports);return exports}catch(e){err("Module.instantiateWasm callback failed with error: "+e);readyPromiseReject(e)}}instantiateAsync().catch(readyPromiseReject);return{}}var tempDouble;var tempI64;function libavjs_wait_reader(fd){return Asyncify.handleAsync(function(){return new Promise(function(res){Module.ff_reader_dev_waiters.push(res)})})}function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module)}}var PATH={isAbs:path=>path.charAt(0)==="/",splitPath:filename=>{var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)},normalizeArray:(parts,allowAboveRoot)=>{var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up;up--){parts.unshift("..")}}return parts},normalize:path=>{var isAbsolute=PATH.isAbs(path),trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter(p=>!!p),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path},dirname:path=>{var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir},basename:path=>{if(path==="/")return"/";path=PATH.normalize(path);path=path.replace(/\/$/,"");var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)},join:function(){var paths=Array.prototype.slice.call(arguments);return PATH.normalize(paths.join("/"))},join2:(l,r)=>{return PATH.normalize(l+"/"+r)}};function getRandomDevice(){if(typeof crypto=="object"&&typeof crypto["getRandomValues"]=="function"){var randomBuffer=new Uint8Array(1);return()=>{crypto.getRandomValues(randomBuffer);return randomBuffer[0]}}else if(ENVIRONMENT_IS_NODE){try{var crypto_module=require("crypto");return()=>crypto_module["randomBytes"](1)[0]}catch(e){}}return()=>abort("randomDevice")}var PATH_FS={resolve:function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=PATH.isAbs(path)}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter(p=>!!p),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."},relative:(from,to)=>{from=PATH_FS.resolve(from).substr(1);to=PATH_FS.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}var TTY={ttys:[],init:function(){},shutdown:function(){},register:function(dev,ops){TTY.ttys[dev]={input:[],output:[],ops:ops};FS.registerDevice(dev,TTY.stream_ops)},stream_ops:{open:function(stream){var tty=TTY.ttys[stream.node.rdev];if(!tty){throw new FS.ErrnoError(43)}stream.tty=tty;stream.seekable=false},close:function(stream){stream.tty.ops.fsync(stream.tty)},fsync:function(stream){stream.tty.ops.fsync(stream.tty)},read:function(stream,buffer,offset,length,pos){if(!stream.tty||!stream.tty.ops.get_char){throw new FS.ErrnoError(60)}var bytesRead=0;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()},put_char:function(tty,val){if(val===null||val===10){out(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync:function(tty){if(tty.output&&tty.output.length>0){out(UTF8ArrayToString(tty.output,0));tty.output=[]}}},default_tty1_ops:{put_char:function(tty,val){if(val===null||val===10){err(UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}},fsync:function(tty){if(tty.output&&tty.output.length>0){err(UTF8ArrayToString(tty.output,0));tty.output=[]}}}};function zeroMemory(address,size){HEAPU8.fill(0,address,address+size);return address}function alignMemory(size,alignment){return Math.ceil(size/alignment)*alignment}function mmapAlloc(size){size=alignMemory(size,65536);var ptr=_emscripten_builtin_memalign(65536,size);if(!ptr)return 0;return zeroMemory(ptr,size)}var MEMFS={ops_table:null,mount:function(mount){return MEMFS.createNode(null,"/",16384|511,0)},createNode:function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(63)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node;parent.timestamp=node.timestamp}return node},getFileDataAsTypedArray:function(node){if(!node.contents)return new Uint8Array(0);if(node.contents.subarray)return node.contents.subarray(0,node.usedBytes);return new Uint8Array(node.contents)},expandFileStorage:function(node,newCapacity){var prevCapacity=node.contents?node.contents.length:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity>>0);if(prevCapacity!=0)newCapacity=Math.max(newCapacity,256);var oldContents=node.contents;node.contents=new Uint8Array(newCapacity);if(node.usedBytes>0)node.contents.set(oldContents.subarray(0,node.usedBytes),0)},resizeFileStorage:function(node,newSize){if(node.usedBytes==newSize)return;if(newSize==0){node.contents=null;node.usedBytes=0}else{var oldContents=node.contents;node.contents=new Uint8Array(newSize);if(oldContents){node.contents.set(oldContents.subarray(0,Math.min(newSize,node.usedBytes)))}node.usedBytes=newSize}},node_ops:{getattr:function(node){var attr={};attr.dev=FS.isChrdev(node.mode)?node.id:1;attr.ino=node.id;attr.mode=node.mode;attr.nlink=1;attr.uid=0;attr.gid=0;attr.rdev=node.rdev;if(FS.isDir(node.mode)){attr.size=4096}else if(FS.isFile(node.mode)){attr.size=node.usedBytes}else if(FS.isLink(node.mode)){attr.size=node.link.length}else{attr.size=0}attr.atime=new Date(node.timestamp);attr.mtime=new Date(node.timestamp);attr.ctime=new Date(node.timestamp);attr.blksize=4096;attr.blocks=Math.ceil(attr.size/attr.blksize);return attr},setattr:function(node,attr){if(attr.mode!==undefined){node.mode=attr.mode}if(attr.timestamp!==undefined){node.timestamp=attr.timestamp}if(attr.size!==undefined){MEMFS.resizeFileStorage(node,attr.size)}},lookup:function(parent,name){throw FS.genericErrors[44]},mknod:function(parent,name,mode,dev){return MEMFS.createNode(parent,name,mode,dev)},rename:function(old_node,new_dir,new_name){if(FS.isDir(old_node.mode)){var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(new_node){for(var i in new_node.contents){throw new FS.ErrnoError(55)}}}delete old_node.parent.contents[old_node.name];old_node.parent.timestamp=Date.now();old_node.name=new_name;new_dir.contents[new_name]=old_node;new_dir.timestamp=old_node.parent.timestamp;old_node.parent=new_dir},unlink:function(parent,name){delete parent.contents[name];parent.timestamp=Date.now()},rmdir:function(parent,name){var node=FS.lookupNode(parent,name);for(var i in node.contents){throw new FS.ErrnoError(55)}delete parent.contents[name];parent.timestamp=Date.now()},readdir:function(node){var entries=[".",".."];for(var key in node.contents){if(!node.contents.hasOwnProperty(key)){continue}entries.push(key)}return entries},symlink:function(parent,newname,oldpath){var node=MEMFS.createNode(parent,newname,511|40960,0);node.link=oldpath;return node},readlink:function(node){if(!FS.isLink(node.mode)){throw new FS.ErrnoError(28)}return node.link}},stream_ops:{read:function(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+length{assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).');onload(new Uint8Array(arrayBuffer));if(dep)removeRunDependency(dep)},event=>{if(onerror){onerror()}else{throw'Loading data file "'+url+'" failed.'}});if(dep)addRunDependency(dep)}var FS={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(path,opts={})=>{path=PATH_FS.resolve(path);if(!path)return{path:"",node:null};var defaults={follow_mount:true,recurse_count:0};opts=Object.assign(defaults,opts);if(opts.recurse_count>8){throw new FS.ErrnoError(32)}var parts=path.split("/").filter(p=>!!p);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(32)}}}}return{path:current_path,node:current}},getPath:node=>{var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}},hashName:(parentid,name)=>{var hash=0;for(var i=0;i>>0)%FS.nameTable.length},hashAddNode:node=>{var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node},hashRemoveNode:node=>{var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}},lookupNode:(parent,name)=>{var errCode=FS.mayLookup(parent);if(errCode){throw new FS.ErrnoError(errCode,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)},createNode:(parent,name,mode,rdev)=>{var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node},destroyNode:node=>{FS.hashRemoveNode(node)},isRoot:node=>{return node===node.parent},isMountpoint:node=>{return!!node.mounted},isFile:mode=>{return(mode&61440)===32768},isDir:mode=>{return(mode&61440)===16384},isLink:mode=>{return(mode&61440)===40960},isChrdev:mode=>{return(mode&61440)===8192},isBlkdev:mode=>{return(mode&61440)===24576},isFIFO:mode=>{return(mode&61440)===4096},isSocket:mode=>{return(mode&49152)===49152},flagModes:{"r":0,"r+":2,"w":577,"w+":578,"a":1089,"a+":1090},modeStringToFlags:str=>{var flags=FS.flagModes[str];if(typeof flags=="undefined"){throw new Error("Unknown file open mode: "+str)}return flags},flagsToPermissionString:flag=>{var perms=["r","w","rw"][flag&3];if(flag&512){perms+="w"}return perms},nodePermissions:(node,perms)=>{if(FS.ignorePermissions){return 0}if(perms.includes("r")&&!(node.mode&292)){return 2}else if(perms.includes("w")&&!(node.mode&146)){return 2}else if(perms.includes("x")&&!(node.mode&73)){return 2}return 0},mayLookup:dir=>{var errCode=FS.nodePermissions(dir,"x");if(errCode)return errCode;if(!dir.node_ops.lookup)return 2;return 0},mayCreate:(dir,name)=>{try{var node=FS.lookupNode(dir,name);return 20}catch(e){}return FS.nodePermissions(dir,"wx")},mayDelete:(dir,name,isdir)=>{var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var errCode=FS.nodePermissions(dir,"wx");if(errCode){return errCode}if(isdir){if(!FS.isDir(node.mode)){return 54}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return 10}}else{if(FS.isDir(node.mode)){return 31}}return 0},mayOpen:(node,flags)=>{if(!node){return 44}if(FS.isLink(node.mode)){return 32}else if(FS.isDir(node.mode)){if(FS.flagsToPermissionString(flags)!=="r"||flags&512){return 31}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))},MAX_OPEN_FDS:4096,nextfd:(fd_start=0,fd_end=FS.MAX_OPEN_FDS)=>{for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(33)},getStream:fd=>FS.streams[fd],createStream:(stream,fd_start,fd_end)=>{if(!FS.FSStream){FS.FSStream=function(){this.shared={}};FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:function(){return this.node},set:function(val){this.node=val}},isRead:{get:function(){return(this.flags&2097155)!==1}},isWrite:{get:function(){return(this.flags&2097155)!==0}},isAppend:{get:function(){return this.flags&1024}},flags:{get:function(){return this.shared.flags},set:function(val){this.shared.flags=val}},position:{get:function(){return this.shared.position},set:function(val){this.shared.position=val}}})}stream=Object.assign(new FS.FSStream,stream);var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream},closeStream:fd=>{FS.streams[fd]=null},chrdev_stream_ops:{open:stream=>{var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}},llseek:()=>{throw new FS.ErrnoError(70)}},major:dev=>dev>>8,minor:dev=>dev&255,makedev:(ma,mi)=>ma<<8|mi,registerDevice:(dev,ops)=>{FS.devices[dev]={stream_ops:ops}},getDevice:dev=>FS.devices[dev],getMounts:mount=>{var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts},syncfs:(populate,callback)=>{if(typeof populate=="function"){callback=populate;populate=false}FS.syncFSRequests++;if(FS.syncFSRequests>1){err("warning: "+FS.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work")}var mounts=FS.getMounts(FS.root.mount);var completed=0;function doCallback(errCode){FS.syncFSRequests--;return callback(errCode)}function done(errCode){if(errCode){if(!done.errored){done.errored=true;return doCallback(errCode)}return}if(++completed>=mounts.length){doCallback(null)}}mounts.forEach(mount=>{if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)})},mount:(type,opts,mountpoint)=>{var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(10)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot},unmount:mountpoint=>{var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(28)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach(hash=>{var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.includes(current.mount)){FS.destroyNode(current)}current=next}});node.mounted=null;var idx=node.mount.mounts.indexOf(mount);node.mount.mounts.splice(idx,1)},lookup:(parent,name)=>{return parent.node_ops.lookup(parent,name)},mknod:(path,mode,dev)=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(28)}var errCode=FS.mayCreate(parent,name);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(63)}return parent.node_ops.mknod(parent,name,mode,dev)},create:(path,mode)=>{mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)},mkdir:(path,mode)=>{mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)},mkdirTree:(path,mode)=>{var dirs=path.split("/");var d="";for(var i=0;i{if(typeof dev=="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)},symlink:(oldpath,newpath)=>{if(!PATH_FS.resolve(oldpath)){throw new FS.ErrnoError(44)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var newname=PATH.basename(newpath);var errCode=FS.mayCreate(parent,newname);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(63)}return parent.node_ops.symlink(parent,newname,oldpath)},rename:(old_path,new_path)=>{var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node;if(!old_dir||!new_dir)throw new FS.ErrnoError(44);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(75)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH_FS.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(28)}relative=PATH_FS.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(55)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var errCode=FS.mayDelete(old_dir,old_name,isdir);if(errCode){throw new FS.ErrnoError(errCode)}errCode=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(errCode){throw new FS.ErrnoError(errCode)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(63)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(10)}if(new_dir!==old_dir){errCode=FS.nodePermissions(old_dir,"w");if(errCode){throw new FS.ErrnoError(errCode)}}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}},rmdir:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,true);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node)},readdir:path=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(54)}return node.node_ops.readdir(node)},unlink:path=>{var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(44)}var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var errCode=FS.mayDelete(parent,name,false);if(errCode){throw new FS.ErrnoError(errCode)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(63)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(10)}parent.node_ops.unlink(parent,name);FS.destroyNode(node)},readlink:path=>{var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(44)}if(!link.node_ops.readlink){throw new FS.ErrnoError(28)}return PATH_FS.resolve(FS.getPath(link.parent),link.node_ops.readlink(link))},stat:(path,dontFollow)=>{var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(44)}if(!node.node_ops.getattr){throw new FS.ErrnoError(63)}return node.node_ops.getattr(node)},lstat:path=>{return FS.stat(path,true)},chmod:(path,mode,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})},lchmod:(path,mode)=>{FS.chmod(path,mode,true)},fchmod:(fd,mode)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chmod(stream.node,mode)},chown:(path,uid,gid,dontFollow)=>{var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}node.node_ops.setattr(node,{timestamp:Date.now()})},lchown:(path,uid,gid)=>{FS.chown(path,uid,gid,true)},fchown:(fd,uid,gid)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}FS.chown(stream.node,uid,gid)},truncate:(path,len)=>{if(len<0){throw new FS.ErrnoError(28)}var node;if(typeof path=="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(63)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(31)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(28)}var errCode=FS.nodePermissions(node,"w");if(errCode){throw new FS.ErrnoError(errCode)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})},ftruncate:(fd,len)=>{var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(28)}FS.truncate(stream.node,len)},utime:(path,atime,mtime)=>{var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})},open:(path,flags,mode)=>{if(path===""){throw new FS.ErrnoError(44)}flags=typeof flags=="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode=="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path=="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(20)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(44)}if(FS.isChrdev(node.mode)){flags&=~512}if(flags&65536&&!FS.isDir(node.mode)){throw new FS.ErrnoError(54)}if(!created){var errCode=FS.mayOpen(node,flags);if(errCode){throw new FS.ErrnoError(errCode)}}if(flags&512&&!created){FS.truncate(node,0)}flags&=~(128|512|131072);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false});if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1}}return stream},close:stream=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(stream.getdents)stream.getdents=null;try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}stream.fd=null},isClosed:stream=>{return stream.fd===null},llseek:(stream,offset,whence)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(70)}if(whence!=0&&whence!=1&&whence!=2){throw new FS.ErrnoError(28)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position},read:(stream,buffer,offset,length,position)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.read){throw new FS.ErrnoError(28)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead},write:(stream,buffer,offset,length,position,canOwn)=>{if(length<0||position<0){throw new FS.ErrnoError(28)}if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(31)}if(!stream.stream_ops.write){throw new FS.ErrnoError(28)}if(stream.seekable&&stream.flags&1024){FS.llseek(stream,0,2)}var seeking=typeof position!="undefined";if(!seeking){position=stream.position}else if(!stream.seekable){throw new FS.ErrnoError(70)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;return bytesWritten},allocate:(stream,offset,length)=>{if(FS.isClosed(stream)){throw new FS.ErrnoError(8)}if(offset<0||length<=0){throw new FS.ErrnoError(28)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(8)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(stream.node.mode)){throw new FS.ErrnoError(43)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(138)}stream.stream_ops.allocate(stream,offset,length)},mmap:(stream,length,position,prot,flags)=>{if((prot&2)!==0&&(flags&2)===0&&(stream.flags&2097155)!==2){throw new FS.ErrnoError(2)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(2)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(43)}return stream.stream_ops.mmap(stream,length,position,prot,flags)},msync:(stream,buffer,offset,length,mmapFlags)=>{if(!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)},munmap:stream=>0,ioctl:(stream,cmd,arg)=>{if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(59)}return stream.stream_ops.ioctl(stream,cmd,arg)},readFile:(path,opts={})=>{opts.flags=opts.flags||0;opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret},writeFile:(path,data,opts={})=>{opts.flags=opts.flags||577;var stream=FS.open(path,opts.flags,opts.mode);if(typeof data=="string"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,undefined,opts.canOwn)}else if(ArrayBuffer.isView(data)){FS.write(stream,data,0,data.byteLength,undefined,opts.canOwn)}else{throw new Error("Unsupported data type")}FS.close(stream)},cwd:()=>FS.currentPath,chdir:path=>{var lookup=FS.lookupPath(path,{follow:true});if(lookup.node===null){throw new FS.ErrnoError(44)}if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(54)}var errCode=FS.nodePermissions(lookup.node,"x");if(errCode){throw new FS.ErrnoError(errCode)}FS.currentPath=lookup.path},createDefaultDirectories:()=>{FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")},createDefaultDevices:()=>{FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:()=>0,write:(stream,buffer,offset,length,pos)=>length});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device=getRandomDevice();FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{FS.mkdir("/proc");var proc_self=FS.mkdir("/proc/self");FS.mkdir("/proc/self/fd");FS.mount({mount:()=>{var node=FS.createNode(proc_self,"fd",16384|511,73);node.node_ops={lookup:(parent,name)=>{var fd=+name;var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);var ret={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>stream.path}};ret.parent=ret;return ret}};return node}},{},"/proc/self/fd")},createStandardStreams:()=>{if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin",0);var stdout=FS.open("/dev/stdout",1);var stderr=FS.open("/dev/stderr",1)},ensureErrnoError:()=>{if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.node=node;this.setErrno=function(errno){this.errno=errno};this.setErrno(errno);this.message="FS error"};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[44].forEach(code=>{FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack=""})},staticInit:()=>{FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices();FS.createSpecialDirectories();FS.filesystems={"MEMFS":MEMFS}},init:(input,output,error)=>{FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()},quit:()=>{FS.init.initialized=false;for(var i=0;i{var mode=0;if(canRead)mode|=292|73;if(canWrite)mode|=146;return mode},findObject:(path,dontResolveLastLink)=>{var ret=FS.analyzePath(path,dontResolveLastLink);if(!ret.exists){return null}return ret.object},analyzePath:(path,dontResolveLastLink)=>{try{var lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});path=lookup.path}catch(e){}var ret={isRoot:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,parentPath:null,parentObject:null};try{var lookup=FS.lookupPath(path,{parent:true});ret.parentExists=true;ret.parentPath=lookup.path;ret.parentObject=lookup.node;ret.name=PATH.basename(path);lookup=FS.lookupPath(path,{follow:!dontResolveLastLink});ret.exists=true;ret.path=lookup.path;ret.object=lookup.node;ret.name=lookup.node.name;ret.isRoot=lookup.path==="/"}catch(e){ret.error=e.errno}return ret},createPath:(parent,path,canRead,canWrite)=>{parent=typeof parent=="string"?parent:FS.getPath(parent);var parts=path.split("/").reverse();while(parts.length){var part=parts.pop();if(!part)continue;var current=PATH.join2(parent,part);try{FS.mkdir(current)}catch(e){}parent=current}return current},createFile:(parent,name,properties,canRead,canWrite)=>{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(canRead,canWrite);return FS.create(path,mode)},createDataFile:(parent,name,data,canRead,canWrite,canOwn)=>{var path=name;if(parent){parent=typeof parent=="string"?parent:FS.getPath(parent);path=name?PATH.join2(parent,name):parent}var mode=FS.getMode(canRead,canWrite);var node=FS.create(path,mode);if(data){if(typeof data=="string"){var arr=new Array(data.length);for(var i=0,len=data.length;i{var path=PATH.join2(typeof parent=="string"?parent:FS.getPath(parent),name);var mode=FS.getMode(!!input,!!output);if(!FS.createDevice.major)FS.createDevice.major=64;var dev=FS.makedev(FS.createDevice.major++,0);FS.registerDevice(dev,{open:stream=>{stream.seekable=false},close:stream=>{if(output&&output.buffer&&output.buffer.length){output(10)}},read:(stream,buffer,offset,length,pos)=>{var bytesRead=0;for(var i=0;i{for(var i=0;i{if(obj.isDevice||obj.isFolder||obj.link||obj.contents)return true;if(typeof XMLHttpRequest!="undefined"){throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.")}else if(read_){try{obj.contents=intArrayFromString(read_(obj.url),true);obj.usedBytes=obj.contents.length}catch(e){throw new FS.ErrnoError(29)}}else{throw new Error("Cannot load without read() or XMLHttpRequest.")}},createLazyFile:(parent,name,url,canRead,canWrite)=>{function LazyUint8Array(){this.lengthKnown=false;this.chunks=[]}LazyUint8Array.prototype.get=function LazyUint8Array_get(idx){if(idx>this.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var usesGzip=(header=xhr.getResponseHeader("Content-Encoding"))&&header==="gzip";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(from,to)=>{if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}return intArrayFromString(xhr.responseText||"",true)};var lazyArray=this;lazyArray.setDataGetter(chunkNum=>{var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]=="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]=="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]});if(usesGzip||!datalength){chunkSize=datalength=1;datalength=this.getter(0).length;chunkSize=datalength;out("LazyFiles on gzip forces download of the whole file when length is accessed")}this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperties(lazyArray,{length:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._length}},chunkSize:{get:function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize}}});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperties(node,{usedBytes:{get:function(){return this.contents.length}}});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach(key=>{var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){FS.forceLoadFile(node);return fn.apply(null,arguments)}});function writeChunks(stream,buffer,offset,length,position){var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);if(contents.slice){for(var i=0;i{FS.forceLoadFile(node);return writeChunks(stream,buffer,offset,length,position)};stream_ops.mmap=(stream,length,position,prot,flags)=>{FS.forceLoadFile(node);var ptr=mmapAlloc(length);if(!ptr){throw new FS.ErrnoError(48)}writeChunks(stream,HEAP8,ptr,length,position);return{ptr:ptr,allocated:true}};node.stream_ops=stream_ops;return node},createPreloadedFile:(parent,name,url,canRead,canWrite,onload,onerror,dontCreateFile,canOwn,preFinish)=>{var fullname=name?PATH_FS.resolve(PATH.join2(parent,name)):parent;var dep=getUniqueRunDependency("cp "+fullname);function processData(byteArray){function finish(byteArray){if(preFinish)preFinish();if(!dontCreateFile){FS.createDataFile(parent,name,byteArray,canRead,canWrite,canOwn)}if(onload)onload();removeRunDependency(dep)}if(Browser.handledByPreloadPlugin(byteArray,fullname,finish,()=>{if(onerror)onerror();removeRunDependency(dep)})){return}finish(byteArray)}addRunDependency(dep);if(typeof url=="string"){asyncLoad(url,byteArray=>processData(byteArray),onerror)}else{processData(url)}},indexedDB:()=>{return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:()=>{return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=()=>{out("creating db");var db=openRequest.result;db.createObjectStore(FS.DB_STORE_NAME)};openRequest.onsuccess=()=>{var db=openRequest.result;var transaction=db.transaction([FS.DB_STORE_NAME],"readwrite");var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var putRequest=files.put(FS.analyzePath(path).object.contents,path);putRequest.onsuccess=()=>{ok++;if(ok+fail==total)finish()};putRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror},loadFilesFromDB:(paths,onload,onerror)=>{onload=onload||(()=>{});onerror=onerror||(()=>{});var indexedDB=FS.indexedDB();try{var openRequest=indexedDB.open(FS.DB_NAME(),FS.DB_VERSION)}catch(e){return onerror(e)}openRequest.onupgradeneeded=onerror;openRequest.onsuccess=()=>{var db=openRequest.result;try{var transaction=db.transaction([FS.DB_STORE_NAME],"readonly")}catch(e){onerror(e);return}var files=transaction.objectStore(FS.DB_STORE_NAME);var ok=0,fail=0,total=paths.length;function finish(){if(fail==0)onload();else onerror()}paths.forEach(path=>{var getRequest=files.get(path);getRequest.onsuccess=()=>{if(FS.analyzePath(path).exists){FS.unlink(path)}FS.createDataFile(PATH.dirname(path),PATH.basename(path),getRequest.result,true,true,true);ok++;if(ok+fail==total)finish()};getRequest.onerror=()=>{fail++;if(ok+fail==total)finish()}});transaction.onerror=onerror};openRequest.onerror=onerror}};var SYSCALLS={DEFAULT_POLLMASK:5,calculateAt:function(dirfd,path,allowEmpty){if(PATH.isAbs(path)){return path}var dir;if(dirfd===-100){dir=FS.cwd()}else{var dirstream=SYSCALLS.getStreamFromFD(dirfd);dir=dirstream.path}if(path.length==0){if(!allowEmpty){throw new FS.ErrnoError(44)}return dir}return PATH.join2(dir,path)},doStat:function(func,path,buf){try{var stat=func(path)}catch(e){if(e&&e.node&&PATH.normalize(path)!==PATH.normalize(FS.getPath(e.node))){return-54}throw e}HEAP32[buf>>2]=stat.dev;HEAP32[buf+8>>2]=stat.ino;HEAP32[buf+12>>2]=stat.mode;HEAPU32[buf+16>>2]=stat.nlink;HEAP32[buf+20>>2]=stat.uid;HEAP32[buf+24>>2]=stat.gid;HEAP32[buf+28>>2]=stat.rdev;tempI64=[stat.size>>>0,(tempDouble=stat.size,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+40>>2]=tempI64[0],HEAP32[buf+44>>2]=tempI64[1];HEAP32[buf+48>>2]=4096;HEAP32[buf+52>>2]=stat.blocks;var atime=stat.atime.getTime();var mtime=stat.mtime.getTime();var ctime=stat.ctime.getTime();tempI64=[Math.floor(atime/1e3)>>>0,(tempDouble=Math.floor(atime/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+56>>2]=tempI64[0],HEAP32[buf+60>>2]=tempI64[1];HEAPU32[buf+64>>2]=atime%1e3*1e3;tempI64=[Math.floor(mtime/1e3)>>>0,(tempDouble=Math.floor(mtime/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+72>>2]=tempI64[0],HEAP32[buf+76>>2]=tempI64[1];HEAPU32[buf+80>>2]=mtime%1e3*1e3;tempI64=[Math.floor(ctime/1e3)>>>0,(tempDouble=Math.floor(ctime/1e3),+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+88>>2]=tempI64[0],HEAP32[buf+92>>2]=tempI64[1];HEAPU32[buf+96>>2]=ctime%1e3*1e3;tempI64=[stat.ino>>>0,(tempDouble=stat.ino,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[buf+104>>2]=tempI64[0],HEAP32[buf+108>>2]=tempI64[1];return 0},doMsync:function(addr,stream,len,flags,offset){if(!FS.isFile(stream.node.mode)){throw new FS.ErrnoError(43)}if(flags&2){return 0}var buffer=HEAPU8.slice(addr,addr+len);FS.msync(stream,buffer,offset,len,flags)},varargs:undefined,get:function(){SYSCALLS.varargs+=4;var ret=HEAP32[SYSCALLS.varargs-4>>2];return ret},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret},getStreamFromFD:function(fd){var stream=FS.getStream(fd);if(!stream)throw new FS.ErrnoError(8);return stream}};function ___syscall_faccessat(dirfd,path,amode,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(amode&~7){return-28}var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node){return-44}var perms="";if(amode&4)perms+="r";if(amode&2)perms+="w";if(amode&1)perms+="x";if(perms&&FS.nodePermissions(node,perms)){return-2}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function setErrNo(value){HEAP32[___errno_location()>>2]=value;return value}function ___syscall_fcntl64(fd,cmd,varargs){SYSCALLS.varargs=varargs;try{var stream=SYSCALLS.getStreamFromFD(fd);switch(cmd){case 0:{var arg=SYSCALLS.get();if(arg<0){return-28}var newStream;newStream=FS.createStream(stream,arg);return newStream.fd}case 1:case 2:return 0;case 3:return stream.flags;case 4:{var arg=SYSCALLS.get();stream.flags|=arg;return 0}case 5:{var arg=SYSCALLS.get();var offset=0;HEAP16[arg+offset>>1]=2;return 0}case 6:case 7:return 0;case 16:case 8:return-28;case 9:setErrNo(28);return-1;default:{return-28}}}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_fstat64(fd,buf){try{var stream=SYSCALLS.getStreamFromFD(fd);return SYSCALLS.doStat(FS.stat,stream.path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_getdents64(fd,dirp,count){try{var stream=SYSCALLS.getStreamFromFD(fd);if(!stream.getdents){stream.getdents=FS.readdir(stream.path)}var struct_size=280;var pos=0;var off=FS.llseek(stream,0,1);var idx=Math.floor(off/struct_size);while(idx>>0,(tempDouble=id,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[dirp+pos>>2]=tempI64[0],HEAP32[dirp+pos+4>>2]=tempI64[1];tempI64=[(idx+1)*struct_size>>>0,(tempDouble=(idx+1)*struct_size,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[dirp+pos+8>>2]=tempI64[0],HEAP32[dirp+pos+12>>2]=tempI64[1];HEAP16[dirp+pos+16>>1]=280;HEAP8[dirp+pos+18>>0]=type;stringToUTF8(name,dirp+pos+19,256);pos+=struct_size;idx+=1}FS.llseek(stream,idx*struct_size,0);return pos}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_lstat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.lstat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_newfstatat(dirfd,path,buf,flags){try{path=SYSCALLS.getStr(path);var nofollow=flags&256;var allowEmpty=flags&4096;flags=flags&~6400;path=SYSCALLS.calculateAt(dirfd,path,allowEmpty);return SYSCALLS.doStat(nofollow?FS.lstat:FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_openat(dirfd,path,flags,varargs){SYSCALLS.varargs=varargs;try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);var mode=varargs?SYSCALLS.get():0;return FS.open(path,flags,mode).fd}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_renameat(olddirfd,oldpath,newdirfd,newpath){try{oldpath=SYSCALLS.getStr(oldpath);newpath=SYSCALLS.getStr(newpath);oldpath=SYSCALLS.calculateAt(olddirfd,oldpath);newpath=SYSCALLS.calculateAt(newdirfd,newpath);FS.rename(oldpath,newpath);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_rmdir(path){try{path=SYSCALLS.getStr(path);FS.rmdir(path);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_stat64(path,buf){try{path=SYSCALLS.getStr(path);return SYSCALLS.doStat(FS.stat,path,buf)}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}function ___syscall_unlinkat(dirfd,path,flags){try{path=SYSCALLS.getStr(path);path=SYSCALLS.calculateAt(dirfd,path);if(flags===0){FS.unlink(path)}else if(flags===512){FS.rmdir(path)}else{abort("Invalid flags passed to unlinkat")}return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return-e.errno}}var nowIsMonotonic=true;function __emscripten_get_now_is_monotonic(){return nowIsMonotonic}function __emscripten_throw_longjmp(){throw Infinity}function _abort(){abort("")}function _emscripten_date_now(){return Date.now()}function getHeapMax(){return 2147483648}function _emscripten_get_heap_max(){return getHeapMax()}var _emscripten_get_now;if(ENVIRONMENT_IS_NODE){_emscripten_get_now=()=>{var t=process["hrtime"]();return t[0]*1e3+t[1]/1e6}}else _emscripten_get_now=()=>performance.now();function emscripten_realloc_buffer(size){var b=wasmMemory.buffer;try{wasmMemory.grow(size-b.byteLength+65535>>>16);updateMemoryViews();return 1}catch(e){}}function _emscripten_resize_heap(requestedSize){var oldSize=HEAPU8.length;requestedSize=requestedSize>>>0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}let alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=emscripten_realloc_buffer(newSize);if(replacement){return true}}return false}var ENV={};function getExecutableName(){return thisProgram||"./this.program"}function getEnvStrings(){if(!getEnvStrings.strings){var lang=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8";var env={"USER":"web_user","LOGNAME":"web_user","PATH":"/","PWD":"/","HOME":"/home/web_user","LANG":lang,"_":getExecutableName()};for(var x in ENV){if(ENV[x]===undefined)delete env[x];else env[x]=ENV[x]}var strings=[];for(var x in env){strings.push(x+"="+env[x])}getEnvStrings.strings=strings}return getEnvStrings.strings}function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}function _environ_get(__environ,environ_buf){var bufSize=0;getEnvStrings().forEach(function(string,i){var ptr=environ_buf+bufSize;HEAPU32[__environ+i*4>>2]=ptr;writeAsciiToMemory(string,ptr);bufSize+=string.length+1});return 0}function _environ_sizes_get(penviron_count,penviron_buf_size){var strings=getEnvStrings();HEAPU32[penviron_count>>2]=strings.length;var bufSize=0;strings.forEach(function(string){bufSize+=string.length+1});HEAPU32[penviron_buf_size>>2]=bufSize;return 0}function _fd_close(fd){try{var stream=SYSCALLS.getStreamFromFD(fd);FS.close(stream);return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function _fd_fdstat_get(fd,pbuf){try{var stream=SYSCALLS.getStreamFromFD(fd);var type=stream.tty?2:FS.isDir(stream.mode)?3:FS.isLink(stream.mode)?7:4;HEAP8[pbuf>>0]=type;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doReadv(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.read(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(curr>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function convertI32PairToI53Checked(lo,hi){return hi+2097152>>>0<4194305-!!lo?(lo>>>0)+hi*4294967296:NaN}function _fd_seek(fd,offset_low,offset_high,whence,newOffset){try{var offset=convertI32PairToI53Checked(offset_low,offset_high);if(isNaN(offset))return 61;var stream=SYSCALLS.getStreamFromFD(fd);FS.llseek(stream,offset,whence);tempI64=[stream.position>>>0,(tempDouble=stream.position,+Math.abs(tempDouble)>=1?tempDouble>0?(Math.min(+Math.floor(tempDouble/4294967296),4294967295)|0)>>>0:~~+Math.ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[newOffset>>2]=tempI64[0],HEAP32[newOffset+4>>2]=tempI64[1];if(stream.getdents&&offset===0&&whence===0)stream.getdents=null;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function doWritev(stream,iov,iovcnt,offset){var ret=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;var curr=FS.write(stream,HEAP8,ptr,len,offset);if(curr<0)return-1;ret+=curr;if(typeof offset!=="undefined"){offset+=curr}}return ret}function _fd_write(fd,iov,iovcnt,pnum){try{var stream=SYSCALLS.getStreamFromFD(fd);var num=doWritev(stream,iov,iovcnt);HEAPU32[pnum>>2]=num;return 0}catch(e){if(typeof FS=="undefined"||!(e instanceof FS.ErrnoError))throw e;return e.errno}}function runAndAbortIfError(func){try{return func()}catch(e){abort(e)}}function handleException(e){if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)}function callUserCallback(func){if(ABORT){return}try{func()}catch(e){handleException(e)}}function runtimeKeepalivePush(){}function runtimeKeepalivePop(){}var Asyncify={instrumentWasmImports:function(imports){var ASYNCIFY_IMPORTS=["env.libavjs_wait_reader","env.invoke_*","env.emscripten_sleep","env.emscripten_wget","env.emscripten_wget_data","env.emscripten_idb_load","env.emscripten_idb_store","env.emscripten_idb_delete","env.emscripten_idb_exists","env.emscripten_idb_load_blob","env.emscripten_idb_store_blob","env.SDL_Delay","env.emscripten_scan_registers","env.emscripten_lazy_load_code","env.emscripten_fiber_swap","wasi_snapshot_preview1.fd_sync","env.__wasi_fd_sync","env._emval_await","env._dlopen_js","env.__asyncjs__*"].map(x=>x.split(".")[1]);for(var x in imports){(function(x){var original=imports[x];var sig=original.sig;if(typeof original=="function"){var isAsyncifyImport=ASYNCIFY_IMPORTS.indexOf(x)>=0||x.startsWith("__asyncjs__")}})(x)}},instrumentWasmExports:function(exports){var ret={};for(var x in exports){(function(x){var original=exports[x];if(typeof original=="function"){ret[x]=function(){Asyncify.exportCallStack.push(x);try{return original.apply(null,arguments)}finally{if(!ABORT){var y=Asyncify.exportCallStack.pop();assert(y===x);Asyncify.maybeStopUnwind()}}}}else{ret[x]=original}})(x)}return ret},State:{Normal:0,Unwinding:1,Rewinding:2,Disabled:3},state:0,StackSize:4096,currData:null,handleSleepReturnValue:0,exportCallStack:[],callStackNameToId:{},callStackIdToName:{},callStackId:0,asyncPromiseHandlers:null,sleepCallbacks:[],getCallStackId:function(funcName){var id=Asyncify.callStackNameToId[funcName];if(id===undefined){id=Asyncify.callStackId++;Asyncify.callStackNameToId[funcName]=id;Asyncify.callStackIdToName[id]=funcName}return id},maybeStopUnwind:function(){if(Asyncify.currData&&Asyncify.state===Asyncify.State.Unwinding&&Asyncify.exportCallStack.length===0){Asyncify.state=Asyncify.State.Normal;runAndAbortIfError(_asyncify_stop_unwind);if(typeof Fibers!="undefined"){Fibers.trampoline()}}},whenDone:function(){return new Promise((resolve,reject)=>{Asyncify.asyncPromiseHandlers={resolve:resolve,reject:reject}})},allocateData:function(){var ptr=_malloc(12+Asyncify.StackSize);Asyncify.setDataHeader(ptr,ptr+12,Asyncify.StackSize);Asyncify.setDataRewindFunc(ptr);return ptr},setDataHeader:function(ptr,stack,stackSize){HEAP32[ptr>>2]=stack;HEAP32[ptr+4>>2]=stack+stackSize},setDataRewindFunc:function(ptr){var bottomOfCallStack=Asyncify.exportCallStack[0];var rewindId=Asyncify.getCallStackId(bottomOfCallStack);HEAP32[ptr+8>>2]=rewindId},getDataRewindFunc:function(ptr){var id=HEAP32[ptr+8>>2];var name=Asyncify.callStackIdToName[id];var func=Module["asm"][name];return func},doRewind:function(ptr){var start=Asyncify.getDataRewindFunc(ptr);return start()},handleSleep:function(startAsync){if(ABORT)return;if(Asyncify.state===Asyncify.State.Normal){var reachedCallback=false;var reachedAfterCallback=false;startAsync(handleSleepReturnValue=>{if(ABORT)return;Asyncify.handleSleepReturnValue=handleSleepReturnValue||0;reachedCallback=true;if(!reachedAfterCallback){return}Asyncify.state=Asyncify.State.Rewinding;runAndAbortIfError(()=>_asyncify_start_rewind(Asyncify.currData));if(typeof Browser!="undefined"&&Browser.mainLoop.func){Browser.mainLoop.resume()}var asyncWasmReturnValue,isError=false;try{asyncWasmReturnValue=Asyncify.doRewind(Asyncify.currData)}catch(err){asyncWasmReturnValue=err;isError=true}var handled=false;if(!Asyncify.currData){var asyncPromiseHandlers=Asyncify.asyncPromiseHandlers;if(asyncPromiseHandlers){Asyncify.asyncPromiseHandlers=null;(isError?asyncPromiseHandlers.reject:asyncPromiseHandlers.resolve)(asyncWasmReturnValue);handled=true}}if(isError&&!handled){throw asyncWasmReturnValue}});reachedAfterCallback=true;if(!reachedCallback){Asyncify.state=Asyncify.State.Unwinding;Asyncify.currData=Asyncify.allocateData();if(typeof Browser!="undefined"&&Browser.mainLoop.func){Browser.mainLoop.pause()}runAndAbortIfError(()=>_asyncify_start_unwind(Asyncify.currData))}}else if(Asyncify.state===Asyncify.State.Rewinding){Asyncify.state=Asyncify.State.Normal;runAndAbortIfError(_asyncify_stop_rewind);_free(Asyncify.currData);Asyncify.currData=null;Asyncify.sleepCallbacks.forEach(func=>callUserCallback(func))}else{abort("invalid state: "+Asyncify.state)}return Asyncify.handleSleepReturnValue},handleAsync:function(startAsync){return Asyncify.handleSleep(wakeUp=>{startAsync().then(wakeUp)})}};function getCFunc(ident){var func=Module["_"+ident];return func}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer)}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){var len=(str.length<<2)+1;ret=stackAlloc(len);stringToUTF8(str,ret,len)}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;itype==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments,opts)}}var FSNode=function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev};var readMode=292|73;var writeMode=146;Object.defineProperties(FSNode.prototype,{read:{get:function(){return(this.mode&readMode)===readMode},set:function(val){val?this.mode|=readMode:this.mode&=~readMode}},write:{get:function(){return(this.mode&writeMode)===writeMode},set:function(val){val?this.mode|=writeMode:this.mode&=~writeMode}},isFolder:{get:function(){return FS.isDir(this.mode)}},isDevice:{get:function(){return FS.isChrdev(this.mode)}}});FS.FSNode=FSNode;FS.staticInit();var asmLibraryArg={"D":___syscall_faccessat,"j":___syscall_fcntl64,"B":___syscall_fstat64,"t":___syscall_getdents64,"y":___syscall_lstat64,"z":___syscall_newfstatat,"u":___syscall_openat,"s":___syscall_renameat,"r":___syscall_rmdir,"A":___syscall_stat64,"p":___syscall_unlinkat,"C":__emscripten_get_now_is_monotonic,"n":__emscripten_throw_longjmp,"a":_abort,"e":_emscripten_date_now,"q":_emscripten_get_heap_max,"d":_emscripten_get_now,"o":_emscripten_resize_heap,"w":_environ_get,"x":_environ_sizes_get,"c":_fd_close,"v":_fd_fdstat_get,"E":_fd_read,"m":_fd_seek,"f":_fd_write,"g":invoke_ii,"b":invoke_iii,"k":invoke_iiiii,"h":invoke_vi,"i":invoke_viiii,"l":invoke_viiiiiii,"F":libavjs_wait_reader};var asm=createWasm();var ___wasm_call_ctors=Module["___wasm_call_ctors"]=function(){return(___wasm_call_ctors=Module["___wasm_call_ctors"]=Module["asm"]["H"]).apply(null,arguments)};var _ff_nothing=Module["_ff_nothing"]=function(){return(_ff_nothing=Module["_ff_nothing"]=Module["asm"]["I"]).apply(null,arguments)};var _AVFrame_channel_layout=Module["_AVFrame_channel_layout"]=function(){return(_AVFrame_channel_layout=Module["_AVFrame_channel_layout"]=Module["asm"]["J"]).apply(null,arguments)};var _AVFrame_channel_layouthi=Module["_AVFrame_channel_layouthi"]=function(){return(_AVFrame_channel_layouthi=Module["_AVFrame_channel_layouthi"]=Module["asm"]["K"]).apply(null,arguments)};var _AVFrame_channel_layout_s=Module["_AVFrame_channel_layout_s"]=function(){return(_AVFrame_channel_layout_s=Module["_AVFrame_channel_layout_s"]=Module["asm"]["L"]).apply(null,arguments)};var _AVFrame_channel_layouthi_s=Module["_AVFrame_channel_layouthi_s"]=function(){return(_AVFrame_channel_layouthi_s=Module["_AVFrame_channel_layouthi_s"]=Module["asm"]["M"]).apply(null,arguments)};var _AVFrame_channels=Module["_AVFrame_channels"]=function(){return(_AVFrame_channels=Module["_AVFrame_channels"]=Module["asm"]["N"]).apply(null,arguments)};var _AVFrame_channels_s=Module["_AVFrame_channels_s"]=function(){return(_AVFrame_channels_s=Module["_AVFrame_channels_s"]=Module["asm"]["O"]).apply(null,arguments)};var _AVFrame_data_a=Module["_AVFrame_data_a"]=function(){return(_AVFrame_data_a=Module["_AVFrame_data_a"]=Module["asm"]["P"]).apply(null,arguments)};var _AVFrame_data_a_s=Module["_AVFrame_data_a_s"]=function(){return(_AVFrame_data_a_s=Module["_AVFrame_data_a_s"]=Module["asm"]["Q"]).apply(null,arguments)};var _AVFrame_format=Module["_AVFrame_format"]=function(){return(_AVFrame_format=Module["_AVFrame_format"]=Module["asm"]["R"]).apply(null,arguments)};var _AVFrame_format_s=Module["_AVFrame_format_s"]=function(){return(_AVFrame_format_s=Module["_AVFrame_format_s"]=Module["asm"]["S"]).apply(null,arguments)};var _AVFrame_height=Module["_AVFrame_height"]=function(){return(_AVFrame_height=Module["_AVFrame_height"]=Module["asm"]["T"]).apply(null,arguments)};var _AVFrame_height_s=Module["_AVFrame_height_s"]=function(){return(_AVFrame_height_s=Module["_AVFrame_height_s"]=Module["asm"]["U"]).apply(null,arguments)};var _AVFrame_key_frame=Module["_AVFrame_key_frame"]=function(){return(_AVFrame_key_frame=Module["_AVFrame_key_frame"]=Module["asm"]["V"]).apply(null,arguments)};var _AVFrame_key_frame_s=Module["_AVFrame_key_frame_s"]=function(){return(_AVFrame_key_frame_s=Module["_AVFrame_key_frame_s"]=Module["asm"]["W"]).apply(null,arguments)};var _AVFrame_linesize_a=Module["_AVFrame_linesize_a"]=function(){return(_AVFrame_linesize_a=Module["_AVFrame_linesize_a"]=Module["asm"]["X"]).apply(null,arguments)};var _AVFrame_linesize_a_s=Module["_AVFrame_linesize_a_s"]=function(){return(_AVFrame_linesize_a_s=Module["_AVFrame_linesize_a_s"]=Module["asm"]["Y"]).apply(null,arguments)};var _AVFrame_nb_samples=Module["_AVFrame_nb_samples"]=function(){return(_AVFrame_nb_samples=Module["_AVFrame_nb_samples"]=Module["asm"]["Z"]).apply(null,arguments)};var _AVFrame_nb_samples_s=Module["_AVFrame_nb_samples_s"]=function(){return(_AVFrame_nb_samples_s=Module["_AVFrame_nb_samples_s"]=Module["asm"]["_"]).apply(null,arguments)};var _AVFrame_pict_type=Module["_AVFrame_pict_type"]=function(){return(_AVFrame_pict_type=Module["_AVFrame_pict_type"]=Module["asm"]["$"]).apply(null,arguments)};var _AVFrame_pict_type_s=Module["_AVFrame_pict_type_s"]=function(){return(_AVFrame_pict_type_s=Module["_AVFrame_pict_type_s"]=Module["asm"]["aa"]).apply(null,arguments)};var _AVFrame_pts=Module["_AVFrame_pts"]=function(){return(_AVFrame_pts=Module["_AVFrame_pts"]=Module["asm"]["ba"]).apply(null,arguments)};var _AVFrame_ptshi=Module["_AVFrame_ptshi"]=function(){return(_AVFrame_ptshi=Module["_AVFrame_ptshi"]=Module["asm"]["ca"]).apply(null,arguments)};var _AVFrame_pts_s=Module["_AVFrame_pts_s"]=function(){return(_AVFrame_pts_s=Module["_AVFrame_pts_s"]=Module["asm"]["da"]).apply(null,arguments)};var _AVFrame_ptshi_s=Module["_AVFrame_ptshi_s"]=function(){return(_AVFrame_ptshi_s=Module["_AVFrame_ptshi_s"]=Module["asm"]["ea"]).apply(null,arguments)};var _AVFrame_sample_rate=Module["_AVFrame_sample_rate"]=function(){return(_AVFrame_sample_rate=Module["_AVFrame_sample_rate"]=Module["asm"]["fa"]).apply(null,arguments)};var _AVFrame_sample_rate_s=Module["_AVFrame_sample_rate_s"]=function(){return(_AVFrame_sample_rate_s=Module["_AVFrame_sample_rate_s"]=Module["asm"]["ga"]).apply(null,arguments)};var _AVFrame_width=Module["_AVFrame_width"]=function(){return(_AVFrame_width=Module["_AVFrame_width"]=Module["asm"]["ha"]).apply(null,arguments)};var _AVFrame_width_s=Module["_AVFrame_width_s"]=function(){return(_AVFrame_width_s=Module["_AVFrame_width_s"]=Module["asm"]["ia"]).apply(null,arguments)};var _AVFrame_sample_aspect_ratio_num=Module["_AVFrame_sample_aspect_ratio_num"]=function(){return(_AVFrame_sample_aspect_ratio_num=Module["_AVFrame_sample_aspect_ratio_num"]=Module["asm"]["ja"]).apply(null,arguments)};var _AVFrame_sample_aspect_ratio_den=Module["_AVFrame_sample_aspect_ratio_den"]=function(){return(_AVFrame_sample_aspect_ratio_den=Module["_AVFrame_sample_aspect_ratio_den"]=Module["asm"]["ka"]).apply(null,arguments)};var _AVFrame_sample_aspect_ratio_s=Module["_AVFrame_sample_aspect_ratio_s"]=function(){return(_AVFrame_sample_aspect_ratio_s=Module["_AVFrame_sample_aspect_ratio_s"]=Module["asm"]["la"]).apply(null,arguments)};var _AVPixFmtDescriptor_log2_chroma_h=Module["_AVPixFmtDescriptor_log2_chroma_h"]=function(){return(_AVPixFmtDescriptor_log2_chroma_h=Module["_AVPixFmtDescriptor_log2_chroma_h"]=Module["asm"]["ma"]).apply(null,arguments)};var _AVPixFmtDescriptor_log2_chroma_h_s=Module["_AVPixFmtDescriptor_log2_chroma_h_s"]=function(){return(_AVPixFmtDescriptor_log2_chroma_h_s=Module["_AVPixFmtDescriptor_log2_chroma_h_s"]=Module["asm"]["na"]).apply(null,arguments)};var _av_opt_set_int_list_js=Module["_av_opt_set_int_list_js"]=function(){return(_av_opt_set_int_list_js=Module["_av_opt_set_int_list_js"]=Module["asm"]["oa"]).apply(null,arguments)};var _AVCodecContext_bit_rate=Module["_AVCodecContext_bit_rate"]=function(){return(_AVCodecContext_bit_rate=Module["_AVCodecContext_bit_rate"]=Module["asm"]["pa"]).apply(null,arguments)};var _AVCodecContext_bit_ratehi=Module["_AVCodecContext_bit_ratehi"]=function(){return(_AVCodecContext_bit_ratehi=Module["_AVCodecContext_bit_ratehi"]=Module["asm"]["qa"]).apply(null,arguments)};var _AVCodecContext_bit_rate_s=Module["_AVCodecContext_bit_rate_s"]=function(){return(_AVCodecContext_bit_rate_s=Module["_AVCodecContext_bit_rate_s"]=Module["asm"]["ra"]).apply(null,arguments)};var _AVCodecContext_bit_ratehi_s=Module["_AVCodecContext_bit_ratehi_s"]=function(){return(_AVCodecContext_bit_ratehi_s=Module["_AVCodecContext_bit_ratehi_s"]=Module["asm"]["sa"]).apply(null,arguments)};var _AVCodecContext_channel_layout=Module["_AVCodecContext_channel_layout"]=function(){return(_AVCodecContext_channel_layout=Module["_AVCodecContext_channel_layout"]=Module["asm"]["ta"]).apply(null,arguments)};var _AVCodecContext_channel_layouthi=Module["_AVCodecContext_channel_layouthi"]=function(){return(_AVCodecContext_channel_layouthi=Module["_AVCodecContext_channel_layouthi"]=Module["asm"]["ua"]).apply(null,arguments)};var _AVCodecContext_channel_layout_s=Module["_AVCodecContext_channel_layout_s"]=function(){return(_AVCodecContext_channel_layout_s=Module["_AVCodecContext_channel_layout_s"]=Module["asm"]["va"]).apply(null,arguments)};var _AVCodecContext_channel_layouthi_s=Module["_AVCodecContext_channel_layouthi_s"]=function(){return(_AVCodecContext_channel_layouthi_s=Module["_AVCodecContext_channel_layouthi_s"]=Module["asm"]["wa"]).apply(null,arguments)};var _AVCodecContext_channels=Module["_AVCodecContext_channels"]=function(){return(_AVCodecContext_channels=Module["_AVCodecContext_channels"]=Module["asm"]["xa"]).apply(null,arguments)};var _AVCodecContext_channels_s=Module["_AVCodecContext_channels_s"]=function(){return(_AVCodecContext_channels_s=Module["_AVCodecContext_channels_s"]=Module["asm"]["ya"]).apply(null,arguments)};var _AVCodecContext_extradata=Module["_AVCodecContext_extradata"]=function(){return(_AVCodecContext_extradata=Module["_AVCodecContext_extradata"]=Module["asm"]["za"]).apply(null,arguments)};var _AVCodecContext_extradata_s=Module["_AVCodecContext_extradata_s"]=function(){return(_AVCodecContext_extradata_s=Module["_AVCodecContext_extradata_s"]=Module["asm"]["Aa"]).apply(null,arguments)};var _AVCodecContext_extradata_size=Module["_AVCodecContext_extradata_size"]=function(){return(_AVCodecContext_extradata_size=Module["_AVCodecContext_extradata_size"]=Module["asm"]["Ba"]).apply(null,arguments)};var _AVCodecContext_extradata_size_s=Module["_AVCodecContext_extradata_size_s"]=function(){return(_AVCodecContext_extradata_size_s=Module["_AVCodecContext_extradata_size_s"]=Module["asm"]["Ca"]).apply(null,arguments)};var _AVCodecContext_frame_size=Module["_AVCodecContext_frame_size"]=function(){return(_AVCodecContext_frame_size=Module["_AVCodecContext_frame_size"]=Module["asm"]["Da"]).apply(null,arguments)};var _AVCodecContext_frame_size_s=Module["_AVCodecContext_frame_size_s"]=function(){return(_AVCodecContext_frame_size_s=Module["_AVCodecContext_frame_size_s"]=Module["asm"]["Ea"]).apply(null,arguments)};var _AVCodecContext_gop_size=Module["_AVCodecContext_gop_size"]=function(){return(_AVCodecContext_gop_size=Module["_AVCodecContext_gop_size"]=Module["asm"]["Fa"]).apply(null,arguments)};var _AVCodecContext_gop_size_s=Module["_AVCodecContext_gop_size_s"]=function(){return(_AVCodecContext_gop_size_s=Module["_AVCodecContext_gop_size_s"]=Module["asm"]["Ga"]).apply(null,arguments)};var _AVCodecContext_height=Module["_AVCodecContext_height"]=function(){return(_AVCodecContext_height=Module["_AVCodecContext_height"]=Module["asm"]["Ha"]).apply(null,arguments)};var _AVCodecContext_height_s=Module["_AVCodecContext_height_s"]=function(){return(_AVCodecContext_height_s=Module["_AVCodecContext_height_s"]=Module["asm"]["Ia"]).apply(null,arguments)};var _AVCodecContext_keyint_min=Module["_AVCodecContext_keyint_min"]=function(){return(_AVCodecContext_keyint_min=Module["_AVCodecContext_keyint_min"]=Module["asm"]["Ja"]).apply(null,arguments)};var _AVCodecContext_keyint_min_s=Module["_AVCodecContext_keyint_min_s"]=function(){return(_AVCodecContext_keyint_min_s=Module["_AVCodecContext_keyint_min_s"]=Module["asm"]["Ka"]).apply(null,arguments)};var _AVCodecContext_level=Module["_AVCodecContext_level"]=function(){return(_AVCodecContext_level=Module["_AVCodecContext_level"]=Module["asm"]["La"]).apply(null,arguments)};var _AVCodecContext_level_s=Module["_AVCodecContext_level_s"]=function(){return(_AVCodecContext_level_s=Module["_AVCodecContext_level_s"]=Module["asm"]["Ma"]).apply(null,arguments)};var _AVCodecContext_pix_fmt=Module["_AVCodecContext_pix_fmt"]=function(){return(_AVCodecContext_pix_fmt=Module["_AVCodecContext_pix_fmt"]=Module["asm"]["Na"]).apply(null,arguments)};var _AVCodecContext_pix_fmt_s=Module["_AVCodecContext_pix_fmt_s"]=function(){return(_AVCodecContext_pix_fmt_s=Module["_AVCodecContext_pix_fmt_s"]=Module["asm"]["Oa"]).apply(null,arguments)};var _AVCodecContext_profile=Module["_AVCodecContext_profile"]=function(){return(_AVCodecContext_profile=Module["_AVCodecContext_profile"]=Module["asm"]["Pa"]).apply(null,arguments)};var _AVCodecContext_profile_s=Module["_AVCodecContext_profile_s"]=function(){return(_AVCodecContext_profile_s=Module["_AVCodecContext_profile_s"]=Module["asm"]["Qa"]).apply(null,arguments)};var _AVCodecContext_rc_max_rate=Module["_AVCodecContext_rc_max_rate"]=function(){return(_AVCodecContext_rc_max_rate=Module["_AVCodecContext_rc_max_rate"]=Module["asm"]["Ra"]).apply(null,arguments)};var _AVCodecContext_rc_max_ratehi=Module["_AVCodecContext_rc_max_ratehi"]=function(){return(_AVCodecContext_rc_max_ratehi=Module["_AVCodecContext_rc_max_ratehi"]=Module["asm"]["Sa"]).apply(null,arguments)};var _AVCodecContext_rc_max_rate_s=Module["_AVCodecContext_rc_max_rate_s"]=function(){return(_AVCodecContext_rc_max_rate_s=Module["_AVCodecContext_rc_max_rate_s"]=Module["asm"]["Ta"]).apply(null,arguments)};var _AVCodecContext_rc_max_ratehi_s=Module["_AVCodecContext_rc_max_ratehi_s"]=function(){return(_AVCodecContext_rc_max_ratehi_s=Module["_AVCodecContext_rc_max_ratehi_s"]=Module["asm"]["Ua"]).apply(null,arguments)};var _AVCodecContext_rc_min_rate=Module["_AVCodecContext_rc_min_rate"]=function(){return(_AVCodecContext_rc_min_rate=Module["_AVCodecContext_rc_min_rate"]=Module["asm"]["Va"]).apply(null,arguments)};var _AVCodecContext_rc_min_ratehi=Module["_AVCodecContext_rc_min_ratehi"]=function(){return(_AVCodecContext_rc_min_ratehi=Module["_AVCodecContext_rc_min_ratehi"]=Module["asm"]["Wa"]).apply(null,arguments)};var _AVCodecContext_rc_min_rate_s=Module["_AVCodecContext_rc_min_rate_s"]=function(){return(_AVCodecContext_rc_min_rate_s=Module["_AVCodecContext_rc_min_rate_s"]=Module["asm"]["Xa"]).apply(null,arguments)};var _AVCodecContext_rc_min_ratehi_s=Module["_AVCodecContext_rc_min_ratehi_s"]=function(){return(_AVCodecContext_rc_min_ratehi_s=Module["_AVCodecContext_rc_min_ratehi_s"]=Module["asm"]["Ya"]).apply(null,arguments)};var _AVCodecContext_sample_fmt=Module["_AVCodecContext_sample_fmt"]=function(){return(_AVCodecContext_sample_fmt=Module["_AVCodecContext_sample_fmt"]=Module["asm"]["Za"]).apply(null,arguments)};var _AVCodecContext_sample_fmt_s=Module["_AVCodecContext_sample_fmt_s"]=function(){return(_AVCodecContext_sample_fmt_s=Module["_AVCodecContext_sample_fmt_s"]=Module["asm"]["_a"]).apply(null,arguments)};var _AVCodecContext_sample_rate=Module["_AVCodecContext_sample_rate"]=function(){return(_AVCodecContext_sample_rate=Module["_AVCodecContext_sample_rate"]=Module["asm"]["$a"]).apply(null,arguments)};var _AVCodecContext_sample_rate_s=Module["_AVCodecContext_sample_rate_s"]=function(){return(_AVCodecContext_sample_rate_s=Module["_AVCodecContext_sample_rate_s"]=Module["asm"]["ab"]).apply(null,arguments)};var _AVCodecContext_qmax=Module["_AVCodecContext_qmax"]=function(){return(_AVCodecContext_qmax=Module["_AVCodecContext_qmax"]=Module["asm"]["bb"]).apply(null,arguments)};var _AVCodecContext_qmax_s=Module["_AVCodecContext_qmax_s"]=function(){return(_AVCodecContext_qmax_s=Module["_AVCodecContext_qmax_s"]=Module["asm"]["cb"]).apply(null,arguments)};var _AVCodecContext_qmin=Module["_AVCodecContext_qmin"]=function(){return(_AVCodecContext_qmin=Module["_AVCodecContext_qmin"]=Module["asm"]["db"]).apply(null,arguments)};var _AVCodecContext_qmin_s=Module["_AVCodecContext_qmin_s"]=function(){return(_AVCodecContext_qmin_s=Module["_AVCodecContext_qmin_s"]=Module["asm"]["eb"]).apply(null,arguments)};var _AVCodecContext_width=Module["_AVCodecContext_width"]=function(){return(_AVCodecContext_width=Module["_AVCodecContext_width"]=Module["asm"]["fb"]).apply(null,arguments)};var _AVCodecContext_width_s=Module["_AVCodecContext_width_s"]=function(){return(_AVCodecContext_width_s=Module["_AVCodecContext_width_s"]=Module["asm"]["gb"]).apply(null,arguments)};var _AVCodecContext_framerate_num=Module["_AVCodecContext_framerate_num"]=function(){return(_AVCodecContext_framerate_num=Module["_AVCodecContext_framerate_num"]=Module["asm"]["hb"]).apply(null,arguments)};var _AVCodecContext_framerate_den=Module["_AVCodecContext_framerate_den"]=function(){return(_AVCodecContext_framerate_den=Module["_AVCodecContext_framerate_den"]=Module["asm"]["ib"]).apply(null,arguments)};var _AVCodecContext_framerate_num_s=Module["_AVCodecContext_framerate_num_s"]=function(){return(_AVCodecContext_framerate_num_s=Module["_AVCodecContext_framerate_num_s"]=Module["asm"]["jb"]).apply(null,arguments)};var _AVCodecContext_framerate_den_s=Module["_AVCodecContext_framerate_den_s"]=function(){return(_AVCodecContext_framerate_den_s=Module["_AVCodecContext_framerate_den_s"]=Module["asm"]["kb"]).apply(null,arguments)};var _AVCodecContext_framerate_s=Module["_AVCodecContext_framerate_s"]=function(){return(_AVCodecContext_framerate_s=Module["_AVCodecContext_framerate_s"]=Module["asm"]["lb"]).apply(null,arguments)};var _AVCodecContext_sample_aspect_ratio_num=Module["_AVCodecContext_sample_aspect_ratio_num"]=function(){return(_AVCodecContext_sample_aspect_ratio_num=Module["_AVCodecContext_sample_aspect_ratio_num"]=Module["asm"]["mb"]).apply(null,arguments)};var _AVCodecContext_sample_aspect_ratio_den=Module["_AVCodecContext_sample_aspect_ratio_den"]=function(){return(_AVCodecContext_sample_aspect_ratio_den=Module["_AVCodecContext_sample_aspect_ratio_den"]=Module["asm"]["nb"]).apply(null,arguments)};var _AVCodecContext_sample_aspect_ratio_num_s=Module["_AVCodecContext_sample_aspect_ratio_num_s"]=function(){return(_AVCodecContext_sample_aspect_ratio_num_s=Module["_AVCodecContext_sample_aspect_ratio_num_s"]=Module["asm"]["ob"]).apply(null,arguments)};var _AVCodecContext_sample_aspect_ratio_den_s=Module["_AVCodecContext_sample_aspect_ratio_den_s"]=function(){return(_AVCodecContext_sample_aspect_ratio_den_s=Module["_AVCodecContext_sample_aspect_ratio_den_s"]=Module["asm"]["pb"]).apply(null,arguments)};var _AVCodecContext_sample_aspect_ratio_s=Module["_AVCodecContext_sample_aspect_ratio_s"]=function(){return(_AVCodecContext_sample_aspect_ratio_s=Module["_AVCodecContext_sample_aspect_ratio_s"]=Module["asm"]["qb"]).apply(null,arguments)};var _AVCodecContext_time_base_s=Module["_AVCodecContext_time_base_s"]=function(){return(_AVCodecContext_time_base_s=Module["_AVCodecContext_time_base_s"]=Module["asm"]["rb"]).apply(null,arguments)};var _AVCodecParameters_codec_id=Module["_AVCodecParameters_codec_id"]=function(){return(_AVCodecParameters_codec_id=Module["_AVCodecParameters_codec_id"]=Module["asm"]["sb"]).apply(null,arguments)};var _AVCodecParameters_codec_id_s=Module["_AVCodecParameters_codec_id_s"]=function(){return(_AVCodecParameters_codec_id_s=Module["_AVCodecParameters_codec_id_s"]=Module["asm"]["tb"]).apply(null,arguments)};var _AVCodecParameters_codec_type=Module["_AVCodecParameters_codec_type"]=function(){return(_AVCodecParameters_codec_type=Module["_AVCodecParameters_codec_type"]=Module["asm"]["ub"]).apply(null,arguments)};var _AVCodecParameters_codec_type_s=Module["_AVCodecParameters_codec_type_s"]=function(){return(_AVCodecParameters_codec_type_s=Module["_AVCodecParameters_codec_type_s"]=Module["asm"]["vb"]).apply(null,arguments)};var _AVCodecParameters_extradata=Module["_AVCodecParameters_extradata"]=function(){return(_AVCodecParameters_extradata=Module["_AVCodecParameters_extradata"]=Module["asm"]["wb"]).apply(null,arguments)};var _AVCodecParameters_extradata_s=Module["_AVCodecParameters_extradata_s"]=function(){return(_AVCodecParameters_extradata_s=Module["_AVCodecParameters_extradata_s"]=Module["asm"]["xb"]).apply(null,arguments)};var _AVCodecParameters_extradata_size=Module["_AVCodecParameters_extradata_size"]=function(){return(_AVCodecParameters_extradata_size=Module["_AVCodecParameters_extradata_size"]=Module["asm"]["yb"]).apply(null,arguments)};var _AVCodecParameters_extradata_size_s=Module["_AVCodecParameters_extradata_size_s"]=function(){return(_AVCodecParameters_extradata_size_s=Module["_AVCodecParameters_extradata_size_s"]=Module["asm"]["zb"]).apply(null,arguments)};var _AVCodecParameters_format=Module["_AVCodecParameters_format"]=function(){return(_AVCodecParameters_format=Module["_AVCodecParameters_format"]=Module["asm"]["Ab"]).apply(null,arguments)};var _AVCodecParameters_format_s=Module["_AVCodecParameters_format_s"]=function(){return(_AVCodecParameters_format_s=Module["_AVCodecParameters_format_s"]=Module["asm"]["Bb"]).apply(null,arguments)};var _AVCodecParameters_bit_rate=Module["_AVCodecParameters_bit_rate"]=function(){return(_AVCodecParameters_bit_rate=Module["_AVCodecParameters_bit_rate"]=Module["asm"]["Cb"]).apply(null,arguments)};var _AVCodecParameters_bit_rate_s=Module["_AVCodecParameters_bit_rate_s"]=function(){return(_AVCodecParameters_bit_rate_s=Module["_AVCodecParameters_bit_rate_s"]=Module["asm"]["Db"]).apply(null,arguments)};var _AVCodecParameters_profile=Module["_AVCodecParameters_profile"]=function(){return(_AVCodecParameters_profile=Module["_AVCodecParameters_profile"]=Module["asm"]["Eb"]).apply(null,arguments)};var _AVCodecParameters_profile_s=Module["_AVCodecParameters_profile_s"]=function(){return(_AVCodecParameters_profile_s=Module["_AVCodecParameters_profile_s"]=Module["asm"]["Fb"]).apply(null,arguments)};var _AVCodecParameters_level=Module["_AVCodecParameters_level"]=function(){return(_AVCodecParameters_level=Module["_AVCodecParameters_level"]=Module["asm"]["Gb"]).apply(null,arguments)};var _AVCodecParameters_level_s=Module["_AVCodecParameters_level_s"]=function(){return(_AVCodecParameters_level_s=Module["_AVCodecParameters_level_s"]=Module["asm"]["Hb"]).apply(null,arguments)};var _AVCodecParameters_width=Module["_AVCodecParameters_width"]=function(){return(_AVCodecParameters_width=Module["_AVCodecParameters_width"]=Module["asm"]["Ib"]).apply(null,arguments)};var _AVCodecParameters_width_s=Module["_AVCodecParameters_width_s"]=function(){return(_AVCodecParameters_width_s=Module["_AVCodecParameters_width_s"]=Module["asm"]["Jb"]).apply(null,arguments)};var _AVCodecParameters_height=Module["_AVCodecParameters_height"]=function(){return(_AVCodecParameters_height=Module["_AVCodecParameters_height"]=Module["asm"]["Kb"]).apply(null,arguments)};var _AVCodecParameters_height_s=Module["_AVCodecParameters_height_s"]=function(){return(_AVCodecParameters_height_s=Module["_AVCodecParameters_height_s"]=Module["asm"]["Lb"]).apply(null,arguments)};var _AVCodecParameters_color_range=Module["_AVCodecParameters_color_range"]=function(){return(_AVCodecParameters_color_range=Module["_AVCodecParameters_color_range"]=Module["asm"]["Mb"]).apply(null,arguments)};var _AVCodecParameters_color_range_s=Module["_AVCodecParameters_color_range_s"]=function(){return(_AVCodecParameters_color_range_s=Module["_AVCodecParameters_color_range_s"]=Module["asm"]["Nb"]).apply(null,arguments)};var _AVCodecParameters_color_primaries=Module["_AVCodecParameters_color_primaries"]=function(){return(_AVCodecParameters_color_primaries=Module["_AVCodecParameters_color_primaries"]=Module["asm"]["Ob"]).apply(null,arguments)};var _AVCodecParameters_color_primaries_s=Module["_AVCodecParameters_color_primaries_s"]=function(){return(_AVCodecParameters_color_primaries_s=Module["_AVCodecParameters_color_primaries_s"]=Module["asm"]["Pb"]).apply(null,arguments)};var _AVCodecParameters_color_trc=Module["_AVCodecParameters_color_trc"]=function(){return(_AVCodecParameters_color_trc=Module["_AVCodecParameters_color_trc"]=Module["asm"]["Qb"]).apply(null,arguments)};var _AVCodecParameters_color_trc_s=Module["_AVCodecParameters_color_trc_s"]=function(){return(_AVCodecParameters_color_trc_s=Module["_AVCodecParameters_color_trc_s"]=Module["asm"]["Rb"]).apply(null,arguments)};var _AVCodecParameters_color_space=Module["_AVCodecParameters_color_space"]=function(){return(_AVCodecParameters_color_space=Module["_AVCodecParameters_color_space"]=Module["asm"]["Sb"]).apply(null,arguments)};var _AVCodecParameters_color_space_s=Module["_AVCodecParameters_color_space_s"]=function(){return(_AVCodecParameters_color_space_s=Module["_AVCodecParameters_color_space_s"]=Module["asm"]["Tb"]).apply(null,arguments)};var _AVCodecParameters_chroma_location=Module["_AVCodecParameters_chroma_location"]=function(){return(_AVCodecParameters_chroma_location=Module["_AVCodecParameters_chroma_location"]=Module["asm"]["Ub"]).apply(null,arguments)};var _AVCodecParameters_chroma_location_s=Module["_AVCodecParameters_chroma_location_s"]=function(){return(_AVCodecParameters_chroma_location_s=Module["_AVCodecParameters_chroma_location_s"]=Module["asm"]["Vb"]).apply(null,arguments)};var _AVCodecParameters_channels=Module["_AVCodecParameters_channels"]=function(){return(_AVCodecParameters_channels=Module["_AVCodecParameters_channels"]=Module["asm"]["Wb"]).apply(null,arguments)};var _AVCodecParameters_channels_s=Module["_AVCodecParameters_channels_s"]=function(){return(_AVCodecParameters_channels_s=Module["_AVCodecParameters_channels_s"]=Module["asm"]["Xb"]).apply(null,arguments)};var _AVCodecParameters_sample_rate=Module["_AVCodecParameters_sample_rate"]=function(){return(_AVCodecParameters_sample_rate=Module["_AVCodecParameters_sample_rate"]=Module["asm"]["Yb"]).apply(null,arguments)};var _AVCodecParameters_sample_rate_s=Module["_AVCodecParameters_sample_rate_s"]=function(){return(_AVCodecParameters_sample_rate_s=Module["_AVCodecParameters_sample_rate_s"]=Module["asm"]["Zb"]).apply(null,arguments)};var _ff_calloc_AVCodecParameters=Module["_ff_calloc_AVCodecParameters"]=function(){return(_ff_calloc_AVCodecParameters=Module["_ff_calloc_AVCodecParameters"]=Module["asm"]["_b"]).apply(null,arguments)};var _calloc=Module["_calloc"]=function(){return(_calloc=Module["_calloc"]=Module["asm"]["$b"]).apply(null,arguments)};var _AVPacket_data=Module["_AVPacket_data"]=function(){return(_AVPacket_data=Module["_AVPacket_data"]=Module["asm"]["ac"]).apply(null,arguments)};var _AVPacket_data_s=Module["_AVPacket_data_s"]=function(){return(_AVPacket_data_s=Module["_AVPacket_data_s"]=Module["asm"]["bc"]).apply(null,arguments)};var _AVPacket_dts=Module["_AVPacket_dts"]=function(){return(_AVPacket_dts=Module["_AVPacket_dts"]=Module["asm"]["cc"]).apply(null,arguments)};var _AVPacket_dtshi=Module["_AVPacket_dtshi"]=function(){return(_AVPacket_dtshi=Module["_AVPacket_dtshi"]=Module["asm"]["dc"]).apply(null,arguments)};var _AVPacket_dts_s=Module["_AVPacket_dts_s"]=function(){return(_AVPacket_dts_s=Module["_AVPacket_dts_s"]=Module["asm"]["ec"]).apply(null,arguments)};var _AVPacket_dtshi_s=Module["_AVPacket_dtshi_s"]=function(){return(_AVPacket_dtshi_s=Module["_AVPacket_dtshi_s"]=Module["asm"]["fc"]).apply(null,arguments)};var _AVPacket_duration=Module["_AVPacket_duration"]=function(){return(_AVPacket_duration=Module["_AVPacket_duration"]=Module["asm"]["gc"]).apply(null,arguments)};var _AVPacket_durationhi=Module["_AVPacket_durationhi"]=function(){return(_AVPacket_durationhi=Module["_AVPacket_durationhi"]=Module["asm"]["hc"]).apply(null,arguments)};var _AVPacket_duration_s=Module["_AVPacket_duration_s"]=function(){return(_AVPacket_duration_s=Module["_AVPacket_duration_s"]=Module["asm"]["ic"]).apply(null,arguments)};var _AVPacket_durationhi_s=Module["_AVPacket_durationhi_s"]=function(){return(_AVPacket_durationhi_s=Module["_AVPacket_durationhi_s"]=Module["asm"]["jc"]).apply(null,arguments)};var _AVPacket_flags=Module["_AVPacket_flags"]=function(){return(_AVPacket_flags=Module["_AVPacket_flags"]=Module["asm"]["kc"]).apply(null,arguments)};var _AVPacket_flags_s=Module["_AVPacket_flags_s"]=function(){return(_AVPacket_flags_s=Module["_AVPacket_flags_s"]=Module["asm"]["lc"]).apply(null,arguments)};var _AVPacket_pts=Module["_AVPacket_pts"]=function(){return(_AVPacket_pts=Module["_AVPacket_pts"]=Module["asm"]["mc"]).apply(null,arguments)};var _AVPacket_ptshi=Module["_AVPacket_ptshi"]=function(){return(_AVPacket_ptshi=Module["_AVPacket_ptshi"]=Module["asm"]["nc"]).apply(null,arguments)};var _AVPacket_pts_s=Module["_AVPacket_pts_s"]=function(){return(_AVPacket_pts_s=Module["_AVPacket_pts_s"]=Module["asm"]["oc"]).apply(null,arguments)};var _AVPacket_ptshi_s=Module["_AVPacket_ptshi_s"]=function(){return(_AVPacket_ptshi_s=Module["_AVPacket_ptshi_s"]=Module["asm"]["pc"]).apply(null,arguments)};var _AVPacket_side_data=Module["_AVPacket_side_data"]=function(){return(_AVPacket_side_data=Module["_AVPacket_side_data"]=Module["asm"]["qc"]).apply(null,arguments)};var _AVPacket_side_data_s=Module["_AVPacket_side_data_s"]=function(){return(_AVPacket_side_data_s=Module["_AVPacket_side_data_s"]=Module["asm"]["rc"]).apply(null,arguments)};var _AVPacket_side_data_elems=Module["_AVPacket_side_data_elems"]=function(){return(_AVPacket_side_data_elems=Module["_AVPacket_side_data_elems"]=Module["asm"]["sc"]).apply(null,arguments)};var _AVPacket_side_data_elems_s=Module["_AVPacket_side_data_elems_s"]=function(){return(_AVPacket_side_data_elems_s=Module["_AVPacket_side_data_elems_s"]=Module["asm"]["tc"]).apply(null,arguments)};var _AVPacket_size=Module["_AVPacket_size"]=function(){return(_AVPacket_size=Module["_AVPacket_size"]=Module["asm"]["uc"]).apply(null,arguments)};var _AVPacket_size_s=Module["_AVPacket_size_s"]=function(){return(_AVPacket_size_s=Module["_AVPacket_size_s"]=Module["asm"]["vc"]).apply(null,arguments)};var _AVPacket_stream_index=Module["_AVPacket_stream_index"]=function(){return(_AVPacket_stream_index=Module["_AVPacket_stream_index"]=Module["asm"]["wc"]).apply(null,arguments)};var _AVPacket_stream_index_s=Module["_AVPacket_stream_index_s"]=function(){return(_AVPacket_stream_index_s=Module["_AVPacket_stream_index_s"]=Module["asm"]["xc"]).apply(null,arguments)};var _AVPacketSideData_data=Module["_AVPacketSideData_data"]=function(){return(_AVPacketSideData_data=Module["_AVPacketSideData_data"]=Module["asm"]["yc"]).apply(null,arguments)};var _AVPacketSideData_size=Module["_AVPacketSideData_size"]=function(){return(_AVPacketSideData_size=Module["_AVPacketSideData_size"]=Module["asm"]["zc"]).apply(null,arguments)};var _AVPacketSideData_type=Module["_AVPacketSideData_type"]=function(){return(_AVPacketSideData_type=Module["_AVPacketSideData_type"]=Module["asm"]["Ac"]).apply(null,arguments)};var _AVFormatContext_nb_streams=Module["_AVFormatContext_nb_streams"]=function(){return(_AVFormatContext_nb_streams=Module["_AVFormatContext_nb_streams"]=Module["asm"]["Bc"]).apply(null,arguments)};var _AVFormatContext_nb_streams_s=Module["_AVFormatContext_nb_streams_s"]=function(){return(_AVFormatContext_nb_streams_s=Module["_AVFormatContext_nb_streams_s"]=Module["asm"]["Cc"]).apply(null,arguments)};var _AVFormatContext_oformat=Module["_AVFormatContext_oformat"]=function(){return(_AVFormatContext_oformat=Module["_AVFormatContext_oformat"]=Module["asm"]["Dc"]).apply(null,arguments)};var _AVFormatContext_oformat_s=Module["_AVFormatContext_oformat_s"]=function(){return(_AVFormatContext_oformat_s=Module["_AVFormatContext_oformat_s"]=Module["asm"]["Ec"]).apply(null,arguments)};var _AVFormatContext_pb=Module["_AVFormatContext_pb"]=function(){return(_AVFormatContext_pb=Module["_AVFormatContext_pb"]=Module["asm"]["Fc"]).apply(null,arguments)};var _AVFormatContext_pb_s=Module["_AVFormatContext_pb_s"]=function(){return(_AVFormatContext_pb_s=Module["_AVFormatContext_pb_s"]=Module["asm"]["Gc"]).apply(null,arguments)};var _AVFormatContext_streams_a=Module["_AVFormatContext_streams_a"]=function(){return(_AVFormatContext_streams_a=Module["_AVFormatContext_streams_a"]=Module["asm"]["Hc"]).apply(null,arguments)};var _AVFormatContext_streams_a_s=Module["_AVFormatContext_streams_a_s"]=function(){return(_AVFormatContext_streams_a_s=Module["_AVFormatContext_streams_a_s"]=Module["asm"]["Ic"]).apply(null,arguments)};var _AVStream_codecpar=Module["_AVStream_codecpar"]=function(){return(_AVStream_codecpar=Module["_AVStream_codecpar"]=Module["asm"]["Jc"]).apply(null,arguments)};var _AVStream_codecpar_s=Module["_AVStream_codecpar_s"]=function(){return(_AVStream_codecpar_s=Module["_AVStream_codecpar_s"]=Module["asm"]["Kc"]).apply(null,arguments)};var _AVStream_duration=Module["_AVStream_duration"]=function(){return(_AVStream_duration=Module["_AVStream_duration"]=Module["asm"]["Lc"]).apply(null,arguments)};var _AVStream_durationhi=Module["_AVStream_durationhi"]=function(){return(_AVStream_durationhi=Module["_AVStream_durationhi"]=Module["asm"]["Mc"]).apply(null,arguments)};var _AVStream_duration_s=Module["_AVStream_duration_s"]=function(){return(_AVStream_duration_s=Module["_AVStream_duration_s"]=Module["asm"]["Nc"]).apply(null,arguments)};var _AVStream_durationhi_s=Module["_AVStream_durationhi_s"]=function(){return(_AVStream_durationhi_s=Module["_AVStream_durationhi_s"]=Module["asm"]["Oc"]).apply(null,arguments)};var _AVStream_time_base_num=Module["_AVStream_time_base_num"]=function(){return(_AVStream_time_base_num=Module["_AVStream_time_base_num"]=Module["asm"]["Pc"]).apply(null,arguments)};var _AVStream_time_base_den=Module["_AVStream_time_base_den"]=function(){return(_AVStream_time_base_den=Module["_AVStream_time_base_den"]=Module["asm"]["Qc"]).apply(null,arguments)};var _AVStream_time_base_s=Module["_AVStream_time_base_s"]=function(){return(_AVStream_time_base_s=Module["_AVStream_time_base_s"]=Module["asm"]["Rc"]).apply(null,arguments)};var _AVFilterInOut_filter_ctx=Module["_AVFilterInOut_filter_ctx"]=function(){return(_AVFilterInOut_filter_ctx=Module["_AVFilterInOut_filter_ctx"]=Module["asm"]["Sc"]).apply(null,arguments)};var _AVFilterInOut_filter_ctx_s=Module["_AVFilterInOut_filter_ctx_s"]=function(){return(_AVFilterInOut_filter_ctx_s=Module["_AVFilterInOut_filter_ctx_s"]=Module["asm"]["Tc"]).apply(null,arguments)};var _AVFilterInOut_name=Module["_AVFilterInOut_name"]=function(){return(_AVFilterInOut_name=Module["_AVFilterInOut_name"]=Module["asm"]["Uc"]).apply(null,arguments)};var _AVFilterInOut_name_s=Module["_AVFilterInOut_name_s"]=function(){return(_AVFilterInOut_name_s=Module["_AVFilterInOut_name_s"]=Module["asm"]["Vc"]).apply(null,arguments)};var _AVFilterInOut_next=Module["_AVFilterInOut_next"]=function(){return(_AVFilterInOut_next=Module["_AVFilterInOut_next"]=Module["asm"]["Wc"]).apply(null,arguments)};var _AVFilterInOut_next_s=Module["_AVFilterInOut_next_s"]=function(){return(_AVFilterInOut_next_s=Module["_AVFilterInOut_next_s"]=Module["asm"]["Xc"]).apply(null,arguments)};var _AVFilterInOut_pad_idx=Module["_AVFilterInOut_pad_idx"]=function(){return(_AVFilterInOut_pad_idx=Module["_AVFilterInOut_pad_idx"]=Module["asm"]["Yc"]).apply(null,arguments)};var _AVFilterInOut_pad_idx_s=Module["_AVFilterInOut_pad_idx_s"]=function(){return(_AVFilterInOut_pad_idx_s=Module["_AVFilterInOut_pad_idx_s"]=Module["asm"]["Zc"]).apply(null,arguments)};var _libavjs_with_swscale=Module["_libavjs_with_swscale"]=function(){return(_libavjs_with_swscale=Module["_libavjs_with_swscale"]=Module["asm"]["_c"]).apply(null,arguments)};var _avformat_alloc_output_context2_js=Module["_avformat_alloc_output_context2_js"]=function(){return(_avformat_alloc_output_context2_js=Module["_avformat_alloc_output_context2_js"]=Module["asm"]["$c"]).apply(null,arguments)};var _avformat_open_input_js=Module["_avformat_open_input_js"]=function(){return(_avformat_open_input_js=Module["_avformat_open_input_js"]=Module["asm"]["ad"]).apply(null,arguments)};var _avformat_open_input=Module["_avformat_open_input"]=function(){return(_avformat_open_input=Module["_avformat_open_input"]=Module["asm"]["bd"]).apply(null,arguments)};var _avio_open2_js=Module["_avio_open2_js"]=function(){return(_avio_open2_js=Module["_avio_open2_js"]=Module["asm"]["cd"]).apply(null,arguments)};var _avfilter_graph_create_filter_js=Module["_avfilter_graph_create_filter_js"]=function(){return(_avfilter_graph_create_filter_js=Module["_avfilter_graph_create_filter_js"]=Module["asm"]["dd"]).apply(null,arguments)};var _ff_error=Module["_ff_error"]=function(){return(_ff_error=Module["_ff_error"]=Module["asm"]["ed"]).apply(null,arguments)};var _mallinfo_uordblks=Module["_mallinfo_uordblks"]=function(){return(_mallinfo_uordblks=Module["_mallinfo_uordblks"]=Module["asm"]["fd"]).apply(null,arguments)};var _avformat_free_context=Module["_avformat_free_context"]=function(){return(_avformat_free_context=Module["_avformat_free_context"]=Module["asm"]["gd"]).apply(null,arguments)};var _av_find_best_stream=Module["_av_find_best_stream"]=function(){return(_av_find_best_stream=Module["_av_find_best_stream"]=Module["asm"]["hd"]).apply(null,arguments)};var _avio_close=Module["_avio_close"]=function(){return(_avio_close=Module["_avio_close"]=Module["asm"]["id"]).apply(null,arguments)};var _av_strdup=Module["_av_strdup"]=function(){return(_av_strdup=Module["_av_strdup"]=Module["asm"]["jd"]).apply(null,arguments)};var _av_dict_set=Module["_av_dict_set"]=function(){return(_av_dict_set=Module["_av_dict_set"]=Module["asm"]["kd"]).apply(null,arguments)};var _avformat_alloc_context=Module["_avformat_alloc_context"]=function(){return(_avformat_alloc_context=Module["_avformat_alloc_context"]=Module["asm"]["md"]).apply(null,arguments)};var _av_dict_free=Module["_av_dict_free"]=function(){return(_av_dict_free=Module["_av_dict_free"]=Module["asm"]["nd"]).apply(null,arguments)};var _avcodec_parameters_to_context=Module["_avcodec_parameters_to_context"]=function(){return(_avcodec_parameters_to_context=Module["_avcodec_parameters_to_context"]=Module["asm"]["od"]).apply(null,arguments)};var _av_packet_unref=Module["_av_packet_unref"]=function(){return(_av_packet_unref=Module["_av_packet_unref"]=Module["asm"]["pd"]).apply(null,arguments)};var _avcodec_free_context=Module["_avcodec_free_context"]=function(){return(_avcodec_free_context=Module["_avcodec_free_context"]=Module["asm"]["qd"]).apply(null,arguments)};var _av_packet_free=Module["_av_packet_free"]=function(){return(_av_packet_free=Module["_av_packet_free"]=Module["asm"]["rd"]).apply(null,arguments)};var _avcodec_find_decoder=Module["_avcodec_find_decoder"]=function(){return(_avcodec_find_decoder=Module["_avcodec_find_decoder"]=Module["asm"]["sd"]).apply(null,arguments)};var _avformat_close_input=Module["_avformat_close_input"]=function(){return(_avformat_close_input=Module["_avformat_close_input"]=Module["asm"]["td"]).apply(null,arguments)};var _av_read_frame=Module["_av_read_frame"]=function(){return(_av_read_frame=Module["_av_read_frame"]=Module["asm"]["ud"]).apply(null,arguments)};var _avcodec_close=Module["_avcodec_close"]=function(){return(_avcodec_close=Module["_avcodec_close"]=Module["asm"]["vd"]).apply(null,arguments)};var _avcodec_get_name=Module["_avcodec_get_name"]=function(){return(_avcodec_get_name=Module["_avcodec_get_name"]=Module["asm"]["wd"]).apply(null,arguments)};var _av_packet_new_side_data=Module["_av_packet_new_side_data"]=function(){return(_av_packet_new_side_data=Module["_av_packet_new_side_data"]=Module["asm"]["xd"]).apply(null,arguments)};var _avformat_find_stream_info=Module["_avformat_find_stream_info"]=function(){return(_avformat_find_stream_info=Module["_avformat_find_stream_info"]=Module["asm"]["yd"]).apply(null,arguments)};var _avcodec_open2=Module["_avcodec_open2"]=function(){return(_avcodec_open2=Module["_avcodec_open2"]=Module["asm"]["zd"]).apply(null,arguments)};var _avcodec_parameters_from_context=Module["_avcodec_parameters_from_context"]=function(){return(_avcodec_parameters_from_context=Module["_avcodec_parameters_from_context"]=Module["asm"]["Ad"]).apply(null,arguments)};var _avcodec_find_decoder_by_name=Module["_avcodec_find_decoder_by_name"]=function(){return(_avcodec_find_decoder_by_name=Module["_avcodec_find_decoder_by_name"]=Module["asm"]["Bd"]).apply(null,arguments)};var _av_frame_alloc=Module["_av_frame_alloc"]=function(){return(_av_frame_alloc=Module["_av_frame_alloc"]=Module["asm"]["Cd"]).apply(null,arguments)};var _avcodec_send_packet=Module["_avcodec_send_packet"]=function(){return(_avcodec_send_packet=Module["_avcodec_send_packet"]=Module["asm"]["Dd"]).apply(null,arguments)};var _avcodec_receive_frame=Module["_avcodec_receive_frame"]=function(){return(_avcodec_receive_frame=Module["_avcodec_receive_frame"]=Module["asm"]["Ed"]).apply(null,arguments)};var _av_frame_free=Module["_av_frame_free"]=function(){return(_av_frame_free=Module["_av_frame_free"]=Module["asm"]["Fd"]).apply(null,arguments)};var _avformat_new_stream=Module["_avformat_new_stream"]=function(){return(_avformat_new_stream=Module["_avformat_new_stream"]=Module["asm"]["Gd"]).apply(null,arguments)};var _av_find_input_format=Module["_av_find_input_format"]=function(){return(_av_find_input_format=Module["_av_find_input_format"]=Module["asm"]["Hd"]).apply(null,arguments)};var _avformat_write_header=Module["_avformat_write_header"]=function(){return(_avformat_write_header=Module["_avformat_write_header"]=Module["asm"]["Id"]).apply(null,arguments)};var _av_write_frame=Module["_av_write_frame"]=function(){return(_av_write_frame=Module["_av_write_frame"]=Module["asm"]["Jd"]).apply(null,arguments)};var _av_interleaved_write_frame=Module["_av_interleaved_write_frame"]=function(){return(_av_interleaved_write_frame=Module["_av_interleaved_write_frame"]=Module["asm"]["Kd"]).apply(null,arguments)};var _av_write_trailer=Module["_av_write_trailer"]=function(){return(_av_write_trailer=Module["_av_write_trailer"]=Module["asm"]["Ld"]).apply(null,arguments)};var _av_packet_alloc=Module["_av_packet_alloc"]=function(){return(_av_packet_alloc=Module["_av_packet_alloc"]=Module["asm"]["Md"]).apply(null,arguments)};var _avcodec_alloc_context3=Module["_avcodec_alloc_context3"]=function(){return(_avcodec_alloc_context3=Module["_avcodec_alloc_context3"]=Module["asm"]["Nd"]).apply(null,arguments)};var ___errno_location=Module["___errno_location"]=function(){return(___errno_location=Module["___errno_location"]=Module["asm"]["Od"]).apply(null,arguments)};var _av_grow_packet=Module["_av_grow_packet"]=function(){return(_av_grow_packet=Module["_av_grow_packet"]=Module["asm"]["Pd"]).apply(null,arguments)};var _av_shrink_packet=Module["_av_shrink_packet"]=function(){return(_av_shrink_packet=Module["_av_shrink_packet"]=Module["asm"]["Qd"]).apply(null,arguments)};var _avfilter_get_by_name=Module["_avfilter_get_by_name"]=function(){return(_avfilter_get_by_name=Module["_avfilter_get_by_name"]=Module["asm"]["Rd"]).apply(null,arguments)};var _avfilter_link=Module["_avfilter_link"]=function(){return(_avfilter_link=Module["_avfilter_link"]=Module["asm"]["Sd"]).apply(null,arguments)};var _avfilter_free=Module["_avfilter_free"]=function(){return(_avfilter_free=Module["_avfilter_free"]=Module["asm"]["Td"]).apply(null,arguments)};var _avfilter_graph_alloc=Module["_avfilter_graph_alloc"]=function(){return(_avfilter_graph_alloc=Module["_avfilter_graph_alloc"]=Module["asm"]["Ud"]).apply(null,arguments)};var _avfilter_graph_free=Module["_avfilter_graph_free"]=function(){return(_avfilter_graph_free=Module["_avfilter_graph_free"]=Module["asm"]["Vd"]).apply(null,arguments)};var _avfilter_graph_config=Module["_avfilter_graph_config"]=function(){return(_avfilter_graph_config=Module["_avfilter_graph_config"]=Module["asm"]["Wd"]).apply(null,arguments)};var _av_get_bytes_per_sample=Module["_av_get_bytes_per_sample"]=function(){return(_av_get_bytes_per_sample=Module["_av_get_bytes_per_sample"]=Module["asm"]["Xd"]).apply(null,arguments)};var _av_pix_fmt_desc_get=Module["_av_pix_fmt_desc_get"]=function(){return(_av_pix_fmt_desc_get=Module["_av_pix_fmt_desc_get"]=Module["asm"]["Yd"]).apply(null,arguments)};var _av_buffersink_get_frame=Module["_av_buffersink_get_frame"]=function(){return(_av_buffersink_get_frame=Module["_av_buffersink_get_frame"]=Module["asm"]["Zd"]).apply(null,arguments)};var _av_buffersink_set_frame_size=Module["_av_buffersink_set_frame_size"]=function(){return(_av_buffersink_set_frame_size=Module["_av_buffersink_set_frame_size"]=Module["asm"]["_d"]).apply(null,arguments)};var _av_buffersrc_add_frame_flags=Module["_av_buffersrc_add_frame_flags"]=function(){return(_av_buffersrc_add_frame_flags=Module["_av_buffersrc_add_frame_flags"]=Module["asm"]["$d"]).apply(null,arguments)};var _avfilter_inout_alloc=Module["_avfilter_inout_alloc"]=function(){return(_avfilter_inout_alloc=Module["_avfilter_inout_alloc"]=Module["asm"]["ae"]).apply(null,arguments)};var _avfilter_inout_free=Module["_avfilter_inout_free"]=function(){return(_avfilter_inout_free=Module["_avfilter_inout_free"]=Module["asm"]["be"]).apply(null,arguments)};var _avfilter_graph_parse=Module["_avfilter_graph_parse"]=function(){return(_avfilter_graph_parse=Module["_avfilter_graph_parse"]=Module["asm"]["ce"]).apply(null,arguments)};var _avcodec_find_encoder=Module["_avcodec_find_encoder"]=function(){return(_avcodec_find_encoder=Module["_avcodec_find_encoder"]=Module["asm"]["de"]).apply(null,arguments)};var _avcodec_find_encoder_by_name=Module["_avcodec_find_encoder_by_name"]=function(){return(_avcodec_find_encoder_by_name=Module["_avcodec_find_encoder_by_name"]=Module["asm"]["ee"]).apply(null,arguments)};var _av_frame_unref=Module["_av_frame_unref"]=function(){return(_av_frame_unref=Module["_av_frame_unref"]=Module["asm"]["fe"]).apply(null,arguments)};var _av_packet_make_writable=Module["_av_packet_make_writable"]=function(){return(_av_packet_make_writable=Module["_av_packet_make_writable"]=Module["asm"]["ge"]).apply(null,arguments)};var _avcodec_send_frame=Module["_avcodec_send_frame"]=function(){return(_avcodec_send_frame=Module["_avcodec_send_frame"]=Module["asm"]["he"]).apply(null,arguments)};var _avcodec_receive_packet=Module["_avcodec_receive_packet"]=function(){return(_avcodec_receive_packet=Module["_avcodec_receive_packet"]=Module["asm"]["ie"]).apply(null,arguments)};var _av_frame_get_buffer=Module["_av_frame_get_buffer"]=function(){return(_av_frame_get_buffer=Module["_av_frame_get_buffer"]=Module["asm"]["je"]).apply(null,arguments)};var _av_frame_make_writable=Module["_av_frame_make_writable"]=function(){return(_av_frame_make_writable=Module["_av_frame_make_writable"]=Module["asm"]["ke"]).apply(null,arguments)};var _free=Module["_free"]=function(){return(_free=Module["_free"]=Module["asm"]["le"]).apply(null,arguments)};var _sws_scale_frame=Module["_sws_scale_frame"]=function(){return(_sws_scale_frame=Module["_sws_scale_frame"]=Module["asm"]["me"]).apply(null,arguments)};var _sws_getContext=Module["_sws_getContext"]=function(){return(_sws_getContext=Module["_sws_getContext"]=Module["asm"]["ne"]).apply(null,arguments)};var _sws_freeContext=Module["_sws_freeContext"]=function(){return(_sws_freeContext=Module["_sws_freeContext"]=Module["asm"]["oe"]).apply(null,arguments)};var _malloc=Module["_malloc"]=function(){return(_malloc=Module["_malloc"]=Module["asm"]["pe"]).apply(null,arguments)};var _emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=function(){return(_emscripten_builtin_memalign=Module["_emscripten_builtin_memalign"]=Module["asm"]["qe"]).apply(null,arguments)};var _setThrew=Module["_setThrew"]=function(){return(_setThrew=Module["_setThrew"]=Module["asm"]["re"]).apply(null,arguments)};var stackSave=Module["stackSave"]=function(){return(stackSave=Module["stackSave"]=Module["asm"]["se"]).apply(null,arguments)};var stackRestore=Module["stackRestore"]=function(){return(stackRestore=Module["stackRestore"]=Module["asm"]["te"]).apply(null,arguments)};var stackAlloc=Module["stackAlloc"]=function(){return(stackAlloc=Module["stackAlloc"]=Module["asm"]["ue"]).apply(null,arguments)};var dynCall_ii=Module["dynCall_ii"]=function(){return(dynCall_ii=Module["dynCall_ii"]=Module["asm"]["ve"]).apply(null,arguments)};var dynCall_iii=Module["dynCall_iii"]=function(){return(dynCall_iii=Module["dynCall_iii"]=Module["asm"]["we"]).apply(null,arguments)};var dynCall_vi=Module["dynCall_vi"]=function(){return(dynCall_vi=Module["dynCall_vi"]=Module["asm"]["xe"]).apply(null,arguments)};var dynCall_iiiii=Module["dynCall_iiiii"]=function(){return(dynCall_iiiii=Module["dynCall_iiiii"]=Module["asm"]["ye"]).apply(null,arguments)};var dynCall_viiii=Module["dynCall_viiii"]=function(){return(dynCall_viiii=Module["dynCall_viiii"]=Module["asm"]["ze"]).apply(null,arguments)};var dynCall_viiiiiii=Module["dynCall_viiiiiii"]=function(){return(dynCall_viiiiiii=Module["dynCall_viiiiiii"]=Module["asm"]["Ae"]).apply(null,arguments)};var _asyncify_start_unwind=Module["_asyncify_start_unwind"]=function(){return(_asyncify_start_unwind=Module["_asyncify_start_unwind"]=Module["asm"]["Be"]).apply(null,arguments)};var _asyncify_stop_unwind=Module["_asyncify_stop_unwind"]=function(){return(_asyncify_stop_unwind=Module["_asyncify_stop_unwind"]=Module["asm"]["Ce"]).apply(null,arguments)};var _asyncify_start_rewind=Module["_asyncify_start_rewind"]=function(){return(_asyncify_start_rewind=Module["_asyncify_start_rewind"]=Module["asm"]["De"]).apply(null,arguments)};var _asyncify_stop_rewind=Module["_asyncify_stop_rewind"]=function(){return(_asyncify_stop_rewind=Module["_asyncify_stop_rewind"]=Module["asm"]["Ee"]).apply(null,arguments)};var _ff_h264_cabac_tables=Module["_ff_h264_cabac_tables"]=112140;var ___start_em_js=Module["___start_em_js"]=546108;var ___stop_em_js=Module["___stop_em_js"]=546248;function invoke_iii(index,a1,a2){var sp=stackSave();try{return dynCall_iii(index,a1,a2)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{dynCall_viiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{dynCall_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{dynCall_vi(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return dynCall_ii(index,a1)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return dynCall_iiiii(index,a1,a2,a3,a4)}catch(e){stackRestore(sp);if(e!==e+0)throw e;_setThrew(1,0)}}Module["cwrap"]=cwrap;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(args){args=args||arguments_;if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run();var ERRNO_CODES={EPERM:1,EIO:5,EAGAIN:6,ESPIPE:29};var readerCallbacks={open:function(stream){if(stream.flags&3){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}},close:function(stream){delete Module.readBuffers[stream.node.name]},read:function(stream,buffer,offset,length,position){var data=Module.readBuffers[stream.node.name];if(!data)throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);if(data.buf.length===0){if(data.eof)return 0;else throw new FS.ErrnoError(ERRNO_CODES.EAGAIN)}var ret;if(lengthdata.length)av_shrink_packet(pkt,data.length)}var ptr=AVPacket_data(pkt);Module.HEAPU8.set(data,ptr)};var ff_init_muxer=Module.ff_init_muxer=function(opts,streamCtxs){var oformat=opts.oformat?opts.oformat:0;var format_name=opts.format_name?opts.format_name:null;var filename=opts.filename?opts.filename:null;var oc=avformat_alloc_output_context2_js(oformat,format_name,filename);if(oc===0)throw new Error("Failed to allocate output context");var fmt=AVFormatContext_oformat(oc);var sts=[];streamCtxs.forEach(function(ctx){var st=avformat_new_stream(oc,0);if(st===0)throw new Error("Could not allocate stream");var codecpar=AVStream_codecpar(st);var ret=avcodec_parameters_from_context(codecpar,ctx[0]);if(ret<0)throw new Error("Could not copy the stream parameters: "+ff_error(ret));AVStream_time_base_s(st,ctx[1],ctx[2])});if(opts.device)FS.mkdev(opts.filename,511,writerDev);var pb=null;if(opts.open){pb=avio_open2_js(opts.filename,2,0,0);if(pb===0)throw new Error("Could not open file");AVFormatContext_pb_s(oc,pb)}return[oc,fmt,pb,sts]};var ff_free_muxer=Module.ff_free_muxer=function(oc,pb){avformat_free_context(oc);if(pb)avio_close(pb)};var ff_init_demuxer_file=Module.ff_init_demuxer_file=function(filename,fmt){var fmt_ctx;return Promise.all([]).then(function(){return avformat_open_input_js(filename,fmt?fmt:null,null)}).then(function(ret){fmt_ctx=ret;if(fmt_ctx===0)throw new Error("Could not open source file");var nb_streams=AVFormatContext_nb_streams(fmt_ctx);var streams=[];for(var i=0;i=opts.limit)return[-6,outPackets];return Promise.all([]).then(step)})}return Promise.all([]).then(step)};var ff_init_filter_graph=Module.ff_init_filter_graph=function(filters_descr,input,output){var abuffersrc,abuffersink,filter_graph,tmp_src_ctx,tmp_sink_ctx,src_ctxs,sink_ctxs,io_outputs,io_inputs,int32s,int64s;var instr,outstr;var multiple_inputs=!!input.length;if(!multiple_inputs)input=[input];var multiple_outputs=!!output.length;if(!multiple_outputs)output=[output];src_ctxs=[];sink_ctxs=[];try{abuffersrc=avfilter_get_by_name("abuffer");if(abuffersrc===0)throw new Error("Failed to load abuffer filter");abuffersink=avfilter_get_by_name("abuffersink");if(abuffersink===0)throw new Error("Failed to load abuffersink filter");filter_graph=avfilter_graph_alloc();if(filter_graph===0)throw new Error("Failed to allocate filter graph");io_outputs=0;var ii=0;input.forEach(function(input){var next_io_outputs=avfilter_inout_alloc();if(next_io_outputs===0)throw new Error("Failed to allocate outputs");AVFilterInOut_next_s(next_io_outputs,io_outputs);io_outputs=next_io_outputs;var nm="in"+(multiple_inputs?ii:"");tmp_src_ctx=avfilter_graph_create_filter_js(abuffersrc,nm,"time_base=1/"+(input.sample_rate?input.sample_rate:48e3)+":sample_rate="+(input.sample_rate?input.sample_rate:48e3)+":sample_fmt="+(input.sample_fmt?input.sample_fmt:3)+":channel_layout="+(input.channel_layout?input.channel_layout:4),null,filter_graph);if(tmp_src_ctx===0)throw new Error("Cannot create audio buffer source");src_ctxs.push(tmp_src_ctx);instr=av_strdup(nm);if(instr===0)throw new Error("Failed to allocate output");AVFilterInOut_name_s(io_outputs,instr);instr=0;AVFilterInOut_filter_ctx_s(io_outputs,tmp_src_ctx);tmp_src_ctx=0;AVFilterInOut_pad_idx_s(io_outputs,0);ii++});io_inputs=0;var oi=0;output.forEach(function(output){var next_io_inputs=avfilter_inout_alloc();if(next_io_inputs===0)throw new Error("Failed to allocate inputs");AVFilterInOut_next_s(next_io_inputs,io_inputs);io_inputs=next_io_inputs;var nm="out"+(multiple_outputs?oi:"");tmp_sink_ctx=avfilter_graph_create_filter_js(abuffersink,nm,null,null,filter_graph);if(tmp_sink_ctx===0)throw new Error("Cannot create audio buffer sink");sink_ctxs.push(tmp_sink_ctx);int32s=ff_malloc_int32_list([output.sample_fmt?output.sample_fmt:3,-1,output.sample_rate?output.sample_rate:48e3,-1]);int64s=ff_malloc_int64_list([output.channel_layout?output.channel_layout:4,-1]);outstr=av_strdup(nm);if(int32s===0||int64s===0||outstr===0)throw new Error("Failed to transfer parameters");if(av_opt_set_int_list_js(tmp_sink_ctx,"sample_fmts",4,int32s,-1,1)<0||av_opt_set_int_list_js(tmp_sink_ctx,"channel_layouts",8,int64s,-1,1)<0||av_opt_set_int_list_js(tmp_sink_ctx,"sample_rates",4,int32s+8,-1,1)<0){throw new Error("Failed to set filter parameters")}free(int32s);int32s=0;free(int64s);int64s=0;AVFilterInOut_name_s(io_inputs,outstr);outstr=0;AVFilterInOut_filter_ctx_s(io_inputs,tmp_sink_ctx);tmp_sink_ctx=0;AVFilterInOut_pad_idx_s(io_inputs,0);oi++});var ret=avfilter_graph_parse(filter_graph,filters_descr,io_inputs,io_outputs,0);if(ret<0)throw new Error("Failed to initialize filters: "+ff_error(ret));io_inputs=io_outputs=0;var oi=0;output.forEach(function(output){if(output.frame_size)av_buffersink_set_frame_size(sink_ctxs[oi],output.frame_size);oi++});ret=avfilter_graph_config(filter_graph,0);if(ret<0)throw new Error("Failed to configure filter graph: "+ff_error(ret))}catch(ex){if(io_outputs)avfilter_inout_free(io_outputs);if(io_inputs)avfilter_inout_free(io_inputs);if(filter_graph)avfilter_graph_free(filter_graph);if(tmp_src_ctx)avfilter_free(tmp_src_ctx);if(tmp_sink_ctx)avfilter_free(tmp_sink_ctx);if(int32s)free(int32s);if(int64s)free(int64s);if(instr)free(instr);if(outstr)free(outstr);throw ex}return[filter_graph,multiple_inputs?src_ctxs:src_ctxs[0],multiple_outputs?sink_ctxs:sink_ctxs[0]]};var ff_filter_multi=Module.ff_filter_multi=function(srcs,buffersink_ctx,framePtr,inFrames,fin){var outFrames=[];if(!srcs.length){srcs=[srcs];inFrames=[inFrames];fin=[fin]}var max=inFrames.map(function(srcFrames){return srcFrames.length}).reduce(function(a,b){return Math.max(a,b)});function handleFrame(buffersrc_ctx,inFrame){if(inFrame!==null)ff_copyin_frame(framePtr,inFrame);var ret=av_buffersrc_add_frame_flags(buffersrc_ctx,inFrame?framePtr:0,8);if(ret<0)throw new Error("Error while feeding the audio filtergraph: "+ff_error(ret));av_frame_unref(framePtr);while(true){ret=av_buffersink_get_frame(buffersink_ctx,framePtr);if(ret===-6||ret===-541478725)break;if(ret<0)throw new Error("Error while receiving a frame from the filtergraph: "+ff_error(ret));var outFrame=ff_copyout_frame(framePtr);outFrames.push(outFrame);av_frame_unref(framePtr)}}for(var fi=0;fi<=max;fi++){for(var ti=0;ti=5){var data=[];for(var ci=0;ci>=AVPixFmtDescriptor_log2_chroma_h(desc);for(var y=0;y>>=1}}["channel_layout","channels","format","pts","ptshi","sample_rate"].forEach(function(key){if(key in frame)CAccessors["AVFrame_"+key+"_s"](framePtr,frame[key])});var nb_samples;if(format>=5){nb_samples=frame.data[0].length}else{nb_samples=frame.data.length/channels}AVFrame_nb_samples_s(framePtr,nb_samples);if(av_frame_make_writable(framePtr)<0){var ret=av_frame_get_buffer(framePtr,0);if(ret<0)throw new Error("Failed to allocate frame buffers: "+ff_error(ret))}if(format>=5){for(var ci=0;ci; -av_opt_set_int_list_js(a0: number,a1: string,a2: number,a3: number,a4: number,a5: number): Promise; -av_frame_alloc(): Promise; -av_frame_free(a0: number): Promise; -av_frame_get_buffer(a0: number,a1: number): Promise; -av_frame_make_writable(a0: number): Promise; -av_frame_unref(a0: number): Promise; -av_packet_alloc(): Promise; -av_packet_free(a0: number): Promise; -av_packet_new_side_data(a0: number,a1: number,a2: number): Promise; -av_packet_unref(a0: number): Promise; -av_strdup(a0: string): Promise; -av_buffersink_get_frame(a0: number,a1: number): Promise; -av_buffersink_set_frame_size(a0: number,a1: number): Promise; -av_buffersrc_add_frame_flags(a0: number,a1: number,a2: number): Promise; -avfilter_free(a0: number): Promise; -avfilter_get_by_name(a0: string): Promise; -avfilter_graph_alloc(): Promise; -avfilter_graph_config(a0: number,a1: number): Promise; -avfilter_graph_create_filter_js(a0: number,a1: string,a2: string,a3: number,a4: number): Promise; -avfilter_graph_free(a0: number): Promise; -avfilter_graph_parse(a0: number,a1: string,a2: number,a3: number,a4: number): Promise; -avfilter_inout_alloc(): Promise; -avfilter_inout_free(a0: number): Promise; -avfilter_link(a0: number,a1: number,a2: number,a3: number): Promise; -avcodec_alloc_context3(a0: number): Promise; -avcodec_close(a0: number): Promise; -avcodec_find_decoder(a0: number): Promise; -avcodec_find_decoder_by_name(a0: string): Promise; -avcodec_find_encoder(a0: number): Promise; -avcodec_find_encoder_by_name(a0: string): Promise; -avcodec_free_context(a0: number): Promise; -avcodec_get_name(a0: number): Promise; -avcodec_open2(a0: number,a1: number,a2: number): Promise; -ff_calloc_AVCodecParameters(): Promise; -avcodec_parameters_from_context(a0: number,a1: number): Promise; -avcodec_parameters_to_context(a0: number,a1: number): Promise; -avcodec_receive_frame(a0: number,a1: number): Promise; -avcodec_receive_packet(a0: number,a1: number): Promise; -avcodec_send_frame(a0: number,a1: number): Promise; -avcodec_send_packet(a0: number,a1: number): Promise; -av_find_input_format(a0: string): Promise; -avformat_alloc_context(): Promise; -avformat_alloc_output_context2_js(a0: number,a1: string,a2: string): Promise; -avformat_close_input(a0: number): Promise; -avformat_find_stream_info(a0: number,a1: number): Promise; -avformat_free_context(a0: number): Promise; -avformat_new_stream(a0: number,a1: number): Promise; -avformat_open_input(a0: number,a1: string,a2: number,a3: number): Promise; -avformat_open_input_js(a0: string,a1: number,a2: number): Promise; -avformat_write_header(a0: number,a1: number): Promise; -avio_open2_js(a0: string,a1: number,a2: number,a3: number): Promise; -avio_close(a0: number): Promise; -av_find_best_stream(a0: number,a1: number,a2: number,a3: number,a4: number,a5: number): Promise; -av_grow_packet(a0: number,a1: number): Promise; -av_interleaved_write_frame(a0: number,a1: number): Promise; -av_packet_make_writable(a0: number): Promise; -av_pix_fmt_desc_get(a0: number): Promise; -av_read_frame(a0: number,a1: number): Promise; -av_shrink_packet(a0: number,a1: number): Promise; -av_write_frame(a0: number,a1: number): Promise; -av_write_trailer(a0: number): Promise; -av_dict_set(a0: number,a1: string,a2: string,a3: number): Promise; -av_dict_free(a0: number): Promise; -sws_getContext(a0: number,a1: number,a2: number,a3: number,a4: number,a5: number,a6: number,a7: number,a8: number,a9: number): Promise; -sws_freeContext(a0: number): Promise; -sws_scale_frame(a0: number,a1: number,a2: number): Promise; -AVFrame_sample_aspect_ratio_num(a0: number): Promise; -AVFrame_sample_aspect_ratio_den(a0: number): Promise; -AVFrame_sample_aspect_ratio_s(a0: number,a1: number,a2: number): Promise; -AVCodecContext_framerate_num(a0: number): Promise; -AVCodecContext_framerate_den(a0: number): Promise; -AVCodecContext_framerate_num_s(a0: number,a1: number): Promise; -AVCodecContext_framerate_den_s(a0: number,a1: number): Promise; -AVCodecContext_framerate_s(a0: number,a1: number,a2: number): Promise; -AVCodecContext_sample_aspect_ratio_num(a0: number): Promise; -AVCodecContext_sample_aspect_ratio_den(a0: number): Promise; -AVCodecContext_sample_aspect_ratio_num_s(a0: number,a1: number): Promise; -AVCodecContext_sample_aspect_ratio_den_s(a0: number,a1: number): Promise; -AVCodecContext_sample_aspect_ratio_s(a0: number,a1: number,a2: number): Promise; -AVCodecContext_time_base_s(a0: number,a1: number,a2: number): Promise; -AVStream_time_base_num(a0: number): Promise; -AVStream_time_base_den(a0: number): Promise; -AVStream_time_base_s(a0: number,a1: number,a2: number): Promise; -AVPacketSideData_data(a0: number,a1: number): Promise; -AVPacketSideData_size(a0: number,a1: number): Promise; -AVPacketSideData_type(a0: number,a1: number): Promise; -ff_error(a0: number): Promise; -ff_nothing(): Promise; -calloc(a0: number,a1: number): Promise; -free(a0: number): Promise; -malloc(a0: number): Promise; -mallinfo_uordblks(): Promise; -libavjs_with_swscale(): Promise; -AVFrame_channel_layout(ptr: number): Promise; -AVFrame_channel_layout_s(ptr: number, val: number): Promise; -AVFrame_channel_layouthi(ptr: number): Promise; -AVFrame_channel_layouthi_s(ptr: number, val: number): Promise; -AVFrame_channels(ptr: number): Promise; -AVFrame_channels_s(ptr: number, val: number): Promise; -AVFrame_data_a(ptr: number, idx: number): Promise; -AVFrame_data_a_s(ptr: number, idx: number, val: number): Promise; -AVFrame_format(ptr: number): Promise; -AVFrame_format_s(ptr: number, val: number): Promise; -AVFrame_height(ptr: number): Promise; -AVFrame_height_s(ptr: number, val: number): Promise; -AVFrame_key_frame(ptr: number): Promise; -AVFrame_key_frame_s(ptr: number, val: number): Promise; -AVFrame_linesize_a(ptr: number, idx: number): Promise; -AVFrame_linesize_a_s(ptr: number, idx: number, val: number): Promise; -AVFrame_nb_samples(ptr: number): Promise; -AVFrame_nb_samples_s(ptr: number, val: number): Promise; -AVFrame_pict_type(ptr: number): Promise; -AVFrame_pict_type_s(ptr: number, val: number): Promise; -AVFrame_pts(ptr: number): Promise; -AVFrame_pts_s(ptr: number, val: number): Promise; -AVFrame_ptshi(ptr: number): Promise; -AVFrame_ptshi_s(ptr: number, val: number): Promise; -AVFrame_sample_rate(ptr: number): Promise; -AVFrame_sample_rate_s(ptr: number, val: number): Promise; -AVFrame_width(ptr: number): Promise; -AVFrame_width_s(ptr: number, val: number): Promise; -AVPixFmtDescriptor_log2_chroma_h(ptr: number): Promise; -AVPixFmtDescriptor_log2_chroma_h_s(ptr: number, val: number): Promise; -AVCodecContext_bit_rate(ptr: number): Promise; -AVCodecContext_bit_rate_s(ptr: number, val: number): Promise; -AVCodecContext_bit_ratehi(ptr: number): Promise; -AVCodecContext_bit_ratehi_s(ptr: number, val: number): Promise; -AVCodecContext_channel_layout(ptr: number): Promise; -AVCodecContext_channel_layout_s(ptr: number, val: number): Promise; -AVCodecContext_channel_layouthi(ptr: number): Promise; -AVCodecContext_channel_layouthi_s(ptr: number, val: number): Promise; -AVCodecContext_channels(ptr: number): Promise; -AVCodecContext_channels_s(ptr: number, val: number): Promise; -AVCodecContext_extradata(ptr: number): Promise; -AVCodecContext_extradata_s(ptr: number, val: number): Promise; -AVCodecContext_extradata_size(ptr: number): Promise; -AVCodecContext_extradata_size_s(ptr: number, val: number): Promise; -AVCodecContext_frame_size(ptr: number): Promise; -AVCodecContext_frame_size_s(ptr: number, val: number): Promise; -AVCodecContext_gop_size(ptr: number): Promise; -AVCodecContext_gop_size_s(ptr: number, val: number): Promise; -AVCodecContext_height(ptr: number): Promise; -AVCodecContext_height_s(ptr: number, val: number): Promise; -AVCodecContext_keyint_min(ptr: number): Promise; -AVCodecContext_keyint_min_s(ptr: number, val: number): Promise; -AVCodecContext_level(ptr: number): Promise; -AVCodecContext_level_s(ptr: number, val: number): Promise; -AVCodecContext_pix_fmt(ptr: number): Promise; -AVCodecContext_pix_fmt_s(ptr: number, val: number): Promise; -AVCodecContext_profile(ptr: number): Promise; -AVCodecContext_profile_s(ptr: number, val: number): Promise; -AVCodecContext_rc_max_rate(ptr: number): Promise; -AVCodecContext_rc_max_rate_s(ptr: number, val: number): Promise; -AVCodecContext_rc_max_ratehi(ptr: number): Promise; -AVCodecContext_rc_max_ratehi_s(ptr: number, val: number): Promise; -AVCodecContext_rc_min_rate(ptr: number): Promise; -AVCodecContext_rc_min_rate_s(ptr: number, val: number): Promise; -AVCodecContext_rc_min_ratehi(ptr: number): Promise; -AVCodecContext_rc_min_ratehi_s(ptr: number, val: number): Promise; -AVCodecContext_sample_fmt(ptr: number): Promise; -AVCodecContext_sample_fmt_s(ptr: number, val: number): Promise; -AVCodecContext_sample_rate(ptr: number): Promise; -AVCodecContext_sample_rate_s(ptr: number, val: number): Promise; -AVCodecContext_qmax(ptr: number): Promise; -AVCodecContext_qmax_s(ptr: number, val: number): Promise; -AVCodecContext_qmin(ptr: number): Promise; -AVCodecContext_qmin_s(ptr: number, val: number): Promise; -AVCodecContext_width(ptr: number): Promise; -AVCodecContext_width_s(ptr: number, val: number): Promise; -AVCodecParameters_codec_id(ptr: number): Promise; -AVCodecParameters_codec_id_s(ptr: number, val: number): Promise; -AVCodecParameters_codec_type(ptr: number): Promise; -AVCodecParameters_codec_type_s(ptr: number, val: number): Promise; -AVCodecParameters_extradata(ptr: number): Promise; -AVCodecParameters_extradata_s(ptr: number, val: number): Promise; -AVCodecParameters_extradata_size(ptr: number): Promise; -AVCodecParameters_extradata_size_s(ptr: number, val: number): Promise; -AVCodecParameters_format(ptr: number): Promise; -AVCodecParameters_format_s(ptr: number, val: number): Promise; -AVCodecParameters_bit_rate(ptr: number): Promise; -AVCodecParameters_bit_rate_s(ptr: number, val: number): Promise; -AVCodecParameters_profile(ptr: number): Promise; -AVCodecParameters_profile_s(ptr: number, val: number): Promise; -AVCodecParameters_level(ptr: number): Promise; -AVCodecParameters_level_s(ptr: number, val: number): Promise; -AVCodecParameters_width(ptr: number): Promise; -AVCodecParameters_width_s(ptr: number, val: number): Promise; -AVCodecParameters_height(ptr: number): Promise; -AVCodecParameters_height_s(ptr: number, val: number): Promise; -AVCodecParameters_color_range(ptr: number): Promise; -AVCodecParameters_color_range_s(ptr: number, val: number): Promise; -AVCodecParameters_color_primaries(ptr: number): Promise; -AVCodecParameters_color_primaries_s(ptr: number, val: number): Promise; -AVCodecParameters_color_trc(ptr: number): Promise; -AVCodecParameters_color_trc_s(ptr: number, val: number): Promise; -AVCodecParameters_color_space(ptr: number): Promise; -AVCodecParameters_color_space_s(ptr: number, val: number): Promise; -AVCodecParameters_chroma_location(ptr: number): Promise; -AVCodecParameters_chroma_location_s(ptr: number, val: number): Promise; -AVCodecParameters_channels(ptr: number): Promise; -AVCodecParameters_channels_s(ptr: number, val: number): Promise; -AVCodecParameters_sample_rate(ptr: number): Promise; -AVCodecParameters_sample_rate_s(ptr: number, val: number): Promise; -AVPacket_pts(ptr: number): Promise; -AVPacket_pts_s(ptr: number, val: number): Promise; -AVPacket_ptshi(ptr: number): Promise; -AVPacket_ptshi_s(ptr: number, val: number): Promise; -AVPacket_dts(ptr: number): Promise; -AVPacket_dts_s(ptr: number, val: number): Promise; -AVPacket_dtshi(ptr: number): Promise; -AVPacket_dtshi_s(ptr: number, val: number): Promise; -AVPacket_data(ptr: number): Promise; -AVPacket_data_s(ptr: number, val: number): Promise; -AVPacket_size(ptr: number): Promise; -AVPacket_size_s(ptr: number, val: number): Promise; -AVPacket_stream_index(ptr: number): Promise; -AVPacket_stream_index_s(ptr: number, val: number): Promise; -AVPacket_flags(ptr: number): Promise; -AVPacket_flags_s(ptr: number, val: number): Promise; -AVPacket_side_data(ptr: number): Promise; -AVPacket_side_data_s(ptr: number, val: number): Promise; -AVPacket_side_data_elems(ptr: number): Promise; -AVPacket_side_data_elems_s(ptr: number, val: number): Promise; -AVPacket_duration(ptr: number): Promise; -AVPacket_duration_s(ptr: number, val: number): Promise; -AVPacket_durationhi(ptr: number): Promise; -AVPacket_durationhi_s(ptr: number, val: number): Promise; -AVFormatContext_nb_streams(ptr: number): Promise; -AVFormatContext_nb_streams_s(ptr: number, val: number): Promise; -AVFormatContext_oformat(ptr: number): Promise; -AVFormatContext_oformat_s(ptr: number, val: number): Promise; -AVFormatContext_pb(ptr: number): Promise; -AVFormatContext_pb_s(ptr: number, val: number): Promise; -AVFormatContext_streams_a(ptr: number, idx: number): Promise; -AVFormatContext_streams_a_s(ptr: number, idx: number, val: number): Promise; -AVStream_codecpar(ptr: number): Promise; -AVStream_codecpar_s(ptr: number, val: number): Promise; -AVStream_duration(ptr: number): Promise; -AVStream_duration_s(ptr: number, val: number): Promise; -AVStream_durationhi(ptr: number): Promise; -AVStream_durationhi_s(ptr: number, val: number): Promise; -AVFilterInOut_filter_ctx(ptr: number): Promise; -AVFilterInOut_filter_ctx_s(ptr: number, val: number): Promise; -AVFilterInOut_name(ptr: number): Promise; -AVFilterInOut_name_s(ptr: number, val: number): Promise; -AVFilterInOut_next(ptr: number): Promise; -AVFilterInOut_next_s(ptr: number, val: number): Promise; -AVFilterInOut_pad_idx(ptr: number): Promise; -AVFilterInOut_pad_idx_s(ptr: number, val: number): Promise; -av_frame_free_js(ptr: number); -av_packet_free_js(ptr: number); -avformat_close_input_js(ptr: number); -avcodec_free_context_js(ptr: number); -avfilter_graph_free_js(ptr: number); -avfilter_inout_free_js(ptr: number); -copyin_u8(ptr: number, arr: Uint8Array): Promise; -copyout_u8(ptr: number, len: number): Promise; -copyin_s16(ptr: number, arr: Int16Array): Promise; -copyout_s16(ptr: number, len: number): Promise; -copyin_s32(ptr: number, arr: Int32Array): Promise; -copyout_s32(ptr: number, len: number): Promise; -copyin_f32(ptr: number, arr: Float32Array): Promise; -copyout_f32(ptr: number, len: number): Promise; - -/** - * Read a complete file from the in-memory filesystem. - * @param name Filename to read - */ -readFile(name: string): Promise; -/** - * Write a complete file to the in-memory filesystem. - * @param name Filename to write - * @param content Content to write to the file - */ -writeFile(name: string, content: Uint8Array): Promise; -/** - * Delete a file in the in-memory filesystem. - * @param name Filename to delete - */ -unlink(name: string): Promise; -/** - * Make a reader device. - * @param name Filename to create - * @param mode Unix permissions (pointless since this is an in-memory - * filesystem) - */ -mkreaderdev(name: string, mode?: number): Promise; -/** - * Make a writer device. - * @param name Filename to create - * @param mode Unix permissions - */ -mkwriterdev(name: string, mode?: number): Promise; -/** - * Send some data to a reader device - * @param name Filename of the reader device - * @param data Data to sending - */ -ff_reader_dev_send(name: string, data: Uint8Array): Promise; -/** - * Metafunction to determine whether any device has any waiters. This can be - * used to determine whether more data needs to be sent before a previous step - * will be fully resolved. - */ -ff_reader_dev_waiting(): Promise; -/** - * Metafunction to initialize an encoder with all the bells and whistles. - * Returns [AVCodec, AVCodecContext, AVFrame, AVPacket, frame_size] - * @param name libav name of the codec - * @param opts Encoder options - */ -ff_init_encoder( - name: string, opts?: { - ctx?: AVCodecContextProps, options?: Record - } -): Promise<[number, number, number, number, number]>; -/** - * Metafunction to initialize a decoder with all the bells and whistles. - * Similar to ff_init_encoder but doesn't need to initialize the frame. - * Returns [AVCodec, AVCodecContext, AVPacket, AVFrame] - * @param name libav decoder identifier or name - * @param codecpar Optional AVCodecParameters - */ -ff_init_decoder( - name: string | number, codecpar?: number -): Promise<[number, number, number, number]>; -/** - * Free everything allocated by ff_init_encoder. - * @param c AVCodecContext - * @param frame AVFrame - * @param pkt AVPacket - */ -ff_free_encoder( - c: number, frame: number, pkt: number -): Promise; -/** - * Free everything allocated by ff_init_decoder - * @param c AVCodecContext - * @param pkt AVPacket - * @param frame AVFrame - */ -ff_free_decoder( - c: number, pkt: number, frame: number -): Promise; -/** - * Encode some number of frames at once. Done in one go to avoid excess message - * passing. - * @param ctx AVCodecContext - * @param frame AVFrame - * @param pkt AVPacket - * @param inFrames Array of frames in libav.js format - * @param fin Set to true if this is the end of encoding - */ -ff_encode_multi( - ctx: number, frame: number, pkt: number, inFrames: Frame[], - fin?: boolean -): Promise; -/** - * Decode some number of packets at once. Done in one go to avoid excess - * message passing. - * @param ctx AVCodecContext - * @param pkt AVPacket - * @param frame AVFrame - * @param inPackets Incoming packets to decode - * @param config Decoding options. May be "true" to indicate end of stream. - */ -ff_decode_multi( - ctx: number, pkt: number, frame: number, inPackets: Packet[], - config?: boolean | { - fin?: boolean, - ignoreErrors?: boolean - } -): Promise; -/** - * Initialize a muxer format, format context and some number of streams. - * Returns [AVFormatContext, AVOutputFormat, AVIOContext, AVStream[]] - * @param opts Muxer options - * @param stramCtxs Context info for each stream to mux - */ -ff_init_muxer( - opts: { - oformat?: number, // format pointer - format_name?: string, // libav name - filename?: string, - device?: boolean, // Create a writer device - open?: boolean // Open the file for writing - }, - streamCtxs: [number, number, number][] // AVCodecContext, time_base_num, time_base_den -): Promise<[number, number, number, number[]]>; -/** - * Free up a muxer format and/or file - * @param oc AVFormatContext - * @param pb AVIOContext - */ -ff_free_muxer(oc: number, pb: number): Promise; -/** - * Initialize a demuxer from a file and format context, and get the list of - * codecs/types. - * Returns [AVFormatContext, Stream[]] - * @param filename Filename to open - * @param fmt Format to use (optional) - */ -ff_init_demuxer_file( - filename: string, fmt?: string -): Promise<[number, Stream[]]>; -/** - * Write some number of packets at once. - * @param oc AVFormatContext - * @param pkt AVPacket - * @param inPackets Packets to write - * @param interleave Set to false to *not* use the interleaved writer. - * Interleaving is the default. - */ -ff_write_multi( - oc: number, pkt: number, inPackets: Packet[], interleave?: boolean -): Promise; -/** - * Read many packets at once. If you don't set any limits, this function will - * block (asynchronously) until the whole file is read, so make sure you set - * some limits if you want to read a bit at a time. Returns a pair [result, - * packets], where the result indicates whether an error was encountered, an - * EOF, or simply limits (EAGAIN), and packets is a dictionary indexed by the - * stream number in which each element is an array of packets from that stream. - * @param fmt_ctx AVFormatContext - * @param pkt AVPacket - * @param devfile Name of the device file being read from, if applicable. Used - * to set limits on when to read based on available data. - * @param opts Other options - */ -ff_read_multi( - fmt_ctx: number, pkt: number, devfile?: string, opts?: { - limit?: number, // OUTPUT limit, in bytes - devLimit?: number // INPUT limit, in bytes (don't read if less than this much data is available) - } -): Promise<[number, Record]>; -/** - * Initialize a filter graph. No equivalent free since you just need to free - * the graph itself (av_filter_graph_free) and everything under it will be - * freed automatically. - * Returns [AVFilterGraph, AVFilterContext, AVFilterContext], where the second - * and third are the input and output buffer source/sink. For multiple - * inputs/outputs, the second and third will be arrays, as appropriate. - * @param filters_descr Filtergraph description - * @param input Input settings, or array of input settings for multiple inputs - * @param output Output settings, or array of output settings for multiple - * outputs - */ -ff_init_filter_graph( - filters_descr: string, - input: FilterIOSettings, - output: FilterIOSettings -): Promise<[number, number, number]>; -ff_init_filter_graph( - filters_descr: string, - input: FilterIOSettings[], - output: FilterIOSettings -): Promise<[number, number[], number]>; -ff_init_filter_graph( - filters_descr: string, - input: FilterIOSettings, - output: FilterIOSettings[] -): Promise<[number, number, number[]]>; -ff_init_filter_graph( - filters_descr: string, - input: FilterIOSettings[], - output: FilterIOSettings[] -): Promise<[number, number[], number[]]>; -/** - * Filter some number of frames, possibly corresponding to multiple sources. - * @param srcs AVFilterContext(s), input - * @param buffersink_ctx AVFilterContext, output - * @param framePtr AVFrame - * @param inFrames Input frames, either as an array of frames or with frames - * per input - * @param fin Indicate end-of-stream(s) - */ -ff_filter_multi( - srcs: number, buffersink_ctx: number, framePtr: number, - inFrames: Frame[], fin?: boolean -): Promise; -ff_filter_multi( - srcs: number[], buffersink_ctx: number, framePtr: number, - inFrames: Frame[][], fin?: boolean[] -): Promise; -/** - * Copy out a frame. - * @param frame AVFrame - */ -ff_copyout_frame(frame: number): Promise; -/** - * Copy in a frame. - * @param framePtr AVFrame - * @param frame Frame to copy in - */ -ff_copyin_frame(framePtr: number, frame: Frame): Promise; -/** - * Copy out a packet. - * @param pkt AVPacket - */ -ff_copyout_packet(pkt: number): Promise; -/** - * Copy in a packet. - * @param pktPtr AVPacket - * @param packet Packet to copy in. - */ -ff_copyin_packet(pktPtr: number, packet: Packet): Promise; -/** - * Allocate and copy in a 32-bit int list. - * @param list List of numbers to copy in - */ -ff_malloc_int32_list(list: number[]): Promise; -/** - * Allocate and copy in a 64-bit int list. - * @param list List of numbers to copy in - */ -ff_malloc_int64_list(list: number[]): Promise; - - - /** - * Callback when writes occur. Set by the user. - */ - onwrite?: (filename: string, position: number, buffer: Uint8Array | Int8Array) => void; - - /** - * Terminate the worker associated with this libav.js instance, rendering - * it inoperable and freeing its memory. - */ - terminate(): void; - - // Enumerations: - AV_OPT_SEARCH_CHILDREN: number; - AVMEDIA_TYPE_UNKNOWN: number; - AVMEDIA_TYPE_VIDEO: number; - AVMEDIA_TYPE_AUDIO: number; - AVMEDIA_TYPE_DATA: number; - AVMEDIA_TYPE_SUBTITLE: number; - AVMEDIA_TYPE_ATTACHMENT: number; - AV_SAMPLE_FMT_NONE: number; - AV_SAMPLE_FMT_U8: number; - AV_SAMPLE_FMT_S16: number; - AV_SAMPLE_FMT_S32: number; - AV_SAMPLE_FMT_FLT: number; - AV_SAMPLE_FMT_DBL: number; - AV_SAMPLE_FMT_U8P: number; - AV_SAMPLE_FMT_S16P: number; - AV_SAMPLE_FMT_S32P: number; - AV_SAMPLE_FMT_FLTP: number; - AV_SAMPLE_FMT_DBLP: number; - AV_SAMPLE_FMT_S64: number; - AV_SAMPLE_FMT_S64P: number; - AV_SAMPLE_FMT_NB: number; - AV_PIX_FMT_NONE: number; - AV_PIX_FMT_YUV420P: number; - AV_PIX_FMT_YUYV422: number; - AV_PIX_FMT_RGB24: number; - AV_PIX_FMT_BGR24: number; - AV_PIX_FMT_YUV422P: number; - AV_PIX_FMT_YUV444P: number; - AV_PIX_FMT_YUV410P: number; - AV_PIX_FMT_YUV411P: number; - AV_PIX_FMT_GRAY8: number; - AV_PIX_FMT_MONOWHITE: number; - AV_PIX_FMT_MONOBLACK: number; - AV_PIX_FMT_PAL8: number; - AV_PIX_FMT_YUVJ420P: number; - AV_PIX_FMT_YUVJ422P: number; - AV_PIX_FMT_YUVJ444P: number; - AV_PIX_FMT_UYVY422: number; - AV_PIX_FMT_UYYVYY411: number; - AV_PIX_FMT_BGR8: number; - AV_PIX_FMT_BGR4: number; - AV_PIX_FMT_BGR4_BYTE: number; - AV_PIX_FMT_RGB8: number; - AV_PIX_FMT_RGB4: number; - AV_PIX_FMT_RGB4_BYTE: number; - AV_PIX_FMT_NV12: number; - AV_PIX_FMT_NV21: number; - AV_PIX_FMT_ARGB: number; - AV_PIX_FMT_RGBA: number; - AV_PIX_FMT_ABGR: number; - AV_PIX_FMT_BGRA: number; - AV_PIX_FMT_GRAY16BE: number; - AV_PIX_FMT_GRAY16LE: number; - AV_PIX_FMT_YUV440P: number; - AV_PIX_FMT_YUVJ440P: number; - AV_PIX_FMT_YUVA420P: number; - AV_PIX_FMT_RGB48BE: number; - AV_PIX_FMT_RGB48LE: number; - AV_PIX_FMT_RGB565BE: number; - AV_PIX_FMT_RGB565LE: number; - AV_PIX_FMT_RGB555BE: number; - AV_PIX_FMT_RGB555LE: number; - AV_PIX_FMT_BGR565BE: number; - AV_PIX_FMT_BGR565LE: number; - AV_PIX_FMT_BGR555BE: number; - AV_PIX_FMT_BGR555LE: number; - AVIO_FLAG_READ: number; - AVIO_FLAG_WRITE: number; - AVIO_FLAG_READ_WRITE: number; - AVIO_FLAG_NONBLOCK: number; - AVIO_FLAG_DIRECT: number; - EAGAIN: number; - AVERROR_EOF: number; -} - -export interface LibAVWrapper { - /** - * URL base from which load workers and modules. - */ - base: string; - - /** - * Create a LibAV instance. - * @param opts Options - */ - LibAV(opts?: { - noworker?: boolean, - nowasm?: boolean - }): Promise; -} diff --git a/src/lib/video-preview/polyfill/config.ts b/src/lib/video-preview/polyfill/config.ts deleted file mode 100644 index 63c0b5ab3..000000000 --- a/src/lib/video-preview/polyfill/config.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -import type * as eac from './encoded-audio-chunk'; -import * as evc from './encoded-video-chunk'; -import * as vf from './video-frame'; -import * as vdec from './video-decoder'; - -/** - * A VideoDecoder environment. - */ -export interface VideoDecoderEnvironment { - VideoDecoder: typeof vdec.VideoDecoder; - EncodedVideoChunk: typeof evc.EncodedVideoChunk; - VideoFrame: typeof vf.VideoFrame; -} - -/** - * Error thrown to indicate a configuration is unsupported. - */ -export class UnsupportedException extends Error { - constructor() { - super('The requested configuration is not supported'); - } -} - -/** - * Get an VideoDecoder environment that supports this configuration. Throws an - * UnsupportedException if no environment supports the configuration. - * @param config Video decoder configuration - */ -export async function getVideoDecoder( - config: vdec.VideoDecoderConfig, -): Promise { - try { - if ( - typeof (global).VideoDecoder !== 'undefined' - && (await (global).VideoDecoder.isConfigSupported(config)).supported - ) { - return { - VideoDecoder: (global).VideoDecoder, - EncodedVideoChunk: (global).EncodedVideoChunk, - VideoFrame: (global).VideoFrame, - }; - } - } catch (ex) {} - - if ((await vdec.VideoDecoder.isConfigSupported(config)).supported) { - return { - VideoDecoder: vdec.VideoDecoder, - EncodedVideoChunk: evc.EncodedVideoChunk, - VideoFrame: vf.VideoFrame, - }; - } - - throw new UnsupportedException(); -} diff --git a/src/lib/video-preview/polyfill/encoded-audio-chunk.ts b/src/lib/video-preview/polyfill/encoded-audio-chunk.ts deleted file mode 100644 index ae8f454e0..000000000 --- a/src/lib/video-preview/polyfill/encoded-audio-chunk.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -export class EncodedAudioChunk { - constructor(init: EncodedAudioChunkInit) { - this.type = init.type; - this.timestamp = init.timestamp; - this.duration = init.duration || 0; - const data = (this._data = new Uint8Array( - (init.data).buffer || init.data, - (init.data).byteOffset || 0 - )); - this.byteLength = data.byteLength; - } - - readonly type: EncodedAudioChunkType; - - readonly timestamp: number; // microseconds - - readonly duration?: number; // microseconds - - readonly byteLength: number; - - private _data: Uint8Array; - - // Internal - _libavGetData() { - return this._data; - } - - copyTo(destination: BufferSource) { - new Uint8Array( - (destination).buffer || destination, - (destination).byteOffset || 0 - ).set(this._data); - } -} - -export interface EncodedAudioChunkInit { - type: EncodedAudioChunkType; - timestamp: number; // microseconds - duration?: number; // microseconds - data: BufferSource; -} - -export type EncodedAudioChunkType = 'key' | 'delta'; diff --git a/src/lib/video-preview/polyfill/encoded-video-chunk.ts b/src/lib/video-preview/polyfill/encoded-video-chunk.ts deleted file mode 100644 index c04e494a5..000000000 --- a/src/lib/video-preview/polyfill/encoded-video-chunk.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -import * as eac from './encoded-audio-chunk'; - -export type EncodedVideoChunk = eac.EncodedAudioChunk; -export const EncodedVideoChunk = eac.EncodedAudioChunk; -export type EncodedVideoChunkInit = eac.EncodedAudioChunkInit; -export type EncodedVideoChunkType = eac.EncodedAudioChunkType; diff --git a/src/lib/video-preview/polyfill/index.ts b/src/lib/video-preview/polyfill/index.ts deleted file mode 100644 index 260ca5e39..000000000 --- a/src/lib/video-preview/polyfill/index.ts +++ /dev/null @@ -1,99 +0,0 @@ -// @ts-nocheck - -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -import type * as LibAVJS from '../libav.types'; -import * as eac from './encoded-audio-chunk'; - -import * as evc from './encoded-video-chunk'; -import * as vf from './video-frame'; -import * as vdec from './video-decoder'; - -import * as rendering from './rendering'; - -import * as config from './config'; -import * as libav from './libav'; -import type * as misc from './misc'; - -declare let LibAV: LibAVJS.LibAVWrapper; - -/** - * Load LibAV-WebCodecs-Polyfill. - */ -export async function load( - options: { - polyfill?: boolean; - libavOptions?: any; - } = {}, -) { - // Set up libavOptions - const libavOptions: any = {}; - if (options.libavOptions) { - Object.assign(libavOptions, options.libavOptions); - } - - // And load the libav handler - libav.setLibAVOptions(libavOptions); - await libav.load(); - - if (options.polyfill) { - globalThis.VideoDecoder = vdec.VideoDecoder; - globalThis.VideoFrame = vf.VideoFrame; - globalThis.EncodedVideoChunk = evc.EncodedVideoChunk; - } - - await rendering.load(libavOptions, !!options.polyfill); -} - -// EncodedVideoChunk -export type EncodedVideoChunk = evc.EncodedVideoChunk; -export const EncodedVideoChunk = evc.EncodedVideoChunk; -export type EncodedVideoChunkInit = evc.EncodedVideoChunkInit; - -// VideoFrame -export type VideoFrame = vf.VideoFrame; -export const VideoFrame = vf.VideoFrame; -export type VideoFrameInit = vf.VideoFrameInit; -export type VideoFrameBufferInit = vf.VideoFrameBufferInit; -export type VideoPixelFormat = vf.VideoPixelFormat; -export type PlaneLayout = vf.PlaneLayout; -export type VideoFrameCopyToOptions = vf.VideoFrameCopyToOptions; - -// VideoDecoder -export type VideoDecoder = vdec.VideoDecoder; -export const VideoDecoder = vdec.VideoDecoder; -export type VideoDecoderInit = vdec.VideoDecoderInit; -export type VideoFrameOutputCallback = vdec.VideoFrameOutputCallback; -export type VideoDecoderConfig = vdec.VideoDecoderConfig; -export type VideoDecoderSupport = vdec.VideoDecoderSupport; - -// Rendering -export const createImageBitmap = rendering.createImageBitmap; - -// Misc -export type CodecState = misc.CodecState; -export type WebCodecsErrorcallback = misc.WebCodecsErrorCallback; - -// Configurations/environments -export type AudioDecoderEnvironment = config.AudioDecoderEnvironment; -export type VideoDecoderEnvironment = config.VideoDecoderEnvironment; -export type UnsupportedException = config.UnsupportedException; -export const UnsupportedException = config.UnsupportedException; -export const getVideoDecoder = config.getVideoDecoder; diff --git a/src/lib/video-preview/polyfill/libav.ts b/src/lib/video-preview/polyfill/libav.ts deleted file mode 100644 index 4da018dec..000000000 --- a/src/lib/video-preview/polyfill/libav.ts +++ /dev/null @@ -1,136 +0,0 @@ -// @ts-nocheck - -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -import type * as LibAVJS from '../libav.types'; - -declare let LibAV: LibAVJS.LibAVWrapper; - -// Currently available libav instances -const libavs: LibAVJS.LibAV[] = []; - -// Options required to create a LibAV instance -let libavOptions: any = {}; - -/** - * Supported decoders. - */ -export let decoders: string[] = null; - -/** - * libav.js-specific codec request, used to bypass the codec registry and use - * anything your implementation of libav.js supports. - */ -export interface LibAVJSCodec { - codec: string; - ctx?: LibAVJS.AVCodecContextProps; - options?: Record; -} - -/** - * Set the libav loading options. - */ -export function setLibAVOptions(to: any) { - libavOptions = to; -} - -/** - * Get a libav instance. - */ -export async function get(): Promise { - if (libavs.length) { - return libavs.shift(); - } - return LibAV.LibAV(libavOptions); -} - -/** - * Free a libav instance for later reuse. - */ -export function free(libav: LibAVJS.LibAV) { - libavs.push(libav); -} - -/** - * Get the list of encoders/decoders supported by libav (which are also - * supported by this polyfill) - */ -async function codecs(): Promise { - const libav = await get(); - const ret: string[] = []; - - for (const [avname, codec] of [ - ['libaom-av1', 'av01'], - ['h264', 'avc1'], - ['hevc', 'hvc1'], - ]) { - if (await libav.avcodec_find_decoder_by_name(avname)) { - ret.push(codec); - } - } - - free(libav); - return ret; -} - -/** - * Load the lists of supported decoders and encoders. - */ -export async function load() { - decoders = await codecs(); -} - -/** - * Convert a decoder from the codec registry (or libav.js-specific parameters) - * to libav.js. Returns null if unsupported. - */ -export function decoder(codec: string | { libavjs: LibAVJSCodec }): LibAVJSCodec { - if (typeof codec === 'string') { - codec = codec.replace(/\..*/, ''); - - let outCodec: string = codec; - switch (codec) { - // Video - case 'av01': - outCodec = 'libaom-av1'; - break; - case 'avc1': - outCodec = 'h264'; - break; - - case 'hvc1': - outCodec = 'hevc'; - break; - - // Unrecognized - default: - return null; - } - - // Check whether we actually support this codec - if (!(decoders.indexOf(codec) >= 0)) { - return null; - } - - return { codec: outCodec }; - } else { - return codec.libavjs; - } -} diff --git a/src/lib/video-preview/polyfill/misc.ts b/src/lib/video-preview/polyfill/misc.ts deleted file mode 100644 index d7b1c487b..000000000 --- a/src/lib/video-preview/polyfill/misc.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -export type CodecState = 'unconfigured' | 'configured' | 'closed'; - -export type WebCodecsErrorCallback = (error: DOMException) => void; - -/** - * Clone this configuration. Just copies over the supported/recognized fields. - */ -export function cloneConfig(config: any, fields: string[]): any { - const ret: any = {}; - for (const field of fields) { - if (field in config) { - ret[field] = config[field]; - } - } - return ret; -} diff --git a/src/lib/video-preview/polyfill/rendering.ts b/src/lib/video-preview/polyfill/rendering.ts deleted file mode 100644 index 1ed6c7a45..000000000 --- a/src/lib/video-preview/polyfill/rendering.ts +++ /dev/null @@ -1,190 +0,0 @@ -// @ts-nocheck - -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -import type * as LibAVJS from '../libav.types'; -import * as vf from './video-frame'; - -declare let LibAV: LibAVJS.LibAVWrapper; - -/* A non-threaded libav.js instance for scaling. This is an any because the - * type definitions only expose the async versions, but this API requires the - * _sync methods. */ -let scalerSync: any = null; - -// A synchronous libav.js instance for scaling. -let scalerAsync: LibAVJS.LibAV = null; - -// The original drawImage -const origDrawImage: any = null; - -// The original createImageBitmap -let origCreateImageBitmap: any = null; - -/** - * Load rendering capability. - * @param libavOptions Options to use while loading libav, only asynchronous - * @param polyfill Set to polyfill CanvasRenderingContext2D.drawImage - */ -export async function load(libavOptions: any, polyfill: boolean) { - // Get our scalers - scalerSync = await LibAV.LibAV({ noworker: true }); - scalerAsync = await LibAV.LibAV(libavOptions); - - // Polyfill createImageBitmap - origCreateImageBitmap = global.createImageBitmap; - if (polyfill) { - (global).createImageBitmap = createImageBitmap; - } -} - -/** - * Create an ImageBitmap from this drawable, asynchronously. NOTE: - * Sub-rectangles are not implemented for VideoFrames, so only options is - * available, and there, only scaling is available. - * @param image VideoFrame (or anything else) to draw - * @param options Other options - */ -export function createImageBitmap( - image: vf.VideoFrame, - opts: { - resizeWidth?: number; - resizeHeight?: number; - } = {}, -): Promise { - if (!(image instanceof vf.VideoFrame)) { - // Just use the original - return origCreateImageBitmap.apply(global, arguments); - } - - // Convert the format to libav.js - let format: number = scalerAsync.AV_PIX_FMT_RGBA; - switch (image.format) { - case 'I420': - format = scalerAsync.AV_PIX_FMT_YUV420P; - break; - - case 'I420A': - format = scalerAsync.AV_PIX_FMT_YUVA420P; - break; - - case 'I422': - format = scalerAsync.AV_PIX_FMT_YUV422P; - break; - - case 'I444': - format = scalerAsync.AV_PIX_FMT_YUV444P; - break; - - case 'NV12': - format = scalerAsync.AV_PIX_FMT_NV12; - break; - - case 'RGBA': - case 'RGBX': - format = scalerAsync.AV_PIX_FMT_RGBA; - break; - - case 'BGRA': - case 'BGRX': - format = scalerAsync.AV_PIX_FMT_BGRA; - break; - } - - // Normalize arguments - const dWidth = typeof opts.resizeWidth === 'number' ? opts.resizeWidth : image.displayWidth; - const dHeight = typeof opts.resizeHeight === 'number' ? opts.resizeHeight : image.displayHeight; - - // Convert the frame - const frameData = new ImageData(dWidth, dHeight); - - return (async () => { - const [sctx, inFrame, outFrame] = await Promise.all([ - scalerAsync.sws_getContext( - image.codedWidth, - image.codedHeight, - format, - dWidth, - dHeight, - scalerAsync.AV_PIX_FMT_RGBA, - 2, - 0, - 0, - 0, - ), - scalerAsync.av_frame_alloc(), - scalerAsync.av_frame_alloc(), - ]); - - // Convert the data (FIXME: duplication) - const rawU8 = image._libavGetData(); - let rawIdx = 0; - const raw: Uint8Array[][] = []; - const planes = vf.numPlanes(image.format); - for (let p = 0; p < planes; p++) { - const plane: Uint8Array[] = []; - raw.push(plane); - const sb = vf.sampleBytes(image.format, p); - const hssf = vf.horizontalSubSamplingFactor(image.format, p); - const vssf = vf.verticalSubSamplingFactor(image.format, p); - const w = ~~((image.codedWidth * sb) / hssf); - const h = ~~(image.codedHeight / vssf); - for (let y = 0; y < h; y++) { - plane.push(rawU8.subarray(rawIdx, rawIdx + w)); - rawIdx += w; - } - } - - const [, , frame] = await Promise.all([ - // Copy it in - scalerAsync.ff_copyin_frame(inFrame, { - data: raw, - format, - width: image.codedWidth, - height: image.codedHeight, - }), - - // Rescale - scalerAsync.sws_scale_frame(sctx, outFrame, inFrame), - - // Get the data back out again - scalerAsync.ff_copyout_frame(outFrame), - - // And clean up - scalerAsync.av_frame_free_js(outFrame), - scalerAsync.av_frame_free_js(inFrame), - scalerAsync.sws_freeContext(sctx), - ]); - - // Transfer all the data - let idx = 0; - for (let i = 0; i < frame.data.length; i++) { - const plane = frame.data[i]; - for (let y = 0; y < plane.length; y++) { - const row = plane[y]; - frameData.data.set(row, idx); - idx += row.length; - } - } - - // And make the ImageBitmap - return await origCreateImageBitmap(frameData); - })(); -} diff --git a/src/lib/video-preview/polyfill/video-decoder.ts b/src/lib/video-preview/polyfill/video-decoder.ts deleted file mode 100644 index ceda72410..000000000 --- a/src/lib/video-preview/polyfill/video-decoder.ts +++ /dev/null @@ -1,423 +0,0 @@ -// @ts-nocheck - -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -import type * as LibAVJS from '../libav.types'; -import type * as evc from './encoded-video-chunk'; -import * as libavs from './libav'; -import * as misc from './misc'; -import * as vf from './video-frame'; - -export class VideoDecoder { - constructor(init: VideoDecoderInit) { - this._output = init.output; - this._error = init.error; - - this.state = 'unconfigured'; - this.decodeQueueSize = 0; - - this._p = Promise.all([]); - this._libav = null; - this._codec = this._c = this._pkt = this._frame = 0; - } - - /* NOTE: These should technically be readonly, but I'm implementing them as - * plain fields, so they're writable */ - state: misc.CodecState; - - decodeQueueSize: number; - - private _output: VideoFrameOutputCallback; - - private _error: misc.WebCodecsErrorCallback; - - // Event queue - private _p: Promise; - - // LibAV state - private _libav: LibAVJS.LibAV; - - private _codec: number; - - private _c: number; - - private _pkt: number; - - private _frame: number; - - configure(config: VideoDecoderConfig): void { - const self = this; - - // 1. If config is not a valid VideoDecoderConfig, throw a TypeError. - // NOTE: We don't support sophisticated codec string parsing (yet) - - // 2. If [[state]] is “closed”, throw an InvalidStateError DOMException. - if (this.state === 'closed') { - throw new DOMException('Decoder is closed', 'InvalidStateError'); - } - - // Free any internal state - if (this._libav) { - this._p = this._p.then(() => this._free()); - } - - // 3. Set [[state]] to "configured". - this.state = 'configured'; - - // 4. Set [[key chunk required]] to true. - // NOTE: Not implemented - - // 5. Queue a control message to configure the decoder with config. - this._p = this._p - .then(async () => { - /* 1. Let supported be the result of running the Check - * Configuration Support algorithm with config. */ - const supported = libavs.decoder(config.codec); - - /* 2. If supported is true, assign [[codec implementation]] with an - * implementation supporting config. */ - if (supported) { - const libav = (self._libav = await libavs.get()); - - const ptr = await libav.malloc(config.description.length); - await libav.copyin_u8(ptr, config.description); - const parm = await libav.calloc(1, 1024); - await libav.AVCodecParameters_extradata_s(parm, ptr); - await libav.AVCodecParameters_extradata_size_s(parm, config.description.length); - // Initialize - [self._codec, self._c, self._pkt, self._frame] = await libav.ff_init_decoder( - supported.codec, - parm, - ); - await libav.AVCodecContext_time_base_s(self._c, 1, 1000); - await libav.free(ptr); - await libav.free(parm); - } else { - /* 3. Otherwise, run the Close VideoDecoder algorithm with - * NotSupportedError DOMException. */ - self._closeVideoDecoder(new DOMException('Unsupported codec', 'NotSupportedError')); - } - }) - .catch(this._error); - } - - // Our own algorithm, close libav - private async _free() { - if (this._c) { - await this._libav.ff_free_decoder(this._c, this._pkt, this._frame); - this._codec = this._c = this._pkt = this._frame = 0; - } - if (this._libav) { - libavs.free(this._libav); - this._libav = null; - } - } - - private _closeVideoDecoder(exception: DOMException) { - // 1. Run the Reset VideoDecoder algorithm with exception. - this._resetVideoDecoder(exception); - - // 2. Set [[state]] to "closed". - this.state = 'closed'; - - /* 3. Clear [[codec implementation]] and release associated system - * resources. */ - this._p = this._p.then(() => this._free()); - - /* 4. If exception is not an AbortError DOMException, queue a task on - * the control thread event loop to invoke the [[error callback]] with - * exception. */ - if (exception.name !== 'AbortError') { - this._p = this._p.then(() => { - this._error(exception); - }); - } - } - - private _resetVideoDecoder(exception: DOMException) { - // 1. If [[state]] is "closed", throw an InvalidStateError. - if (this.state === 'closed') { - throw new DOMException('Decoder closed', 'InvalidStateError'); - } - - // 2. Set [[state]] to "unconfigured". - this.state = 'unconfigured'; - - // ... really, we're just going to free it now - this._p = this._p.then(() => this._free()); - } - - decode(chunk: evc.EncodedVideoChunk): void { - const self = this; - - // 1. If [[state]] is not "configured", throw an InvalidStateError. - if (this.state !== 'configured') { - throw new DOMException('Unconfigured', 'InvalidStateError'); - } - - // 2. If [[key chunk required]] is true: - // 1. If chunk.[[type]] is not key, throw a DataError. - /* 2. Implementers SHOULD inspect the chunk’s [[internal data]] to - * verify that it is truly a key chunk. If a mismatch is detected, - * throw a DataError. */ - // 3. Otherwise, assign false to [[key chunk required]]. - - // 3. Increment [[decodeQueueSize]]. - this.decodeQueueSize++; - - // 4. Queue a control message to decode the chunk. - this._p = this._p - .then(async () => { - const libav = self._libav; - const c = self._c; - const pkt = self._pkt; - const frame = self._frame; - - let decodedOutputs: LibAVJS.Frame[] = null; - - // 1. Attempt to use [[codec implementation]] to decode the chunk. - try { - // Convert to a libav packet - const ptsFull = Math.floor(chunk.timestamp / 1000); - const pts = ptsFull % 0x100000000; - const ptshi = ~~(ptsFull / 0x100000000); - const packet: LibAVJS.Packet = { - data: chunk._libavGetData(), - pts, - ptshi, - dts: pts, - dtshi: ptshi, - }; - if (chunk.duration) { - packet.duration = Math.floor(chunk.duration / 1000); - packet.durationhi = 0; - } - - decodedOutputs = await libav.ff_decode_multi(c, pkt, frame, [packet]); - - /* 2. If decoding results in an error, queue a task on the control - * thread event loop to run the Close VideoDecoder algorithm with - * EncodingError. */ - } catch (ex) { - // console.log('Error decoding', ex); - self._p = self._p.then(() => { - self._closeVideoDecoder(ex); - }); - } - - /* 3. Queue a task on the control thread event loop to decrement - * [[decodeQueueSize]]. */ - self.decodeQueueSize--; - - /* 4. Let decoded outputs be a list of decoded audio data outputs - * emitted by [[codec implementation]]. */ - /* 5. If decoded outputs is not empty, queue a task on the control - * thread event loop to run the Output VideoData algorithm with - * decoded outputs. */ - if (decodedOutputs) { - self._outputVideoFrames(decodedOutputs); - } - }) - .catch(this._error); - } - - private _outputVideoFrames(frames: LibAVJS.Frame[]) { - const libav = this._libav; - - for (const frame of frames) { - // 1. format - let format: vf.VideoPixelFormat; - switch (frame.format) { - case libav.AV_PIX_FMT_YUV420P: - format = 'I420'; - break; - - case libav.AV_PIX_FMT_YUVA420P: - format = 'I420A'; - break; - - case libav.AV_PIX_FMT_YUV422P: - format = 'I422'; - break; - - case libav.AV_PIX_FMT_YUV444P: - format = 'I444'; - break; - - case libav.AV_PIX_FMT_NV12: - format = 'NV12'; - break; - - case libav.AV_PIX_FMT_RGBA: - format = 'RGBA'; - break; - - case libav.AV_PIX_FMT_BGRA: - format = 'BGRA'; - break; - - default: - throw new DOMException('Unsupported libav format!', 'EncodingError'); - } - - // 2. width and height - const codedWidth = frame.width; - const codedHeight = frame.height; - - // Check for non-square pixels - let displayWidth = codedWidth; - let displayHeight = codedHeight; - if (frame.sample_aspect_ratio[0]) { - const sar = frame.sample_aspect_ratio; - if (sar[0] > sar[1]) { - displayWidth = ~~((codedWidth * sar[0]) / sar[1]); - } else { - displayHeight = ~~((codedHeight * sar[1]) / sar[0]); - } - } - - // 3. timestamp - const timestamp = (frame.ptshi * 0x100000000 + frame.pts) * 1000; - - // 4. data - let raw: Uint8Array; - { - let size = 0; - const planes = vf.numPlanes(format); - const sbs = []; - const hssfs = []; - const vssfs = []; - for (let i = 0; i < planes; i++) { - sbs.push(vf.sampleBytes(format, i)); - hssfs.push(vf.horizontalSubSamplingFactor(format, i)); - vssfs.push(vf.verticalSubSamplingFactor(format, i)); - } - for (let i = 0; i < planes; i++) { - size += frame.width * frame.height * sbs[i] / hssfs[i] - / vssfs[i]; - } - raw = new Uint8Array(size); - let off = 0; - for (let i = 0; i < planes; i++) { - const fd = frame.data[i]; - for (let j = 0; j < frame.height / vssfs[i]; j++) { - const part = fd[j].subarray(0, frame.width / hssfs[i]); - raw.set(part, off); - off += part.length; - } - } - } - - const data = new vf.VideoFrame(raw, { - format, - codedWidth, - codedHeight, - displayWidth, - displayHeight, - timestamp, - }); - - this._output(data); - } - } - - flush(): Promise { - const self = this; - - const ret = this._p.then(async () => { - if (!self._c) { - return; - } - - // Make sure any last data is flushed - const libav = self._libav; - const c = self._c; - const pkt = self._pkt; - const frame = self._frame; - - let decodedOutputs: LibAVJS.Frame[] = null; - - try { - decodedOutputs = await libav.ff_decode_multi(c, pkt, frame, [], true); - } catch (ex) { - self._p = self._p.then(() => { - self._closeVideoDecoder(ex); - }); - } - - if (decodedOutputs) { - self._outputVideoFrames(decodedOutputs); - } - }); - this._p = ret; - return ret; - } - - reset(): void { - this._resetVideoDecoder(new DOMException('Reset', 'AbortError')); - } - - close(): void { - this._closeVideoDecoder(new DOMException('Close', 'AbortError')); - } - - static async isConfigSupported(config: VideoDecoderConfig): Promise { - const dec = libavs.decoder(config.codec); - let supported = false; - if (dec) { - const libav = await libavs.get(); - try { - const [, c, pkt, frame] = await libav.ff_init_decoder(dec.codec); - await libav.ff_free_decoder(c, pkt, frame); - supported = true; - } catch (ex) {} - await libavs.free(libav); - } - - return { - supported, - config: misc.cloneConfig(config, ['codec', 'codedWidth', 'codedHeight']), - }; - } -} - -export interface VideoDecoderInit { - output: VideoFrameOutputCallback; - error: misc.WebCodecsErrorCallback; -} - -export type VideoFrameOutputCallback = (output: vf.VideoFrame) => void; - -export interface VideoDecoderConfig { - codec: string | { libavjs: libavs.LibAVJSCodec }; - description: Uint8Array; - codedWidth?: number; - codedHeight?: number; - displayAspectWidth?: number; - displayAspectHeight?: number; - colorSpace?: vf.VideoColorSpaceInit; - hardwareAcceleration?: string; // Ignored - optimizeForLatency?: boolean; -} - -export interface VideoDecoderSupport { - supported: boolean; - config: VideoDecoderConfig; -} diff --git a/src/lib/video-preview/polyfill/video-frame.ts b/src/lib/video-preview/polyfill/video-frame.ts deleted file mode 100644 index f5055adcd..000000000 --- a/src/lib/video-preview/polyfill/video-frame.ts +++ /dev/null @@ -1,822 +0,0 @@ -// @ts-nocheck - -/* - * This file is part of the libav.js WebCodecs Polyfill implementation. The - * interface implemented is derived from the W3C standard. No attribution is - * required when using this library. - * - * Copyright (c) 2021 Yahweasel - * - * 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. - */ - -// A canvas element used to convert CanvasImageSources to buffers -let offscreenCanvas: HTMLCanvasElement = null; - -export class VideoFrame { - constructor(data: CanvasImageSource | BufferSource, init: VideoFrameInit | VideoFrameBufferInit) { - if (data instanceof ArrayBuffer || (data).buffer instanceof ArrayBuffer) { - this._constructBuffer(data, init); - } else { - this._constructCanvas(data, init); - } - } - - private _constructCanvas(image: any, init: VideoFrameInit) { - if (offscreenCanvas === null) { - offscreenCanvas = document.createElement('canvas'); - offscreenCanvas.style.display = 'none'; - document.body.appendChild(offscreenCanvas); - } - - // Convert it to a buffer - - // Get the width and height - let width = 0; - let height = 0; - if (image.naturalWidth) { - width = image.naturalWidth; - height = image.naturalHeight; - } else if (image.videoWidth) { - width = image.videoWidth; - height = image.videoHeight; - } else if (image.width) { - width = image.width; - height = image.height; - } - if (!width || !height) { - throw new DOMException('Could not determine dimensions', 'InvalidStateError'); - } - - // Draw it - offscreenCanvas.width = width; - offscreenCanvas.height = height; - const ctx = offscreenCanvas.getContext('2d'); - ctx.clearRect(0, 0, width, height); - ctx.drawImage(image, 0, 0); - this._constructBuffer(ctx.getImageData(0, 0, width, height).data, { - format: 'RGBA', - codedWidth: width, - codedHeight: height, - timestamp: init.timestamp, - duration: init.duration || 0, - layout: [ - { - offset: 0, - stride: width * 4 - } - ], - displayWidth: init.displayWidth || width, - displayHeight: init.displayHeight || height - }); - } - - private _constructBuffer(data: BufferSource, init: VideoFrameBufferInit) { - const format = (this.format = init.format); - const width = (this.codedWidth = init.codedWidth); - const height = (this.codedHeight = init.codedHeight); - this.visibleRect = new DOMRect(0, 0, width, height); - - const dWidth = (this.displayWidth = init.displayWidth || init.codedWidth); - const dHeight = (this.displayHeight = init.displayHeight || init.codedHeight); - - // Account for non-square pixels - if (dWidth !== width || dHeight !== height) { - // Dubious (but correct) SAR calculation - this._nonSquarePixels = true; - this._sar_num = dWidth * height; - this._sar_den = dHeight * width; - } else { - this._nonSquarePixels = false; - } - - this.timestamp = init.timestamp; - if (init.duration) { - this.duration = init.duration; - } - - if (init.layout) { - this._layout = init.layout; // FIXME: Make sure it's the right size - } else { - const numPlanes_ = numPlanes(format); - const layout: PlaneLayout[] = []; - let offset = 0; - for (let i = 0; i < numPlanes_; i++) { - const sampleWidth = horizontalSubSamplingFactor(format, i); - const sampleHeight = verticalSubSamplingFactor(format, i); - const stride = ~~(width / sampleWidth); - layout.push({ - offset, - stride - }); - offset += stride * ~~(height / sampleHeight); - } - this._layout = layout; - } - - this._data = new Uint8Array((data).buffer || data, (data).byteOffset || 0); - } - - /* NOTE: These should all be readonly, but the constructor style above - * doesn't work with that */ - format: VideoPixelFormat; - - codedWidth: number; - - codedHeight: number; - - codedRect: DOMRectReadOnly; - - visibleRect: DOMRectReadOnly; - - displayWidth: number; - - displayHeight: number; - - duration: number; // microseconds - - timestamp: number; // microseconds - - colorSpace: VideoColorSpace; - - private _layout: PlaneLayout[]; - - private _data: Uint8Array; - - /** - * (Internal) Does this use non-square pixels? - */ - _nonSquarePixels: boolean; - - /** - * (Internal) If non-square pixels, the SAR (sample/pixel aspect ratio) - */ - _sar_num: number; - - _sar_den: number; - - // Internal - _libavGetData() { - return this._data; - } - - allocationSize(options: VideoFrameCopyToOptions = {}): number { - // 1. If [[Detached]] is true, throw an InvalidStateError DOMException. - if (this._data === null) { - throw new DOMException('Detached', 'InvalidStateError'); - } - - // 2. If [[format]] is null, throw a NotSupportedError DOMException. - if (this.format === null) { - throw new DOMException('Not supported', 'NotSupportedError'); - } - - /* 3. Let combinedLayout be the result of running the Parse - * VideoFrameCopyToOptions algorithm with options. */ - // 4. If combinedLayout is an exception, throw combinedLayout. - const combinedLayout = this._parseVideoFrameCopyToOptions(options); - - // 5. Return combinedLayout’s allocationSize. - return combinedLayout.allocationSize; - } - - private _parseVideoFrameCopyToOptions(options: VideoFrameCopyToOptions) { - /* 1. Let defaultRect be the result of performing the getter steps for - * visibleRect. */ - const defaultRect = this.visibleRect; - - // 2. Let overrideRect be undefined. - // 3. If options.rect exists, assign its value to overrideRect. - const overrideRect: DOMRectReadOnly = options.rect - ? new DOMRect(options.rect.x, options.rect.y, options.rect.width, options.rect.height) - : null; - - /* 4. Let parsedRect be the result of running the Parse Visible Rect - * algorithm with defaultRect, overrideRect, [[coded width]], [[coded - * height]], and [[format]]. */ - // 5. If parsedRect is an exception, return parsedRect. - const parsedRect = this._parseVisibleRect(defaultRect, overrideRect); - - // 6. Let optLayout be undefined. - // 7. If options.layout exists, assign its value to optLayout. - const optLayout = options.layout || null; - - /* 8. Let combinedLayout be the result of running the Compute Layout - * and Allocation Size algorithm with parsedRect, [[format]], and - * optLayout. */ - const combinedLayout = this._computeLayoutAndAllocationSize(parsedRect, optLayout); - - // 9. Return combinedLayout. - return combinedLayout; - } - - private _parseVisibleRect(defaultRect: DOMRectReadOnly, overrideRect: DOMRectReadOnly) { - // 1. Let sourceRect be defaultRect - let sourceRect = defaultRect; - - // 2. If overrideRect is not undefined: - if (overrideRect) { - /* 1. If either of overrideRect.width or height is 0, return a - * TypeError. */ - if (overrideRect.width === 0 || overrideRect.height === 0) { - throw new TypeError('Invalid rectangle'); - } - - /* 2. If the sum of overrideRect.x and overrideRect.width is - * greater than [[coded width]], return a TypeError. */ - if (overrideRect.x + overrideRect.width > this.codedWidth) { - throw new TypeError('Invalid rectangle'); - } - - /* 3. If the sum of overrideRect.y and overrideRect.height is - * greater than [[coded height]], return a TypeError. */ - if (overrideRect.y + overrideRect.height > this.codedHeight) { - throw new TypeError('Invalid rectangle'); - } - - // 4. Assign overrideRect to sourceRect. - sourceRect = overrideRect; - } - - /* 3. Let validAlignment be the result of running the Verify Rect - * Sample Alignment algorithm with format and sourceRect. */ - const validAlignment = this._verifyRectSampleAlignment(sourceRect); - - // 4. If validAlignment is false, throw a TypeError. - if (!validAlignment) { - throw new TypeError('Invalid alignment'); - } - - // 5. Return sourceRect. - return sourceRect; - } - - private _computeLayoutAndAllocationSize(parsedRect: DOMRectReadOnly, layout: PlaneLayout[]) { - // 1. Let numPlanes be the number of planes as defined by format. - const numPlanes_ = numPlanes(this.format); - - /* 2. If layout is not undefined and its length does not equal - * numPlanes, throw a TypeError. */ - if (layout && layout.length !== numPlanes_) { - throw new TypeError('Invalid layout'); - } - - // 3. Let minAllocationSize be 0. - let minAllocationSize = 0; - - // 4. Let computedLayouts be a new list. - const computedLayouts: ComputedPlaneLayout[] = []; - - // 5. Let endOffsets be a new list. - const endOffsets = []; - - // 6. Let planeIndex be 0. - let planeIndex = 0; - - // 7. While planeIndex < numPlanes: - while (planeIndex < numPlanes_) { - /* 1. Let plane be the Plane identified by planeIndex as defined by - * format. */ - - // 2. Let sampleBytes be the number of bytes per sample for plane. - const sampleBytes_ = sampleBytes(this.format, planeIndex); - - /* 3. Let sampleWidth be the horizontal sub-sampling factor of each - * subsample for plane. */ - const sampleWidth = horizontalSubSamplingFactor(this.format, planeIndex); - - /* 4. Let sampleHeight be the vertical sub-sampling factor of each - * subsample for plane. */ - const sampleHeight = verticalSubSamplingFactor(this.format, planeIndex); - - /* 5. Let sampleWidthBytes be the product of multiplying - * sampleWidth by sampleBytes. */ - const sampleWidthBytes = sampleWidth * sampleBytes_; - - // 6. Let computedLayout be a new computed plane layout. - const computedLayout: ComputedPlaneLayout = { - destinationOffset: 0, - destinationStride: 0, - - /* 7. Set computedLayout’s sourceTop to the result of the - * integer division of truncated parsedRect.y by sampleHeight. */ - sourceTop: ~~(parsedRect.y / sampleHeight), - - /* 8. Set computedLayout’s sourceHeight to the result of the - * integer division of truncated parsedRect.height by - * sampleHeight */ - sourceHeight: ~~(parsedRect.height / sampleHeight), - - /* 9. Set computedLayout’s sourceLeftBytes to the result of the - * integer division of truncated parsedRect.x by - * sampleWidthBytes. */ - sourceLeftBytes: ~~(parsedRect.x / sampleWidthBytes), - - /* 10. Set computedLayout’s sourceWidthBytes to the result of - * the integer division of truncated parsedRect.width by - * sampleWidthBytes. */ - sourceWidthBytes: ~~(parsedRect.width / sampleWidthBytes) - }; - - // 11. If layout is not undefined: - if (layout) { - /* 1. Let planeLayout be the PlaneLayout in layout at position - * planeIndex. */ - const planeLayout = layout[planeIndex]; - - /* 2. If planeLayout.stride is less than computedLayout’s - * sourceWidthBytes, return a TypeError. */ - if (planeLayout.stride < computedLayout.sourceWidthBytes) { - throw new TypeError('Invalid stride'); - } - - /* 3. Assign planeLayout.offset to computedLayout’s - * destinationOffset. */ - computedLayout.destinationOffset = planeLayout.offset; - - /* 4. Assign planeLayout.stride to computedLayout’s - * destinationStride. */ - computedLayout.destinationStride = planeLayout.stride; - - // 12. Otherwise: - } else { - /* 1. Assign minAllocationSize to computedLayout’s - * destinationOffset. */ - computedLayout.destinationOffset = minAllocationSize; - - /* 2. Assign computedLayout’s sourceWidthBytes to - * computedLayout’s destinationStride. */ - computedLayout.destinationStride = computedLayout.sourceWidthBytes; - } - - /* 13. Let planeSize be the product of multiplying computedLayout’s - * destinationStride and sourceHeight. */ - const planeSize = computedLayout.destinationStride * computedLayout.sourceHeight; - - /* 14. Let planeEnd be the sum of planeSize and computedLayout’s - * destinationOffset. */ - const planeEnd = planeSize + computedLayout.destinationOffset; - - /* 15. If planeSize or planeEnd is greater than maximum range of - * unsigned long, return a TypeError. */ - if (planeSize >= 0x100000000 || planeEnd >= 0x100000000) { - throw new TypeError('Plane too large'); - } - - // 16. Append planeEnd to endOffsets. - endOffsets.push(planeEnd); - - /* 17. Assign the maximum of minAllocationSize and planeEnd to - * minAllocationSize. */ - if (planeEnd > minAllocationSize) { - minAllocationSize = planeEnd; - } - - // 18. Let earlierPlaneIndex be 0. - let earlierPlaneIndex = 0; - - // 19. While earlierPlaneIndex is less than planeIndex. - while (earlierPlaneIndex < planeIndex) { - // 1. Let earlierLayout be computedLayouts[earlierPlaneIndex]. - const earlierLayout = computedLayouts[earlierPlaneIndex]; - - /* 2. If endOffsets[planeIndex] is less than or equal to - * earlierLayout’s destinationOffset or if - * endOffsets[earlierPlaneIndex] is less than or equal to - * computedLayout’s destinationOffset, continue. */ - if ( - planeEnd <= earlierLayout.destinationOffset || - endOffsets[earlierPlaneIndex] <= computedLayout.destinationOffset - ) { - // 3. Otherwise, return a TypeError. - } else { - throw new TypeError('Invalid plane layout'); - } - - // 4. Increment earlierPlaneIndex by 1. - earlierPlaneIndex++; - } - - // 20. Append computedLayout to computedLayouts. - computedLayouts.push(computedLayout); - - // 21. Increment planeIndex by 1. - planeIndex++; - } - - /* 8. Let combinedLayout be a new combined buffer layout, initialized - * as follows: */ - const combinedLayout = { - // 1. Assign computedLayouts to computedLayouts. - computedLayouts, - - // 2. Assign minAllocationSize to allocationSize. - allocationSize: minAllocationSize - }; - - // 9. Return combinedLayout. - return combinedLayout; - } - - private _verifyRectSampleAlignment(rect: DOMRectReadOnly) { - // 1. If format is null, return true. - if (!this.format) { - return true; - } - - // 2. Let planeIndex be 0. - let planeIndex = 0; - - // 3. Let numPlanes be the number of planes as defined by format. - const numPlanes_ = numPlanes(this.format); - - // 4. While planeIndex is less than numPlanes: - while (planeIndex < numPlanes_) { - /* 1. Let plane be the Plane identified by planeIndex as defined by - * format. */ - - /* 2. Let sampleWidth be the horizontal sub-sampling factor of each - * subsample for plane. */ - const sampleWidth = horizontalSubSamplingFactor(this.format, planeIndex); - - /* 3. Let sampleHeight be the vertical sub-sampling factor of each - * subsample for plane. */ - const sampleHeight = verticalSubSamplingFactor(this.format, planeIndex); - - /* 4. If rect.x and rect.width are not both multiples of - * sampleWidth, return false. */ - const xw = rect.x / sampleWidth; - if (xw !== ~~xw) { - return false; - } - const ww = rect.width / sampleWidth; - if (ww !== ~~ww) { - return false; - } - - /* 5. If rect.y and rect.height are not both multiples of - * sampleHeight, return false. */ - const yh = rect.y / sampleHeight; - if (yh !== ~~yh) { - return false; - } - const hh = rect.height / sampleHeight; - if (hh !== ~~hh) { - return false; - } - - // 6. Increment planeIndex by 1. - planeIndex++; - } - - // 5. Return true. - return true; - } - - async copyTo( - destination: BufferSource, - options: VideoFrameCopyToOptions = {} - ): Promise { - const destBuf = new Uint8Array( - (destination).buffer || destination, - (destination).byteOffset || 0 - ); - - // 1. If [[Detached]] is true, throw an InvalidStateError DOMException. - if (this._data === null) { - throw new DOMException('Detached', 'InvalidStateError'); - } - - // 2. If [[format]] is null, throw a NotSupportedError DOMException. - if (!this.format) { - throw new DOMException('No format', 'NotSupportedError'); - } - - /* 3. Let combinedLayout be the result of running the Parse - * VideoFrameCopyToOptions algorithm with options. */ - /* 4. If combinedLayout is an exception, return a promise rejected with - * combinedLayout. */ - const combinedLayout = this._parseVideoFrameCopyToOptions(options); - - /* 5. If destination.byteLength is less than combinedLayout’s - * allocationSize, return a promise rejected with a TypeError. */ - if (destination.byteLength < combinedLayout.allocationSize) { - throw new TypeError('Insufficient space'); - } - - // 6. Let p be a new Promise. - /* 7. Let copyStepsQueue be the result of starting a new parallel - * queue. */ - // 8. Enqueue the following steps to copyStepsQueue: - // NOTE: This is an async function anyway, so we can just do these. - const ret: PlaneLayout[] = []; - - /* 1. Let resource be the media resource referenced by [[resource - * reference]]. */ - - // 2. Let numPlanes be the number of planes as defined by [[format]]. - const numPlanes_ = numPlanes(this.format); - - // 3. Let planeIndex be 0. - let planeIndex = 0; - - // 4. While planeIndex is less than combinedLayout’s numPlanes: - while (planeIndex < combinedLayout.computedLayouts.length) { - /* 1. Let sourceStride be the stride of the plane in resource as - * identified by planeIndex. */ - const sourceStride = this._layout[planeIndex].stride; - - /* 2. Let computedLayout be the computed plane layout in - * combinedLayout’s computedLayouts at the position of planeIndex */ - const computedLayout = combinedLayout.computedLayouts[planeIndex]; - - /* 3. Let sourceOffset be the product of multiplying - * computedLayout’s sourceTop by sourceStride */ - let sourceOffset = computedLayout.sourceTop * sourceStride; - - // 4. Add computedLayout’s sourceLeftBytes to sourceOffset. - sourceOffset += computedLayout.sourceLeftBytes; - - // 5. Let destinationOffset be computedLayout’s destinationOffset. - let destinationOffset = computedLayout.destinationOffset; - - // 6. Let rowBytes be computedLayout’s sourceWidthBytes. - const rowBytes = computedLayout.sourceWidthBytes; - - // 7. Let row be 0. - let row = 0; - - // 8. While row is less than computedLayout’s sourceHeight: - while (row < computedLayout.sourceHeight) { - /* 1. Copy rowBytes bytes from resource starting at - * sourceOffset to destination starting at destinationOffset. */ - destBuf.set(this._data.subarray(sourceOffset, sourceOffset + rowBytes), destinationOffset); - - // 2. Increment sourceOffset by sourceStride. - sourceOffset += sourceStride; - - /* 3. Increment destinationOffset by computedLayout’s - * destinationStride. */ - destinationOffset += computedLayout.destinationStride; - - // 4. Increment row by 1. - row++; - } - - // 9. Increment planeIndex by 1. - planeIndex++; - ret.push({ - offset: computedLayout.destinationOffset, - stride: computedLayout.destinationStride - }); - } - - // 5. Queue a task on the control thread event loop to resolve p. - // 6. Return p. - return ret; - } - - clone(): VideoFrame { - return new VideoFrame(this._data, { - format: this.format, - codedWidth: this.codedWidth, - codedHeight: this.codedHeight, - timestamp: this.timestamp, - duration: this.duration, - layout: this._layout - }); - } - - close(): void { - this._data = null; - } -} - -export interface VideoFrameInit { - duration?: number; // microseconds - timestamp: number; // microseconds - // FIXME: AlphaOption alpha = "keep"; - - // Default matches image. May be used to efficiently crop. Will trigger - // new computation of displayWidth and displayHeight using image’s pixel - // aspect ratio unless an explicit displayWidth and displayHeight are given. - visibleRect?: DOMRectInit; - - // Default matches image unless visibleRect is provided. - displayWidth?: number; - displayHeight?: number; -} - -export interface VideoFrameBufferInit { - format: VideoPixelFormat; - codedWidth: number; - codedHeight: number; - timestamp: number; // microseconds - duration?: number; // microseconds - - // Default layout is tightly-packed. - layout?: PlaneLayout[]; - - // Default visible rect is coded size positioned at (0,0) - visibleRect?: DOMRectInit; - - // Default display dimensions match visibleRect. - displayWidth?: number; - displayHeight?: number; - - // FIXME: Not used - colorSpace?: VideoColorSpaceInit; -} - -export type VideoPixelFormat = - // 4:2:0 Y, U, V - | 'I420' - // 4:2:0 Y, U, V, A - | 'I420A' - // 4:2:2 Y, U, V - | 'I422' - // 4:4:4 Y, U, V - | 'I444' - // 4:2:0 Y, UV - | 'NV12' - // 32bpp RGBA - | 'RGBA' - // 32bpp RGBX (opaque) - | 'RGBX' - // 32bpp BGRA - | 'BGRA' - // 32bpp BGRX (opaque) - | 'BGRX'; - -/** - * Number of planes in the given format. - * @param format The format - */ -export function numPlanes(format: VideoPixelFormat) { - switch (format) { - case 'I420': - case 'I422': - case 'I444': - return 3; - - case 'I420A': - return 4; - - case 'NV12': - return 2; - - case 'RGBA': - case 'RGBX': - case 'BGRA': - case 'BGRX': - return 1; - - default: - throw new DOMException('Unsupported video pixel format', 'NotSupportedError'); - } -} - -/** - * Number of bytes per sample in the given format and plane. - * @param format The format - * @param planeIndex The plane index - */ -export function sampleBytes(format: VideoPixelFormat, planeIndex: number) { - switch (format) { - case 'I420': - case 'I420A': - case 'I422': - case 'I444': - return 1; - - case 'NV12': - if (planeIndex === 1) { - return 2; - } else { - return 1; - } - - case 'RGBA': - case 'RGBX': - case 'BGRA': - case 'BGRX': - return 4; - - default: - throw new DOMException('Unsupported video pixel format', 'NotSupportedError'); - } -} - -/** - * Horizontal sub-sampling factor for the given format and plane. - * @param format The format - * @param planeIndex The plane index - */ -export function horizontalSubSamplingFactor(format: VideoPixelFormat, planeIndex: number) { - // First plane (often luma) is always full - if (planeIndex === 0) { - return 1; - } - - switch (format) { - case 'I420': - case 'I422': - return 2; - - case 'I420A': - if (planeIndex === 3) { - return 1; - } else { - return 2; - } - - case 'I444': - return 1; - - case 'NV12': - return 2; - - case 'RGBA': - case 'RGBX': - case 'BGRA': - case 'BGRX': - return 1; - - default: - throw new DOMException('Unsupported video pixel format', 'NotSupportedError'); - } -} - -/** - * Vertical sub-sampling factor for the given format and plane. - * @param format The format - * @param planeIndex The plane index - */ -export function verticalSubSamplingFactor(format: VideoPixelFormat, planeIndex: number) { - // First plane (often luma) is always full - if (planeIndex === 0) { - return 1; - } - - switch (format) { - case 'I420': - return 2; - - case 'I420A': - if (planeIndex === 3) { - return 1; - } else { - return 2; - } - - case 'I422': - case 'I444': - return 1; - - case 'NV12': - return 2; - - case 'RGBA': - case 'RGBX': - case 'BGRA': - case 'BGRX': - return 1; - - default: - throw new DOMException('Unsupported video pixel format', 'NotSupportedError'); - } -} - -/** - * NOTE: Color space is not actually supported - */ -export type VideoColorSpace = any; -export type VideoColorSpaceInit = any; - -export interface PlaneLayout { - offset: number; - stride: number; -} - -export interface VideoFrameCopyToOptions { - rect?: DOMRectInit; - layout?: PlaneLayout[]; -} - -interface ComputedPlaneLayout { - destinationOffset: number; - destinationStride: number; - sourceTop: number; - sourceHeight: number; - sourceLeftBytes: number; - sourceWidthBytes: number; -} diff --git a/src/lib/video-preview/video-preview.worker.ts b/src/lib/video-preview/video-preview.worker.ts index 03d526f9e..5e76d1deb 100644 --- a/src/lib/video-preview/video-preview.worker.ts +++ b/src/lib/video-preview/video-preview.worker.ts @@ -1,14 +1,11 @@ import { createWorkerInterface } from '../../util/createPostMessageInterface'; import type { CancellableCallback } from '../../util/PostMessageConnector'; import { MP4Demuxer } from './MP4Demuxer'; -import * as LibAVWebCodecs from './polyfill'; let decoder: any; let demuxer: any; let onDestroy: VoidFunction | undefined; -let isLoaded = false; - async function init( url: string, maxFrames: number, @@ -18,7 +15,11 @@ async function init( ) { const hasWebCodecs = 'VideoDecoder' in globalThis; if (!hasWebCodecs) { - await loadLibAV(); + // eslint-disable-next-line no-console + console.log('[Video Preview] WebCodecs not supported'); + return new Promise((resolve) => { + onDestroy = resolve; + }); } const decodedFrames = new Set(); @@ -73,18 +74,6 @@ function destroy() { onDestroy?.(); } -async function loadLibAV() { - if (isLoaded) return; - - importScripts(new URL('./libav-3.10.5.1.2-webcodecs.js', import.meta.url)); - await LibAVWebCodecs.load({ - polyfill: true, - libavOptions: { noworker: true, nosimd: true }, - }); - - isLoaded = true; -} - const api = { 'video-preview:init': init, 'video-preview:destroy': destroy,