debugging: refactor functions into debugging_c; use debugging_option_c more

This commit is contained in:
Moritz Bunkus 2013-12-08 16:34:37 +01:00
parent 9722ecb10f
commit af8e118af2
71 changed files with 223 additions and 318 deletions

View File

@ -340,11 +340,11 @@ int
ac3::parser_c::find_consecutive_frames(unsigned char const *buffer,
size_t buffer_size,
size_t num_required_headers) {
static auto s_debug = debugging_option_c{"ac3_consecutive_frames"};
size_t base = 0;
bool debug = debugging_requested("ac3_consecutive_frames");
do {
mxdebug_if(debug, boost::format("Starting search for %2% headers with base %1%, buffer size %3%\n") % base % num_required_headers % buffer_size);
mxdebug_if(s_debug, boost::format("Starting search for %2% headers with base %1%, buffer size %3%\n") % base % num_required_headers % buffer_size);
size_t position = base;
@ -352,7 +352,7 @@ ac3::parser_c::find_consecutive_frames(unsigned char const *buffer,
while (((position + 8) < buffer_size) && !first_frame.decode_header(&buffer[position], buffer_size - position))
++position;
mxdebug_if(debug, boost::format("First frame at %1% valid %2%\n") % position % first_frame.m_valid);
mxdebug_if(s_debug, boost::format("First frame at %1% valid %2%\n") % position % first_frame.m_valid);
if (!first_frame.m_valid)
return -1;
@ -368,27 +368,27 @@ ac3::parser_c::find_consecutive_frames(unsigned char const *buffer,
break;
if (8 > current_frame.m_bytes) {
mxdebug_if(debug, boost::format("Current frame at %1% has invalid size %2%\n") % offset % current_frame.m_bytes);
mxdebug_if(s_debug, boost::format("Current frame at %1% has invalid size %2%\n") % offset % current_frame.m_bytes);
break;
}
if ( (current_frame.m_bs_id != first_frame.m_bs_id)
&& (current_frame.m_channels != first_frame.m_channels)
&& (current_frame.m_sample_rate != first_frame.m_sample_rate)) {
mxdebug_if(debug,
mxdebug_if(s_debug,
boost::format("Current frame at %7% differs from first frame. (first/current) BS ID: %1%/%2% channels: %3%/%4% sample rate: %5%/%6%\n")
% first_frame.m_bs_id % current_frame.m_bs_id % first_frame.m_channels % current_frame.m_channels % first_frame.m_sample_rate % current_frame.m_sample_rate % offset);
break;
}
mxdebug_if(debug, boost::format("Current frame at %1% equals first frame, found %2%\n") % offset % (num_headers_found + 1));
mxdebug_if(s_debug, boost::format("Current frame at %1% equals first frame, found %2%\n") % offset % (num_headers_found + 1));
++num_headers_found;
offset += current_frame.m_bytes;
}
if (num_headers_found == num_required_headers) {
mxdebug_if(debug, boost::format("Found required number of headers at %1%\n") % position);
mxdebug_if(s_debug, boost::format("Found required number of headers at %1%\n") % position);
return position;
}

View File

@ -24,7 +24,7 @@ script_parser_c::script_parser_c(memory_cptr const &mem)
, m_data{*mem.get()}
, m_in_meta_data{}
, m_level{}
, m_debug{debugging_requested("amf|amf_script_parser")}
, m_debug{"amf|amf_script_parser"}
{
}

View File

@ -64,7 +64,7 @@ private:
bool m_in_meta_data;
unsigned int m_level;
bool m_debug;
debugging_option_c m_debug;
public:
script_parser_c(memory_cptr const &mem);

View File

@ -71,7 +71,7 @@ clpi::program_stream_t::dump() {
clpi::parser_c::parser_c(const std::string &file_name)
: m_file_name(file_name)
, m_ok(false)
, m_debug(debugging_requested("clpi") || debugging_requested("clpi_parser"))
, m_debug{"clpi|clpi_parser"}
{
}

View File

@ -57,7 +57,8 @@ namespace clpi {
class parser_c {
protected:
std::string m_file_name;
bool m_ok, m_debug;
bool m_ok;
debugging_option_c m_debug;
size_t m_sequence_info_start, m_program_info_start;

View File

@ -189,7 +189,7 @@ handle_common_cli_args(std::vector<std::string> &args,
if ((i + 1) == args.size())
mxerror("Missing argument for '--debug'.\n");
request_debugging(args[i + 1]);
debugging_c::request(args[i + 1]);
args.erase(args.begin() + i, args.begin() + i + 2);
} else if (args[i] == "--engage") {

View File

@ -165,7 +165,7 @@ mtx_common_init(std::string const &program_name) {
srand(time(nullptr));
init_debugging();
debugging_c::init();
init_hacks();
init_locales();

View File

@ -44,7 +44,7 @@ url_retriever_c::url_retriever_c()
: m_connect_timeout(10)
, m_download_timeout(0)
, m_total_size(-1)
, m_debug(debugging_requested("curl|url_retriever"))
, m_debug{"curl|url_retriever"}
{
}

View File

@ -33,7 +33,7 @@ protected:
std::string *m_data;
int m_connect_timeout, m_download_timeout;
int64_t m_total_size;
bool m_debug;
debugging_option_c m_debug;
public:
url_retriever_c();

View File

@ -16,17 +16,18 @@
#include "common/logger.h"
#include "common/strings/editing.h"
static std::map<std::string, std::string> s_debugging_options;
std::unordered_map<std::string, std::string> debugging_c::ms_debugging_options;
bool debugging_c::ms_send_to_logger = false;
bool
debugging_requested(const char *option,
std::string *arg) {
std::vector<std::string> options = split(option, "|");
debugging_c::requested(const char *option,
std::string *arg) {
auto options = split(option, "|");
for (auto &current_option : options) {
std::map<std::string, std::string>::iterator option_ptr = s_debugging_options.find(current_option);
auto option_ptr = ms_debugging_options.find(current_option);
if (s_debugging_options.end() != option_ptr) {
if (ms_debugging_options.end() != option_ptr) {
if (arg)
*arg = option_ptr->second;
return true;
@ -36,45 +37,54 @@ debugging_requested(const char *option,
return false;
}
bool
debugging_requested(const std::string &option,
std::string *arg) {
return debugging_requested(option.c_str(), arg);
}
void
request_debugging(const std::string &options,
bool enable) {
std::vector<std::string> all_options = split(options);
debugging_c::request(const std::string &options,
bool enable) {
auto all_options = split(options);
for (auto &one_option : all_options) {
std::vector<std::string> parts = split(one_option, "=", 2);
auto parts = split(one_option, "=", 2);
if (!parts[0].size())
continue;
if (parts[0] == "!")
s_debugging_options.clear();
ms_debugging_options.clear();
else if (parts[0] == "to_logger")
debugging_c::send_to_logger(true);
else if (!enable)
s_debugging_options.erase(parts[0]);
ms_debugging_options.erase(parts[0]);
else
s_debugging_options[parts[0]] = 1 == parts.size() ? std::string("") : parts[1];
ms_debugging_options[parts[0]] = 1 == parts.size() ? std::string("") : parts[1];
}
debugging_option_c::invalidate_cache();
}
void
init_debugging() {
std::vector<std::string> env_vars = { "MKVTOOLNIX_DEBUG", "MTX_DEBUG", balg::to_upper_copy(get_program_name()) + "_DEBUG" };
debugging_c::init() {
auto env_vars = std::vector<std::string>{ "MKVTOOLNIX_DEBUG", "MTX_DEBUG", balg::to_upper_copy(get_program_name()) + "_DEBUG" };
for (auto &name : env_vars) {
auto value = getenv(name.c_str());
if (value)
request_debugging(value);
request(value);
}
}
void
debugging_c::send_to_logger(bool enable) {
ms_send_to_logger = enable;
}
void
debugging_c::output(std::string const &msg) {
if (ms_send_to_logger)
log_it(msg);
else
mxmsg(MXMSG_INFO, msg);
}
// ------------------------------------------------------------
std::vector<debugging_option_c::option_c> debugging_option_c::ms_registered_options;
size_t
@ -93,18 +103,3 @@ debugging_option_c::invalidate_cache() {
for (auto &opt : ms_registered_options)
opt.m_requested = boost::logic::indeterminate;
}
bool debugging_c::ms_send_to_logger = false;
void
debugging_c::send_to_logger(bool enable) {
ms_send_to_logger = enable;
}
void
debugging_c::output(std::string const &msg) {
if (ms_send_to_logger)
log_it(msg);
else
mxmsg(MXMSG_INFO, msg);
}

View File

@ -16,12 +16,27 @@
#include "common/common_pch.h"
bool debugging_requested(const char *option, std::string *arg = nullptr);
bool debugging_requested(const std::string &option, std::string *arg = nullptr);
void request_debugging(const std::string &options, bool enable = true);
void init_debugging();
#include <unordered_map>
int parse_debug_interval_arg(const std::string &option, int default_value = 1000, int invalid_value = -1);
class debugging_c {
protected:
static bool ms_send_to_logger;
static std::unordered_map<std::string, std::string> ms_debugging_options;
public:
static void send_to_logger(bool enable);
static void output(std::string const &msg);
static void output(boost::format const &msg) {
output(msg.str());
}
static bool requested(const char *option, std::string *arg = nullptr);
static bool requested(const std::string &option, std::string *arg = nullptr) {
return requested(option.c_str(), arg);
}
static void request(const std::string &options, bool enable = true);
static void init();
};
class debugging_option_c {
struct option_c {
@ -36,14 +51,14 @@ class debugging_option_c {
bool get() {
if (boost::logic::indeterminate(m_requested))
m_requested = debugging_requested(m_option);
m_requested = debugging_c::requested(m_option);
return m_requested;
}
};
protected:
size_t m_registered_idx;
mutable size_t m_registered_idx;
std::string m_option;
private:
@ -56,11 +71,11 @@ public:
{
}
operator bool() {
operator bool() const {
if (m_registered_idx == std::numeric_limits<size_t>::max())
m_registered_idx = register_option(m_option);
return ms_registered_options[m_registered_idx].get();
return ms_registered_options.at(m_registered_idx).get();
}
public:
@ -68,18 +83,6 @@ public:
static void invalidate_cache();
};
class debugging_c {
protected:
static bool ms_send_to_logger;
public:
static void send_to_logger(bool enable);
static void output(std::string const &msg);
static void output(boost::format const &msg) {
output(msg.str());
}
};
#define mxdebug(msg) debugging_c::output((boost::format("Debug> %1%:%2%: %3%") % __FILE__ % __LINE__ % (msg)).str())
#define mxdebug_if(condition, msg) \

View File

@ -249,6 +249,8 @@ int
find_consecutive_dts_headers(const unsigned char *buf,
unsigned int size,
unsigned int num) {
static auto s_debug = debugging_option_c{"dts_detection"};
dts_header_s dts_header, new_header;
int pos = find_dts_header(buf, size, &dts_header, false);
@ -260,10 +262,9 @@ find_consecutive_dts_headers(const unsigned char *buf,
return pos;
unsigned int base = pos;
bool debug = debugging_requested("dts_detection");
do {
mxdebug_if(debug, boost::format("find_cons_dts_h: starting with base at %1%\n") % base);
mxdebug_if(s_debug, boost::format("find_cons_dts_h: starting with base at %1%\n") % base);
int offset = dts_header.frame_byte_size;
unsigned int i;
@ -274,7 +275,7 @@ find_consecutive_dts_headers(const unsigned char *buf,
pos = find_dts_header(&buf[base + offset], size - base - offset, &new_header, false);
if (0 == pos) {
if (new_header == dts_header) {
mxdebug_if(debug, boost::format("find_cons_dts_h: found good header %1%\n") % i);
mxdebug_if(s_debug, boost::format("find_cons_dts_h: found good header %1%\n") % i);
offset += new_header.frame_byte_size;
continue;
} else

View File

@ -66,7 +66,7 @@ kax_analyzer_c::kax_analyzer_c(std::string file_name)
, m_file(nullptr)
, m_close_file(true)
, m_stream(nullptr)
, m_debugging_requested(debugging_requested("kax_analyzer"))
, m_debugging_requested{"kax_analyzer"}
{
}
@ -75,7 +75,7 @@ kax_analyzer_c::kax_analyzer_c(mm_file_io_c *file)
, m_file(file)
, m_close_file(false)
, m_stream(nullptr)
, m_debugging_requested(debugging_requested("kax_analyzer"))
, m_debugging_requested{"kax_analyzer"}
{
}
@ -110,7 +110,7 @@ kax_analyzer_c::_log_debug_message(const std::string &message) {
bool
kax_analyzer_c::analyzer_debugging_requested(const std::string &section) {
return m_debugging_requested || debugging_requested(std::string("kax_analyzer_") + section);
return m_debugging_requested || debugging_c::requested(std::string("kax_analyzer_") + section);
}
void
@ -316,13 +316,13 @@ kax_analyzer_c::read_element(kax_analyzer_data_c *element_data) {
return e;
}
#define call_and_validate(function_call, hook_name) \
function_call; \
debug_dump_elements_maybe(hook_name); \
validate_data_structures(hook_name); \
if (analyzer_debugging_requested("verify")) \
verify_data_structures_against_file(hook_name); \
if (debugging_requested("kax_analyzer_" hook_name "_break")) \
#define call_and_validate(function_call, hook_name) \
function_call; \
debug_dump_elements_maybe(hook_name); \
validate_data_structures(hook_name); \
if (analyzer_debugging_requested("verify")) \
verify_data_structures_against_file(hook_name); \
if (debugging_c::requested("kax_analyzer_" hook_name "_break")) \
return uer_success;
kax_analyzer_c::update_element_result_e

View File

@ -98,7 +98,7 @@ private:
std::shared_ptr<KaxSegment> m_segment;
std::map<int64_t, bool> m_meta_seeks_by_position;
EbmlStream *m_stream;
bool m_debugging_requested;
debugging_option_c m_debugging_requested;
public: // Static functions
static bool probe(std::string file_name);

View File

@ -33,8 +33,8 @@ kax_file_c::kax_file_c(mm_io_cptr &in)
, m_timecode_scale{TIMECODE_SCALE}
, m_last_timecode{-1}
, m_es(new EbmlStream(*m_in))
, m_debug_read_next(debugging_requested("kax_file|kax_file_read_next"))
, m_debug_resync(debugging_requested( "kax_file|kax_file_resync"))
, m_debug_read_next{"kax_file|kax_file_read_next"}
, m_debug_resync{ "kax_file|kax_file_resync"}
{
}

View File

@ -32,7 +32,7 @@ protected:
int64_t m_timecode_scale, m_last_timecode;
std::shared_ptr<EbmlStream> m_es;
bool m_debug_read_next, m_debug_resync;
debugging_option_c m_debug_read_next, m_debug_resync;
public:
kax_file_c(mm_io_cptr &in);

View File

@ -6,6 +6,8 @@
#include "common/mm_mpls_multi_file_io.h"
#include "common/strings/formatting.h"
debugging_option_c mm_mpls_multi_file_io_c::ms_debug{"mpls|mpls_multi_io"};
mm_mpls_multi_file_io_c::mm_mpls_multi_file_io_c(std::vector<bfs::path> const &file_names,
std::string const &display_file_name,
mtx::mpls::parser_cptr const &mpls_parser)
@ -35,11 +37,10 @@ mm_mpls_multi_file_io_c::open_multi(std::string const &display_file_name) {
mm_io_cptr
mm_mpls_multi_file_io_c::open_multi(mm_io_c *in) {
bool debug = debugging_requested("mpls|mpls_multi_io");
auto mpls_parser = std::make_shared<mtx::mpls::parser_c>();
if (!mpls_parser->parse(in) || mpls_parser->get_playlist().items.empty()) {
mxdebug_if(debug, boost::format("Not handling because %1%\n") % (mpls_parser->is_ok() ? "playlist is empty" : "parser not OK"));
mxdebug_if(ms_debug, boost::format("Not handling because %1%\n") % (mpls_parser->is_ok() ? "playlist is empty" : "parser not OK"));
return mm_io_cptr{};
}
@ -51,7 +52,7 @@ mm_mpls_multi_file_io_c::open_multi(mm_io_c *in) {
auto have_stream_dir = bfs::exists(stream_dir);
mxdebug_if(debug, boost::format("MPLS dir: %1% have stream dir: %2% stream dir: %3%\n") % mpls_dir.string() % have_stream_dir % stream_dir.string());
mxdebug_if(ms_debug, boost::format("MPLS dir: %1% have stream dir: %2% stream dir: %3%\n") % mpls_dir.string() % have_stream_dir % stream_dir.string());
auto find_file = [mpls_dir,stream_dir,have_stream_dir](mtx::mpls::play_item_t const &item) -> bfs::path {
if (have_stream_dir) {
@ -78,7 +79,7 @@ mm_mpls_multi_file_io_c::open_multi(mm_io_c *in) {
for (auto const &item : mpls_parser->get_playlist().items) {
auto file = find_file(item);
mxdebug_if(debug, boost::format("Item clip ID: %1% codec ID: %2%: have file? %3% file: %4%\n") % item.clip_id % item.codec_id % !file.empty() % file.string());
mxdebug_if(ms_debug, boost::format("Item clip ID: %1% codec ID: %2%: have file? %3% file: %4%\n") % item.clip_id % item.codec_id % !file.empty() % file.string());
if (file.empty() || file_names_seen[file.string()])
continue;
@ -86,7 +87,7 @@ mm_mpls_multi_file_io_c::open_multi(mm_io_c *in) {
file_names_seen[file.string()] = true;
}
mxdebug_if(debug, boost::format("Number of files left: %1%\n") % file_names.size());
mxdebug_if(ms_debug, boost::format("Number of files left: %1%\n") % file_names.size());
if (file_names.empty())
return mm_io_cptr{};

View File

@ -23,6 +23,9 @@ class mm_mpls_multi_file_io_c: public mm_multi_file_io_c {
protected:
mtx::mpls::parser_cptr m_mpls_parser;
protected:
static debugging_option_c ms_debug;
public:
mm_mpls_multi_file_io_c(const std::vector<bfs::path> &file_names, std::string const &display_file_name, mtx::mpls::parser_cptr const &mpls_parser);
virtual ~mm_mpls_multi_file_io_c();

View File

@ -29,8 +29,8 @@ mm_read_buffer_io_c::mm_read_buffer_io_c(mm_io_c *in,
, m_offset(0)
, m_size(buffer_size)
, m_buffering(true)
, m_debug_seek(debugging_requested("read_buffer_io") || debugging_requested("read_buffer_io_read"))
, m_debug_read(debugging_requested("read_buffer_io") || debugging_requested("read_buffer_io_read"))
, m_debug_seek{"read_buffer_io|read_buffer_io_read"}
, m_debug_read{"read_buffer_io|read_buffer_io_read"}
{
setFilePointer(0, seek_beginning);
}

View File

@ -28,7 +28,8 @@ protected:
size_t m_fill;
int64_t m_offset;
const size_t m_size;
bool m_buffering, m_debug_seek, m_debug_read;
bool m_buffering;
debugging_option_c m_debug_seek, m_debug_read;
public:
mm_read_buffer_io_c(mm_io_c *in, size_t buffer_size = 1 << 12, bool delete_in = true);

View File

@ -25,8 +25,8 @@ mm_write_buffer_io_c::mm_write_buffer_io_c(mm_io_c *out,
, m_buffer(m_af_buffer->get_buffer())
, m_fill(0)
, m_size(buffer_size)
, m_debug_seek( debugging_requested("write_buffer_io") || debugging_requested("write_buffer_io_read"))
, m_debug_write(debugging_requested("write_buffer_io") || debugging_requested("write_buffer_io_write"))
, m_debug_seek{ "write_buffer_io|write_buffer_io_read"}
, m_debug_write{"write_buffer_io|write_buffer_io_write"}
{
}

View File

@ -25,7 +25,7 @@ protected:
unsigned char *m_buffer;
size_t m_fill;
const size_t m_size;
bool m_debug_seek, m_debug_write;
debugging_option_c m_debug_seek, m_debug_write;
public:
mm_write_buffer_io_c(mm_io_c *out, size_t buffer_size, bool delete_out = true);

View File

@ -978,24 +978,24 @@ mpeg4::p10::avc_es_parser_c::avc_es_parser_c()
, m_have_incomplete_frame(false)
, m_ignore_nalu_size_length_errors(false)
, m_discard_actual_frames(false)
, m_debug_keyframe_detection(debugging_requested("avc_parser|avc_keyframe_detection"))
, m_debug_nalu_types( debugging_requested("avc_parser|avc_nalu_types"))
, m_debug_timecodes( debugging_requested("avc_parser|avc_timecodes"))
, m_debug_sps_info( debugging_requested("avc_parser|avc_sps|avc_sps_info"))
, m_debug_keyframe_detection{"avc_parser|avc_keyframe_detection"}
, m_debug_nalu_types{ "avc_parser|avc_nalu_types"}
, m_debug_timecodes{ "avc_parser|avc_timecodes"}
, m_debug_sps_info{ "avc_parser|avc_sps|avc_sps_info"}
{
if (m_debug_nalu_types)
init_nalu_names();
}
mpeg4::p10::avc_es_parser_c::~avc_es_parser_c() {
mxdebug_if(debugging_requested("avc_statistics"),
mxdebug_if(debugging_c::requested("avc_statistics"),
boost::format("AVC statistics: #frames: out %1% discarded %2% #timecodes: in %3% generated %4% discarded %5% num_fields: %6% num_frames: %7%\n")
% m_stats.num_frames_out % m_stats.num_frames_discarded % m_stats.num_timecodes_in % m_stats.num_timecodes_generated % m_stats.num_timecodes_discarded
% m_stats.num_field_slices % m_stats.num_frame_slices);
mxdebug_if(m_debug_timecodes, boost::format("stream_position %1% parsed_position %2%\n") % m_stream_position % m_parsed_position);
if (!debugging_requested("avc_num_slices_by_type"))
if (!debugging_c::requested("avc_num_slices_by_type"))
return;
static const char *s_type_names[] = {

View File

@ -263,7 +263,7 @@ protected:
bool m_ignore_nalu_size_length_errors, m_discard_actual_frames;
bool m_debug_keyframe_detection, m_debug_nalu_types, m_debug_timecode_statistics, m_debug_timecodes, m_debug_sps_info;
debugging_option_c m_debug_keyframe_detection, m_debug_nalu_types, m_debug_timecodes, m_debug_sps_info;
std::map<int, std::string> m_nalu_names_by_type;
struct stats_t {

View File

@ -104,7 +104,7 @@ stream_t::dump(std::string const &type)
parser_c::parser_c()
: m_ok{}
, m_debug{debugging_requested("mpls")}
, m_debug{"mpls"}
, m_header(header_t())
{
}

View File

@ -82,7 +82,8 @@ struct playlist_t {
class parser_c {
protected:
bool m_ok, m_debug;
bool m_ok;
debugging_option_c m_debug;
header_t m_header;
playlist_t m_playlist;

View File

@ -115,7 +115,7 @@ translation_c::look_up_translation(int language_id, int sub_language_id) {
});
int idx = ptr == ms_available_translations.end() ? -1 : std::distance(ms_available_translations.begin(), ptr);
mxdebug_if(debugging_requested("locale"), boost::format("look_up_translation for 0x%|1$04x|/0x%|2$02x|: %3%\n") % language_id % sub_language_id % idx);
mxdebug_if(debugging_c::requested("locale"), boost::format("look_up_translation for 0x%|1$04x|/0x%|2$02x|: %3%\n") % language_id % sub_language_id % idx);
return idx;
}
@ -123,7 +123,7 @@ translation_c::look_up_translation(int language_id, int sub_language_id) {
std::string
translation_c::get_default_ui_locale() {
std::string locale;
bool debug = debugging_requested("locale");
bool debug = debugging_c::requested("locale");
#if defined(HAVE_LIBINTL_H)
# if defined(SYS_WINDOWS)
@ -185,7 +185,7 @@ translation_c::set_active_translation(const std::string &locale) {
int idx = look_up_translation(locale);
ms_active_translation_idx = std::max(idx, 0);
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[translation_c::set_active_translation() active_translation_idx %1% for locale %2%]\n") % ms_active_translation_idx % locale);
}
@ -227,21 +227,21 @@ void
init_locales(std::string locale) {
translation_c::initialize_available_translations();
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[init_locales start: locale %1%]\n") % locale);
std::string locale_dir;
std::string default_locale = translation_c::get_default_ui_locale();
if (-1 == translation_c::look_up_translation(locale)) {
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[init_locales lookup failed; clearing locale]\n"));
locale = "";
}
if (locale.empty()) {
locale = default_locale;
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[init_locales setting to default locale %1%]\n") % locale);
}
@ -291,11 +291,11 @@ init_locales(std::string locale) {
}
} catch (mtx::locale_string_format_x &error) {
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[init_locales format error in %1%]\n") % error.error());
}
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[init_locales chosen locale %1%]\n") % chosen_locale);
// Hard fallback to "C" locale if no suitable locale was
@ -317,7 +317,7 @@ init_locales(std::string locale) {
# if defined(SYS_APPLE)
int result = setenv("LC_MESSAGES", chosen_locale.c_str(), 1);
if (debugging_requested("locale"))
if (debugging_c::requested("locale"))
mxinfo(boost::format("[init_locales setenv() return code: %1%]\n") % result);
# endif

View File

@ -38,7 +38,7 @@ version_number_t::version_number_t(const std::string &s)
{
memset(parts, 0, 5 * sizeof(unsigned int));
if (debugging_requested("version_check"))
if (debugging_c::requested("version_check"))
mxinfo(boost::format("version check: Parsing %1%\n") % s);
// Match the following:
@ -73,7 +73,7 @@ version_number_t::version_number_t(const std::string &s)
valid = true;
if (debugging_requested("version_check"))
if (debugging_c::requested("version_check"))
mxinfo(boost::format("version check: parse OK; result: %1%\n") % to_string());
}
@ -157,7 +157,7 @@ get_current_version() {
#if defined(HAVE_CURL_EASY_H)
static mtx::xml::document_cptr
retrieve_and_parse_xml(std::string const &url) {
bool debug = debugging_requested("version_check|releases_info|curl");
bool debug = debugging_c::requested("version_check|releases_info|curl");
std::string data;
auto result = url_retriever_c().set_timeout(10, 20).retrieve(url, data);
@ -190,9 +190,9 @@ retrieve_and_parse_xml(std::string const &url) {
mtx_release_version_t
get_latest_release_version() {
bool debug = debugging_requested("version_check|curl");
bool debug = debugging_c::requested("version_check|curl");
std::string url = MTX_VERSION_CHECK_URL;
debugging_requested("version_check_url", &url);
debugging_c::requested("version_check_url", &url);
mxdebug_if(debug, boost::format("Update check started with URL %1%\n") % url);
@ -229,7 +229,7 @@ get_latest_release_version() {
mtx::xml::document_cptr
get_releases_info() {
std::string url = MTX_RELEASES_INFO_URL;
debugging_requested("releases_info_url", &url);
debugging_c::requested("releases_info_url", &url);
return retrieve_and_parse_xml(url + ".gz");
}

View File

@ -53,7 +53,7 @@ ebml_chapters_converter_c::setup_maps() {
reverse_debug_to_tag_name_map();
if (debugging_requested("ebml_converter_semantics"))
if (debugging_c::requested("ebml_converter_semantics"))
dump_semantics("Chapters");
}

View File

@ -352,7 +352,7 @@ ebml_converter_c::to_ebml(std::string const &file_name,
ebml_root->Remove(0);
if (debugging_requested("ebml_converter"))
if (debugging_c::requested("ebml_converter"))
dump_ebml_elements(master, true);
return ebml_master_cptr{master};

View File

@ -50,7 +50,7 @@ ebml_segmentinfo_converter_c::setup_maps() {
reverse_debug_to_tag_name_map();
if (debugging_requested("ebml_converter_semantics"))
if (debugging_c::requested("ebml_converter_semantics"))
dump_semantics("Info");
}

View File

@ -49,7 +49,7 @@ ebml_tags_converter_c::setup_maps() {
reverse_debug_to_tag_name_map();
if (debugging_requested("ebml_converter_semantics"))
if (debugging_c::requested("ebml_converter_semantics"))
dump_semantics("Tags");
}

View File

@ -359,7 +359,7 @@ xtr_oggopus_c::xtr_oggopus_c(const std::string &codec_id,
: xtr_oggbase_c{codec_id, tid, tspec}
, m_position{timecode_c::ns(0)}
{
m_debug = debugging_requested("opus|opus_extrator");
m_debug = debugging_c::requested("opus|opus_extrator");
}
void

View File

@ -117,7 +117,7 @@ avi_reader_c::read_headers() {
verify_video_track();
parse_subtitle_chunks();
if (debugging_requested("avi_dump_video_index"))
if (debugging_c::requested("avi_dump_video_index"))
debug_dump_video_index();
}

View File

@ -50,9 +50,9 @@ coreaudio_reader_c::coreaudio_reader_c(const track_info_c &ti,
, m_frames_per_packet{}
, m_channels{}
, m_bites_per_sample{}
, m_debug_headers{debugging_requested("coreaudio_reader|coreaudio_reader_headers")}
, m_debug_chunks{ debugging_requested("coreaudio_reader|coreaudio_reader_chunks")}
, m_debug_packets{debugging_requested("coreaudio_reader|coreaudio_reader_packets")}
, m_debug_headers{"coreaudio_reader|coreaudio_reader_headers"}
, m_debug_chunks{ "coreaudio_reader|coreaudio_reader_chunks"}
, m_debug_packets{"coreaudio_reader|coreaudio_reader_packets"}
{
}

View File

@ -50,7 +50,7 @@ private:
samples_to_timecode_converter_c m_frames_to_timecode;
bool m_debug_headers, m_debug_chunks, m_debug_packets;
debugging_option_c m_debug_headers, m_debug_chunks, m_debug_packets;
public:
coreaudio_reader_c(const track_info_c &ti, const mm_io_cptr &in);

View File

@ -57,7 +57,7 @@ dts_reader_c::dts_reader_c(const track_info_c &ti,
, m_cur_buf(0)
, m_dts14_to_16(false)
, m_swap_bytes(false)
, m_debug(debugging_requested("dts") || debugging_requested("dts_reader"))
, m_debug{"dts|dts_reader"}
{
m_buf[0] = reinterpret_cast<unsigned short *>(m_af_buf->get_buffer());
m_buf[1] = reinterpret_cast<unsigned short *>(m_af_buf->get_buffer() + READ_SIZE);

View File

@ -30,7 +30,8 @@ private:
unsigned short *m_buf[2];
unsigned int m_cur_buf;
dts_header_t m_dtsheader;
bool m_dts14_to_16, m_swap_bytes, m_debug;
bool m_dts14_to_16, m_swap_bytes;
debugging_option_c m_debug;
public:
dts_reader_c(const track_info_c &ti, const mm_io_cptr &in);

View File

@ -80,7 +80,7 @@ flv_tag_c::flv_tag_c()
, m_timecode_extended{}
, m_next_position{}
, m_ok{}
, m_debug{debugging_requested("flv_full|flv_tags|flv_tag")}
, m_debug{"flv_full|flv_tags|flv_tag"}
{
}
@ -253,7 +253,7 @@ flv_reader_c::flv_reader_c(track_info_c const &ti,
, m_video_track_idx{0}
, m_selected_track_idx{-1}
, m_file_done{false}
, m_debug{debugging_requested("flv|flv_full")}
, m_debug{"flv|flv_full"}
{
}

View File

@ -71,7 +71,8 @@ public:
uint32_t m_previous_tag_size;
uint8_t m_flags;
uint64_t m_data_size, m_timecode, m_timecode_extended, m_next_position;
bool m_ok, m_debug;
bool m_ok;
debugging_option_c m_debug;
public:
flv_tag_c();
@ -136,7 +137,7 @@ private:
std::vector<flv_track_cptr> m_tracks;
bool m_debug;
debugging_option_c m_debug;
public:
flv_reader_c(const track_info_c &ti, const mm_io_cptr &in);

View File

@ -64,7 +64,7 @@ mpeg_ps_reader_c::mpeg_ps_reader_c(const track_info_c &ti,
const mm_io_cptr &in)
: generic_reader_c(ti, in)
, file_done(false)
, m_debug_timecodes(debugging_requested("mpeg_ps|mpeg_ps_timecodes"))
, m_debug_timecodes{"mpeg_ps|mpeg_ps_timecodes"}
{
}

View File

@ -17,6 +17,7 @@
#include "common/common_pch.h"
#include "common/bit_cursor.h"
#include "common/debugging.h"
#include "common/dts.h"
#include "common/mm_multi_file_io.h"
#include "common/mpeg1_2.h"
@ -200,7 +201,7 @@ private:
std::vector<mpeg_ps_track_ptr> tracks;
std::map<generic_packetizer_c *, mpeg_ps_track_ptr> m_ptzr_to_track_map;
bool m_debug_timecodes;
debugging_option_c m_debug_timecodes;
public:
mpeg_ps_reader_c(const track_info_c &ti, const mm_io_cptr &in);

View File

@ -281,12 +281,12 @@ mpeg_ts_track_c::set_pid(uint16_t new_pid) {
pid = new_pid;
std::string arg;
m_debug_delivery = debugging_requested("mpeg_ts")
|| ( debugging_requested("mpeg_ts_delivery", &arg)
m_debug_delivery = debugging_c::requested("mpeg_ts")
|| ( debugging_c::requested("mpeg_ts_delivery", &arg)
&& (arg.empty() || (arg == to_string(pid))));
m_debug_timecode_wrapping = debugging_requested("mpeg_ts")
|| ( debugging_requested("mpeg_ts_timecode_wrapping", &arg)
m_debug_timecode_wrapping = debugging_c::requested("mpeg_ts")
|| ( debugging_c::requested("mpeg_ts_timecode_wrapping", &arg)
&& (arg.empty() || (arg == to_string(pid))));
}
@ -391,11 +391,12 @@ mpeg_ts_reader_c::mpeg_ts_reader_c(const track_info_c &ti,
, track_buffer_ready(-1)
, file_done{}
, m_packet_sent_to_packetizer{}
, m_dont_use_audio_pts{ debugging_requested("mpeg_ts|mpeg_ts_dont_use_audio_pts")}
, m_debug_resync{ debugging_requested("mpeg_ts|mpeg_ts_resync")}
, m_debug_pat_pmt{ debugging_requested("mpeg_ts|mpeg_ts_pat|mpeg_ts_pmt")}
, m_debug_aac{ debugging_requested("mpeg_ts|mpeg_aac")}
, m_debug_timecode_wrapping{debugging_requested("mpeg_ts|mpeg_ts_timecode_wrapping")}
, m_dont_use_audio_pts{ "mpeg_ts|mpeg_ts_dont_use_audio_pts"}
, m_debug_resync{ "mpeg_ts|mpeg_ts_resync"}
, m_debug_pat_pmt{ "mpeg_ts|mpeg_ts_pat|mpeg_ts_pmt"}
, m_debug_aac{ "mpeg_ts|mpeg_aac"}
, m_debug_timecode_wrapping{"mpeg_ts|mpeg_ts_timecode_wrapping"}
, m_debug_clpi{ "clpi"}
, m_detected_packet_size{}
{
auto mpls_in = mm_mpls_multi_file_io_c::open_multi(m_in.get());
@ -1264,14 +1265,12 @@ mpeg_ts_reader_c::read(generic_packetizer_c *requested_ptzr,
bfs::path
mpeg_ts_reader_c::find_clip_info_file() {
bool debug = debugging_requested("clpi");
auto mpls_multi_in = dynamic_cast<mm_mpls_multi_file_io_c *>(get_underlying_input_as_multi_file_io());
auto clpi_file = mpls_multi_in ? mpls_multi_in->get_file_names()[0] : bfs::path{m_ti.m_fname};
clpi_file.replace_extension(".clpi");
mxdebug_if(debug, boost::format("Checking %1%\n") % clpi_file.string());
mxdebug_if(m_debug_clpi, boost::format("Checking %1%\n") % clpi_file.string());
if (bfs::exists(clpi_file))
return clpi_file;
@ -1284,16 +1283,16 @@ mpeg_ts_reader_c::find_clip_info_file() {
// return clpi_file;
clpi_file = path / ".." / "clipinf" / file_name;
mxdebug_if(debug, boost::format("Checking %1%\n") % clpi_file.string());
mxdebug_if(m_debug_clpi, boost::format("Checking %1%\n") % clpi_file.string());
if (bfs::exists(clpi_file))
return clpi_file;
clpi_file = path / ".." / "CLIPINF" / file_name;
mxdebug_if(debug, boost::format("Checking %1%\n") % clpi_file.string());
mxdebug_if(m_debug_clpi, boost::format("Checking %1%\n") % clpi_file.string());
if (bfs::exists(clpi_file))
return clpi_file;
mxdebug_if(debug, "CLPI not found\n");
mxdebug_if(m_debug_clpi, "CLPI not found\n");
return bfs::path();
}

View File

@ -374,7 +374,7 @@ protected:
std::vector<timecode_c> m_chapter_timecodes;
bool m_dont_use_audio_pts, m_debug_resync, m_debug_pat_pmt, m_debug_aac, m_debug_timecode_wrapping;
debugging_option_c m_dont_use_audio_pts, m_debug_resync, m_debug_pat_pmt, m_debug_aac, m_debug_timecode_wrapping, m_debug_clpi;
int m_detected_packet_size;

View File

@ -44,7 +44,7 @@ pgssup_reader_c::probe_file(mm_io_c *in,
pgssup_reader_c::pgssup_reader_c(const track_info_c &ti,
const mm_io_cptr &in)
: generic_reader_c(ti, in)
, m_debug(debugging_requested("pgssup_reader"))
, m_debug{"pgssup_reader"}
{
}

View File

@ -16,15 +16,14 @@
#include "common/common_pch.h"
#include <stdio.h>
#include "common/debugging.h"
#include "common/error.h"
#include "common/mm_io.h"
#include "merge/pr_generic.h"
class pgssup_reader_c: public generic_reader_c {
private:
bool m_debug;
debugging_option_c m_debug;
public:
pgssup_reader_c(const track_info_c &ti, const mm_io_cptr &in);

View File

@ -131,11 +131,11 @@ qtmp4_reader_c::qtmp4_reader_c(const track_info_c &ti,
, m_compression_algorithm{}
, m_main_dmx(-1)
, m_audio_encoder_delay_samples(0)
, m_debug_chapters( debugging_requested("qtmp4") || debugging_requested("qtmp4_full") || debugging_requested("qtmp4_chapters"))
, m_debug_headers( debugging_requested("qtmp4") || debugging_requested("qtmp4_full") || debugging_requested("qtmp4_headers"))
, m_debug_tables( debugging_requested("qtmp4_full") || debugging_requested("qtmp4_tables"))
, m_debug_interleaving(debugging_requested("qtmp4") || debugging_requested("qtmp4_full") || debugging_requested("qtmp4_interleaving"))
, m_debug_resync( debugging_requested("qtmp4|qtmp4_full|qtmp4_resync"))
, m_debug_chapters{ "qtmp4|qtmp4_full|qtmp4_chapters"}
, m_debug_headers{ "qtmp4|qtmp4_full|qtmp4_headers"}
, m_debug_tables{ "qtmp4_full|qtmp4_tables"}
, m_debug_interleaving{"qtmp4|qtmp4_full|qtmp4_interleaving"}
, m_debug_resync{ "qtmp4|qtmp4_full|qtmp4_resync"}
{
}

View File

@ -178,7 +178,7 @@ struct qtmp4_demuxer_c {
std::string language;
bool m_debug_tables, m_debug_fps, m_debug_headers, m_debug_editlists;
debugging_option_c m_debug_tables, m_debug_fps, m_debug_headers, m_debug_editlists;
qtmp4_demuxer_c()
: ok{false}
@ -208,10 +208,10 @@ struct qtmp4_demuxer_c {
, a_aac_config_parsed{false}
, warning_printed{false}
, ptzr{-1}
, m_debug_tables{ debugging_requested( "qtmp4_full|qtmp4_tables")}
, m_debug_fps{ debugging_requested("qtmp4|qtmp4_full|qtmp4_fps")}
, m_debug_headers{ debugging_requested("qtmp4|qtmp4_full|qtmp4_headers")}
, m_debug_editlists{debugging_requested("qtmp4|qtmp4_full|qtmp4_editlists")}
, m_debug_tables{ "qtmp4_full|qtmp4_tables"}
, m_debug_fps{ "qtmp4|qtmp4_full|qtmp4_fps"}
, m_debug_headers{ "qtmp4|qtmp4_full|qtmp4_headers"}
, m_debug_editlists{"qtmp4|qtmp4_full|qtmp4_editlists"}
{
memset(&esds, 0, sizeof(esds_t));
}
@ -334,7 +334,7 @@ private:
unsigned int m_audio_encoder_delay_samples;
bool m_debug_chapters, m_debug_headers, m_debug_tables, m_debug_interleaving, m_debug_resync;
debugging_option_c m_debug_chapters, m_debug_headers, m_debug_tables, m_debug_interleaving, m_debug_resync;
public:
qtmp4_reader_c(const track_info_c &ti, const mm_io_cptr &in);

View File

@ -505,7 +505,7 @@ wav_reader_c::parse_file() {
if ((m_cur_data_chunk_idx = find_chunk("data", 0, false)) == -1)
throw mtx::input::header_parsing_x();
if (debugging_requested("wav_reader") || debugging_requested("wav_reader_headers"))
if (debugging_c::requested("wav_reader|wav_reader_headers"))
dump_headers();
m_in->setFilePointer(m_chunks[m_cur_data_chunk_idx].pos + sizeof(struct chunk_struct), seek_beginning);
@ -613,7 +613,7 @@ wav_reader_c::read(generic_packetizer_c *,
void
wav_reader_c::scan_chunks() {
wav_chunk_t new_chunk;
bool debug_chunks = debugging_requested("wav_reader") || debugging_requested("wav_reader_chunks");
bool debug_chunks = debugging_c::requested("wav_reader|wav_reader_chunks");
try {
int64_t file_size = m_in->get_size();

View File

@ -55,10 +55,10 @@ cluster_helper_c::cluster_helper_c()
, m_current_split_point(m_split_points.begin())
, m_discarding{false}
, m_splitting_and_processed_fully{false}
, m_debug_splitting{debugging_requested("cluster_helper|splitting")}
, m_debug_packets{ debugging_requested("cluster_helper|cluster_helper_packets")}
, m_debug_duration{ debugging_requested("cluster_helper|cluster_helper_duration")}
, m_debug_rendering{debugging_requested("cluster_helper|cluster_helper_rendering")}
, m_debug_splitting{"cluster_helper|splitting"}
, m_debug_packets{ "cluster_helper|cluster_helper_packets"}
, m_debug_duration{ "cluster_helper|cluster_helper_duration"}
, m_debug_rendering{"cluster_helper|cluster_helper_rendering"}
{
}

View File

@ -61,7 +61,7 @@ private:
bool m_discarding, m_splitting_and_processed_fully;
bool m_debug_splitting, m_debug_packets, m_debug_duration, m_debug_rendering;
debugging_option_c m_debug_splitting, m_debug_packets, m_debug_duration, m_debug_rendering;
public:
cluster_helper_c();

View File

@ -29,8 +29,8 @@ cues_c::cues_c()
: m_num_cue_points_postprocessed{}
, m_no_cue_duration{hack_engaged(ENGAGE_NO_CUE_DURATION)}
, m_no_cue_relative_position{hack_engaged(ENGAGE_NO_CUE_RELATIVE_POSITION)}
, m_debug_cue_duration{debugging_requested("cues|cues_cue_duration")}
, m_debug_cue_relative_position{debugging_requested("cues|cues_cue_relative_position")}
, m_debug_cue_duration{ "cues|cues_cue_duration"}
, m_debug_cue_relative_position{"cues|cues_cue_relative_position"}
{
}

View File

@ -38,7 +38,8 @@ protected:
std::map<id_timecode_t, uint64_t> m_id_timecode_duration_map, m_codec_state_position_map;
size_t m_num_cue_points_postprocessed;
bool m_no_cue_duration, m_no_cue_relative_position, m_debug_cue_duration, m_debug_cue_relative_position;
bool m_no_cue_duration, m_no_cue_relative_position;
debugging_option_c m_debug_cue_duration, m_debug_cue_relative_position;
protected:
static cues_cptr s_cues;

View File

@ -1,78 +0,0 @@
/*
mkvmerge -- utility for splicing together matroska files
from component media subtypes
Distributed under the GPL
see the file COPYING for details
or visit http://www.gnu.org/copyleft/gpl.html
mkvmerge debugging routines
Written by Moritz Bunkus <moritz@bunkus.org>.
*/
#include "common/common_pch.h"
#include "common/fs_sys_helpers.h"
#include "common/output.h"
#include "common/strings/editing.h"
#include "common/strings/parsing.h"
#include "merge/debugging.h"
#include "merge/output_control.h"
static int s_debug_memory_usage_details = -1;
static void
debug_memory_usage_details_hook() {
if (-1 == s_debug_memory_usage_details)
return;
static int64_t s_previous_call = 0;
int64_t now = get_current_time_millis();
if ((now - s_previous_call) < s_debug_memory_usage_details)
return;
s_previous_call = now;
std::string timecode = (boost::format("memory_usage_details :: %1%.%|2$04d| :: ") % (now / 1000) % (now % 1000)).str();
for (auto &file : g_files) {
mxinfo(boost::format("%1%reader :: %2% :: %3%\n") % timecode % file.name % file.reader->get_queued_bytes());
for (auto packetizer : file.reader->m_reader_packetizers)
mxinfo(boost::format("%1%packetizer :: %2% :: %3% :: %4%\n") % timecode % packetizer->m_ti.m_id % typeid(*packetizer).name() % packetizer->get_queued_bytes());
}
}
int
parse_debug_interval_arg(const std::string &option,
int default_value,
int invalid_value) {
int value = invalid_value;
std::string arg;
if (!debugging_requested(option, &arg))
return value;
if (arg.empty() || !parse_number(arg, value) || (0 >= value))
value = default_value;
if (250 > value)
value *= 1000;
return value;
}
void
debug_run_main_loop_hooks() {
static bool s_main_loop_hooks_initialized = false;
if (!s_main_loop_hooks_initialized) {
s_main_loop_hooks_initialized = true;
s_debug_memory_usage_details = parse_debug_interval_arg("memory_usage_details");
}
debug_memory_usage_details_hook();
}

View File

@ -1,19 +0,0 @@
/*
mkvmerge -- utility for splicing together matroska files
from component media subtypes
Distributed under the GPL
see the file COPYING for details
or visit http://www.gnu.org/copyleft/gpl.html
mkvmerge debugging routines
Written by Moritz Bunkus <moritz@bunkus.org>.
*/
#ifndef MTX_MERGE_DEBUGGING_H
#define MTX_MERGE_DEBUGGING_H
void debug_run_main_loop_hooks();
#endif // MTX_MERGE_DEBUGGING_H

View File

@ -112,7 +112,6 @@
#include "merge/cues.h"
#include "merge/mkvmerge.h"
#include "merge/output_control.h"
#include "merge/debugging.h"
#include "merge/webm.h"
using namespace libmatroska;
@ -193,8 +192,8 @@ std::string g_splitting_by_chapters_arg;
append_mode_e g_append_mode = APPEND_MODE_FILE_BASED;
bool s_appending_files = false;
bool s_debug_appending = false;
bool s_debug_rerender_track_headers = false;
auto s_debug_appending = debugging_option_c{"append|appending"};
auto s_debug_rerender_track_headers = debugging_option_c{"rerender|rerender_track_headers"};
bool g_stereo_mode_used = false;
@ -521,13 +520,10 @@ determine_display_reader() {
*/
static void
display_progress(bool is_100percent = false) {
static boost::tribool s_no_progress{boost::logic::indeterminate};
static auto s_no_progress = debugging_option_c{"no_progress"};
static int64_t s_previous_progress_on = 0;
static int s_previous_percentage = -1;
if (boost::logic::indeterminate(s_no_progress))
s_no_progress = debugging_requested("no_progress");
if (s_no_progress)
return;
@ -645,7 +641,7 @@ set_timecode_scale() {
highest_sample_rate = std::max(static_cast<int64_t>(ptzr.packetizer->get_audio_sampling_freq()), highest_sample_rate);
}
bool debug = debugging_requested("set_timecode_scale|timecode_scale");
bool debug = debugging_c::requested("set_timecode_scale|timecode_scale");
mxdebug_if(debug,
boost::format("timecode_scale: %1% audio present: %2% video present: %3% highest sample rate: %4%\n")
% ( TIMECODE_SCALE_MODE_NORMAL == g_timecode_scale_mode ? "normal"
@ -1609,7 +1605,8 @@ prepare_tags_for_rendering() {
*/
void
create_next_output_file() {
mxdebug_if(debugging_requested("splitting"), boost::format("splitting: Create next output file; splitting? %1% discarding? %2%\n") % g_cluster_helper->splitting() % g_cluster_helper->discarding());
auto s_debug = debugging_option_c{"splitting"};
mxdebug_if(s_debug, boost::format("splitting: Create next output file; splitting? %1% discarding? %2%\n") % g_cluster_helper->splitting() % g_cluster_helper->discarding());
auto this_outfile = g_cluster_helper->split_mode_produces_many_files() ? create_output_name() : g_outfile;
g_kax_segment = new KaxSegment();
@ -1642,9 +1639,9 @@ create_next_output_file() {
static void
add_chapters_for_current_part() {
bool debug = debugging_requested("splitting_chapters");
auto s_debug = debugging_option_c{"splitting_chapters"};
mxdebug_if(debug, boost::format("Adding chapters. have_global? %1% splitting? %2%\n") % !!g_kax_chapters % g_cluster_helper->splitting());
mxdebug_if(s_debug, boost::format("Adding chapters. have_global? %1% splitting? %2%\n") % !!g_kax_chapters % g_cluster_helper->splitting());
if (!g_cluster_helper->splitting()) {
s_chapters_in_this_file = clone(g_kax_chapters);
@ -1660,7 +1657,7 @@ add_chapters_for_current_part() {
auto chapters_here = clone(g_kax_chapters);
bool have_chapters_in_timeframe = select_chapters_in_timeframe(chapters_here.get(), start, end, offset);
mxdebug_if(debug, boost::format("offset %1% start %2% end %3% have chapters in timeframe? %4% chapters in this file? %5%\n") % offset % start % end % have_chapters_in_timeframe % !!s_chapters_in_this_file);
mxdebug_if(s_debug, boost::format("offset %1% start %2% end %3% have chapters in timeframe? %4% chapters in this file? %5%\n") % offset % start % end % have_chapters_in_timeframe % !!s_chapters_in_this_file);
if (!have_chapters_in_timeframe)
return;
@ -1676,9 +1673,9 @@ add_chapters_for_current_part() {
static void
render_chapters() {
bool debug = debugging_requested("splitting_chapters");
auto s_debug = debugging_option_c{"splitting_chapters"};
mxdebug_if(debug,
mxdebug_if(s_debug,
boost::format("render_chapters: have void? %1% size %2% have chapters? %3% size %4%\n")
% !!s_kax_chapters_void % (s_kax_chapters_void ? s_kax_chapters_void ->ElementSize() : 0)
% !!s_chapters_in_this_file % (s_chapters_in_this_file ? s_chapters_in_this_file->ElementSize() : 0));
@ -2203,13 +2200,8 @@ discard_queued_packets() {
*/
void
main_loop() {
s_debug_appending = debugging_requested("append|appending");
s_debug_rerender_track_headers = debugging_requested("rerender|rerender_track_headers");
// Let's go!
while (1) {
debug_run_main_loop_hooks();
// Step 1: Make sure a packet is available for each output
// as long we haven't already processed the last one.
pull_packetizers_for_packets();

View File

@ -50,7 +50,8 @@ protected:
std::string m_file_name, m_source_name;
int64_t m_tid;
int m_version;
bool m_preserve_duration, m_debug;
bool m_preserve_duration;
debugging_option_c m_debug;
public:
timecode_factory_c(const std::string &file_name,
@ -62,7 +63,7 @@ public:
, m_tid(tid)
, m_version(version)
, m_preserve_duration(false)
, m_debug(debugging_requested("timecode_factory"))
, m_debug{"timecode_factory"}
{
}
virtual ~timecode_factory_c() {

View File

@ -10,7 +10,7 @@ AttachmentModel::AttachmentModel(QObject *parent,
QList<AttachmentPtr> &attachments)
: QAbstractItemModel(parent)
, m_attachments(&attachments)
, m_debug(debugging_requested("attachment_model"))
, m_debug{"attachment_model"}
{
}

View File

@ -25,7 +25,7 @@ protected:
QList<AttachmentPtr> *m_attachments;
bool m_debug;
debugging_option_c m_debug;
public:
AttachmentModel(QObject *parent, QList<AttachmentPtr> &attachments);

View File

@ -17,7 +17,7 @@ TrackModel::TrackModel(QObject *parent)
, m_genericIcon(":/icons/16x16/application-octet-stream.png")
, m_yesIcon(":/icons/16x16/dialog-ok-apply.png")
, m_noIcon(":/icons/16x16/dialog-cancel.png")
, m_debug(debugging_requested("track_model"))
, m_debug{"track_model"}
{
}

View File

@ -28,7 +28,7 @@ protected:
QList<Track *> *m_tracks;
QIcon m_audioIcon, m_videoIcon, m_subtitleIcon, m_attachmentIcon, m_chaptersIcon, m_tagsIcon, m_genericIcon, m_yesIcon, m_noIcon;
bool m_debug;
debugging_option_c m_debug;
public:
TrackModel(QObject *parent);

View File

@ -228,7 +228,7 @@ header_editor_frame_c::clear_pages() {
void
header_editor_frame_c::on_file_open(wxCommandEvent &) {
if (debugging_requested("he_open_std")) {
if (debugging_c::requested("he_open_std")) {
wxString home;
wxGetEnv(wxT("HOME"), &home);
open_file(wxFileName(wxString::Format(wxT("%s/prog/video/mkvtoolnix/data/muh.mkv"), home.c_str())));

View File

@ -31,8 +31,8 @@ mpeg4_p10_es_video_packetizer_c(generic_reader_c *p_reader,
, m_default_duration_for_interlaced_content(-1)
, m_first_frame(true)
, m_set_display_dimensions(false)
, m_debug_timecodes( debugging_requested("mpeg4_p10_es|mpeg4_p10_es_timecodes"))
, m_debug_aspect_ratio(debugging_requested("mpeg4_p10_es|mpeg4_p10_es_aspect_ratio"))
, m_debug_timecodes{ "mpeg4_p10_es|mpeg4_p10_es_timecodes"}
, m_debug_aspect_ratio{"mpeg4_p10_es|mpeg4_p10_es_aspect_ratio"}
{
m_relaxed_timecode_checking = true;

View File

@ -25,7 +25,8 @@ class mpeg4_p10_es_video_packetizer_c: public generic_packetizer_c {
protected:
avc_es_parser_c m_parser;
int64_t m_default_duration_for_interlaced_content;
bool m_first_frame, m_set_display_dimensions, m_debug_timecodes, m_debug_aspect_ratio;
bool m_first_frame, m_set_display_dimensions;
debugging_option_c m_debug_timecodes, m_debug_aspect_ratio;
public:
mpeg4_p10_es_video_packetizer_c(generic_reader_c *p_reader, track_info_c &p_ti);

View File

@ -37,7 +37,7 @@ mpeg1_2_video_packetizer_c(generic_reader_c *p_reader,
, m_framed{framed}
, m_aspect_ratio_extracted{true}
, m_num_removed_stuffing_bytes{}
, m_debug_stuffing_removal{debugging_requested("mpeg1_2|mpeg1_2_stuffing_removal")}
, m_debug_stuffing_removal{"mpeg1_2|mpeg1_2_stuffing_removal"}
{
set_codec_id((boost::format("V_MPEG%1%") % version).str());

View File

@ -26,7 +26,7 @@ protected:
memory_cptr m_seq_hdr;
bool m_framed, m_aspect_ratio_extracted;
int64_t m_num_removed_stuffing_bytes;
bool m_debug_stuffing_removal;
debugging_option_c m_debug_stuffing_removal;
public:
mpeg1_2_video_packetizer_c(generic_reader_c *p_reader, track_info_c &p_ti, int version, double fps, int width, int height, int dwidth, int dheight, bool framed);

View File

@ -68,7 +68,7 @@ mpeg4_p2_video_packetizer_c(generic_reader_c *p_reader,
}
mpeg4_p2_video_packetizer_c::~mpeg4_p2_video_packetizer_c() {
if (!debugging_requested("mpeg4_p2_statistics"))
if (!debugging_c::requested("mpeg4_p2_statistics"))
return;
mxinfo(boost::format("mpeg4_p2_video_packetizer_c statistics:\n"

View File

@ -23,7 +23,7 @@ using namespace libmatroska;
opus_packetizer_c::opus_packetizer_c(generic_reader_c *reader,
track_info_c &ti)
: generic_packetizer_c(reader, ti)
, m_debug{debugging_requested("opus|opus_packetizer")}
, m_debug{"opus|opus_packetizer"}
, m_next_calculated_timecode{timecode_c::ns(0)}
, m_id_header(mtx::opus::id_header_t::decode(ti.m_private_data))
{

View File

@ -23,7 +23,7 @@ class opus_packetizer_c: public generic_packetizer_c {
private:
static bool ms_experimental_warning_shown;
bool m_debug;
debugging_option_c m_debug;
timecode_c m_next_calculated_timecode, m_previous_provided_timecode;
mtx::opus::id_header_t m_id_header;

View File

@ -39,7 +39,7 @@ video_packetizer_c::video_packetizer_c(generic_reader_c *p_reader,
, m_frames_output(0)
, m_ref_timecode(-1)
, m_duration_shift(0)
, m_rederive_frame_types(debugging_requested("rederive_frame_types"))
, m_rederive_frame_types(debugging_c::requested("rederive_frame_types"))
, m_codec_type(video_packetizer_c::ct_unknown)
{
set_track_type(track_video);

View File

@ -109,7 +109,7 @@ run(options_cptr &options) {
options->find_elements(analyzer.get());
options->validate();
if (debugging_requested("dump_options")) {
if (debugging_c::requested("dump_options")) {
mxinfo("\nDumping options after file and element analysis\n\n");
options->dump_info();
}
@ -145,7 +145,7 @@ main(int argc,
options_cptr options = propedit_cli_parser_c(command_line_utf8(argc, argv)).run();
if (debugging_requested("dump_options")) {
if (debugging_c::requested("dump_options")) {
mxinfo("\nDumping options after parsing the command line\n\n");
options->dump_info();
}