From 6b98dc9e42833ed2a713716a0cafeeba418897e8 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 15 Jun 2018 22:54:26 +0200 Subject: [PATCH] Write some drop counters to stderr. --- jpeg_frame_view.cpp | 8 ++++++++ main.cpp | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jpeg_frame_view.cpp b/jpeg_frame_view.cpp index 4f317e0..e7ee5f1 100644 --- a/jpeg_frame_view.cpp +++ b/jpeg_frame_view.cpp @@ -59,6 +59,8 @@ void prune_cache() void jpeg_decoder_thread() { + size_t num_decoded = 0, num_dropped = 0; + pthread_setname_np(pthread_self(), "JPEGDecoder"); for ( ;; ) { JPEGID id; @@ -91,6 +93,7 @@ void jpeg_decoder_thread() } } if (num_pending > 3) { + ++num_dropped; continue; } @@ -103,6 +106,11 @@ void jpeg_decoder_thread() if (cache.size() > CACHE_SIZE) { prune_cache(); } + ++num_decoded; + if (num_decoded % 1000 == 0) { + fprintf(stderr, "Decoded %zu images, dropped %zu (%.2f%% dropped)\n", + num_decoded, num_dropped, (100.0 * num_dropped) / (num_decoded + num_dropped)); + } } dest->setPixmap(pixmap); diff --git a/main.cpp b/main.cpp index ad42075..d916f44 100644 --- a/main.cpp +++ b/main.cpp @@ -76,8 +76,8 @@ int record_thread_func() if (av_read_frame(format_ctx.get(), &pkt) != 0) { break; } - fprintf(stderr, "Got a frame from camera %d, pts = %ld, size = %d\n", - pkt.stream_index, pkt.pts, pkt.size); + //fprintf(stderr, "Got a frame from camera %d, pts = %ld, size = %d\n", + // pkt.stream_index, pkt.pts, pkt.size); string filename = filename_for_frame(pkt.stream_index, pkt.pts); FILE *fp = fopen(filename.c_str(), "wb"); if (fp == nullptr) { -- 2.39.2