tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

inspect-cli.js (1126B)


      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 */
      9 load("inspect.js");
     10 var buffer = read(scriptArgs[0], "binary");
     11 var 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 };
     30 DecoderModule(Module);
     31 Module.FS.writeFile("/tmp/input.ivf", buffer, { encoding: "binary" });
     32 Module._open_file();
     33 Module._set_layers(0xFFFFFFFF); // Set this to zero if you want to benchmark decoding.
     34 while(true) {
     35  printErr("Decoding Frame ...");
     36  if (Module._read_frame()) {
     37    break;
     38  }
     39 }