diff --git a/src/common/common.cpp b/src/common/common.cpp index 5bd28ad4c..d04abf603 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -49,6 +49,7 @@ using namespace std; #include "common.h" +#include "hacks.h" int verbose = 1; @@ -599,6 +600,8 @@ void clear_list_of_unique_uint32() { bool is_unique_uint32(uint32_t number) { int i; + if (hack_engaged(ENGAGE_NO_VARIABLE_DATA)) + return true; for (i = 0; i < ru_numbers.size(); i++) if (ru_numbers[i] == number) return false; @@ -607,12 +610,20 @@ bool is_unique_uint32(uint32_t number) { } void add_unique_uint32(uint32_t number) { - ru_numbers.push_back(number); + if (hack_engaged(ENGAGE_NO_VARIABLE_DATA)) + ru_numbers.push_back(ru_numbers.size() + 1); + else + ru_numbers.push_back(number); } uint32_t create_unique_uint32() { uint32_t rnumber, half; + if (hack_engaged(ENGAGE_NO_VARIABLE_DATA)) { + ru_numbers.push_back(ru_numbers.size() + 1); + return ru_numbers.size(); + } + do { half = (uint32_t)(65535.0 * rand() / RAND_MAX); rnumber = half; @@ -1252,3 +1263,46 @@ string mxsprintf(const char *fmt, ...) { return dst; } + +static const char *mosu_hacks[] = { + ENGAGE_SPACE_AFTER_CHAPTERS, + ENGAGE_NO_CHAPTERS_IN_META_SEEK, + ENGAGE_NO_META_SEEK, + ENGAGE_LACING_XIPH, + ENGAGE_LACING_EBML, + ENGAGE_NATIVE_BFRAMES, + ENGAGE_NO_VARIABLE_DATA, + NULL +}; +static vector engaged_hacks; + +bool hack_engaged(const char *hack) { + uint32_t i; + + if (hack == NULL) + return false; + for (i = 0; i < engaged_hacks.size(); i++) + if (!strcmp(engaged_hacks[i], hack)) + return true; + + return false; +} + +void engage_hacks(const char *hacks) { + vector engage_args; + int aidx, hidx; + bool valid_hack; + + engage_args = split(hacks, ","); + for (aidx = 0; aidx < engage_args.size(); aidx++) { + valid_hack = false; + for (hidx = 0; mosu_hacks[hidx] != NULL; hidx++) + if (engage_args[aidx] == mosu_hacks[hidx]) { + valid_hack = true; + engaged_hacks.push_back(mosu_hacks[hidx]); + break; + } + if (!valid_hack) + mxerror("'%s' is not a valid hack.\n", engage_args[aidx].c_str()); + } +} diff --git a/src/common/common.h b/src/common/common.h index eba95eb3a..469ef0eee 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -184,6 +184,9 @@ bool MTX_DLL_API parse_double(const char *s, double &value); int MTX_DLL_API get_arg_len(const char *fmt, ...); int MTX_DLL_API get_varg_len(const char *fmt, va_list ap); +void MTX_DLL_API engage_hacks(const char *hacks); +bool MTX_DLL_API hack_engaged(const char *hack); + extern int MTX_DLL_API verbose; class MTX_DLL_API bit_cursor_c { diff --git a/src/hacks.h b/src/hacks.h index b85875fe9..5408afa08 100644 --- a/src/hacks.h +++ b/src/hacks.h @@ -29,6 +29,7 @@ #define ENGAGE_LACING_XIPH "lacing_xiph" #define ENGAGE_LACING_EBML "lacing_ebml" #define ENGAGE_NATIVE_BFRAMES "native_bframes" +#define ENGAGE_NO_VARIABLE_DATA "no_variable_data" bool hack_engaged(const char *hack); diff --git a/src/mkvmerge.cpp b/src/mkvmerge.cpp index bf8c927ba..6c66a20c8 100644 --- a/src/mkvmerge.cpp +++ b/src/mkvmerge.cpp @@ -197,29 +197,6 @@ mm_io_c *out = NULL; bitvalue_c seguid_prev(128), seguid_current(128), seguid_next(128); bitvalue_c *seguid_link_previous = NULL, *seguid_link_next = NULL; -const char *mosu_hacks[] = { - ENGAGE_SPACE_AFTER_CHAPTERS, - ENGAGE_NO_CHAPTERS_IN_META_SEEK, - ENGAGE_NO_META_SEEK, - ENGAGE_LACING_XIPH, - ENGAGE_LACING_EBML, - ENGAGE_NATIVE_BFRAMES, - NULL -}; -vector engaged_hacks; - -bool hack_engaged(const char *hack) { - uint32_t i; - - if (hack == NULL) - return false; - for (i = 0; i < engaged_hacks.size(); i++) - if (!strcmp(engaged_hacks[i], hack)) - return true; - - return false; -} - file_type_t file_types[] = {{"---", TYPEUNKNOWN, ""}, {"demultiplexers:", -1, ""}, @@ -986,22 +963,31 @@ static void render_headers(mm_io_c *rout, bool last_file, bool first_file) { cstr_to_UTFstring(version.c_str()); *((EbmlUnicodeString *)&GetChild(*kax_infos)) = cstr_to_UTFstring(VERSIONINFO); - GetChild(*kax_infos).SetEpochDate(time(NULL)); + if (!hack_engaged(ENGAGE_NO_VARIABLE_DATA)) + GetChild(*kax_infos).SetEpochDate(time(NULL)); + else + GetChild(*kax_infos).SetEpochDate(0); if (segment_title.length() > 0) *((EbmlUnicodeString *)&GetChild(*kax_infos)) = cstrutf8_to_UTFstring(segment_title.c_str()); // Generate the segment UIDs. - if (first_file) { - seguid_current.generate_random(); - if (!last_file) - seguid_next.generate_random(); + if (!hack_engaged(ENGAGE_NO_VARIABLE_DATA)) { + if (first_file) { + seguid_current.generate_random(); + if (!last_file) + seguid_next.generate_random(); + } else { + seguid_prev = seguid_current; + seguid_current = seguid_next; + if (!last_file) + seguid_next.generate_random(); + } } else { - seguid_prev = seguid_current; - seguid_current = seguid_next; - if (!last_file) - seguid_next.generate_random(); + memset(seguid_current.data(), 0, 128 / 8); + memset(seguid_prev.data(), 0, 128 / 8); + memset(seguid_next.data(), 0, 128 / 8); } // Set the segment UIDs. @@ -1371,24 +1357,9 @@ static void parse_args(int argc, char **argv) { // Global options if (!strcmp(this_arg, "--engage")) { - vector engage_args; - int aidx, hidx; - bool valid_hack; - if (next_arg == NULL) mxerror("'--engage' lacks its argument.\n"); - engage_args = split(next_arg, ","); - for (aidx = 0; aidx < engage_args.size(); aidx++) { - valid_hack = false; - for (hidx = 0; mosu_hacks[hidx] != NULL; hidx++) - if (engage_args[aidx] == mosu_hacks[hidx]) { - valid_hack = true; - engaged_hacks.push_back(mosu_hacks[hidx]); - break; - } - if (!valid_hack) - mxerror("'%s' is not a valid hack.\n", engage_args[aidx].c_str()); - } + engage_hacks(next_arg); i++; } else if (!strcmp(this_arg, "-q"))