~ubuntu-branches/ubuntu/wily/mkvtoolnix/wily

« back to all changes in this revision

Viewing changes to src/common/hacks.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Clément Stenac
  • Date: 2005-09-07 19:54:42 UTC
  • Revision ID: james.westby@ubuntu.com-20050907195442-funmigmy8ua340hq
Tags: upstream-1.5.6
Import upstream version 1.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   mkvmerge -- utility for splicing together matroska files
 
3
   from component media subtypes
 
4
 
 
5
   Distributed under the GPL
 
6
   see the file COPYING for details
 
7
   or visit http://www.gnu.org/copyleft/gpl.html
 
8
 
 
9
   $Id: hacks.cpp 3071 2005-09-06 09:47:27Z mosu $
 
10
 
 
11
   hacks :)
 
12
 
 
13
   Written by Moritz Bunkus <moritz@bunkus.org>.
 
14
*/
 
15
 
 
16
#include "os.h"
 
17
 
 
18
#include <string.h>
 
19
 
 
20
#include <string>
 
21
#include <vector>
 
22
 
 
23
using namespace std;
 
24
 
 
25
#include "base64.h"
 
26
#include "common.h"
 
27
#include "hacks.h"
 
28
 
 
29
static const char *mosu_hacks[] = {
 
30
  ENGAGE_SPACE_AFTER_CHAPTERS,
 
31
  ENGAGE_NO_CHAPTERS_IN_META_SEEK,
 
32
  ENGAGE_NO_META_SEEK,
 
33
  ENGAGE_LACING_XIPH,
 
34
  ENGAGE_LACING_EBML,
 
35
  ENGAGE_NATIVE_MPEG4,
 
36
  ENGAGE_NO_VARIABLE_DATA,
 
37
  ENGAGE_NO_DEFAULT_HEADER_VALUES,
 
38
  ENGAGE_FORCE_PASSTHROUGH_PACKETIZER,
 
39
  ENGAGE_AVC_USE_BFRAMES,
 
40
  ENGAGE_WRITE_HEADERS_TWICE,
 
41
  ENGAGE_ALLOW_AVC_IN_VFW_MODE,
 
42
  ENGAGE_KEEP_BITSTREAM_AR_INFO,
 
43
  NULL
 
44
};
 
45
static vector<string> engaged_hacks;
 
46
 
 
47
bool
 
48
hack_engaged(const string &hack) {
 
49
  vector<string>::const_iterator hit;
 
50
 
 
51
  foreach(hit, engaged_hacks)
 
52
    if (*hit == hack)
 
53
      return true;
 
54
 
 
55
  return false;
 
56
}
 
57
 
 
58
void
 
59
engage_hacks(const string &hacks) {
 
60
  vector<string> engage_args;
 
61
  int aidx, hidx;
 
62
  bool valid_hack;
 
63
 
 
64
  engage_args = split(hacks, ",");
 
65
  for (aidx = 0; aidx < engage_args.size(); aidx++)
 
66
    if (engage_args[aidx] == "list") {
 
67
      mxinfo("Valid hacks are:\n");
 
68
      for (hidx = 0; mosu_hacks[hidx] != NULL; hidx++)
 
69
        mxinfo("%s\n", mosu_hacks[hidx]);
 
70
      mxexit(0);
 
71
    } else if (engage_args[aidx] == "cow") {
 
72
      const string initial = "ICAgICAgICAgIChfXykKICAgICAgICAgICgqKikg"
 
73
        "IE9oIGhvbmV5LCB0aGF0J3Mgc28gc3dlZXQhCiAgIC8tLS0tLS0tXC8gICBPZiB"
 
74
        "jb3Vyc2UgSSdsbCBtYXJyeSB5b3UhCiAgLyB8ICAgICB8fAogKiAgfHwtLS0tfH"
 
75
        "wKICAgIF5eICAgIF5eCg==";
 
76
      char correction[200];
 
77
      memset(correction, 0, 200);
 
78
      base64_decode(initial, (unsigned char *)correction);
 
79
      mxinfo("%s", correction);
 
80
      mxexit(0);
 
81
    }
 
82
  for (aidx = 0; aidx < engage_args.size(); aidx++) {
 
83
    valid_hack = false;
 
84
    for (hidx = 0; mosu_hacks[hidx] != NULL; hidx++)
 
85
      if (engage_args[aidx] == mosu_hacks[hidx]) {
 
86
        valid_hack = true;
 
87
        engaged_hacks.push_back(mosu_hacks[hidx]);
 
88
        break;
 
89
      }
 
90
    if (!valid_hack)
 
91
      mxerror("'%s' is not a valid hack.\n", engage_args[aidx].c_str());
 
92
  }
 
93
}