]> git.sesse.net Git - nageru/blobdiff - x264encode.cpp
Make it possible to set x264 preset/tune from the command line.
[nageru] / x264encode.cpp
index 4efa3774489d5e564ebbbf8f9f8df79930a19fbd..cafb64d813c83a778051c99bb085d8b77064e892 100644 (file)
@@ -1,7 +1,9 @@
 #include <string.h>
+#include <unistd.h>
 
 #include "defs.h"
-#include "httpd.h"
+#include "flags.h"
+#include "mux.h"
 #include "timebase.h"
 #include "x264encode.h"
 
@@ -11,8 +13,8 @@ extern "C" {
 
 using namespace std;
 
-X264Encoder::X264Encoder(HTTPD *httpd)
-       : httpd(httpd)
+X264Encoder::X264Encoder(Mux *mux)
+       : mux(mux)
 {
        frame_pool.reset(new uint8_t[WIDTH * HEIGHT * 2 * X264_QUEUE_LENGTH]);
        for (unsigned i = 0; i < X264_QUEUE_LENGTH; ++i) {
@@ -59,7 +61,7 @@ void X264Encoder::end_encoding()
 void X264Encoder::init_x264()
 {
        x264_param_t param;
-       x264_param_default_preset(&param, "ultrafast", "film");  // TODO: flags
+       x264_param_default_preset(&param, global_flags.x264_preset.c_str(), global_flags.x264_tune.c_str());
 
        param.i_width = WIDTH;
        param.i_height = HEIGHT;
@@ -166,5 +168,5 @@ void X264Encoder::encode_frame(X264Encoder::QueuedFrame qf)
                pkt.flags = 0;
        }
 
-       httpd->add_packet(pkt, pic.i_pts, pic.i_dts);
+       mux->add_packet(pkt, pic.i_pts, pic.i_dts);
 }