Removed the useless "debug_c" debugging facility class and associated functions.

This commit is contained in:
Moritz Bunkus 2008-08-21 15:04:24 +00:00
parent f8c3f2e635
commit ed05a12209
39 changed files with 0 additions and 345 deletions

View File

@ -204,9 +204,6 @@ die(const char *fmt,
vfprintf(stdout, fmt, ap);
va_end(ap);
mxprint(stdout, "\n");
#ifdef DEBUG
debug_facility.dump_info();
#endif
exit(2);
}
@ -1140,132 +1137,6 @@ to_string(int64_t i) {
return string(buf);
}
#ifdef DEBUG
/*
debugging stuff
*/
debug_c debug_facility;
debug_c::debug_c() {
}
debug_c::~debug_c() {
while (entries.size() > 0) {
safefree(entries[entries.size() - 1]);
entries.pop_back();
}
}
void
debug_c::enter(const char *label) {
int i;
debug_data_t *entry;
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
struct timeval tv;
#endif
entry = NULL;
for (i = 0; i < entries.size(); i++)
if (!strcmp(entries[i]->label, label)) {
entry = entries[i];
break;
}
if (entry == NULL) {
entry = (debug_data_t *)safemalloc(sizeof(debug_data_t));
memset(entry, 0, sizeof(debug_data_t));
entry->label = label;
entries.push_back(entry);
}
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
gettimeofday(&tv, NULL);
entry->entered_at = (uint64_t)tv.tv_sec * (uint64_t)1000000 +
tv.tv_usec;
#else
entry->entered_at = (uint64_t)time(NULL) * (uint64_t)1000000;
#endif
}
void
debug_c::leave(const char *label) {
int i;
debug_data_t *entry;
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
struct timeval tv;
gettimeofday(&tv, NULL);
#else
time_t now;
now = time(NULL);
#endif
entry = NULL;
for (i = 0; i < entries.size(); i++)
if (!strcmp(entries[i]->label, label)) {
entry = entries[i];
break;
}
if ((entry == NULL) || (entry->entered_at == 0))
die("common.cpp/debug_c::leave() leave without enter: %s", label);
entry->number_of_calls++;
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
entry->elapsed_time += (uint64_t)tv.tv_sec * (uint64_t)1000000 +
tv.tv_usec - entry->entered_at;
#else
entry->elapsed_time += (uint64_t)now * (uint64_t)1000000;
#endif
entry->entered_at = 0;
}
void
debug_c::add_packetizer(void *ptzr) {
int i;
for (i = 0; i < packetizers.size(); i++)
if (packetizers[i] == ptzr)
return;
packetizers.push_back((generic_packetizer_c *)ptzr);
}
void
debug_c::dump_info() {
#if defined(SYS_UNIX) || defined(SYS_APPLE)
int i;
debug_data_t *entry;
uint64_t diff_calls, diff_time;
mxprint(stdout, "\nDBG> dumping time info:\n");
for (i = 0; i < entries.size(); i++) {
entry = entries[i];
mxprint(stdout, "DBG> function: %s, # calls: " LLU ", elapsed time: %.3fs,"
" time/call: %.3fms", entry->label, entry->number_of_calls,
entry->elapsed_time / 1000000.0,
entry->elapsed_time / (float)entry->number_of_calls / 1000.0);
diff_calls = entry->number_of_calls - entry->last_number_of_calls;
diff_time = entry->elapsed_time - entry->last_elapsed_time;
if ((entry->last_elapsed_time != 0) &&
(entry->last_number_of_calls != 0) &&
(diff_calls > 0)) {
mxprint(stdout, ", since the last call: # calls: " LLU ", elapsed time: "
"%.3fs, time/call: %.3fms", diff_calls, diff_time / 1000000.0,
diff_time / (float)diff_calls / 1000.0);
}
mxprint(stdout, "\n");
entry->last_elapsed_time = entry->elapsed_time;
entry->last_number_of_calls = entry->number_of_calls;
}
#endif // defined SYS_UNIX
}
#endif // DEBUG
/*
Other related news
*/

View File

@ -327,42 +327,4 @@ public:
unsigned char *data() const;
};
#ifdef DEBUG
class generic_packetizer_c;
typedef struct {
uint64_t entered_at, elapsed_time, number_of_calls;
uint64_t last_elapsed_time, last_number_of_calls;
const char *label;
} debug_data_t;
class MTX_DLL_API debug_c {
private:
vector<generic_packetizer_c *> packetizers;
vector<debug_data_t *> entries;
public:
debug_c();
~debug_c();
void enter(const char *label);
void leave(const char *label);
void add_packetizer(void *ptzr);
void dump_info();
};
extern debug_c MTX_DLL_API debug_facility;
#define debug_enter(func) debug_facility.enter(func)
#define debug_leave(func) debug_facility.leave(func)
#else // DEBUG
#define debug_enter(func)
#define debug_leave(func)
#endif // DEBUG
#endif // __COMMON_H

View File

@ -218,11 +218,6 @@ family_uids_c::add_family_uid(const KaxSegmentFamily &family) {
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
void
sighandler(int signum) {
#ifdef DEBUG
if (signum == SIGUSR1)
debug_facility.dump_info();
#endif // DEBUG
if (out == NULL)
mxerror(_("mkvmerge was interrupted by a SIGINT (Ctrl+C?)\n"));

View File

@ -52,9 +52,6 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader,
next_packet_wo_assigned_timecode(0), ti(_ti) {
int i;
#ifdef DEBUG
debug_facility.add_packetizer(this);
#endif
reader = nreader;
track_entry = NULL;

View File

@ -452,8 +452,6 @@ public:
}
virtual int process(packet_cptr packet) = 0;
virtual void dump_debug_info() = 0;
virtual void set_cue_creation(cue_strategy_e create_cue_data) {
ti.cues = create_cue_data;
}

View File

@ -194,12 +194,6 @@ aac_packetizer_c::process(packet_cptr packet) {
return FILE_STATUS_MOREDATA;
}
void
aac_packetizer_c::dump_debug_info() {
mxdebug("aac_packetizer_c: queue: %u; buffer size: %d\n",
(unsigned int)packet_queue.size(), byte_buffer.get_size());
}
connection_result_e
aac_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -51,8 +51,6 @@ private:
virtual unsigned char *get_aac_packet(unsigned long *header,
aac_header_t *aacheader);
virtual int process_headerless(packet_cptr packet);
virtual void dump_debug_info();
};
#endif // __P_AAC_H

View File

@ -133,8 +133,6 @@ ac3_packetizer_c::process(packet_cptr packet) {
unsigned long header;
ac3_header_t ac3header;
debug_enter("ac3_packetizer_c::process");
add_to_buffer(packet->data->get(), packet->data->get_size());
while ((ac3_packet = get_ac3_packet(&header, &ac3header)) != NULL) {
adjust_header_values(ac3header);
@ -145,8 +143,6 @@ ac3_packetizer_c::process(packet_cptr packet) {
packetno++;
}
debug_leave("ac3_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
@ -167,12 +163,6 @@ ac3_packetizer_c::adjust_header_values(ac3_header_t &ac3header) {
rerender_track_headers();
}
void
ac3_packetizer_c::dump_debug_info() {
mxdebug("ac3_packetizer_c: queue: %u; buffer size: %d\n",
(unsigned int)packet_queue.size(), byte_buffer.get_size());
}
connection_result_e
ac3_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -50,8 +50,6 @@ protected:
ac3_header_t *ac3header);
virtual void add_to_buffer(unsigned char *buf, int size);
virtual void adjust_header_values(ac3_header_t &ac3header);
virtual void dump_debug_info();
};
class ac3_bs_packetizer_c: public ac3_packetizer_c {

View File

@ -176,10 +176,6 @@ enable_timecode_generation(bool enable,
}
}
void
mpeg4_p10_es_video_packetizer_c::dump_debug_info() {
}
connection_result_e
mpeg4_p10_es_video_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -46,8 +46,6 @@ public:
int64_t default_duration = -1);
virtual void extract_aspect_ratio();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "video";
};

View File

@ -154,8 +154,6 @@ dts_packetizer_c::process(packet_cptr packet) {
dts_header_t dtsheader;
unsigned char *dts_packet;
debug_enter("dts_packetizer_c::process");
add_to_buffer(packet->data->get(), packet->data->get_size());
while ((dts_packet = get_dts_packet(dtsheader)) != NULL) {
int64_t new_timecode = -1 == packet->timecode ? (int64_t)(((double)samples_written * 1000000000.0) / ((double)dtsheader.core_sampling_frequency)) : packet->timecode;
@ -166,16 +164,9 @@ dts_packetizer_c::process(packet_cptr packet) {
samples_written += get_dts_packet_length_in_core_samples(&dtsheader);
}
debug_leave("dts_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
dts_packetizer_c::dump_debug_info() {
mxdebug("dts_packetizer_c: queue: %u\n", (unsigned int)packet_queue.size());
}
connection_result_e
dts_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -55,8 +55,6 @@ private:
virtual unsigned char *get_dts_packet(dts_header_t &dts_header);
virtual int dts_packet_available();
virtual void remove_dts_packet(int pos, int framesize);
virtual void dump_debug_info();
};
#endif // __P_DTS_H

View File

@ -83,8 +83,6 @@ flac_packetizer_c::set_headers() {
int
flac_packetizer_c::process(packet_cptr packet) {
debug_enter("flac_packetizer_c::process");
packet->duration =
flac_get_num_samples(packet->data->get(), packet->data->get_size(),
stream_info);
@ -92,22 +90,15 @@ flac_packetizer_c::process(packet_cptr packet) {
mxwarn(_(FMT_TID "Packet number " LLD " contained an invalid FLAC header "
"and is being skipped.\n"), ti.fname.c_str(), (int64_t)ti.id,
num_packets + 1);
debug_leave("flac_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
packet->duration = packet->duration * 1000000000ll / stream_info.sample_rate;
add_packet(packet);
num_packets++;
debug_leave("flac_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
flac_packetizer_c::dump_debug_info() {
mxdebug("flac_packetizer_c: queue: %u\n", (unsigned int)packet_queue.size());
}
connection_result_e
flac_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -43,8 +43,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "Flac";
}

View File

@ -109,11 +109,6 @@ kate_packetizer_c::process(packet_cptr packet) {
return FILE_STATUS_MOREDATA;
}
void
kate_packetizer_c::dump_debug_info() {
mxdebug("kate_packetizer_c: queue: %u\n", (unsigned int)packet_queue.size());
}
connection_result_e
kate_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -40,8 +40,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "Kate";
}

View File

@ -162,8 +162,6 @@ mp3_packetizer_c::process(packet_cptr packet) {
unsigned char *mp3_packet;
mp3_header_t mp3header;
debug_enter("mp3_packetizer_c::process");
byte_buffer.add(packet->data->get(), packet->data->get_size());
while ((mp3_packet = get_mp3_packet(&mp3header)) != NULL) {
int64_t new_timecode = -1 == packet->timecode ? (int64_t)(1000000000.0 * packetno * spf / samples_per_sec) : packet->timecode;
@ -171,17 +169,9 @@ mp3_packetizer_c::process(packet_cptr packet) {
packetno++;
}
debug_leave("mp3_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
mp3_packetizer_c::dump_debug_info() {
mxdebug("mp3_packetizer_c: queue: %u; buffer_size: %d\n",
(unsigned int)packet_queue.size(), byte_buffer.get_size());
}
connection_result_e
mp3_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -48,7 +48,6 @@ public:
private:
virtual unsigned char *get_mp3_packet(mp3_header_t *mp3header);
virtual void dump_debug_info();
virtual void handle_garbage(int64_t bytes);
};

View File

@ -41,25 +41,14 @@ passthrough_packetizer_c::set_headers() {
int
passthrough_packetizer_c::process(packet_cptr packet) {
debug_enter("passthrough_packetizer_c::process");
packets_processed++;
bytes_processed += packet->data->get_size();
add_packet(packet);
debug_leave("passthrough_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
passthrough_packetizer_c::dump_debug_info() {
mxdebug("passthrough_packetizer_c: packets processed: " LLD ", "
"bytes processed: " LLD ", packets in queue: %u\n",
packets_processed, bytes_processed,
(unsigned int)packet_queue.size());
}
#define CMP(member) (member != psrc->member)
connection_result_e

View File

@ -32,8 +32,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "passthrough";
}

View File

@ -75,8 +75,6 @@ pcm_packetizer_c::set_headers() {
int
pcm_packetizer_c::process(packet_cptr packet) {
debug_enter("pcm_packetizer_c::process");
buffer.add(packet->data->get(), packet->data->get_size());
while (buffer.get_size() >= packet_size) {
@ -85,8 +83,6 @@ pcm_packetizer_c::process(packet_cptr packet) {
bytes_output += packet_size;
}
debug_leave("pcm_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
@ -106,11 +102,6 @@ pcm_packetizer_c::flush() {
generic_packetizer_c::flush();
}
void
pcm_packetizer_c::dump_debug_info() {
mxdebug("pcm_packetizer_c: queue: %u\n", (unsigned int)packet_queue.size());
}
connection_result_e
pcm_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -40,8 +40,6 @@ public:
virtual void set_headers();
virtual void flush();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "PCM";
}

View File

@ -71,19 +71,11 @@ ra_packetizer_c::set_headers() {
int
ra_packetizer_c::process(packet_cptr packet) {
debug_enter("ra_packetizer_c::process");
add_packet(packet);
debug_leave("ra_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
ra_packetizer_c::dump_debug_info() {
}
connection_result_e
ra_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -48,9 +48,6 @@ public:
}
virtual connection_result_e can_connect_to(generic_packetizer_c *src,
string &error_message);
protected:
virtual void dump_debug_info();
};
#endif // __P_REALAUDIO_H

View File

@ -132,12 +132,6 @@ textsubs_packetizer_c::process(packet_cptr packet) {
return FILE_STATUS_MOREDATA;
}
void
textsubs_packetizer_c::dump_debug_info() {
mxdebug("textsubs_packetizer_c: queue: %u\n",
(unsigned int)packet_queue.size());
}
connection_result_e
textsubs_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -39,8 +39,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "text subtitle";
}

View File

@ -54,8 +54,6 @@ tta_packetizer_c::set_headers() {
int
tta_packetizer_c::process(packet_cptr packet) {
debug_enter("tta_packetizer_c::process");
packet->timecode = irnd((double)samples_output * 1000000000 / sample_rate);
if (-1 == packet->duration) {
packet->duration = irnd(1000000000.0 * TTA_FRAME_TIME);
@ -68,16 +66,9 @@ tta_packetizer_c::process(packet_cptr packet) {
}
add_packet(packet);
debug_leave("tta_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
tta_packetizer_c::dump_debug_info() {
mxdebug("tta_packetizer_c: queue: %u\n", (unsigned int)packet_queue.size());
}
connection_result_e
tta_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -35,8 +35,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "TTA";
}

View File

@ -126,13 +126,6 @@ video_packetizer_c::process(packet_cptr packet) {
return FILE_STATUS_MOREDATA;
}
void
video_packetizer_c::dump_debug_info() {
mxdebug("video_packetizer_c: queue: %u; frames_output: %d; "
"ref_timecode: " LLD "\n", (unsigned int)packet_queue.size(),
frames_output, ref_timecode);
}
connection_result_e
video_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -42,8 +42,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "video";
}

View File

@ -78,12 +78,6 @@ vobbtn_packetizer_c::process(packet_cptr packet) {
return FILE_STATUS_MOREDATA;
}
void
vobbtn_packetizer_c::dump_debug_info() {
mxdebug("vobbtn_packetizer_c: queue: %u\n",
(unsigned int)packet_queue.size());
}
connection_result_e
vobbtn_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -36,8 +36,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "VobBtn";
}

View File

@ -63,12 +63,6 @@ vobsub_packetizer_c::process(packet_cptr packet) {
return FILE_STATUS_MOREDATA;
}
void
vobsub_packetizer_c::dump_debug_info() {
mxdebug("vobsub_packetizer_c: queue: %u\n",
(unsigned int)packet_queue.size());
}
connection_result_e
vobsub_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -37,8 +37,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "VobSub";
}

View File

@ -116,8 +116,6 @@ vorbis_packetizer_c::process(packet_cptr packet) {
int64_t this_bs, samples_here, expected_timecode;
int64_t chosen_timecode;
debug_enter("vorbis_packetizer_c::process");
// Remember the very first timecode we received.
if ((samples == 0) && (packet->timecode > 0))
timecode_offset = packet->timecode;
@ -150,17 +148,9 @@ vorbis_packetizer_c::process(packet_cptr packet) {
packet->timecode = chosen_timecode;
add_packet(packet);
debug_leave("vorbis_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
vorbis_packetizer_c::dump_debug_info() {
mxdebug("vorbis_packetizer_c: queue: %u\n",
(unsigned int)packet_queue.size());
}
connection_result_e
vorbis_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -45,8 +45,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "Vorbis";
}

View File

@ -56,7 +56,6 @@ wavpack_packetizer_c::set_headers() {
int
wavpack_packetizer_c::process(packet_cptr packet) {
debug_enter("wavpack_packetizer_c::process");
int64_t samples = get_uint32_le(packet->data->get());
if (-1 == packet->duration)
@ -69,17 +68,9 @@ wavpack_packetizer_c::process(packet_cptr packet) {
samples_output += samples;
add_packet(packet);
debug_leave("wavpack_packetizer_c::process");
return FILE_STATUS_MOREDATA;
}
void
wavpack_packetizer_c::dump_debug_info() {
mxdebug("wavpack_packetizer_c: queue: %u\n",
(unsigned int)packet_queue.size());
}
connection_result_e
wavpack_packetizer_c::can_connect_to(generic_packetizer_c *src,
string &error_message) {

View File

@ -37,8 +37,6 @@ public:
virtual int process(packet_cptr packet);
virtual void set_headers();
virtual void dump_debug_info();
virtual const char *get_format_name() {
return "WAVPACK4";
}