]> git.sesse.net Git - nageru/blobdiff - jpeg_frame_view.cpp
Write some drop counters to stderr.
[nageru] / jpeg_frame_view.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);