]> granicus.if.org Git - handbrake/commitdiff
vfr: add cfr frame drop debugging logs
authorJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 22 Sep 2016 18:57:56 +0000 (11:57 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Tue, 21 Feb 2017 20:54:40 +0000 (13:54 -0700)
These logs can be enabled by uncommenting HB_DEBUG_CFR_DROPS at the top
of the file.

If you have any sources that use progressive frame upsampling that you
would like to test with this new frame drop algo, enable these debug
logs to get full details of what frames are dropped and passed.

They show which frames are dropped and the metrics that the decision to
drop is based on.  They also show which frames are passed and the
cadence of passed vs. dropped frames.

libhb/vfr.c

index 41be58f5e321db2bc4c801afc9db68070dbc0938..81ab4183e3763d181c8acc99d8d5fb6902bd9732 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "hb.h"
 
+//#define HB_DEBUG_CFR_DROPS 1
 #define MAX_FRAME_ANALYSIS_DEPTH 10
 
 struct hb_filter_private_s
@@ -37,6 +38,9 @@ struct hb_filter_private_s
     double        * frame_metric;
 
     unsigned        gamma_lut[256];
+#if defined(HB_DEBUG_CFR_DROPS)
+    int64_t         sequence;
+#endif
 };
 
 static int hb_vfr_init( hb_filter_object_t * filter,
@@ -188,6 +192,9 @@ static hb_buffer_t * adjust_frame_rate( hb_filter_private_t * pv,
             pv->out_last_stop = in->s.start;
         }
 
+#if defined(HB_DEBUG_CFR_DROPS)
+        in->s.pcr = pv->sequence++;
+#endif
         hb_list_add(pv->frame_rate_list, in);
         count = hb_list_count(pv->frame_rate_list);
         if (count < 2)
@@ -234,6 +241,24 @@ static hb_buffer_t * adjust_frame_rate( hb_filter_private_t * pv,
 
         drop_frame = find_drop_frame(pv->frame_metric, count);
         out = hb_list_item(pv->frame_rate_list, drop_frame);
+
+#if defined(HB_DEBUG_CFR_DROPS)
+        hb_log("CFR Drop: %ld metric %d", out->s.pcr, (int)pv->frame_metric[drop_frame]);
+        int jj;
+        for (jj = 0; jj < count; jj++)
+        {
+            if (jj == drop_frame)
+            {
+                fprintf(stderr, "(%4d) ", (int)pv->frame_metric[jj]);
+            }
+            else
+            {
+                fprintf(stderr, "%6d ", (int)pv->frame_metric[jj]);
+            }
+        }
+        fprintf(stderr, "\n");
+#endif
+
         hb_list_rem(pv->frame_rate_list, out);
         hb_buffer_close(&out);
         delete_metric(pv->frame_metric, drop_frame, count);
@@ -242,6 +267,13 @@ static hb_buffer_t * adjust_frame_rate( hb_filter_private_t * pv,
     }
 
     out = hb_list_item(pv->frame_rate_list, 0);
+
+#if defined(HB_DEBUG_CFR_DROPS)
+    static int64_t lastpass = 0;
+    hb_log("CFR Pass: %ld ~ %ld metric %d", out->s.pcr, out->s.pcr - lastpass, (int)pv->frame_metric[0]);
+    lastpass = out->s.pcr;
+#endif
+
     hb_list_rem(pv->frame_rate_list, out);
     hb_buffer_list_append(&list, out);
     delete_metric(pv->frame_metric, 0, count);