Skip to content

Commit

Permalink
Fix bandwidth value in OSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
gehee committed May 4, 2024
1 parent b60181e commit c8c250c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ void *__DISPLAY_THREAD__(void *param)
{
int ret;
int frame_counter = 0;
uint64_t latency_avg[200];
uint64_t min_latency = 1844674407370955161; // almost MAX_uint64_t
uint64_t max_latency = 0;
float latency_avg[200];
float min_latency = 1844674407370955161; // almost MAX_uint64_t
float max_latency = 0;
struct timespec fps_start, fps_end;
clock_gettime(CLOCK_MONOTONIC, &fps_start);

Expand Down Expand Up @@ -287,7 +287,7 @@ void *__DISPLAY_THREAD__(void *param)
clock_gettime(CLOCK_MONOTONIC, &fps_end);
uint64_t time_us=(fps_end.tv_sec - fps_start.tv_sec)*1000000ll + ((fps_end.tv_nsec - fps_start.tv_nsec)/1000ll) % 1000000ll;
if (time_us >= osd_vars.refresh_frequency_ms*1000) {
uint64_t sum = 0;
float sum = 0;
for (int i = 0; i < frame_counter; ++i) {
sum += latency_avg[i];
if (latency_avg[i] > max_latency) {
Expand Down Expand Up @@ -375,7 +375,7 @@ void read_gstreamerpipe_stream(MppPacket *packet, int gst_udp_port, const VideoC
if ((now-period_start) >= 1000) {
period_start = now;
osd_vars.bw_curr = (osd_vars.bw_curr + 1) % 10;
osd_vars.bw_stats[osd_vars.bw_curr] = bytes_received;
osd_vars.bw_stats[osd_vars.bw_curr] = bytes_received ;
bytes_received = 0;
}
feed_packet_to_decoder(packet,frame->data(),frame->size());
Expand Down
8 changes: 4 additions & 4 deletions osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void modeset_paint_buffer(struct modeset_buf *buf) {
cairo_paint (cr);
cairo_set_source_rgba (cr, 255.0, 255.0, 255.0, 1);
cairo_move_to (cr,osd_x+60, stats_top_margin+stats_row_height*2);
sprintf(msg, "%.2f ms (%.2f, %.2f)", osd_vars.latency_avg, osd_vars.latency_min, osd_vars.latency_max);
sprintf(msg, "%.2f ms (%.f, %.f)", osd_vars.latency_avg, osd_vars.latency_min, osd_vars.latency_max);
cairo_show_text (cr, msg);
}

Expand All @@ -107,11 +107,11 @@ void modeset_paint_buffer(struct modeset_buf *buf) {
avg_cnt++;
}
}
avg_bw = avg_bw / avg_cnt / 100;
avg_bw = avg_bw / avg_cnt;
if (avg_bw < 1000) {
sprintf(msg, "%.2f KB/s", avg_bw );
sprintf(msg, "%.2f Kbps", avg_bw / 125 );
} else {
sprintf(msg, "%.2f MB/s", avg_bw / 1000 );
sprintf(msg, "%.2f Mbps", avg_bw / 125000 );
}
row_count++;
cairo_set_source_surface (cr, net_icon, osd_x+22, stats_top_margin+row_count*stats_row_height-19);
Expand Down

0 comments on commit c8c250c

Please sign in to comment.