#include <string>
#include <thread>
#include <unordered_map>
+#include <vector>
extern "C" {
#include <libavformat/avformat.h>
#include <movit/image_format.h>
+#include "defs.h"
+#include "metrics.h"
#include "print_latency.h"
+#include "x264_dynamic.h"
class Mux;
class X264SpeedControl;
~X264Encoder();
// Must be called before first frame. Does not take ownership.
- void set_mux(Mux *mux) { this->mux = mux; }
+ void add_mux(Mux *mux) { muxes.push_back(mux); }
// <data> is taken to be raw NV12 data of WIDTHxHEIGHT resolution.
// Does not block.
void init_x264();
void encode_frame(QueuedFrame qf);
+ // bitrate_kbit can be 0 for no change.
+ static void speed_control_override_func(unsigned bitrate_kbit, movit::YCbCrLumaCoefficients coefficients, x264_param_t *param);
+
// One big memory chunk of all 50 (or whatever) frames, allocated in
// the constructor. All data functions just use pointers into this
// pool.
std::unique_ptr<uint8_t[]> frame_pool;
- Mux *mux = nullptr;
+ std::vector<Mux *> muxes;
bool wants_global_headers;
std::string global_headers;
std::thread encoder_thread;
std::atomic<bool> x264_init_done{false};
std::atomic<bool> should_quit{false};
+ X264Dynamic dyn;
x264_t *x264;
std::unique_ptr<X264SpeedControl> speed_control;
- std::function<void(x264_param_t *)> bitrate_override_func;
-
std::atomic<unsigned> new_bitrate_kbit{0}; // 0 for no change.
// Protects everything below it.