1/** 2 * This tool lets you test if the compiled Javascript decoder is functioning properly. You'll 3 * need to download a SpiderMonkey js-shell to run this script. 4 * https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/ 5 * 6 * Example: 7 * js-shell inspect-cli.js video.ivf 8 */ 9load("inspect.js"); 10var buffer = read(scriptArgs[0], "binary"); 11var Module = { 12 noExitRuntime: true, 13 noInitialRun: true, 14 preInit: [], 15 preRun: [], 16 postRun: [function () { 17 printErr(`Loaded Javascript Decoder OK`); 18 }], 19 memoryInitializerPrefixURL: "bin/", 20 arguments: ['input.ivf', 'output.raw'], 21 on_frame_decoded_json: function (jsonString) { 22 let json = JSON.parse("[" + Module.UTF8ToString(jsonString) + "null]"); 23 json.forEach(frame => { 24 if (frame) { 25 print(frame.frame); 26 } 27 }); 28 } 29}; 30DecoderModule(Module); 31Module.FS.writeFile("/tmp/input.ivf", buffer, { encoding: "binary" }); 32Module._open_file(); 33Module._set_layers(0xFFFFFFFF); // Set this to zero if you want to benchmark decoding. 34while(true) { 35 printErr("Decoding Frame ..."); 36 if (Module._read_frame()) { 37 break; 38 } 39} 40