]> git.sesse.net Git - nageru/blobdiff - x264_speed_control.h
Rename ui_foo.ui to foo.ui; seemingly, it is more standard.
[nageru] / x264_speed_control.h
index af4513ea5a037ab596e7a016ed98fee1e1acf73b..b0a1739d022e462c48c7e80e7b73b905fcdb6411 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _X264_SPEED_CONTROL_H
+#define _X264_SPEED_CONTROL_H 1
+
 // The x264 speed control tries to encode video at maximum possible quality
 // without skipping frames (at the expense of higher encoding latency and
 // less even output rates, although VBV is still respected). It does this
 // one does not need to patch x264 to use it in Nageru. It still could do with
 // some cleanup, but it's much, much better than just using a static preset.
 
-#include <stdio.h>
 #include <stdint.h>
-#include <string.h>
-#include <math.h>
+#include <atomic>
 #include <chrono>
 #include <functional>
 
 extern "C" {
-#include "x264.h"
+#include <x264.h>
 }
 
+#include "metrics.h"
+#include "x264_dynamic.h"
+
 class X264SpeedControl {
 public:
        // x264: Encoding object we are using; must be opened. Assumed to be
@@ -98,6 +102,8 @@ private:
        int dither_preset(float f);
        void apply_preset(int new_preset);
 
+       X264Dynamic dyn;
+
        // Not owned by us.
        x264_t *x264;
 
@@ -126,4 +132,13 @@ private:
        } stat;
 
        std::function<void(x264_param_t *)> override_func = nullptr;
+
+       // Metrics.
+       Histogram metric_x264_speedcontrol_preset_used_frames;
+       std::atomic<double> metric_x264_speedcontrol_buffer_available_seconds{0.0};
+       std::atomic<double> metric_x264_speedcontrol_buffer_size_seconds{0.0};
+       std::atomic<int64_t> metric_x264_speedcontrol_idle_frames{0};
+       std::atomic<int64_t> metric_x264_speedcontrol_late_frames{0};
 };
+
+#endif  // !defined(_X264_SPEED_CONTROL_H)