summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLion-Simba <lion-simba@pridelands.ru>2010-12-04 17:06:19 +0100
committerMartin Lambers <marlam@marlam.de>2010-12-04 17:06:19 +0100
commit1b1d643e77b281e17975d8754ee39c32e1003922 (patch)
tree31aefc860785fae06e24d2b43b28366be875eedd
parent7579144893ab96263a87094b5ff5c137d723ee5a (diff)
downloadbino-1b1d643e77b281e17975d8754ee39c32e1003922.tar.gz
Add a benchmark mode.
This mode disables audio and time synchronization, and displays frames-per-second information.
-rw-r--r--doc/bino.13
-rw-r--r--src/main.cpp10
-rw-r--r--src/player.cpp25
-rw-r--r--src/player.h9
-rw-r--r--src/player_equalizer.cpp2
-rw-r--r--src/player_qt.cpp1
6 files changed, 45 insertions, 5 deletions
diff --git a/doc/bino.1 b/doc/bino.1
index d2131da..23c21d2 100644
--- a/doc/bino.1
+++ b/doc/bino.1
@@ -94,6 +94,9 @@ Fullscreen
Center window on screen
.IP "\-s|\-\-swap\-eyes"
Swap left/right view
+.IP "\-b|\-\-benchmark"
+Benchmark mode: no audio, no time synchronization, output of frames-per-second
+measurements.
.SH INTERACTIVE CONTROL
.IP "q or ESC"
quit
diff --git a/src/main.cpp b/src/main.cpp
index c271d81..6adda34 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -97,6 +97,8 @@ int main(int argc, char *argv[])
options.push_back(&center);
opt::flag swap_eyes("swap-eyes", 's', opt::optional);
options.push_back(&swap_eyes);
+ opt::flag benchmark("benchmark", 'b', opt::optional);
+ options.push_back(&benchmark);
// Accept some Equalizer options. These are passed to Equalizer for interpretation.
opt::val<std::string> eq_server("eq-server", '\0', opt::optional);
options.push_back(&eq_server);
@@ -170,7 +172,8 @@ int main(int argc, char *argv[])
" equalizer-3d Multi-display OpenGL via Equalizer (3D setup)\n"
" -f|--fullscreen Fullscreen\n"
" -c|--center Center window on screen\n"
- " -s|--swap-eyes Swap left/right view\n"
+ " -s|--swap-eyes Swap left/right view\n"
+ " -b|--benchmark Benchmark mode (no audio, no timesync, show fps)\n"
"\n"
"Keyboard control:\n"
" q or ESC Quit\n"
@@ -279,6 +282,11 @@ int main(int argc, char *argv[])
{
init_data.video_flags |= video_output::center;
}
+ init_data.benchmark = benchmark.value();
+ if (init_data.benchmark)
+ {
+ msg::inf("benchmark mode: audio and time synchronization disabled");
+ }
int retval = 0;
player *player = NULL;
diff --git a/src/player.cpp b/src/player.cpp
index 1384196..2cb634e 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -35,7 +35,7 @@
player_init_data::player_init_data()
- : filenames(),
+ : log_level(msg::INF), benchmark(false), filenames(),
input_mode(input::automatic),
video_mode(video_output::stereo),
video_state(),
@@ -162,7 +162,7 @@ void player::get_input_info(int *w, int *h, float *ar, enum decoder::video_frame
void player::create_audio_output()
{
- if (_input->has_audio())
+ if (_input->has_audio() && !_benchmark)
{
_audio_output = new audio_output_openal();
_audio_output->open(_input->audio_channels(), _input->audio_rate(), _input->audio_sample_format());
@@ -249,6 +249,8 @@ void player::run_step(bool *more_steps, int64_t *seek_to, bool *prep_frame, bool
{
_sync_point_time = timer::get_microseconds(timer::monotonic);
}
+ _fps_mark_time = _sync_point_time;
+ _frames_shown = 0;
_running = true;
_need_frame = false;
_first_frame = true;
@@ -303,6 +305,8 @@ void player::run_step(bool *more_steps, int64_t *seek_to, bool *prep_frame, bool
_sync_point_time = timer::get_microseconds(timer::monotonic);
_sync_point_av_offset = 0;
}
+ _fps_mark_time = _sync_point_time;
+ _frames_shown = 0;
notify(notification::pos, _current_pos / 1e6f, _sync_point_pos / 1e6f);
_need_frame = false;
_current_pos = _sync_point_pos;
@@ -374,6 +378,8 @@ void player::run_step(bool *more_steps, int64_t *seek_to, bool *prep_frame, bool
else
{
_sync_point_time += timer::get_microseconds(timer::monotonic) - _pause_start;
+ _fps_mark_time = _sync_point_time;
+ _frames_shown = 0;
}
_in_pause = false;
notify(notification::pause, true, false);
@@ -402,11 +408,11 @@ void player::run_step(bool *more_steps, int64_t *seek_to, bool *prep_frame, bool
}
int64_t time_to_next_frame = (_next_frame_pos - _sync_point_pos) - (_current_time - _sync_point_time) - _sync_point_av_offset;
- if (time_to_next_frame <= 0)
+ if (time_to_next_frame <= 0 || _benchmark)
{
// Output current video frame
_drop_next_frame = false;
- if (-time_to_next_frame > _input->video_frame_duration() * 75 / 100)
+ if (-time_to_next_frame > _input->video_frame_duration() * 75 / 100 && !_benchmark)
{
msg::wrn("video: delay %g seconds; dropping next frame", (-time_to_next_frame) / 1e6f);
_drop_next_frame = true;
@@ -414,6 +420,16 @@ void player::run_step(bool *more_steps, int64_t *seek_to, bool *prep_frame, bool
if (!_previous_frame_dropped)
{
*display_frame = true;
+ if (_benchmark)
+ {
+ _frames_shown++;
+ if (_frames_shown % 100 == 0) //show fps each 100 frames
+ {
+ msg::inf("fps: %.2f", 100.0f / ((_current_time - _fps_mark_time) / 1e6));
+ _fps_mark_time = _current_time;
+ _frames_shown = 0;
+ }
+ }
}
_need_frame = true;
_current_pos = _next_frame_pos;
@@ -442,6 +458,7 @@ void player::release_video_frame()
void player::open(const player_init_data &init_data)
{
msg::set_level(init_data.log_level);
+ set_benchmark(init_data.benchmark);
reset_playstate();
create_decoders(init_data.filenames);
create_input(init_data.input_mode);
diff --git a/src/player.h b/src/player.h
index 04d59e9..6afda06 100644
--- a/src/player.h
+++ b/src/player.h
@@ -35,6 +35,7 @@ class player_init_data
{
public:
msg::level_t log_level;
+ bool benchmark;
std::vector<std::string> filenames;
enum input::mode input_mode;
enum video_output::mode video_mode;
@@ -61,6 +62,7 @@ private:
audio_output *_audio_output;
video_output *_video_output;
video_output_state _video_state;
+ bool _benchmark;
bool _running;
bool _first_frame;
@@ -88,7 +90,14 @@ private:
int64_t _current_time; // current master time
int64_t _next_frame_pos; // presentation time of next video frame
+ int _frames_shown; // frames shown since last _sync_point_time update
+ int64_t _fps_mark_time; // time when _frames_shown was reset to zero
+
protected:
+ void set_benchmark(bool benchmark)
+ {
+ _benchmark = benchmark;
+ }
void reset_playstate();
void create_decoders(const std::vector<std::string> &filenames);
void create_input(enum input::mode input_mode);
diff --git a/src/player_equalizer.cpp b/src/player_equalizer.cpp
index 8d4056f..e8cec28 100644
--- a/src/player_equalizer.cpp
+++ b/src/player_equalizer.cpp
@@ -84,6 +84,8 @@ public:
{
try
{
+ set_benchmark(init_data.benchmark);
+ reset_playstate();
create_decoders(init_data.filenames);
create_input(init_data.input_mode);
get_input_info(src_width, src_height, src_aspect_ratio, src_preferred_frame_format);
diff --git a/src/player_qt.cpp b/src/player_qt.cpp
index 848d00c..431de64 100644
--- a/src/player_qt.cpp
+++ b/src/player_qt.cpp
@@ -53,6 +53,7 @@ player_qt_internal::~player_qt_internal()
void player_qt_internal::open(const player_init_data &init_data)
{
reset_playstate();
+ set_benchmark(init_data.benchmark);
create_decoders(init_data.filenames);
create_input(init_data.input_mode);
create_audio_output();