diff --git a/doc/bino.1 b/doc/bino.1 index d2131da..1c4877f 100644 --- a/doc/bino.1 +++ b/doc/bino.1 @@ -94,6 +94,8 @@ Fullscreen Center window on screen .IP "\-s|\-\-swap\-eyes" Swap left/right view +.IP "\-b|\-\-benchmark" +Benchmark mode (no timesync, no audio, fps counter) .SH INTERACTIVE CONTROL .IP "q or ESC" quit diff --git a/src/main.cpp b/src/main.cpp index c271d81..80f4af8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -108,6 +108,8 @@ int main(int argc, char *argv[]) options.push_back(&eq_logfile); opt::val eq_render_client("eq-render-client", '\0', opt::optional); options.push_back(&eq_render_client); + opt::flag benchmark("benchmark", 'b', opt::optional); + options.push_back(&benchmark); std::vector arguments; if (!opt::parse(argc, argv, options, 0, 3, arguments)) @@ -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,9 @@ 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 enabled: audio and time synchronization will be disabled"); int retval = 0; player *player = NULL; diff --git a/src/player.cpp b/src/player.cpp index 1384196..400ce6c 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -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 % 250 == 0) //show fps each 250 frames + { + msg::inf("fps: %.2f", 250.0 / ((_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); + _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..230044a 100644 --- a/src/player.h +++ b/src/player.h @@ -40,6 +40,7 @@ public: enum video_output::mode video_mode; video_output_state video_state; unsigned int video_flags; + bool benchmark; public: player_init_data(); @@ -61,7 +62,7 @@ private: audio_output *_audio_output; video_output *_video_output; video_output_state _video_state; - + bool _running; bool _first_frame; bool _need_frame; @@ -72,7 +73,7 @@ private: bool _quit_request; bool _pause_request; int64_t _seek_request; - + uint8_t *_l_data[3], *_r_data[3]; size_t _l_line_size[3], _r_line_size[3]; void *_audio_data; @@ -87,8 +88,13 @@ private: int64_t _current_pos; // current input position 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: + bool _benchmark; + void reset_playstate(); void create_decoders(const std::vector &filenames); void create_input(enum input::mode input_mode); diff --git a/src/player_qt.cpp b/src/player_qt.cpp index 848d00c..37756d4 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(); + _benchmark = init_data.benchmark; create_decoders(init_data.filenames); create_input(init_data.input_mode); create_audio_output();