Better progress report at the end, always going to 100%.

This commit is contained in:
Moritz Bunkus 2003-09-10 15:21:16 +00:00
parent 1dbfa3bec8
commit b446636faa
28 changed files with 99 additions and 73 deletions

View File

@ -395,19 +395,22 @@ static void sighandler(int signum) {
#endif
static int display_counter = 1;
static generic_reader_c *display_reader = NULL;
static void display_progress(int force) {
filelist_t *winner;
static void display_progress(bool force) {
generic_reader_c *winner;
int i;
if (((display_counter % 500) == 0) || force) {
display_counter = 0;
winner = files[0];
for (i = 1; i < files.size(); i++)
if (files[i]->reader->display_priority() >
winner->reader->display_priority())
winner = files[i];
winner->reader->display_progress();
if (display_reader == NULL) {
winner = files[0]->reader;
for (i = 1; i < files.size(); i++)
if (files[i]->reader->display_priority() > winner->display_priority())
winner = files[i]->reader;
display_reader = winner;
}
display_reader->display_progress(force);
}
display_counter++;
}
@ -1958,7 +1961,7 @@ void main_loop() {
// display some progress information
if (verbose >= 1)
display_progress(0);
display_progress(false);
}
// Render all remaining packets (if there are any).
@ -1966,7 +1969,7 @@ void main_loop() {
cluster_helper->render();
if (verbose >= 1)
display_progress(1);
display_progress(true);
}
// }}}

View File

@ -220,7 +220,7 @@ public:
virtual ~generic_reader_c();
virtual int read(generic_packetizer_c *ptzr) = 0;
virtual int display_priority() = 0;
virtual void display_progress() = 0;
virtual void display_progress(bool final = false) = 0;
virtual void set_headers() = 0;
virtual void identify() = 0;

View File

@ -160,11 +160,12 @@ int aac_reader_c::display_priority() {
return DISPLAYPRIORITY_HIGH - 1;
}
void aac_reader_c::display_progress() {
mxinfo("progress: %lld/%lld bytes (%d%%)\r",
bytes_processed, size,
(int)(bytes_processed * 100L / size));
fflush(stdout);
void aac_reader_c::display_progress(bool final) {
if (final)
mxinfo("progress: %lld/%lld bytes (100%%)\r", size, size);
else
mxinfo("progress: %lld/%lld bytes (%d%%)\r", bytes_processed, size,
(int)(bytes_processed * 100L / size));
}
void aac_reader_c::set_headers() {

View File

@ -46,7 +46,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -111,10 +111,12 @@ int ac3_reader_c::display_priority() {
return DISPLAYPRIORITY_HIGH - 1;
}
void ac3_reader_c::display_progress() {
mxinfo("progress: %lld/%lld bytes (%d%%)\r",
bytes_processed, size,
(int)(bytes_processed * 100L / size));
void ac3_reader_c::display_progress(bool final) {
if (final)
mxinfo("progress: %lld/%lld bytes (100%%)\r", size, size);
else
mxinfo("progress: %lld/%lld bytes (%d%%)\r", bytes_processed, size,
(int)(bytes_processed * 100L / size));
}
void ac3_reader_c::set_headers() {

View File

@ -45,7 +45,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -439,21 +439,25 @@ int avi_reader_c::display_priority() {
static char wchar[] = "-\\|/-\\|/-";
void avi_reader_c::display_progress() {
void avi_reader_c::display_progress(bool final) {
int myframes;
if (vpacketizer != NULL) {
int myframes = frames;
myframes = frames;
if (frames == (maxframes + 1))
myframes--;
mxinfo("progress: %d/%ld frames (%ld%%)\r",
myframes, AVI_video_frames(avi),
myframes * 100 / AVI_video_frames(avi));
if (final)
mxinfo("progress: %ld/%ld frames (100%%)\r", AVI_video_frames(avi),
AVI_video_frames(avi));
else
mxinfo("progress: %d/%ld frames (%ld%%)\r", myframes,
AVI_video_frames(avi), myframes * 100 / AVI_video_frames(avi));
} else {
mxinfo("Working... %c\r", wchar[act_wchar]);
act_wchar++;
if (act_wchar == strlen(wchar))
act_wchar = 0;
}
fflush(stdout);
}
// }}}

View File

@ -65,7 +65,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -112,11 +112,12 @@ int dts_reader_c::display_priority() {
return DISPLAYPRIORITY_HIGH - 1;
}
void dts_reader_c::display_progress() {
mxinfo("progress: %lld/%lld bytes (%d%%)\r",
bytes_processed, size,
(int)(bytes_processed * 100L / size));
fflush(stdout);
void dts_reader_c::display_progress(bool final) {
if (final)
mxinfo("progress: %lld/%lld bytes (100%%)\r", size, size);
else
mxinfo("progress: %lld/%lld bytes (%d%%)\r", bytes_processed, size,
(int)(bytes_processed * 100L / size));
}
void dts_reader_c::set_headers() {

View File

@ -45,7 +45,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -1441,13 +1441,17 @@ int kax_reader_c::display_priority() {
static char wchar[] = "-\\|/-\\|/-";
void kax_reader_c::display_progress() {
void kax_reader_c::display_progress(bool final) {
int i;
if (segment_duration != 0.0) {
mxinfo("progress: %.3fs/%.3fs (%d%%)\r",
(last_timecode - first_timecode) / 1000.0, segment_duration,
(int)((last_timecode - first_timecode) / 10 / segment_duration));
if (final)
mxinfo("progress: %.3fs/%.3fs (100%%)\r", segment_duration,
segment_duration);
else
mxinfo("progress: %.3fs/%.3fs (%d%%)\r",
(last_timecode - first_timecode) / 1000.0, segment_duration,
(int)((last_timecode - first_timecode) / 10 / segment_duration));
return;
}

View File

@ -112,7 +112,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -45,7 +45,7 @@ public:
PACKET_TYPE_HEADER);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
static int probe_file(mm_io_c *mm_io, int64_t size);

View File

@ -121,11 +121,12 @@ int mp3_reader_c::display_priority() {
return DISPLAYPRIORITY_HIGH - 1;
}
void mp3_reader_c::display_progress() {
mxinfo("progress: %lld/%lld bytes (%d%%)\r",
bytes_processed, size,
(int)(bytes_processed * 100L / size));
fflush(stdout);
void mp3_reader_c::display_progress(bool final) {
if (final)
mxinfo("progress: %lld/%lld bytes (100%%)\r", size, size);
else
mxinfo("progress: %lld/%lld bytes (%d%%)\r", bytes_processed, size,
(int)(bytes_processed * 100L / size));
}
void mp3_reader_c::set_headers() {

View File

@ -47,7 +47,7 @@ public:
virtual void identify();
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
static int probe_file(mm_io_c *mm_io, int64_t size);
};

View File

@ -697,15 +697,16 @@ int ogm_reader_c::display_priority() {
static char wchar[] = "-\\|/-\\|/-";
void ogm_reader_c::display_progress() {
void ogm_reader_c::display_progress(bool final) {
int i;
for (i = 0; i < num_sdemuxers; i++)
if (sdemuxers[i]->stype == OGM_STREAM_TYPE_VIDEO) {
mxinfo("progress: %d frames (%d%%)\r",
sdemuxers[i]->units_processed, (int)(mm_io->getFilePointer() *
100 / file_size));
fflush(stdout);
if (final)
mxinfo("progress: %d frames (100%%)\r", sdemuxers[i]->units_processed);
else
mxinfo("progress: %d frames (%d%%)\r", sdemuxers[i]->units_processed,
(int)(mm_io->getFilePointer() * 100 / file_size));
return;
}

View File

@ -68,7 +68,7 @@ public:
virtual void identify();
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
static int probe_file(mm_io_c *mm_io, int64_t size);

View File

@ -1107,7 +1107,7 @@ int qtmp4_reader_c::display_priority() {
return DISPLAYPRIORITY_MEDIUM;
}
void qtmp4_reader_c::display_progress() {
void qtmp4_reader_c::display_progress(bool final) {
uint32_t max_chunks;
qtmp4_demuxer_t *dmx;
@ -1116,8 +1116,11 @@ void qtmp4_reader_c::display_progress() {
max_chunks = dmx->sample_table_len;
else
max_chunks = dmx->chunk_table_len;
mxinfo("progress: %d/%d chunks (%d%%)\r", dmx->pos, max_chunks,
dmx->pos * 100 / max_chunks);
if (final)
mxinfo("progress: %d/%d chunks (100%%)\r", max_chunks, max_chunks);
else
mxinfo("progress: %d/%d chunks (%d%%)\r", dmx->pos, max_chunks,
dmx->pos * 100 / max_chunks);
}
void qtmp4_reader_c::identify() {

View File

@ -125,7 +125,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -638,9 +638,13 @@ int real_reader_c::display_priority() {
return DISPLAYPRIORITY_MEDIUM;
}
void real_reader_c::display_progress() {
mxinfo("progress: %lld/%lld packets (%lld%%)\r", num_packets,
num_packets_in_chunk, num_packets * 100 / num_packets_in_chunk);
void real_reader_c::display_progress(bool final) {
if (final)
mxinfo("progress: %lld/%lld packets (100%%)\r", num_packets_in_chunk,
num_packets_in_chunk);
else
mxinfo("progress: %lld/%lld packets (%lld%%)\r", num_packets,
num_packets_in_chunk, num_packets * 100 / num_packets_in_chunk);
}
void real_reader_c::set_headers() {

View File

@ -77,7 +77,7 @@ public:
virtual int read(generic_packetizer_c *ptzr);
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
virtual void set_headers();
virtual void identify();

View File

@ -154,7 +154,7 @@ int srt_reader_c::display_priority() {
static char wchar[] = "-\\|/-\\|/-";
void srt_reader_c::display_progress() {
void srt_reader_c::display_progress(bool) {
mxinfo("working... %c\r", wchar[act_wchar]);
act_wchar++;
if (act_wchar == strlen(wchar))

View File

@ -46,7 +46,7 @@ public:
virtual void identify();
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
static int probe_file(mm_text_io_c *mm_io, int64_t size);
};

View File

@ -296,7 +296,7 @@ int ssa_reader_c::display_priority() {
static char wchar[] = "-\\|/-\\|/-";
void ssa_reader_c::display_progress() {
void ssa_reader_c::display_progress(bool) {
mxinfo("working... %c\r", wchar[act_wchar]);
act_wchar++;
if (act_wchar == strlen(wchar))

View File

@ -53,7 +53,7 @@ public:
virtual void identify();
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
static int probe_file(mm_text_io_c *mm_io, int64_t size);

View File

@ -331,10 +331,9 @@ void vobsub_reader_c::reset() {
static char wchar[] = "-\\|/-\\|/-";
void vobsub_reader_c::display_progress() {
void vobsub_reader_c::display_progress(bool final) {
mxprint(stdout, "working... %c\r", wchar[act_wchar]);
act_wchar++;
if (act_wchar == strlen(wchar))
act_wchar = 0;
fflush(stdout);
}

View File

@ -270,12 +270,15 @@ int wav_reader_c::display_priority() {
return DISPLAYPRIORITY_HIGH - 1;
}
void wav_reader_c::display_progress() {
void wav_reader_c::display_progress(bool final) {
int samples = (wheader.riff.len - sizeof(wheader) + 8) / bps;
mxinfo("progress: %d/%d seconds (%d%%)\r",
(int)(bytes_processed / bps), (int)samples,
(int)(bytes_processed * 100L / bps / samples));
fflush(stdout);
if (final)
mxinfo("progress: %d/%d seconds (100%%)\r", (int)samples, (int)samples);
else
mxinfo("progress: %d/%d seconds (%d%%)\r",
(int)(bytes_processed / bps), (int)samples,
(int)(bytes_processed * 100L / bps / samples));
}
void wav_reader_c::set_headers() {

View File

@ -58,7 +58,7 @@ public:
virtual void identify();
virtual int display_priority();
virtual void display_progress();
virtual void display_progress(bool final = false);
static int probe_file(mm_io_c *mm_io, int64_t size);
};