Beispiel #1
0
static void
show_help() {
  mxinfo("mpls_dump [options] input_file_name\n"
         "\n"
         "General options:\n"
         "\n"
         "  -h, --help             This help text\n"
         "  -V, --version          Print version information\n");
  mxexit(0);
}
Beispiel #2
0
static void
run(options_cptr &options) {
  console_kax_analyzer_cptr analyzer;

  try {
    if (!kax_analyzer_c::probe(options->m_file_name))
      mxerror(boost::format("The file '%1%' is not a Matroska file or it could not be found.\n") % options->m_file_name);

    analyzer = console_kax_analyzer_cptr(new console_kax_analyzer_c(options->m_file_name));
  } catch (mtx::mm_io::exception &ex) {
    mxerror(boost::format("The file '%1%' could not be opened for reading and writing: %1.\n") % options->m_file_name % ex);
  }

  mxinfo(boost::format("%1%\n") % Y("The file is being analyzed."));

  analyzer->set_show_progress(options->m_show_progress);

  bool ok = false;
  try {
    ok = analyzer
      ->set_parse_mode(options->m_parse_mode)
      .set_open_mode(MODE_WRITE)
      .set_throw_on_error(true)
      .process();
  } catch (mtx::mm_io::exception &ex) {
    mxerror(boost::format(Y("The file '%1%' could not be opened for reading and writing, or a read/write operation on it failed: %2%.\n")) % options->m_file_name % ex);
  } catch (...) {
  }

  if (!ok)
    mxerror(Y("This file could not be opened or parsed.\n"));

  options->find_elements(analyzer.get());
  options->validate();

  if (debugging_c::requested("dump_options")) {
    mxinfo("\nDumping options after file and element analysis\n\n");
    options->dump_info();
  }

  options->execute(*analyzer);

  if (has_content_been_modified(options)) {
    mxinfo(Y("The changes are written to the file.\n"));

    write_changes(options, analyzer.get());

    mxinfo(Y("Done.\n"));

  } else
    mxinfo(Y("No changes were made.\n"));

  mxexit();
}
static void
parse_file(const std::string &file_name) {
  mm_file_io_c in(file_name);

  g_in        = ∈
  g_file_size = in.get_size();

  g_start     = std::min(g_file_size, g_start);
  g_end       = std::min(g_file_size, g_end);

  if (!in.setFilePointer2(g_start))
    mxerror(boost::format(Y("Error: Seek to %1%\n")) % g_start);

  parse_content(0, g_end);

  if (g_errors_found)
    mxexit(2);
  if (g_warnings_found)
    mxexit(1);
}
int
main(int argc,
     char **argv) {
  registerMetaTypes();

  App app(argc, argv);

  MainWindow mainWindow;
  mainWindow.show();

  app.exec();

  mxexit(0);
}
Beispiel #5
0
void
engage_hacks(const std::string &hacks) {
  std::vector<std::string> engage_args = split(hacks, ",");
  size_t aidx, hidx;

  for (aidx = 0; engage_args.size() > aidx; aidx++)
    if (engage_args[aidx] == "list") {
      mxinfo(Y("Valid hacks are:\n"));
      for (hidx = 0; NULL != s_available_hacks[hidx].name; ++hidx)
        mxinfo(boost::format("%1%\n") % s_available_hacks[hidx].name);
      mxexit(0);

    } else if (engage_args[aidx] == "cow") {
      const std::string initial = "ICAgICAgICAgIChfXykKICAgICAgICAgICgqKikg"
        "IE9oIGhvbmV5LCB0aGF0J3Mgc28gc3dlZXQhCiAgIC8tLS0tLS0tXC8gICBPZiB"
        "jb3Vyc2UgSSdsbCBtYXJyeSB5b3UhCiAgLyB8ICAgICB8fAogKiAgfHwtLS0tfH"
        "wKICAgIF5eICAgIF5eCg==";
      char correction[200];
      memset(correction, 0, 200);
      base64_decode(initial, (unsigned char *)correction);
      mxinfo(correction);
      mxexit(0);
    }

  for (aidx = 0; engage_args.size() > aidx; aidx++) {
    bool valid_hack = false;
    for (hidx = 0; s_available_hacks[hidx].name != NULL; hidx++)
      if (engage_args[aidx] == s_available_hacks[hidx].name) {
        valid_hack = true;
        s_engaged_hacks[s_available_hacks[hidx].id] = true;
        break;
      }

    if (!valid_hack)
      mxerror(boost::format(Y("'%1%' is not a valid hack.\n")) % engage_args[aidx]);
  }
}
/** \brief Handle frame sequences in which too few timecodes are available

   This function gets called if mkvmerge wants to flush its frame queue
   but it doesn't have enough timecodes and/or durations available for
   each queued frame. This can happen in two cases:

   1. A picture sequence is found that mkvmerge does not support. An
      example: Two frames have been read. The first contained a
      P and a B frame (that's OK so far), but the second one contained
      another P or I frame without an intermediate dummy frame.

   2. The end of the file has been reached but the frame queue contains
      more frames than the timecode queue. For example: The last frame
      contained two frames, a P and a B frame. Right afterwards the
      end of the file is reached. In this case a dummy frame is missing.

   Both cases can be solved if the source file provides a FPS for this
   track. The other case is not supported.
*/
void
mpeg4_p2_video_packetizer_c::generate_timecode_and_duration() {
    if (0.0 >= m_fps) {
        // TODO: error
        mxexit(1);
    }

    if (m_available_timecodes.empty()) {
        m_previous_timecode = (int64_t)(m_previous_timecode + 1000000000.0 / m_fps);
        m_available_timecodes.push_back(timecode_duration_t(m_previous_timecode, (int64_t)(1000000000.0 / m_fps)));

        mxverb(3, boost::format("mpeg4_p2::flush_frames(): Needed new timecode %1%\n") % m_previous_timecode);
        ++m_statistics.m_num_generated_timecodes;
    }
}
Beispiel #7
0
static void
show_help() {
  mxinfo("ac3parser [options] input_file_name\n"
         "\n"
         "Options for output and information control:\n"
         "\n"
         "  -c, --checksum         Calculate and output checksums of each unit\n"
         "  -f, --frame-headers    Show the content of frame headers\n"
         "\n"
         "General options:\n"
         "\n"
         "  -h, --help             This help text\n"
         "  -V, --version          Print version information\n");
  mxexit(0);
}
Beispiel #8
0
int
main(int argc,
     char **argv) {
  mtx_common_init("ac3parser", argv[0]);

  std::vector<std::string> args = command_line_utf8(argc, argv);
  std::string file_name         = parse_args(args);

  try {
    parse_file(file_name);
  } catch (mtx::mm_io::exception &) {
    mxerror(Y("File not found\n"));
  }

  mxexit();
}
Beispiel #9
0
/** \brief Setup and high level program control

   Calls the functions for setup, handling the command line arguments,
   the actual processing and cleaning up.
*/
int
main(int argc,
     char **argv) {
  setup(argv);

  options_cptr options = propedit_cli_parser_c(command_line_utf8(argc, argv)).run();

  if (debugging_c::requested("dump_options")) {
    mxinfo("\nDumping options after parsing the command line\n\n");
    options->dump_info();
  }

  run(options);

  mxexit();
}
Beispiel #10
0
int
main(int argc,
     char **argv) {
  mtx_common_init("vc1parser", argv[0]);

  std::vector<std::string> args = command_line_utf8(argc, argv);
  std::string file_name    = parse_args(args);

  try {
    parse_file(file_name);
  } catch (...) {
    mxerror(Y("File not found\n"));
  }

  mxexit(0);
}
static void
show_help() {
  mxinfo(Y("ebml_validor [options] input_file_name\n"
           "\n"
           "Options output and information control:\n"
           "\n"
           "  -s, --start <value>    Start parsing at file position value\n"
           "  -e, --end <value>      Stop parsing at file position value\n"
           "  -m, --master <value>   The EBML ID value (in hex) is a master\n"
           "  -M, --auto-masters     Use all of Matroska's master elements\n"
           "\n"
           "General options:\n"
           "\n"
           "  -h, --help             This help text\n"
           "  -V, --version          Print version information\n"));
  mxexit();
}
Beispiel #12
0
static void
show_help() {
  mxinfo(Y("vc1parser [options] input_file_name\n"
           "\n"
           "Options for output and information control:\n"
           "\n"
           "  -c, --checksum         Calculate and output checksums of each unit\n"
           "  -e, --entrypoints      Show the content of entry point headers\n"
           "  -f, --frames           Show basic frame header content\n"
           "  -s, --sequence-headers Show the content of sequence headers\n"
           "\n"
           "General options:\n"
           "\n"
           "  -h, --help             This help text\n"
           "  -V, --version          Print version information\n"));
  mxexit(0);
}
int
main(int argc,
     char **argv) {
  mtx_common_init("ebml_validator", argv[0]);

  init_element_names();
  init_master_information();

  std::vector<std::string> args = command_line_utf8(argc, argv);
  std::string file_name         = parse_args(args);

  try {
    parse_file(file_name);
  } catch (...) {
    mxerror(Y("File not found\n"));
  }

  mxexit();
}
Beispiel #14
0
int
main(int argc,
     char **argv) {
  mtx_common_init("mpls_dump", argv[0]);

  auto args = command_line_utf8(argc, argv);
  while (handle_common_cli_args(args, "-r"))
    ;

  auto file_name = parse_args(args);

  try {
    parse_file(file_name);
  } catch (mtx::mm_io::exception &) {
    mxerror(Y("File not found\n"));
  }

  mxexit(0);
}
Beispiel #15
0
static void
run(options_cptr &options) {
  console_kax_analyzer_cptr analyzer;

  try {
    if (!kax_analyzer_c::probe(options->m_file_name))
      mxerror(boost::format("The file '%1%' is not a Matroska file or it could not be found.\n") % options->m_file_name);

    analyzer = console_kax_analyzer_cptr(new console_kax_analyzer_c(options->m_file_name));
  } catch (...) {
    mxerror(boost::format("The file '%1%' could not be opened for read/write access.\n") % options->m_file_name);
  }

  mxinfo(Y("The file is analyzed.\n"));

  analyzer->set_show_progress(options->m_show_progress);

  if (!analyzer->process(options->m_parse_mode))
    mxerror(Y("This file could not be opened or parsed.\n"));

  options->find_elements(analyzer.get_object());
  options->validate();

  if (debugging_requested("dump_options")) {
    mxinfo("\nDumping options after file and element analysis\n\n");
    options->dump_info();
  }

  options->execute();

  mxinfo(Y("The changes are written to the file.\n"));

  write_changes(options, analyzer.get_object());

  mxinfo(Y("Done.\n"));

  mxexit(0);
}
Beispiel #16
0
static void
show_version() {
  mxinfo("ac3parser v" PACKAGE_VERSION "\n");
  mxexit();
}
Beispiel #17
0
static void
default_mxerror(unsigned int,
                std::string const &error) {
  mxmsg(MXMSG_ERROR, error);
  mxexit(2);
}
Beispiel #18
0
static void
show_version() {
  mxinfo("vc1parser v" VERSION "\n");
  mxexit(0);
}
Beispiel #19
0
static void
show_version() {
  mxinfo("ebml_validator v" VERSION "\n");
  mxexit(0);
}
static void
show_version() {
  mxinfo("ebml_validator v" PACKAGE_VERSION "\n");
  mxexit();
}
Beispiel #21
0
static void
show_version() {
  mxinfo("mpls_dump v" VERSION "\n");
  mxexit(0);
}
Beispiel #22
0
int
main(int argc,
     char *argv[]) {
  int maxlen;
  uint64_t size;
  unsigned char *buffer;
  char mode;
  std::string s, line;

  mtx_common_init("base64tool", argv[0]);

  set_usage();

  if (argc < 4)
    usage(0);

  mode = 0;
  if (!strcmp(argv[1], "encode"))
    mode = 'e';
  else if (!strcmp(argv[1], "decode"))
    mode = 'd';
  else
    mxerror(boost::format(Y("Invalid mode '%1%'.\n")) % argv[1]);

  maxlen = 72;
  if ((argc == 5) && (mode == 'e')) {
    if (!parse_number(argv[4], maxlen) || (maxlen < 4))
      mxerror(Y("Max line length must be >= 4.\n\n"));
  } else if ((argc > 5) || ((argc > 4) && (mode == 'd')))
    usage(2);

  maxlen = ((maxlen + 3) / 4) * 4;

  mm_io_cptr in, intext;
  try {
    in = mm_io_cptr(new mm_file_io_c(argv[2]));
    if (mode != 'e')
      intext = mm_io_cptr(new mm_text_io_c(in.get(), false));
  } catch (mtx::mm_io::exception &ex) {
    mxerror(boost::format(Y("The file '%1%' could not be opened for reading: %2%.\n")) % argv[2] % ex);
  }

  mm_io_cptr out;
  try {
    out = mm_write_buffer_io_c::open(argv[3], 128 * 1024);
  } catch (mtx::mm_io::exception &ex) {
    mxerror(boost::format(Y("The file '%1%' could not be opened for writing: %2%.\n")) % argv[3] % ex);
  }

  in->save_pos();
  in->setFilePointer(0, seek_end);
  size = in->getFilePointer();
  in->restore_pos();

  if (mode == 'e') {
    buffer = (unsigned char *)safemalloc(size);
    size = in->read(buffer, size);

    s = base64_encode(buffer, size, true, maxlen);
    safefree(buffer);

    out->write(s.c_str(), s.length());

  } else {

    while (intext->getline2(line)) {
      strip(line);
      s += line;
    }

    buffer = (unsigned char *)safemalloc(s.length() / 4 * 3 + 100);
    try {
      size = base64_decode(s, buffer);
    } catch(...) {
      mxerror(Y("The Base64 encoded data could not be decoded.\n"));
    }
    out->write(buffer, size);

    safefree(buffer);
  }

  mxinfo(Y("Done.\n"));

  mxexit(0);
}