]> git.sesse.net Git - nageru/commitdiff
Write some drop counters to stderr.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 15 Jun 2018 20:54:26 +0000 (22:54 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 15 Jun 2018 20:54:26 +0000 (22:54 +0200)
jpeg_frame_view.cpp
main.cpp

index 4f317e0991c83721399e45772f1a1e1ee92f949d..e7ee5f1733fd77673bc9b3214ff980e0baf67c1d 100644 (file)
@@ -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);
index ad42075363054145fc23d80777b43b1c90f3ca8b..d916f44819841b105a80dfba6e3b5b2bf7d2d6e6 100644 (file)
--- 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) {